kkoch986 / js-parse Goto Github PK
View Code? Open in Web Editor NEWA generic node.js based LR(1) shift-reduce parser.
A generic node.js based LR(1) shift-reduce parser.
Currently, excludeFromProduction
is only true or false, would be cool to allow specification of the circumstances under which it should be excluded.
For example, in regex,
{
head: "REW.REX.RANGE",
body:
[
{ head: "REW.REX.CHAR",
body: [ { type: 'REW.REX.NONMETACHAR', value: '0' }, [length]: 1 ] },
{ type: 'REW.REX.-', value: '-' },
{ head: 'REW.REX.CHAR',
body: [ { type: 'REW.REX.NONMETACHAR', value: '9' }, [length]: 1 ] },
[length]: 3
]
}
Would like to exclude the "-" here but potentially not in other places.
This would also necessitate an includeInProductions
which carries out the inverse effect, excluding from all but the specified productions.
some rapid updating has caused the tests to fall into disrepair. would like to fix them asap.
Currently the exclude option set in the symbols array will only work for terminal symbols.
A bunch of tests were broken when conflict detection was added since some of the test cases used grammars which contained conflicts.
has set a production as
"X":[ "Y" ]
instead of
"X":[ ["Y"] ]
And the error was very unclear:
TypeError: Cannot read property '*e*' of undefined
at Object.computeFirstSetForGrammar (/home/ken/Documents/projects/js-parse/lib/parser/utils/first_set.js:82:31)
at CreateLRParser (/home/ken/Documents/projects/js-parse/lib/parser/lr_parser.js:146:42)
at Object.CreateLRParserWithLexer [as CreateWithLexer] (/home/ken/Documents/projects/js-parse/lib/parser/lr_parser.js:62:15)
at Context.<anonymous> (/home/ken/Documents/projects/js-parse/examples/php/spec/tokens_spec.js:10:25)
at callFn (/usr/local/lib/node_modules/mocha/lib/runnable.js:249:21)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:242:7)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:373:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:451:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:298:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:308:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:246:23)
at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:275:5)
at processImmediate [as _immediateCallback] (timers.js:336:15)
in reference to the comments on #4, would like to build a mergeIntoParent
option for terminals which causes all of their children to be given as arguments to the parent and the symbol to be excluded from the production.
im sure there will be a litany of things to fix....
related to #4, would be good to be able to define a time to apply merge into parent.
Ideally this would be defined in the parent rather than the child.
big problem in the lexer currently, consider a digit
which would match [0-9]
and a non-zero-digit
which would match [1-9]
.
Solution i initially went with was to create terminals which created unique ranges i.e. zero
and one_through_nine
and wrote digit
and non-zero-digit
as productions like
digit -> zero | one_through_nine
non-zero-digit -> one_through_nine
This is a working solution, but far from ideal in my opinion. What im currently considering is modifying the production definition to allow constraints, but this is leading to reduce-reduce conflicts because the name of the token still matches as digit (in a slightly more complex case).
Going to keep working on the second solution, but also looking for a third.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.