Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH #23: Add preliminary support for extending the grammar:
To add new lexemes: Guacamole->add_lexemes( [ 'name' => 'value' ], [ 'another_name' => 'another_value' ], ); This creates entries of: name ~ 'value' another_name ~ 'another_value' This doesn't even handle escaping "'" yet, so figure it out yourself. :) To add new keywords: Guacamole->add_keyword( 'MyNewKeyword', 'unary', # or: nullary, assign, list 'my_new_keyword', # whatever name it has [ 'OpKeywordMyNewKeyword BlockNonEmpty' ], ); This will create the appropriate lexemes (prefixing your keyword with 'OpKeyword' which you can use in the rules) and the rules you provide. Here is a small example of writing a try/catch implementation: Example of adding support for Try::Tiny's try/catch: Guacamole->add_keyword( 'Catch', 'unary', 'catch', [ 'OpKeywordCatch BlockNonEmpty' ] ); Guacamole->add_keyword( 'Try', 'list', 'try', [ 'OpKeywordTry BlockNonEmpty OpKeywordCatchExpr', 'OpKeywordTry BlockNonEmpty', ], ); This, of course, does not check whether `Try::Tiny` is in effect. Support "finally {}" is about the same with a few adjustments to the different combinations ("try {} finally {}", "try {} catch {} finally {}", etc.).
- Loading branch information