-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding and removing rules from a grammar #3
Comments
@jarble Excuse me for a bit delayed response. Currently, Grammar object is implemented in such way, that it encapsulates a data structure with all grammar productions - indexed by nonterminal symbols (the left hand side of grammar rules). {
'S': [['S', 'add_sub', 'M'], ['M']],
'N': [['S', 'lt_gt', 'S'], ['S']],
} Please, check the source code of the constructor of Grammar objects for more implementation details: https://github.com/lagodiuk/earley-parser-js/blob/master/earley-oop.js#L4-L23 Given code can be reused for parsing of the new rules, and addition of them to the dictionary with already existing rules. I will try to find a time within nearest days - to implement requested feature. However, a pull request with this feature will be appreciated as well. |
I'm developing an application that requires the grammar rules to be modified after the grammar is created. After creating a grammar like this one, would it be possible to add or modify individual rules in the grammar?
Would I be able to add a new rule to the grammar using
grammar.add('A -> B')
or something similar?The text was updated successfully, but these errors were encountered: