Skip to content

Instantly share code, notes, and snippets.

@andydude
Created March 29, 2013 19:47
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 andydude/5273148 to your computer and use it in GitHub Desktop.
Save andydude/5273148 to your computer and use it in GitHub Desktop.
use Grammar::Debugger;
grammar C::CInteger;
token TOP {^ <integer-constant> $}
token integer-constant {
<integer-value> <integer-suffix>*
}
proto token integer-value {*}
token integer-value:sym<8> { <octal-constant> }
token integer-value:sym<10> { <decimal-constant> }
token integer-value: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]> }
proto token integer-suffix {*}
token integer-suffix:sym<L> { <[lL]> }
token integer-suffix:sym<LL> { < ll LL > }
token integer-suffix:sym<U> { <[uU]> }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment