Created
December 17, 2012 20:00
-
-
Save FROGGS/4321533 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
grammar PackageDeclarator { | |
rule TOP { <package_declarator>+ % [ .*? ] } | |
token namespace { <[\w]>+ } | |
token package_def { <namespace>+ % [ '::' ] } | |
token end_keyword { [ ';' | '{' ] } | |
rule package_declarator { | |
[ | |
'package' $<package> = <package_def> <end_keyword> | |
| 'module' $<module> = <package_def> <end_keyword> | |
| 'class' $<class> = <package_def> <end_keyword> | |
| 'role' $<role> = <package_def> <end_keyword> | |
| 'knowhow' $<knowhow> = <package_def> <end_keyword> | |
| 'native' $<native> = <package_def> <end_keyword> | |
| 'slang' $<slang> = <package_def> <end_keyword> | |
| 'grammar' $<grammar> = <package_def> <end_keyword> | |
] | |
} | |
} | |
my $module = PackageDeclarator.parse(q{ | |
module Debug::UI::CommandLine; | |
use Term::ANSIColor; | |
# The source code of the files we've encountred while debugging. | |
my %sources; | |
... | |
}); | |
for $module<package_declarator> -> $thing { | |
say ~$thing<package_def>; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment