Skip to content

Instantly share code, notes, and snippets.

@SineSwiper
Created August 31, 2012 13:32
Show Gist options
  • Save SineSwiper/3552700 to your computer and use it in GitHub Desktop.
Save SineSwiper/3552700 to your computer and use it in GitHub Desktop.
multi rule declaration
sunday_morning: Im waking up | ( cant even focus on a coffee_cup )
coffee_cup: dont even know whos bed Im in
# Parser problems
lyric:
where
do
I
start
where
do
I
begin: / ( <WORD> ) /
# Works, but requires ;
lyric:
where
do
I
start
;
where
do
I
begin: / ( <WORD> ) /
# Might be a better route, since {} is never used in parser so far
lyric:
where
do
I
start
{ where do I begin }: / ( <WORD> ) /
@SineSwiper
Copy link
Author

Also, use something like <P_!NAME!_END>, meaning "prefix all of these with P_ and suffix with _END". The normal form would be <!NAME!>.

This would go along with some new meta attrs:

%prefix L_
%suffix _END
%atom_prefix C_
%atom_suffix _END

The %prefix / %suffix would be a "default" prefix/suffix for all declared rules. It only applies to rule names and only ones that don't already have a prefix/suffix declaration (like the <!NAME!> form above). The latter two are for adding prefix/suffix info to Atoms. This helps me out with things like keyword "ALWAYS" bumping into Atom "ALWAYS". Instead, prefixes can fix those:

%atom_prefix C_
%prefix L_
QUOTECONTINUE : / <C_SINGLE> <L_WHITESPACE_WITH_NEWLINE> <C_SINGLE> /

Obviously, the prefix/suffixes need to be manually used in rules:

%prefix L_
rule: L_rule2 <L_rule3>*
rule2: / <DOT> /
rule3: / <STAR> /

@SineSwiper
Copy link
Author

Bah, the <!NAME!> form is backwards... The naming stuff needs to go in the rule_name part, but that section is more sensitive to symbols/changes. Need to think about that angle some more...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment