Skip to content

Instantly share code, notes, and snippets.

@colomon
Last active December 15, 2015 14:08
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 colomon/5271962 to your computer and use it in GitHub Desktop.
Save colomon/5271962 to your computer and use it in GitHub Desktop.
# use Grammar::Tracer;
grammar G {
token TOP {^ <integer-constant> $};
proto token integer-constant {*};
token integer-constant:sym<8> { <octal-constant> };
token integer-constant:sym<10> { <decimal-constant> };
token integer-constant:sym<16> { <hexadecimal-constant> };
token octal-constant { '0' <odigit>* };
token decimal-constant { <nzdigit> <digit>* };
token hexadecimal-constant { <.hexadecimal-prefix> <xdigit>* };
token hexadecimal-prefix { '0' <[xX]> };
token nzdigit { <[1..9]> };
token odigit { <[0..7]> };
}
say G.parse('0');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment