Parse EBNF: Difference between revisions

m
→‎{{header|Raku}}: Fix code and comments: Perl 6 --> Raku
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (→‎{{header|Raku}}: Fix code and comments: Perl 6 --> Raku)
Line 1,658:
{{works with|Rakudo|2019.03.1}}
 
This parses the EBNF rule set using a perl 6Raku grammar, then if it parses as valid EBNF, constructs a grammar and parses the test strings with that. EBNF rule sets that are naively syntactically correct but missing rules will parse as valid but will give a runtime failure warning about missing methods.
It is implemented and exercised using the flavor of EBNF and test cases specified on the [[Parse EBNF/Tests|test page]].
 
<lang perl6># A perl 6Raku grammar to parse EBNF
grammar EBNF {
rule TOP { ^ <title>? '{' [ <production> ]+ '}' <comment>? $ }
Line 1,794:
$fh.say( qq| "\\n"} |);
$fh.close;
say qqx/perl6raku $fn/;
say '*' x 79, "\n";
unlink $fn;
2,392

edits