mips-parser
Version:
MIPS Assembly parser in JavaScript
644 lines (550 loc) • 52.9 kB
JavaScript
/**
* LR parser generated by the Syntax tool.
*
* https://www.npmjs.com/package/syntax-cli
*
* npm install -g syntax-cli
*
* syntax-cli --help
*
* To regenerate run:
*
* syntax-cli \
* --grammar ~/path-to-grammar-file \
* --mode <parsing-mode> \
* --output ~/path-to-output-parser-file.js
*/
'use strict';
/**
* Matched token text.
*/
let yytext;
/**
* Length of the matched token text.
*/
let yyleng;
/**
* Storage object.
*/
let yy = {};
/**
* Result of semantic action.
*/
let __;
/**
* Result location object.
*/
let __loc;
function yyloc(start, end) {
if (!yy.options.captureLocations) {
return null;
}
// Epsilon doesn't produce location.
if (!start || !end) {
return start || end;
}
return {
startOffset: start.startOffset,
endOffset: end.endOffset,
startLine: start.startLine,
endLine: end.endLine,
startColumn: start.startColumn,
endColumn: end.endColumn,
};
}
const EOF = '$';
/**
* List of productions (generated by Syntax tool).
*/
const productions = [[-1,1,(_1) => { __ = _1 }],
[0,1,(_1) => { __ = {type: 'Program', segments, labels, directives} }],
[1,1,(_1) => { __ = _1 }],
[1,2],
[2,1,(_1) => { handleLabel({type: 'Label', value: _1}) }],
[2,1,(_1) => { handleElement(_1) }],
[3,1,(_1) => { __ = _1 }],
[3,1,(_1) => { __ = _1 }],
[3,1,(_1) => { __ = _1 }],
[4,2,(_1,_2) => { __ = {type: 'Instruction', opcode: _1, operands: _2} }],
[5,1,(_1) => { __ = [_1] }],
[5,3,(_1,_2,_3) => { __ = [_1, _3] }],
[5,5,(_1,_2,_3,_4,_5) => { __ = [_1, _3, _5] }],
[5,0],
[6,1,(_1) => { __ = _1 }],
[6,1,(_1) => { __ = _1 }],
[7,1,(_1) => { __ = {type: 'Register', value: _1, kind: 'Numeric'} }],
[7,1,(_1) => { __ = {type: 'Register', value: _1, kind: 'Float'} }],
[7,1,(_1) => { __ = {type: 'Register', value: _1, kind: 'Name'} }],
[8,3,(_1,_2,_3) => { __ = _2 }],
[9,2,(_1,_2) => { __ = {type: 'Address', offset: _1, base: _2} }],
[9,1,(_1) => { __ = _1 }],
[10,1,(_1) => { __ = _1 }],
[10,2,(_1,_2) => { __ = {type: 'Unary', 'operator': '-', value: _2} }],
[11,1,(_1) => { __ = _1 }],
[11,3,(_1,_2,_3) => { __ = {type: 'Offset', kind: 'offset', base: _1, offset: _3, operator: '+'} }],
[11,3,(_1,_2,_3) => { __ = {type: 'Offset', kind: 'offset', base: _1, offset: _3, operator: '-'} }],
[12,2,(_1,_2) => { __ = {type: 'Data', mode: _1, value: _2.length === 1 ? _2[0] : _2} }],
[12,2,(_1,_2) => { __ = {type: 'Data', mode: _1, value: _2} }],
[12,2,(_1,_2) => { __ = {type: 'Data', mode: _1, value: _2} }],
[12,2,(_1,_2) => { __ = {type: 'Data', mode: _1, value: _2} }],
[13,1,(_1) => { __ = {type: 'String', value: _1} }],
[14,1,(_1) => { __ = _1 }],
[14,1,(_1) => { __ = _1 }],
[14,1,(_1) => { __ = _1 }],
[14,1,(_1) => { __ = _1 }],
[14,1,(_1) => { __ = _1 }],
[15,1,(_1) => { __ = [_1] }],
[15,3,(_1,_2,_3) => { _1.push(_3); __ = _1; }],
[16,1,(_1) => { __ = _1 }],
[16,1,(_1) => { __ = _1 }],
[16,1,(_1) => { __ = _1 }],
[16,1,(_1) => { __ = _1 }],
[16,1,(_1) => { __ = _1 }],
[17,2,(_1,_2) => {
// Record current segment on entering it.
currentSegment = _1;
instructionsCount = 0;
// If address is specified, the segmented starts
// at that specific memory location.
const address = _2 ? _2.value : undefined;
__ = {
type: 'Segment',
value: _1,
address,
};
// Initialize the segment if it's not allocated yet.
if (!segments[_1]) {
segments[_1] = {
address,
instructions: [],
};
}
}],
[18,2,(_1,_2) => { __ = {type: 'Directive', kind: 'set', argument: _2} }],
[19,1,(_1) => { __ = _1 }],
[19,1,(_1) => { __ = _1 }],
[20,2,(_1,_2) => { __ = {type: 'Directive', kind: 'symbol', directive: _1, name: _2} }],
[20,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'symbol', directive: _1, name: _2, value: _4} }],
[21,3,(_1,_2,_3) => { __ = {type: 'Directive', kind: 'align', expression: _3} }],
[22,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, reg1: _2, reg2: _4} }],
[22,2,(_1,_2) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, expression: _2} }],
[22,2,(_1,_2) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, expression: _2} }],
[22,3,(_1,_2,_3) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, name: _2, path: _3} }],
[22,1,(_1) => { __ = {type: 'Directive', kind: 'compiler', directive: _1} }],
[22,1,(_1) => { __ = {type: 'Directive', kind: 'compiler', directive: _1} }],
[22,1,(_1) => { __ = {type: 'Directive', kind: 'compiler', directive: _1} }],
[22,2,(_1,_2) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, name: _2} }],
[22,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, expr1: _2, expr2: _4} }],
[22,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, reg1: _2, reg2: _4} }],
[22,2,(_1,_2) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, flag: _2} }],
[22,3,(_1,_2,_3) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, value1: _2, value2: _3} }],
[22,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'compiler', directive: _1, expr1: _2, expr2: _4} }],
[23,2,(_1,_2) => { __ = {type: 'Directive', kind: 'block', directive: _1, value: _2} }],
[23,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'block', directive: _1, name: _2, value: _4} }],
[23,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'block', directive: _1, expr1: _2, expr2: _4} }],
[23,4,(_1,_2,_3,_4) => { __ = {type: 'Directive', kind: 'block', directive: _1, name: _2, value: _4} }],
[23,6,(_1,_2,_3,_4,_5,_6) => { __ = {type: 'Directive', kind: 'block', directive: _1, reg1: _2, value: _4, reg2: _6} }],
[23,2,(_1,_2) => { __ = {type: 'Directive', kind: 'block', directive: _1, name: _2} }],
[24,1,(_1) => { __ = _1 }],
[24,0],
[25,1,(_1) => { __ = _1 }],
[25,0],
[26,1,(_1) => { __ = _1 }],
[26,0],
[27,1,(_1) => { __ = _1 }],
[27,0,() => { __ = {type: 'Offset', kind: 'Const', value: 0} }],
[28,3,(_1,_2,_3) => { __ = {type: 'Binary', 'operator': '+', left: _1, right: _3} }],
[28,3,(_1,_2,_3) => { __ = {type: 'Binary', 'operator': '-', left: _1, right: _3} }],
[28,3,(_1,_2,_3) => { __ = {type: 'Binary', 'operator': '*', left: _1, right: _3} }],
[28,3,(_1,_2,_3) => { __ = {type: 'Binary', 'operator': '/', left: _1, right: _3} }],
[28,3,(_1,_2,_3) => { __ = _2 }],
[28,2,(_1,_2) => { __ = {type: 'Unary', 'operator': '-', value: _2} }],
[28,1,(_1) => { __ = _1 }],
[29,1,(_1) => { __ = {type: 'Number', kind: 'decimal', value: Number(_1)} }],
[29,1,(_1) => { __ = {type: 'Number', kind: 'hex', value: Number(_1), raw: _1} }],
[30,1,(_1) => { __ = _1 }],
[30,1,(_1) => { __ = {type: 'Char', value: _1} }],
[30,1,(_1) => { __ = {type: 'Identifier', value: _1} }]];
/**
* Encoded tokens map.
*/
const tokens = {"LABEL":"31","OPCODE":"32",",":"33","NUM_REG":"34","FLOAT_REG":"35","NAME_REG":"36","(":"37",")":"38","-":"39","+":"40",".ascii":"41",".asciiz":"42",".space":"43","STRING":"44",".byte":"45",".half":"46",".word":"47",".float":"48",".double":"49","SEGMENT":"50","SET_DIR":"51","SET_DIR_ARG":"52","SYM_GLOB_DIR":"53","ID":"54","SYM_CONS_DIR":"55",".align":"56",".alias":"57",".bgnb":"58",".endb":"59",".file":"60",".galive":"61",".gjaldef":"62",".gjrlive":"63",".lab":"64",".livereg":"65",".noalias":"66",".option":"67",".verstamp":"68",".vreg":"69",".ent":"70",".aent":"71",".mask":"72",".fmask":"73",".frame":"74",".end":"75","*":"76","/":"77","DECIMAL":"78","HEXADECIMAL":"79","CHAR":"80","'flag'":"81","$":"82"};
/**
* Parsing table (generated by Syntax tool).
*/
const table = [{"0":120,"1":1,"2":2,"3":4,"4":5,"12":6,"14":9,"16":7,"17":14,"18":13,"20":15,"21":16,"22":17,"31":"s3","32":"s8","41":"s10","42":"s11","43":"s12","45":"s121","46":"s122","47":"s123","48":"s124","49":"s125","50":"s19","51":"s18","53":"s20","55":"s21","56":"s22","57":"s23","58":"s24","59":"s25","60":"s26","61":"s27","62":"s28","63":"s29","64":"s30","65":"s31","66":"s32","67":"s33","68":"s34","69":"s35"},{"2":36,"3":4,"4":5,"12":6,"14":9,"16":7,"17":14,"18":13,"20":15,"21":16,"22":17,"31":"s3","32":"s8","41":"s10","42":"s11","43":"s12","45":"s121","46":"s122","47":"s123","48":"s124","49":"s125","50":"s19","51":"s18","53":"s20","55":"s21","56":"s22","57":"s23","58":"s24","59":"s25","60":"s26","61":"s27","62":"s28","63":"s29","64":"s30","65":"s31","66":"s32","67":"s33","68":"s34","69":"s35","82":"r1"},{"31":"r2","32":"r2","41":"r2","42":"r2","43":"r2","45":"r2","46":"r2","47":"r2","48":"r2","49":"r2","50":"r2","51":"r2","53":"r2","55":"r2","56":"r2","57":"r2","58":"r2","59":"r2","60":"r2","61":"r2","62":"r2","63":"r2","64":"r2","65":"r2","66":"r2","67":"r2","68":"r2","69":"r2","82":"r2"},{"31":"r4","32":"r4","41":"r4","42":"r4","43":"r4","45":"r4","46":"r4","47":"r4","48":"r4","49":"r4","50":"r4","51":"r4","53":"r4","55":"r4","56":"r4","57":"r4","58":"r4","59":"r4","60":"r4","61":"r4","62":"r4","63":"r4","64":"r4","65":"r4","66":"r4","67":"r4","68":"r4","69":"r4","82":"r4"},{"31":"r5","32":"r5","41":"r5","42":"r5","43":"r5","45":"r5","46":"r5","47":"r5","48":"r5","49":"r5","50":"r5","51":"r5","53":"r5","55":"r5","56":"r5","57":"r5","58":"r5","59":"r5","60":"r5","61":"r5","62":"r5","63":"r5","64":"r5","65":"r5","66":"r5","67":"r5","68":"r5","69":"r5","82":"r5"},{"31":"r6","32":"r6","41":"r6","42":"r6","43":"r6","45":"r6","46":"r6","47":"r6","48":"r6","49":"r6","50":"r6","51":"r6","53":"r6","55":"r6","56":"r6","57":"r6","58":"r6","59":"r6","60":"r6","61":"r6","62":"r6","63":"r6","64":"r6","65":"r6","66":"r6","67":"r6","68":"r6","69":"r6","82":"r6"},{"31":"r7","32":"r7","41":"r7","42":"r7","43":"r7","45":"r7","46":"r7","47":"r7","48":"r7","49":"r7","50":"r7","51":"r7","53":"r7","55":"r7","56":"r7","57":"r7","58":"r7","59":"r7","60":"r7","61":"r7","62":"r7","63":"r7","64":"r7","65":"r7","66":"r7","67":"r7","68":"r7","69":"r7","82":"r7"},{"31":"r8","32":"r8","41":"r8","42":"r8","43":"r8","45":"r8","46":"r8","47":"r8","48":"r8","49":"r8","50":"r8","51":"r8","53":"r8","55":"r8","56":"r8","57":"r8","58":"r8","59":"r8","60":"r8","61":"r8","62":"r8","63":"r8","64":"r8","65":"r8","66":"r8","67":"r8","68":"r8","69":"r8","82":"r8"},{"5":37,"6":38,"7":39,"9":40,"10":46,"11":45,"27":44,"29":49,"30":47,"31":"r13","32":"r13","34":"s41","35":"s42","36":"s43","37":"r77","39":"s48","41":"r13","42":"r13","43":"r13","45":"r13","46":"r13","47":"r13","48":"r13","49":"r13","50":"r13","51":"r13","53":"r13","54":"s51","55":"r13","56":"r13","57":"r13","58":"r13","59":"r13","60":"r13","61":"r13","62":"r13","63":"r13","64":"r13","65":"r13","66":"r13","67":"r13","68":"r13","69":"r13","78":"s52","79":"s53","80":"s50","82":"r13"},{"15":67,"28":68,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"13":85,"44":"s86"},{"13":87,"44":"s86"},{"28":88,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r39","32":"r39","41":"r39","42":"r39","43":"r39","45":"r39","46":"r39","47":"r39","48":"r39","49":"r39","50":"r39","51":"r39","53":"r39","55":"r39","56":"r39","57":"r39","58":"r39","59":"r39","60":"r39","61":"r39","62":"r39","63":"r39","64":"r39","65":"r39","66":"r39","67":"r39","68":"r39","69":"r39","82":"r39"},{"31":"r40","32":"r40","41":"r40","42":"r40","43":"r40","45":"r40","46":"r40","47":"r40","48":"r40","49":"r40","50":"r40","51":"r40","53":"r40","55":"r40","56":"r40","57":"r40","58":"r40","59":"r40","60":"r40","61":"r40","62":"r40","63":"r40","64":"r40","65":"r40","66":"r40","67":"r40","68":"r40","69":"r40","82":"r40"},{"31":"r41","32":"r41","41":"r41","42":"r41","43":"r41","45":"r41","46":"r41","47":"r41","48":"r41","49":"r41","50":"r41","51":"r41","53":"r41","55":"r41","56":"r41","57":"r41","58":"r41","59":"r41","60":"r41","61":"r41","62":"r41","63":"r41","64":"r41","65":"r41","66":"r41","67":"r41","68":"r41","69":"r41","82":"r41"},{"31":"r42","32":"r42","41":"r42","42":"r42","43":"r42","45":"r42","46":"r42","47":"r42","48":"r42","49":"r42","50":"r42","51":"r42","53":"r42","55":"r42","56":"r42","57":"r42","58":"r42","59":"r42","60":"r42","61":"r42","62":"r42","63":"r42","64":"r42","65":"r42","66":"r42","67":"r42","68":"r42","69":"r42","82":"r42"},{"31":"r43","32":"r43","41":"r43","42":"r43","43":"r43","45":"r43","46":"r43","47":"r43","48":"r43","49":"r43","50":"r43","51":"r43","53":"r43","55":"r43","56":"r43","57":"r43","58":"r43","59":"r43","60":"r43","61":"r43","62":"r43","63":"r43","64":"r43","65":"r43","66":"r43","67":"r43","68":"r43","69":"r43","82":"r43"},{"19":89,"32":"s91","52":"s90"},{"25":92,"29":93,"31":"r73","32":"r73","41":"r73","42":"r73","43":"r73","45":"r73","46":"r73","47":"r73","48":"r73","49":"r73","50":"r73","51":"r73","53":"r73","55":"r73","56":"r73","57":"r73","58":"r73","59":"r73","60":"r73","61":"r73","62":"r73","63":"r73","64":"r73","65":"r73","66":"r73","67":"r73","68":"r73","69":"r73","78":"s52","79":"s53","82":"r73"},{"54":"s94"},{"54":"s95"},{"33":"s98"},{"7":100,"34":"s41","35":"s42","36":"s43"},{"28":103,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"28":104,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"29":49,"30":105,"54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r55","32":"r55","41":"r55","42":"r55","43":"r55","45":"r55","46":"r55","47":"r55","48":"r55","49":"r55","50":"r55","51":"r55","53":"r55","55":"r55","56":"r55","57":"r55","58":"r55","59":"r55","60":"r55","61":"r55","62":"r55","63":"r55","64":"r55","65":"r55","66":"r55","67":"r55","68":"r55","69":"r55","82":"r55"},{"31":"r56","32":"r56","41":"r56","42":"r56","43":"r56","45":"r56","46":"r56","47":"r56","48":"r56","49":"r56","50":"r56","51":"r56","53":"r56","55":"r56","56":"r56","57":"r56","58":"r56","59":"r56","60":"r56","61":"r56","62":"r56","63":"r56","64":"r56","65":"r56","66":"r56","67":"r56","68":"r56","69":"r56","82":"r56"},{"31":"r57","32":"r57","41":"r57","42":"r57","43":"r57","45":"r57","46":"r57","47":"r57","48":"r57","49":"r57","50":"r57","51":"r57","53":"r57","55":"r57","56":"r57","57":"r57","58":"r57","59":"r57","60":"r57","61":"r57","62":"r57","63":"r57","64":"r57","65":"r57","66":"r57","67":"r57","68":"r57","69":"r57","82":"r57"},{"54":"s107"},{"28":108,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"7":111,"34":"s41","35":"s42","36":"s43"},{"81":"s114"},{"29":49,"30":115,"54":"s51","78":"s52","79":"s53","80":"s50"},{"28":117,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r3","32":"r3","41":"r3","42":"r3","43":"r3","45":"r3","46":"r3","47":"r3","48":"r3","49":"r3","50":"r3","51":"r3","53":"r3","55":"r3","56":"r3","57":"r3","58":"r3","59":"r3","60":"r3","61":"r3","62":"r3","63":"r3","64":"r3","65":"r3","66":"r3","67":"r3","68":"r3","69":"r3","82":"r3"},{"31":"r9","32":"r9","41":"r9","42":"r9","43":"r9","45":"r9","46":"r9","47":"r9","48":"r9","49":"r9","50":"r9","51":"r9","53":"r9","55":"r9","56":"r9","57":"r9","58":"r9","59":"r9","60":"r9","61":"r9","62":"r9","63":"r9","64":"r9","65":"r9","66":"r9","67":"r9","68":"r9","69":"r9","82":"r9"},{"31":"r10","32":"r10","33":"s54","41":"r10","42":"r10","43":"r10","45":"r10","46":"r10","47":"r10","48":"r10","49":"r10","50":"r10","51":"r10","53":"r10","55":"r10","56":"r10","57":"r10","58":"r10","59":"r10","60":"r10","61":"r10","62":"r10","63":"r10","64":"r10","65":"r10","66":"r10","67":"r10","68":"r10","69":"r10","82":"r10"},{"31":"r14","32":"r14","33":"r14","41":"r14","42":"r14","43":"r14","45":"r14","46":"r14","47":"r14","48":"r14","49":"r14","50":"r14","51":"r14","53":"r14","55":"r14","56":"r14","57":"r14","58":"r14","59":"r14","60":"r14","61":"r14","62":"r14","63":"r14","64":"r14","65":"r14","66":"r14","67":"r14","68":"r14","69":"r14","82":"r14"},{"31":"r15","32":"r15","33":"r15","41":"r15","42":"r15","43":"r15","45":"r15","46":"r15","47":"r15","48":"r15","49":"r15","50":"r15","51":"r15","53":"r15","55":"r15","56":"r15","57":"r15","58":"r15","59":"r15","60":"r15","61":"r15","62":"r15","63":"r15","64":"r15","65":"r15","66":"r15","67":"r15","68":"r15","69":"r15","82":"r15"},{"31":"r16","32":"r16","33":"r16","38":"r16","41":"r16","42":"r16","43":"r16","45":"r16","46":"r16","47":"r16","48":"r16","49":"r16","50":"r16","51":"r16","53":"r16","55":"r16","56":"r16","57":"r16","58":"r16","59":"r16","60":"r16","61":"r16","62":"r16","63":"r16","64":"r16","65":"r16","66":"r16","67":"r16","68":"r16","69":"r16","82":"r16"},{"31":"r17","32":"r17","33":"r17","38":"r17","41":"r17","42":"r17","43":"r17","45":"r17","46":"r17","47":"r17","48":"r17","49":"r17","50":"r17","51":"r17","53":"r17","55":"r17","56":"r17","57":"r17","58":"r17","59":"r17","60":"r17","61":"r17","62":"r17","63":"r17","64":"r17","65":"r17","66":"r17","67":"r17","68":"r17","69":"r17","82":"r17"},{"31":"r18","32":"r18","33":"r18","38":"r18","41":"r18","42":"r18","43":"r18","45":"r18","46":"r18","47":"r18","48":"r18","49":"r18","50":"r18","51":"r18","53":"r18","55":"r18","56":"r18","57":"r18","58":"r18","59":"r18","60":"r18","61":"r18","62":"r18","63":"r18","64":"r18","65":"r18","66":"r18","67":"r18","68":"r18","69":"r18","82":"r18"},{"8":58,"37":"s59"},{"31":"r21","32":"r21","33":"r21","37":"r76","41":"r21","42":"r21","43":"r21","45":"r21","46":"r21","47":"r21","48":"r21","49":"r21","50":"r21","51":"r21","53":"r21","55":"r21","56":"r21","57":"r21","58":"r21","59":"r21","60":"r21","61":"r21","62":"r21","63":"r21","64":"r21","65":"r21","66":"r21","67":"r21","68":"r21","69":"r21","82":"r21"},{"31":"r24","32":"r24","33":"r24","37":"r24","41":"r24","42":"r24","43":"r24","45":"r24","46":"r24","47":"r24","48":"r24","49":"r24","50":"r24","51":"r24","53":"r24","55":"r24","56":"r24","57":"r24","58":"r24","59":"r24","60":"r24","61":"r24","62":"r24","63":"r24","64":"r24","65":"r24","66":"r24","67":"r24","68":"r24","69":"r24","82":"r24"},{"31":"r22","32":"r22","33":"r22","37":"r22","39":"s63","40":"s62","41":"r22","42":"r22","43":"r22","45":"r22","46":"r22","47":"r22","48":"r22","49":"r22","50":"r22","51":"r22","53":"r22","55":"r22","56":"r22","57":"r22","58":"r22","59":"r22","60":"r22","61":"r22","62":"r22","63":"r22","64":"r22","65":"r22","66":"r22","67":"r22","68":"r22","69":"r22","82":"r22"},{"29":49,"30":66,"54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r87","32":"r87","33":"r87","37":"r87","38":"r87","39":"r87","40":"r87","41":"r87","42":"r87","43":"r87","44":"r87","45":"r87","46":"r87","47":"r87","48":"r87","49":"r87","50":"r87","51":"r87","53":"r87","54":"r87","55":"r87","56":"r87","57":"r87","58":"r87","59":"r87","60":"r87","61":"r87","62":"r87","63":"r87","64":"r87","65":"r87","66":"r87","67":"r87","68":"r87","69":"r87","76":"r87","77":"r87","78":"r87","79":"r87","80":"r87","82":"r87"},{"31":"r88","32":"r88","33":"r88","37":"r88","38":"r88","39":"r88","40":"r88","41":"r88","42":"r88","43":"r88","44":"r88","45":"r88","46":"r88","47":"r88","48":"r88","49":"r88","50":"r88","51":"r88","53":"r88","54":"r88","55":"r88","56":"r88","57":"r88","58":"r88","59":"r88","60":"r88","61":"r88","62":"r88","63":"r88","64":"r88","65":"r88","66":"r88","67":"r88","68":"r88","69":"r88","76":"r88","77":"r88","78":"r88","79":"r88","80":"r88","82":"r88"},{"31":"r89","32":"r89","33":"r89","37":"r89","38":"r89","39":"r89","40":"r89","41":"r89","42":"r89","43":"r89","44":"r89","45":"r89","46":"r89","47":"r89","48":"r89","49":"r89","50":"r89","51":"r89","53":"r89","54":"r89","55":"r89","56":"r89","57":"r89","58":"r89","59":"r89","60":"r89","61":"r89","62":"r89","63":"r89","64":"r89","65":"r89","66":"r89","67":"r89","68":"r89","69":"r89","76":"r89","77":"r89","78":"r89","79":"r89","80":"r89","82":"r89"},{"31":"r85","32":"r85","33":"r85","37":"r85","38":"r85","39":"r85","40":"r85","41":"r85","42":"r85","43":"r85","44":"r85","45":"r85","46":"r85","47":"r85","48":"r85","49":"r85","50":"r85","51":"r85","53":"r85","54":"r85","55":"r85","56":"r85","57":"r85","58":"r85","59":"r85","60":"r85","61":"r85","62":"r85","63":"r85","64":"r85","65":"r85","66":"r85","67":"r85","68":"r85","69":"r85","76":"r85","77":"r85","78":"r85","79":"r85","80":"r85","82":"r85"},{"31":"r86","32":"r86","33":"r86","37":"r86","38":"r86","39":"r86","40":"r86","41":"r86","42":"r86","43":"r86","44":"r86","45":"r86","46":"r86","47":"r86","48":"r86","49":"r86","50":"r86","51":"r86","53":"r86","54":"r86","55":"r86","56":"r86","57":"r86","58":"r86","59":"r86","60":"r86","61":"r86","62":"r86","63":"r86","64":"r86","65":"r86","66":"r86","67":"r86","68":"r86","69":"r86","76":"r86","77":"r86","78":"r86","79":"r86","80":"r86","82":"r86"},{"6":55,"7":39,"9":40,"10":46,"11":45,"27":44,"29":49,"30":47,"34":"s41","35":"s42","36":"s43","37":"r77","39":"s48","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r11","32":"r11","33":"s56","41":"r11","42":"r11","43":"r11","45":"r11","46":"r11","47":"r11","48":"r11","49":"r11","50":"r11","51":"r11","53":"r11","55":"r11","56":"r11","57":"r11","58":"r11","59":"r11","60":"r11","61":"r11","62":"r11","63":"r11","64":"r11","65":"r11","66":"r11","67":"r11","68":"r11","69":"r11","82":"r11"},{"6":57,"7":39,"9":40,"10":46,"11":45,"27":44,"29":49,"30":47,"34":"s41","35":"s42","36":"s43","37":"r77","39":"s48","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r12","32":"r12","41":"r12","42":"r12","43":"r12","45":"r12","46":"r12","47":"r12","48":"r12","49":"r12","50":"r12","51":"r12","53":"r12","55":"r12","56":"r12","57":"r12","58":"r12","59":"r12","60":"r12","61":"r12","62":"r12","63":"r12","64":"r12","65":"r12","66":"r12","67":"r12","68":"r12","69":"r12","82":"r12"},{"31":"r20","32":"r20","33":"r20","41":"r20","42":"r20","43":"r20","45":"r20","46":"r20","47":"r20","48":"r20","49":"r20","50":"r20","51":"r20","53":"r20","55":"r20","56":"r20","57":"r20","58":"r20","59":"r20","60":"r20","61":"r20","62":"r20","63":"r20","64":"r20","65":"r20","66":"r20","67":"r20","68":"r20","69":"r20","82":"r20"},{"7":60,"34":"s41","35":"s42","36":"s43"},{"38":"s61"},{"31":"r19","32":"r19","33":"r19","41":"r19","42":"r19","43":"r19","45":"r19","46":"r19","47":"r19","48":"r19","49":"r19","50":"r19","51":"r19","53":"r19","55":"r19","56":"r19","57":"r19","58":"r19","59":"r19","60":"r19","61":"r19","62":"r19","63":"r19","64":"r19","65":"r19","66":"r19","67":"r19","68":"r19","69":"r19","82":"r19"},{"29":49,"30":64,"54":"s51","78":"s52","79":"s53","80":"s50"},{"29":49,"30":65,"54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r25","32":"r25","33":"r25","37":"r25","41":"r25","42":"r25","43":"r25","45":"r25","46":"r25","47":"r25","48":"r25","49":"r25","50":"r25","51":"r25","53":"r25","55":"r25","56":"r25","57":"r25","58":"r25","59":"r25","60":"r25","61":"r25","62":"r25","63":"r25","64":"r25","65":"r25","66":"r25","67":"r25","68":"r25","69":"r25","82":"r25"},{"31":"r26","32":"r26","33":"r26","37":"r26","41":"r26","42":"r26","43":"r26","45":"r26","46":"r26","47":"r26","48":"r26","49":"r26","50":"r26","51":"r26","53":"r26","55":"r26","56":"r26","57":"r26","58":"r26","59":"r26","60":"r26","61":"r26","62":"r26","63":"r26","64":"r26","65":"r26","66":"r26","67":"r26","68":"r26","69":"r26","82":"r26"},{"31":"r23","32":"r23","33":"r23","37":"r23","41":"r23","42":"r23","43":"r23","45":"r23","46":"r23","47":"r23","48":"r23","49":"r23","50":"r23","51":"r23","53":"r23","55":"r23","56":"r23","57":"r23","58":"r23","59":"r23","60":"r23","61":"r23","62":"r23","63":"r23","64":"r23","65":"r23","66":"r23","67":"r23","68":"r23","69":"r23","82":"r23"},{"31":"r27","32":"r27","33":"s72","41":"r27","42":"r27","43":"r27","45":"r27","46":"r27","47":"r27","48":"r27","49":"r27","50":"r27","51":"r27","53":"r27","55":"r27","56":"r27","57":"r27","58":"r27","59":"r27","60":"r27","61":"r27","62":"r27","63":"r27","64":"r27","65":"r27","66":"r27","67":"r27","68":"r27","69":"r27","82":"r27"},{"31":"r37","32":"r37","33":"r37","39":"s75","40":"s74","41":"r37","42":"r37","43":"r37","45":"r37","46":"r37","47":"r37","48":"r37","49":"r37","50":"r37","51":"r37","53":"r37","55":"r37","56":"r37","57":"r37","58":"r37","59":"r37","60":"r37","61":"r37","62":"r37","63":"r37","64":"r37","65":"r37","66":"r37","67":"r37","68":"r37","69":"r37","76":"s76","77":"s77","82":"r37"},{"28":82,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"28":84,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r84","32":"r84","33":"r84","38":"r84","39":"r84","40":"r84","41":"r84","42":"r84","43":"r84","45":"r84","46":"r84","47":"r84","48":"r84","49":"r84","50":"r84","51":"r84","53":"r84","55":"r84","56":"r84","57":"r84","58":"r84","59":"r84","60":"r84","61":"r84","62":"r84","63":"r84","64":"r84","65":"r84","66":"r84","67":"r84","68":"r84","69":"r84","76":"r84","77":"r84","82":"r84"},{"28":73,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r38","32":"r38","33":"r38","39":"s75","40":"s74","41":"r38","42":"r38","43":"r38","45":"r38","46":"r38","47":"r38","48":"r38","49":"r38","50":"r38","51":"r38","53":"r38","55":"r38","56":"r38","57":"r38","58":"r38","59":"r38","60":"r38","61":"r38","62":"r38","63":"r38","64":"r38","65":"r38","66":"r38","67":"r38","68":"r38","69":"r38","76":"s76","77":"s77","82":"r38"},{"28":78,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"28":79,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"28":80,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"28":81,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r78","32":"r78","33":"r78","38":"r78","39":"r78","40":"r78","41":"r78","42":"r78","43":"r78","45":"r78","46":"r78","47":"r78","48":"r78","49":"r78","50":"r78","51":"r78","53":"r78","55":"r78","56":"r78","57":"r78","58":"r78","59":"r78","60":"r78","61":"r78","62":"r78","63":"r78","64":"r78","65":"r78","66":"r78","67":"r78","68":"r78","69":"r78","76":"s76","77":"s77","82":"r78"},{"31":"r79","32":"r79","33":"r79","38":"r79","39":"r79","40":"r79","41":"r79","42":"r79","43":"r79","45":"r79","46":"r79","47":"r79","48":"r79","49":"r79","50":"r79","51":"r79","53":"r79","55":"r79","56":"r79","57":"r79","58":"r79","59":"r79","60":"r79","61":"r79","62":"r79","63":"r79","64":"r79","65":"r79","66":"r79","67":"r79","68":"r79","69":"r79","76":"s76","77":"s77","82":"r79"},{"31":"r80","32":"r80","33":"r80","38":"r80","39":"r80","40":"r80","41":"r80","42":"r80","43":"r80","45":"r80","46":"r80","47":"r80","48":"r80","49":"r80","50":"r80","51":"r80","53":"r80","55":"r80","56":"r80","57":"r80","58":"r80","59":"r80","60":"r80","61":"r80","62":"r80","63":"r80","64":"r80","65":"r80","66":"r80","67":"r80","68":"r80","69":"r80","76":"r80","77":"r80","82":"r80"},{"31":"r81","32":"r81","33":"r81","38":"r81","39":"r81","40":"r81","41":"r81","42":"r81","43":"r81","45":"r81","46":"r81","47":"r81","48":"r81","49":"r81","50":"r81","51":"r81","53":"r81","55":"r81","56":"r81","57":"r81","58":"r81","59":"r81","60":"r81","61":"r81","62":"r81","63":"r81","64":"r81","65":"r81","66":"r81","67":"r81","68":"r81","69":"r81","76":"r81","77":"r81","82":"r81"},{"38":"s83","39":"s75","40":"s74","76":"s76","77":"s77"},{"31":"r82","32":"r82","33":"r82","38":"r82","39":"r82","40":"r82","41":"r82","42":"r82","43":"r82","45":"r82","46":"r82","47":"r82","48":"r82","49":"r82","50":"r82","51":"r82","53":"r82","55":"r82","56":"r82","57":"r82","58":"r82","59":"r82","60":"r82","61":"r82","62":"r82","63":"r82","64":"r82","65":"r82","66":"r82","67":"r82","68":"r82","69":"r82","76":"r82","77":"r82","82":"r82"},{"31":"r83","32":"r83","33":"r83","38":"r83","39":"r83","40":"r83","41":"r83","42":"r83","43":"r83","45":"r83","46":"r83","47":"r83","48":"r83","49":"r83","50":"r83","51":"r83","53":"r83","55":"r83","56":"r83","57":"r83","58":"r83","59":"r83","60":"r83","61":"r83","62":"r83","63":"r83","64":"r83","65":"r83","66":"r83","67":"r83","68":"r83","69":"r83","76":"r83","77":"r83","82":"r83"},{"31":"r28","32":"r28","41":"r28","42":"r28","43":"r28","45":"r28","46":"r28","47":"r28","48":"r28","49":"r28","50":"r28","51":"r28","53":"r28","55":"r28","56":"r28","57":"r28","58":"r28","59":"r28","60":"r28","61":"r28","62":"r28","63":"r28","64":"r28","65":"r28","66":"r28","67":"r28","68":"r28","69":"r28","82":"r28"},{"31":"r31","32":"r31","41":"r31","42":"r31","43":"r31","45":"r31","46":"r31","47":"r31","48":"r31","49":"r31","50":"r31","51":"r31","53":"r31","55":"r31","56":"r31","57":"r31","58":"r31","59":"r31","60":"r31","61":"r31","62":"r31","63":"r31","64":"r31","65":"r31","66":"r31","67":"r31","68":"r31","69":"r31","82":"r31"},{"31":"r29","32":"r29","41":"r29","42":"r29","43":"r29","45":"r29","46":"r29","47":"r29","48":"r29","49":"r29","50":"r29","51":"r29","53":"r29","55":"r29","56":"r29","57":"r29","58":"r29","59":"r29","60":"r29","61":"r29","62":"r29","63":"r29","64":"r29","65":"r29","66":"r29","67":"r29","68":"r29","69":"r29","82":"r29"},{"31":"r30","32":"r30","39":"s75","40":"s74","41":"r30","42":"r30","43":"r30","45":"r30","46":"r30","47":"r30","48":"r30","49":"r30","50":"r30","51":"r30","53":"r30","55":"r30","56":"r30","57":"r30","58":"r30","59":"r30","60":"r30","61":"r30","62":"r30","63":"r30","64":"r30","65":"r30","66":"r30","67":"r30","68":"r30","69":"r30","76":"s76","77":"s77","82":"r30"},{"31":"r45","32":"r45","41":"r45","42":"r45","43":"r45","45":"r45","46":"r45","47":"r45","48":"r45","49":"r45","50":"r45","51":"r45","53":"r45","55":"r45","56":"r45","57":"r45","58":"r45","59":"r45","60":"r45","61":"r45","62":"r45","63":"r45","64":"r45","65":"r45","66":"r45","67":"r45","68":"r45","69":"r45","82":"r45"},{"31":"r46","32":"r46","41":"r46","42":"r46","43":"r46","45":"r46","46":"r46","47":"r46","48":"r46","49":"r46","50":"r46","51":"r46","53":"r46","55":"r46","56":"r46","57":"r46","58":"r46","59":"r46","60":"r46","61":"r46","62":"r46","63":"r46","64":"r46","65":"r46","66":"r46","67":"r46","68":"r46","69":"r46","82":"r46"},{"31":"r47","32":"r47","41":"r47","42":"r47","43":"r47","45":"r47","46":"r47","47":"r47","48":"r47","49":"r47","50":"r47","51":"r47","53":"r47","55":"r47","56":"r47","57":"r47","58":"r47","59":"r47","60":"r47","61":"r47","62":"r47","63":"r47","64":"r47","65":"r47","66":"r47","67":"r47","68":"r47","69":"r47","82":"r47"},{"31":"r44","32":"r44","41":"r44","42":"r44","43":"r44","45":"r44","46":"r44","47":"r44","48":"r44","49":"r44","50":"r44","51":"r44","53":"r44","55":"r44","56":"r44","57":"r44","58":"r44","59":"r44","60":"r44","61":"r44","62":"r44","63":"r44","64":"r44","65":"r44","66":"r44","67":"r44","68":"r44","69":"r44","82":"r44"},{"31":"r72","32":"r72","41":"r72","42":"r72","43":"r72","45":"r72","46":"r72","47":"r72","48":"r72","49":"r72","50":"r72","51":"r72","53":"r72","55":"r72","56":"r72","57":"r72","58":"r72","59":"r72","60":"r72","61":"r72","62":"r72","63":"r72","64":"r72","65":"r72","66":"r72","67":"r72","68":"r72","69":"r72","82":"r72"},{"31":"r48","32":"r48","41":"r48","42":"r48","43":"r48","45":"r48","46":"r48","47":"r48","48":"r48","49":"r48","50":"r48","51":"r48","53":"r48","55":"r48","56":"r48","57":"r48","58":"r48","59":"r48","60":"r48","61":"r48","62":"r48","63":"r48","64":"r48","65":"r48","66":"r48","67":"r48","68":"r48","69":"r48","82":"r48"},{"33":"s96"},{"29":49,"30":97,"54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r49","32":"r49","41":"r49","42":"r49","43":"r49","45":"r49","46":"r49","47":"r49","48":"r49","49":"r49","50":"r49","51":"r49","53":"r49","55":"r49","56":"r49","57":"r49","58":"r49","59":"r49","60":"r49","61":"r49","62":"r49","63":"r49","64":"r49","65":"r49","66":"r49","67":"r49","68":"r49","69":"r49","82":"r49"},{"28":99,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r50","32":"r50","39":"s75","40":"s74","41":"r50","42":"r50","43":"r50","45":"r50","46":"r50","47":"r50","48":"r50","49":"r50","50":"r50","51":"r50","53":"r50","55":"r50","56":"r50","57":"r50","58":"r50","59":"r50","60":"r50","61":"r50","62":"r50","63":"r50","64":"r50","65":"r50","66":"r50","67":"r50","68":"r50","69":"r50","76":"s76","77":"s77","82":"r50"},{"33":"s101"},{"7":102,"34":"s41","35":"s42","36":"s43"},{"31":"r51","32":"r51","41":"r51","42":"r51","43":"r51","45":"r51","46":"r51","47":"r51","48":"r51","49":"r51","50":"r51","51":"r51","53":"r51","55":"r51","56":"r51","57":"r51","58":"r51","59":"r51","60":"r51","61":"r51","62":"r51","63":"r51","64":"r51","65":"r51","66":"r51","67":"r51","68":"r51","69":"r51","82":"r51"},{"31":"r52","32":"r52","39":"s75","40":"s74","41":"r52","42":"r52","43":"r52","45":"r52","46":"r52","47":"r52","48":"r52","49":"r52","50":"r52","51":"r52","53":"r52","55":"r52","56":"r52","57":"r52","58":"r52","59":"r52","60":"r52","61":"r52","62":"r52","63":"r52","64":"r52","65":"r52","66":"r52","67":"r52","68":"r52","69":"r52","76":"s76","77":"s77","82":"r52"},{"31":"r53","32":"r53","39":"s75","40":"s74","41":"r53","42":"r53","43":"r53","45":"r53","46":"r53","47":"r53","48":"r53","49":"r53","50":"r53","51":"r53","53":"r53","55":"r53","56":"r53","57":"r53","58":"r53","59":"r53","60":"r53","61":"r53","62":"r53","63":"r53","64":"r53","65":"r53","66":"r53","67":"r53","68":"r53","69":"r53","76":"s76","77":"s77","82":"r53"},{"44":"s106"},{"31":"r54","32":"r54","41":"r54","42":"r54","43":"r54","45":"r54","46":"r54","47":"r54","48":"r54","49":"r54","50":"r54","51":"r54","53":"r54","55":"r54","56":"r54","57":"r54","58":"r54","59":"r54","60":"r54","61":"r54","62":"r54","63":"r54","64":"r54","65":"r54","66":"r54","67":"r54","68":"r54","69":"r54","82":"r54"},{"31":"r58","32":"r58","41":"r58","42":"r58","43":"r58","45":"r58","46":"r58","47":"r58","48":"r58","49":"r58","50":"r58","51":"r58","53":"r58","55":"r58","56":"r58","57":"r58","58":"r58","59":"r58","60":"r58","61":"r58","62":"r58","63":"r58","64":"r58","65":"r58","66":"r58","67":"r58","68":"r58","69":"r58","82":"r58"},{"33":"s109","39":"s75","40":"s74","76":"s76","77":"s77"},{"28":110,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r59","32":"r59","39":"s75","40":"s74","41":"r59","42":"r59","43":"r59","45":"r59","46":"r59","47":"r59","48":"r59","49":"r59","50":"r59","51":"r59","53":"r59","55":"r59","56":"r59","57":"r59","58":"r59","59":"r59","60":"r59","61":"r59","62":"r59","63":"r59","64":"r59","65":"r59","66":"r59","67":"r59","68":"r59","69":"r59","76":"s76","77":"s77","82":"r59"},{"33":"s112"},{"7":113,"34":"s41","35":"s42","36":"s43"},{"31":"r60","32":"r60","41":"r60","42":"r60","43":"r60","45":"r60","46":"r60","47":"r60","48":"r60","49":"r60","50":"r60","51":"r60","53":"r60","55":"r60","56":"r60","57":"r60","58":"r60","59":"r60","60":"r60","61":"r60","62":"r60","63":"r60","64":"r60","65":"r60","66":"r60","67":"r60","68":"r60","69":"r60","82":"r60"},{"31":"r61","32":"r61","41":"r61","42":"r61","43":"r61","45":"r61","46":"r61","47":"r61","48":"r61","49":"r61","50":"r61","51":"r61","53":"r61","55":"r61","56":"r61","57":"r61","58":"r61","59":"r61","60":"r61","61":"r61","62":"r61","63":"r61","64":"r61","65":"r61","66":"r61","67":"r61","68":"r61","69":"r61","82":"r61"},{"29":49,"30":116,"54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r62","32":"r62","41":"r62","42":"r62","43":"r62","45":"r62","46":"r62","47":"r62","48":"r62","49":"r62","50":"r62","51":"r62","53":"r62","55":"r62","56":"r62","57":"r62","58":"r62","59":"r62","60":"r62","61":"r62","62":"r62","63":"r62","64":"r62","65":"r62","66":"r62","67":"r62","68":"r62","69":"r62","82":"r62"},{"33":"s118","39":"s75","40":"s74","76":"s76","77":"s77"},{"28":119,"29":49,"30":71,"37":"s69","39":"s70","54":"s51","78":"s52","79":"s53","80":"s50"},{"31":"r63","32":"r63","39":"s75","40":"s74","41":"r63","42":"r63","43":"r63","45":"r63","46":"r63","47":"r63","48":"r63","49":"r63","50":"r63","51":"r63","53":"r63","55":"r63","56":"r63","57":"r63","58":"r63","59":"r63","60":"r63","61":"r63","62":"r63","63":"r63","64":"r63","65":"r63","66":"r63","67":"r63","68":"r63","69":"r63","76":"s76","77":"s77","82":"r63"},{"82":"acc"},{"37":"r32","39":"r32","54":"r32","78":"r32","79":"r32","80":"r32"},{"37":"r33","39":"r33","54":"r33","78":"r33","79":"r33","80":"r33"},{"37":"r34","39":"r34","54":"r34","78":"r34","79":"r34","80":"r34"},{"37":"r35","39":"r35","54":"r35","78":"r35","79":"r35","80":"r35"},{"37":"r36","39":"r36","54":"r36","78":"r36","79":"r36","80":"r36"}];
/**
* Parsing stack.
*/
const stack = [];
/**
* Tokenizer instance.
*/
let tokenizer;
/**
* Generic tokenizer used by the parser in the Syntax tool.
*
* https://www.npmjs.com/package/syntax-cli
*
* See `--custom-tokinzer` to skip this generation, and use a custom one.
*/
const lexRules = [[/^\s+/, function() { /* skip whitespace */ }, ],
[/^#[^\n]*/, function() { /* skip comments */ }, ],
[/^"[^"]*"/, function() { yytext = yytext.slice(1, -1); return 'STRING'; }, ],
[/^'[^']*'/, function() { yytext = yytext.slice(1, -1); return 'CHAR'; }, ],
[/^(\$)f?\d{1,2}\b/, function() {
const isFloat = yytext[1] === 'f';
const reg = yytext.slice(isFloat ? 2 : 1);
const n = Number(reg);
if ((reg.length === 2 && n < 10) || n > 31) {
throw new Error('Unknown register: ' + reg);
}
return isFloat ? 'FLOAT_REG' : 'NUM_REG';
}, ],
[/^\$(zero|at|v0|v1|a0|a1|a2|a3|t0|t1|t2|t3|t4|t5|t6|t7|s0|s1|s2|s3|s4|s5|s6|s7|t8|t9|k0|k1|gp|sp|s8|fp|ra)/, function() { return 'NAME_REG' }, ],
[/^\.asciiz/, function() { return '.asciiz' }, ],
[/^\.ascii/, function() { return '.ascii' }, ],
[/^\.space/, function() { return '.space' }, ],
[/^\.byte/, function() { return '.byte' }, ],
[/^\.half/, function() { return '.half' }, ],
[/^\.word/, function() { return '.word' }, ],
[/^\.float/, function() { return '.float' }, ],
[/^\.double/, function() { return '.double' }, ],
[/^\.set/, function() { return 'SET_DIR' }, ],
[/^(volatile|novolatile|reorder|noreorder|at|noat|macro|nomacro|bopt|nobopt|nomove)/, function() { return 'SET_DIR_ARG' }, ],
[/^\.globa?l/, function() { return 'SYM_GLOB_DIR' }, ],
[/^(\.extern|\.comm|\.lcomm)/, function() { return 'SYM_CONS_DIR' }, ],
[/^\.align/, function() { return '.align' }, ],
[/^\.alias/, function() { return '.alias' }, ],
[/^\.bgnb/, function() { return '.bgnb' }, ],
[/^\.endb/, function() { return '.endb' }, ],
[/^\.file/, function() { return '.file' }, ],
[/^\.galive/, function() { return '.galive' }, ],
[/^\.gjaldef/, function() { return '.gjaldef' }, ],
[/^\.gjrlive/, function() { return '.gjrlive' }, ],
[/^\.lab/, function() { return '.lab' }, ],
[/^\.livereg/, function() { return '.livereg' }, ],
[/^\.noalias/, function() { return '.noalias' }, ],
[/^\.option/, function() { return '.option' }, ],
[/^\.verstamp/, function() { return '.verstamp' }, ],
[/^\.vreg/, function() { return '.vreg' }, ],
[/^\.ent/, function() { return '.ent' }, ],
[/^\.aent/, function() { return '.aent' }, ],
[/^\.mask/, function() { return '.mask' }, ],
[/^\.fmask/, function() { return '.fmask' }, ],
[/^\.frame/, function() { return '.frame' }, ],
[/^\.end/, function() { return '.end' }, ],
[/^(\.text|\.data|\.rdata|\.sdata)/, function() { return 'SEGMENT' }, ],
[/^\b(trunc\.l\.s|trunc\.l\.d|sub\.s|sqrt\.s|s\.s|s\.d|rsqrt\.s|round\.w\.s|round\.w\.d|round\.l\.s|round\.l\.d|recip\.s|nmsub\.s|nmadd\.s|neg\.s|mul\.s|msub\.s|movz\.s|movt\.s|movn\.s|movf\.s|mov\.s|madd\.s|ldc1|l\.s|l\.d|floor\.w\.s|floor\.w\.d|floor\.l\.s|floor\.l\.d|div\.s|cvt\.w\.s|cvt\.w\.d|cvt\.s\.w|cvt\.s\.l|cvt\.s\.d|cvt\.l\.s|cvt\.l\.d|cvt\.d\.w|cvt\.d\.s|cvt\.d\.l|ceil\.w\.s|ceil\.w\.d|ceil\.l\.s|ceil\.l\.d|c\.un\.s|c\.ult\.s|c\.ule\.s|c\.ueq\.s|c\.sf.\s|c\.seq\.s|c\.olt\.s|c\.ole\.s|c\.ngt\.s|c\.ngl\.s|c\.nge\.s|c\.lt\.s|c\.le\.s|c\.f.s|c\.eq\.s|add.s|abs.s|xori|xor|wb|waiti|ushusw|usd|ulw|ulhu|ulh|uld|u2r|tnei|tne|tltu|tltiu|tlti|tlt|tlbwr|tlbwi|tlbr|tlbp|tgeu|tgeiu|tgei|tge|teqi|teq|syscall|sync|swxc1|swr|swl|swc1|sw|suspend|subu|subi|sub|standby|srlv|srl|srav|sra|sne|sltu|sltiu|slti|slt|sllv|sll|sleu|sle|sh|sgtu|sgt|sgeu|sge|seq|selsr|selsl|sdxc1|sdr|sdl|sdc1|sdbbp|sd|scd|sc|sb|rsub|ror|rol|rmul|rfe|remu|rem|radd|r2u|prefx|pref|ori|or|not|nor|nop|negu|neg|multu|mult|mulou|mulo|mulu|mul|mtlo|mthi|mtc2|mtc1|mtc0|msubu|msub|movz|movt|movn|movf|move|min|mflo|mfhi|mfc2|mfc1|mfc0|max|madd16|madu|mad|maddu|madd|lwxc1|lwu|lwr|lwl|lwc1|lw|lui|lld|ll|li|lhu|lh|ldxc1|ldr|ldl|ld|lbu|lb|la|jalr|jal|jr|j|flushd|ffs|ffc|eret|divu|divou|divo|divdu|divd|div|ctc2|ctc1|ctc0|cfc2|cfc1|cfc0|cache|break|bnezl|bnez|bnel|bne|bltzl|bltzall|bltzal|bltz|bltul|bltu|bltl|blt|blezl|blez|bleul|bleu|blel|ble|bgtzl|bgtz|bgtul|bgtu|bgtl|bgt|bgezl|bgezall|bgezal|bgez|bgeul|bgeu|bgel|bge|beqzl|beqz|beql|beq|bc2tl|bc2t|bc2fl|bc2f|bc1tl|bc1t|bc1fl|bc0tlbc1f|bc0t|bc0fl|bc0f|bal|b|andi|and|addu|addiu|addi|addciu|add|abs)\b/, function() { return 'OPCODE' }, ],
[/^\+/, function() { return '+' }, ],
[/^\-/, function() { return '-' }, ],
[/^\*/, function() { return '*' }, ],
[/^\//, function() { return '/' }, ],
[/^0x[0-9A-Fa-z]+/, function() { return 'HEXADECIMAL'; }, ],
[/^\d*\.?\d+/, function() { return 'DECIMAL'; }, ],
[/^[a-zA-Z0-9_]+\:/, function() {
yytext = yytext.slice(0, -1);
return 'LABEL';
}, ],
[/^[a-zA-Z0-9_]+/, function() { return 'ID' }, ],
[/^\(/, function() { return '(' }, ],
[/^\)/, function() { return ')' }, ],
[/^,/, function() { return ',' }, ],
[/^flag/, function() { return "'flag'"; }, ]];
const lexRulesByConditions = {"INITIAL":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]};
const EOF_TOKEN = {
type: EOF,
value: '',
};
tokenizer = {
initString(string) {
this._string = string;
this._cursor = 0;
this._states = ['INITIAL'];
this._tokensQueue = [];
this._currentLine = 1;
this._currentColumn = 0;
this._currentLineBeginOffset = 0;
/**
* Matched token location data.
*/
this._tokenStartOffset = 0;
this._tokenEndOffset = 0;
this._tokenStartLine = 1;
this._tokenEndLine = 1;
this._tokenStartColumn = 0;
this._tokenEndColumn = 0;
return this;
},
/**
* Returns tokenizer states.
*/
getStates() {
return this._states;
},
getCurrentState() {
return this._states[this._states.length - 1];
},
pushState(state) {
this._states.push(state);
},
begin(state) {
this.pushState(state);
},
popState() {
if (this._states.length > 1) {
return this._states.pop();
}
return this._states[0];
},
getNextToken() {
// Something was queued, return it.
if (this._tokensQueue.length > 0) {
return this._toToken(this._tokensQueue.shift());
}
if (!this.hasMoreTokens()) {
return EOF_TOKEN;
}
let string = this._string.slice(this._cursor);
let lexRulesForState = lexRulesByConditions[this.getCurrentState()];
for (let i = 0; i < lexRulesForState.length; i++) {
let lexRuleIndex = lexRulesForState[i];
let lexRule = lexRules[lexRuleIndex];
let matched = this._match(string, lexRule[0]);
// Manual handling of EOF token (the end of string). Return it
// as `EOF` symbol.
if (string === '' && matched === '') {
this._cursor++;
}
if (matched !== null) {
yytext = matched;
yyleng = yytext.length;
let token = lexRule[1].call(this);
if (!token) {
return this.getNextToken();
}
// If multiple tokens are returned, save them to return
// on next `getNextToken` call.
if (Array.isArray(token)) {
const tokensToQueue = token.slice(1);
token = token[0];
if (tokensToQueue.length > 0) {
this._tokensQueue.unshift(...tokensToQueue);
}
}
return this._toToken(token, yytext);
}
}
if (this.isEOF()) {
this._cursor++;
return EOF_TOKEN;
}
this.throwUnexpectedToken(
string[0],
this._currentLine,
this._currentColumn
);
},
/**
* Throws default "Unexpected token" exception, showing the actual
* line from the source, pointing with the ^ marker to the bad token.
* In addition, shows `line:column` location.
*/
throwUnexpectedToken(symbol, line, column) {
const lineSource = this._string.split('\n')[line - 1];
let lineData = '';
if (lineSource) {
const pad = ' '.repeat(column);
lineData = '\n\n' + lineSource + '\n' + pad + '^\n';
}
throw new SyntaxError(
`${lineData}Unexpected token: "${symbol}" ` +
`at ${line}:${column}.`
);
},
getCursor() {
return this._cursor;
},
getCurrentLine() {
return this._currentLine;
},
getCurrentColumn() {
return this._currentColumn;
},
_captureLocation(matched) {
const nlRe = /\n/g;
// Absolute offsets.
this._tokenStartOffset = this._cursor;
// Line-based locations, start.
this._tokenStartLine = this._currentLine;
this._tokenStartColumn =
this._tokenStartOffset - this._currentLineBeginOffset;
// Extract `\n` in the matched token.
let nlMatch;
while ((nlMatch = nlRe.exec(matched)) !== null) {
this._currentLine++;
this._currentLineBeginOffset = this._tokenStartOffset + nlMatch.index + 1;
}
this._tokenEndOffset = this._cursor + matched.length;
// Line-based locations, end.
this._tokenEndLine = this._currentLine;
this._tokenEndColumn = this._currentColumn =
(this._tokenEndOffset - this._currentLineBeginOffset);
},
_toToken(tokenType, yytext = '') {
return {
// Basic data.
type: tokenType,
value: yytext,
// Location data.
startOffset: this._tokenStartOffset,
endOffset: this._tokenEndOffset,
startLine: this._tokenStartLine,
endLine: this._tokenEndLine,
startColumn: this._tokenStartColumn,
endColumn: this._tokenEndColumn,
};
},
isEOF() {
return this._cursor === this._string.length;
},
hasMoreTokens() {
return this._cursor <= this._string.length;
},
_match(string, regexp) {
let matched = string.match(regexp);
if (matched) {
// Handle `\n` in the matched token to track line numbers.
this._captureLocation(matched[0]);
this._cursor += matched[0].length;
return matched[0];
}
return null;
},
};
/**
* Expose tokenizer so it can be accessed in semantic actions.
*/
yy.lexer = tokenizer;
yy.tokenizer = tokenizer;
/**
* Global parsing options. Some options can be shadowed per
* each `parse` call, if the optations are passed.
*
* Initalized to the `captureLocations` which is passed
* from the generator. Other options can be added at runtime.
*/
yy.options = {
captureLocations: false,
};
/**
* Parsing module.
*/
const yyparse = {
/**
* Sets global parsing options.
*/
setOptions(options) {
yy.options = options;
return this;
},
/**
* Returns parsing options.
*/
getOptions() {
return yy.options;
},
/**
* Parses a string.
*/
parse(string, parseOptions) {
if (!tokenizer) {
throw new Error(`Tokenizer instance wasn't specified.`);
}
tokenizer.initString(string);
/**
* If parse options are passed, override global parse options for
* this call, and later restore global options.
*/
let globalOptions = yy.options;
if (parseOptions) {
yy.options = Object.assign({}, yy.options, parseOptions);
}
/**
* Allow callers to do setup work based on the
* parsing string, and passed options.
*/
yyparse.onParseBegin(string, tokenizer, yy.options);
stack.length = 0;
stack.push(0);
let token = tokenizer.getNextToken();
let shiftedToken = null;
do {
if (!token) {
// Restore options.
yy.options = globalOptions;
unexpectedEndOfInput();
}
let state = stack[stack.length - 1];
let column = tokens[token.type];
if (!table[state].hasOwnProperty(column)) {
yy.options = globalOptions;
unexpectedToken(token);
}
let entry = table[state][column];
// Shift action.
if (entry[0] === 's') {
let loc = null;
if (yy.options.captureLocations) {
loc = {
startOffset: token.startOffset,
endOffset: token.endOffset,
startLine: token.startLine,
endLine: token.endLine,
startColumn: token.startColumn,
endColumn: token.endColumn,
};
}
stack.push(
{symbol: tokens[token.type], semanticValue: token.value, loc},
Number(entry.slice(1))
);
shiftedToken = token;
token = tokenizer.getNextToken();
}
// Reduce action.
else if (entry[0] === 'r') {
let productionNumber = entry.slice(1);
let production = productions[productionNumber];
let hasSemanticAction = typeof production[2] === 'function';
let semanticValueArgs = hasSemanticAction ? [] : null;
const locationArgs = (
hasSemanticAction && yy.options.captureLocations
? []
: null
);
if (production[1] !== 0) {
let rhsLength = production[1];
while (rhsLength-- > 0) {
stack.pop();
let stackEntry = stack.pop();
if (hasSemanticAction) {
semanticValueArgs.unshift(stackEntry.semanticValue);
if (locationArgs) {
locationArgs.unshift(stackEntry.loc);
}
}
}
}
const reduceStackEntry = {symbol: production[0]};
if (hasSemanticAction) {
yytext = shiftedToken ? shiftedToken.value : null;
yyleng = shiftedToken ? shiftedToken.value.length : null;
const semanticActionArgs = (
locationArgs !== null
? semanticValueArgs.concat(locationArgs)
: semanticValueArgs
);
production[2](...semanticActionArgs);
reduceStackEntry.semanticValue = __;
if