Created
May 15, 2010 11:40
-
-
Save bacek/402156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/src/nqp-rx (types)$ git diff master | |
diff --git a/src/NQP/Grammar.pm b/src/NQP/Grammar.pm | |
index 95f590a..4657ddc 100644 | |
--- a/src/NQP/Grammar.pm | |
+++ b/src/NQP/Grammar.pm | |
@@ -7,7 +7,9 @@ method TOP() { | |
%*LANG<Regex-actions> := NQP::RegexActions; | |
%*LANG<MAIN> := NQP::Grammar; | |
%*LANG<MAIN-actions> := NQP::Actions; | |
- my $*SCOPE := ''; | |
+ my $*SCOPE := ''; | |
+ my $*MULTIS := ''; | |
+ my $*TYPENAME := ''; | |
self.comp_unit; | |
} | |
@@ -76,6 +78,7 @@ token pod_comment { | |
] | |
} | |
+token typename { <name> } | |
## Top-level rules | |
@@ -273,6 +276,32 @@ token scope_declarator:sym<has> { <sym> <scoped('has')> } | |
rule scoped($*SCOPE) { | |
| <variable_declarator> | |
| <routine_declarator> | |
+ | <typename>+ | |
+ { | |
+ if +$<typename> > 1 { | |
+ $/.CURSOR.panic("Multiple prefix constraints not yet supported"); | |
+ } | |
+ $*TYPENAME := $<typename>[0].ast; | |
+ } | |
+ <multi_declarator> | |
+ | <multi_declarator> | |
+} | |
+ | |
+token declarator { | |
+ [ | |
+ | <variable_declarator> | |
+ | <routine_declarator> | |
+ ] | |
+} | |
+ | |
+proto token multi_declarator { <...> } | |
+token multi_declarator:sym<multi> { | |
+ <sym> :my $*MULTINESS := 'multi'; | |
+ <.ws> [ <declarator> || <routine_def> || <.panic: 'Malformed multi'> ] | |
+} | |
+token multi_declarator:sym<null> { | |
+ :my $*MULTINESS := ''; | |
+ <declarator> | |
} | |
token variable_declarator { <variable> } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment