Skip to content

Commit

Permalink
Fix jison generate
Browse files Browse the repository at this point in the history
  • Loading branch information
zyc9012 committed May 6, 2024
1 parent 77a7030 commit 8b15a84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 111 deletions.
4 changes: 2 additions & 2 deletions packages/formula-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "cross-env BABEL_ENV=commonjs jest",
"coverage": "cross-env BABEL_ENV=commonjs jest --coverage",
"build": "father-build",
"generate-parser": "cd src/grammar-parser && jison grammar-parser.jison",
"generate-parser": "cd src/grammar-parser && jison-es -m es grammar-parser.jison",
"release": "generate-release"
},
"keywords": [
Expand All @@ -42,7 +42,7 @@
"generate-release": "^1.1.1",
"jest": "^26.6.3",
"jest-cli": "^29.3.1",
"jison": "^0.4.17",
"jison-es": "^0.4.18",
"rimraf": "^3.0.2",
"webpack": "^4.44.2",
"webpack-cli": "^4.2.0"
Expand Down
103 changes: 5 additions & 98 deletions packages/formula-parser/src/grammar-parser/grammar-parser.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,3 @@
/* parser generated by jison 0.4.18 */
/*
Returns a Parser object of the following structure:
Parser: {
yy: {}
}
Parser.prototype: {
yy: {},
trace: function(),
symbols_: {associative list: name ==> number},
terminals_: {associative list: number ==> name},
productions_: [...],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
table: [...],
defaultActions: {...},
parseError: function(str, hash),
parse: function(input),
lexer: {
EOF: 1,
parseError: function(str, hash),
setInput: function(input),
input: function(),
unput: function(str),
more: function(),
less: function(n),
pastInput: function(),
upcomingInput: function(),
showPosition: function(),
test_match: function(regex_match_array, rule_index),
next: function(),
lex: function(),
begin: function(condition),
popState: function(),
_currentRules: function(),
topState: function(),
pushState: function(condition),
options: {
ranges: boolean (optional: true ==> token location info will include a .range[] member)
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
},
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
rules: [...],
conditions: {associative list: name ==> set},
}
}
token location info (@$, _$, etc.): {
first_line: n,
last_line: n,
first_column: n,
last_column: n,
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
}
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
text: (matched text)
token: (the produced terminal token, if any)
line: (yylineno)
}
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
loc: (yylloc)
expected: (string describing the set of expected tokens)
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
}
*/
var grammarParser = (function(){
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,5],$V1=[1,8],$V2=[1,6],$V3=[1,7],$V4=[1,9],$V5=[1,14],$V6=[1,15],$V7=[1,16],$V8=[1,12],$V9=[1,13],$Va=[1,17],$Vb=[1,19],$Vc=[1,20],$Vd=[1,21],$Ve=[1,22],$Vf=[1,23],$Vg=[1,24],$Vh=[1,25],$Vi=[1,26],$Vj=[1,27],$Vk=[1,28],$Vl=[5,9,10,11,13,14,15,16,17,18,19,20,29,30],$Vm=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,32],$Vn=[5,9,10,11,13,14,15,16,17,18,19,20,29,30,34],$Vo=[5,10,11,13,14,15,16,17,29,30],$Vp=[5,10,13,14,15,16,29,30],$Vq=[5,10,11,13,14,15,16,17,18,19,29,30],$Vr=[13,29,30];
var parser = {trace: function trace () { },
yy: {},
Expand Down Expand Up @@ -509,6 +435,7 @@ _handle_error:
return true;
}};


/* generated by jison-lex 0.3.4 */
var lexer = (function(){
var lexer = ({
Expand Down Expand Up @@ -921,27 +848,7 @@ conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,
return lexer;
})();
parser.lexer = lexer;
function Parser () {
this.yy = {};
}
Parser.prototype = parser;parser.Parser = Parser;
return new Parser;
})();


if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
exports.parser = grammarParser;
exports.Parser = grammarParser.Parser;
exports.parse = function () { return grammarParser.parse.apply(grammarParser, arguments); };
exports.main = function commonjsMain (args) {
if (!args[1]) {
console.log('Usage: '+args[0]+' FILE');
process.exit(1);
}
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
return exports.parser.parse(source);
};
if (typeof module !== 'undefined' && require.main === module) {
exports.main(process.argv.slice(1));
}
}
function Parser() { this.yy = {} };
Parser.prototype = parser;
parser.Parser = Parser;
export {parser, Parser};
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13890,18 +13890,10 @@ jest@^29.3.1:
import-local "^3.0.2"
jest-cli "^29.3.1"

jison-lex@0.3.x:
version "0.3.4"
resolved "https://registry.npmmirror.com/jison-lex/-/jison-lex-0.3.4.tgz#81ca28d84f84499dfa8c594dcde3d8a3f26ec7a5"
integrity sha512-EBh5wrXhls1cUwROd5DcDHR1sG7CdsCFSqY1027+YA1RGxz+BX2TDLAhdsQf40YEtFDGoiO0Qm8PpnBl2EzDJw==
dependencies:
lex-parser "0.1.x"
nomnom "1.5.2"

jison@^0.4.17:
jison-es@^0.4.18:
version "0.4.18"
resolved "https://registry.npmmirror.com/jison/-/jison-0.4.18.tgz#c68a6a54bfe7028fa40bcfc6cc8bbd9ed291f502"
integrity sha512-FKkCiJvozgC7VTHhMJ00a0/IApSxhlGsFIshLW6trWJ8ONX2TQJBBz6DlcO1Gffy4w9LT+uL+PA+CVnUSJMF7w==
resolved "https://registry.yarnpkg.com/jison-es/-/jison-es-0.4.18.tgz#76ad76bdbd57041d2e8a2306dac159c3be99058a"
integrity sha512-R7tinbjcEcXU9e0CLNkQ4jeNdHzRv5haz3+ydB4LRV6GEKHJp34xpze5fFR8jn9lVOIrVARmXFKKOWLiOXHiuA==
dependencies:
JSONSelect "0.4.0"
cjson "0.3.0"
Expand All @@ -13912,6 +13904,14 @@ jison@^0.4.17:
lex-parser "~0.1.3"
nomnom "1.5.2"

jison-lex@0.3.x:
version "0.3.4"
resolved "https://registry.npmmirror.com/jison-lex/-/jison-lex-0.3.4.tgz#81ca28d84f84499dfa8c594dcde3d8a3f26ec7a5"
integrity sha512-EBh5wrXhls1cUwROd5DcDHR1sG7CdsCFSqY1027+YA1RGxz+BX2TDLAhdsQf40YEtFDGoiO0Qm8PpnBl2EzDJw==
dependencies:
lex-parser "0.1.x"
nomnom "1.5.2"

js-sdsl@^4.1.4:
version "4.2.0"
resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.2.0.tgz#278e98b7bea589b8baaf048c20aeb19eb7ad09d0"
Expand Down

0 comments on commit 8b15a84

Please sign in to comment.