Skip to content

Instantly share code, notes, and snippets.

@skids
Created December 18, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skids/b4caab210a473a586d51 to your computer and use it in GitHub Desktop.
Save skids/b4caab210a473a586d51 to your computer and use it in GitHub Desktop.
regex ℙ_production {
( <ℙ_new-lexical-item-name> ) <ℙ_lexical_separator>
'::=' <ℙ_lexical_separator>
# This next bit should be producing a prestructured lol-ish thing.
# Two things NYI|buggy prevent that:
# 1) @<alternatives>=(...)*
# 2) /(...) :my $f = $0; ($f)/
# So though it may appear the below several lines would be simpler
# put as [ $<a>=a | $<b>=b | $<c>=c ]* % <sep>
# they are kept in a future-looking form.
[ [ $<ℙ_recursive>=$0 <.ℙ_ident_stopper> | <ℙ_lexical-item> ]*
%% <ℙ_lexical_separator>
]*
% [ $<ℙ_next_alternative>='|' <ℙ_lexical_separator> ]
{ @defined-lexical-item-names.push($0);
my $r := production_to_rx($/);
$r.set_name($0);
self.^add_method($0, $r);
@defined-lexical-items.push($r);
make $r;
}
}
...
regex ℙ_defined-lexical-item-name {
@defined-lexical-item-names
}
our @defined-lexical-items = ();
regex ℙ_defined-lexical-item {
<@defined-lexical-items>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment