import { byte } from 'js/types';

/** Map from token to keyword */
export const TOKEN_TO_STRING: Record<byte, string> = {
    0x80: 'END',
    0x81: 'FOR',
    0x82: 'NEXT',
    0x83: 'DATA',
    0x84: 'INPUT',
    0x85: 'DEL',
    0x86: 'DIM',
    0x87: 'READ',
    0x88: 'GR',
    0x89: 'TEXT',
    0x8a: 'PR#',
    0x8b: 'IN#',
    0x8c: 'CALL',
    0x8d: 'PLOT',
    0x8e: 'HLIN',
    0x8f: 'VLIN',
    0x90: 'HGR2',
    0x91: 'HGR',
    0x92: 'HCOLOR=',
    0x93: 'HPLOT',
    0x94: 'DRAW',
    0x95: 'XDRAW',
    0x96: 'HTAB',
    0x97: 'HOME',
    0x98: 'ROT=',
    0x99: 'SCALE=',
    0x9a: 'SHLOAD',
    0x9b: 'TRACE',
    0x9c: 'NOTRACE',
    0x9d: 'NORMAL',
    0x9e: 'INVERSE',
    0x9f: 'FLASH',
    0xa0: 'COLOR=',
    0xa1: 'POP=',
    0xa2: 'VTAB',
    0xa3: 'HIMEM:',
    0xa4: 'LOMEM:',
    0xa5: 'ONERR',
    0xa6: 'RESUME',
    0xa7: 'RECALL',
    0xa8: 'STORE',
    0xa9: 'SPEED=',
    0xaa: 'LET',
    0xab: 'GOTO',
    0xac: 'RUN',
    0xad: 'IF',
    0xae: 'RESTORE',
    0xaf: '&',
    0xb0: 'GOSUB',
    0xb1: 'RETURN',
    0xb2: 'REM',
    0xb3: 'STOP',
    0xb4: 'ON',
    0xb5: 'WAIT',
    0xb6: 'LOAD',
    0xb7: 'SAVE',
    0xb8: 'DEF',
    0xb9: 'POKE',
    0xba: 'PRINT',
    0xbb: 'CONT',
    0xbc: 'LIST',
    0xbd: 'CLEAR',
    0xbe: 'GET',
    0xbf: 'NEW',
    0xc0: 'TAB(',
    0xc1: 'TO',
    0xc2: 'FN',
    0xc3: 'SPC(',
    0xc4: 'THEN',
    0xc5: 'AT',
    0xc6: 'NOT',
    0xc7: 'STEP',
    0xc8: '+',
    0xc9: '-',
    0xca: '*',
    0xcb: '/',
    0xcc: '^',
    0xcd: 'AND',
    0xce: 'OR',
    0xcf: '>',
    0xd0: '=',
    0xd1: '<',
    0xd2: 'SGN',
    0xd3: 'INT',
    0xd4: 'ABS',
    0xd5: 'USR',
    0xd6: 'FRE',
    0xd7: 'SCRN(',
    0xd8: 'PDL',
    0xd9: 'POS',
    0xda: 'SQR',
    0xdb: 'RND',
    0xdc: 'LOG',
    0xdd: 'EXP',
    0xde: 'COS',
    0xdf: 'SIN',
    0xe0: 'TAN',
    0xe1: 'ATN',
    0xe2: 'PEEK',
    0xe3: 'LEN',
    0xe4: 'STR$',
    0xe5: 'VAL',
    0xe6: 'ASC',
    0xe7: 'CHR$',
    0xe8: 'LEFT$',
    0xe9: 'RIGHT$',
    0xea: 'MID$',
};

/** Map from keyword to token. */
export const STRING_TO_TOKEN: Record<string, byte> = {
    END: 0x80,
    FOR: 0x81,
    NEXT: 0x82,
    DATA: 0x83,
    INPUT: 0x84,
    DEL: 0x85,
    DIM: 0x86,
    READ: 0x87,
    GR: 0x88,
    TEXT: 0x89,
    'PR#': 0x8a,
    'IN#': 0x8b,
    CALL: 0x8c,
    PLOT: 0x8d,
    HLIN: 0x8e,
    VLIN: 0x8f,
    HGR2: 0x90,
    HGR: 0x91,
    'HCOLOR=': 0x92,
    HPLOT: 0x93,
    DRAW: 0x94,
    XDRAW: 0x95,
    HTAB: 0x96,
    HOME: 0x97,
    'ROT=': 0x98,
    'SCALE=': 0x99,
    SHLOAD: 0x9a,
    TRACE: 0x9b,
    NOTRACE: 0x9c,
    NORMAL: 0x9d,
    INVERSE: 0x9e,
    FLASH: 0x9f,
    'COLOR=': 0xa0,
    'POP=': 0xa1,
    VTAB: 0xa2,
    'HIMEM:': 0xa3,
    'LOMEM:': 0xa4,
    ONERR: 0xa5,
    RESUME: 0xa6,
    RECALL: 0xa7,
    STORE: 0xa8,
    'SPEED=': 0xa9,
    LET: 0xaa,
    GOTO: 0xab,
    RUN: 0xac,
    IF: 0xad,
    RESTORE: 0xae,
    '&': 0xaf,
    GOSUB: 0xb0,
    RETURN: 0xb1,
    REM: 0xb2,
    STOP: 0xb3,
    ON: 0xb4,
    WAIT: 0xb5,
    LOAD: 0xb6,
    SAVE: 0xb7,
    DEF: 0xb8,
    POKE: 0xb9,
    PRINT: 0xba,
    CONT: 0xbb,
    LIST: 0xbc,
    CLEAR: 0xbd,
    GET: 0xbe,
    NEW: 0xbf,
    'TAB(': 0xc0,
    TO: 0xc1,
    FN: 0xc2,
    'SPC(': 0xc3,
    THEN: 0xc4,
    AT: 0xc5,
    NOT: 0xc6,
    STEP: 0xc7,
    '+': 0xc8,
    '-': 0xc9,
    '*': 0xca,
    '/': 0xcb,
    '^': 0xcc,
    AND: 0xcd,
    OR: 0xce,
    '>': 0xcf,
    '=': 0xd0,
    '<': 0xd1,
    SGN: 0xd2,
    INT: 0xd3,
    ABS: 0xd4,
    USR: 0xd5,
    FRE: 0xd6,
    'SCRN(': 0xd7,
    PDL: 0xd8,
    POS: 0xd9,
    SQR: 0xda,
    RND: 0xdb,
    LOG: 0xdc,
    EXP: 0xdd,
    COS: 0xde,
    SIN: 0xdf,
    TAN: 0xe0,
    ATN: 0xe1,
    PEEK: 0xe2,
    LEN: 0xe3,
    STR$: 0xe4,
    VAL: 0xe5,
    ASC: 0xe6,
    CHR$: 0xe7,
    LEFT$: 0xe8,
    RIGHT$: 0xe9,
    MID$: 0xea,
};
