-
Notifications
You must be signed in to change notification settings - Fork 8
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
Pluggable grammars #23
Labels
capability
A capability we need to support
Comments
Support from the wonderful #marpa developer community: 😍
|
xsawyerx
added a commit
that referenced
this issue
May 30, 2022
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.).
Preliminary implementation available with documentation of it here: 801bcb6 |
xsawyerx
added a commit
that referenced
this issue
Jun 20, 2022
* GH #23: (VERY) Preliminary support for extending the grammar. * GH #111: Support "die". * GH #112: Support "readline STDIN" or "readline(STDIN)". * GH #113: Support "$#_" (but not "$# _"). * GH #114: Support all forms of binmode() (Val @valcomm). * GH #115: Support all forms of for() loop (Val @valcomm). * RT #132920: Fix confusion of quote-like operators by comments. * Support "_" in file operations ("-x _", etc.). * Support "$foo->$bar" and "$foo->$_". * Support 'eval "..."' or 'eval $foo'. * Improve wording on top-level anonymous hashes. * When failing without an exception, we throw an exception with more information (e.g., "print _").
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We can support grammar plugins so people could load additional grammar to parse DSLs.
Examples:
We can document the base lexemes so others can use them. They could create their own lexemes with a prefix for them, like
MooseKeywordHasExpr
andMooseKeywordHas
.The text was updated successfully, but these errors were encountered: