parrotcode: A grammar for parsing Perl 1 | |
Contents | Language Implementations | Punie |
PunieGrammar -- A grammar for parsing Perl 1
.sub _main :main
load_bytecode 'PunieGrammar.pir'
.local pmc start_rule
.local pmc match
.local string source
# Perl 1 source code
source = 'print 1;'
# Retrieve the start rule
start_rule = find_global 'PunieGrammar', 'prog'
# Parse the source and return a match object
match = prog(source)
... # Do something with the parse tree
end
.end
This is a grammar to parse Perl 1 programs. It inherits the behavior of the PGE::Grammar class. It parses a string of source code according to its hierarchy of rules and returns a PGE::Match object (a parse tree).
Copyright (C) 2005, The Perl Foundation.
This is free software; you may redistribute it and/or modify it under the same terms as Parrot.
Allison Randal <allison@perl.org>
|