Skip to content

Instantly share code, notes, and snippets.

@zah
Created October 9, 2011 13:27
Show Gist options
  • Select an option

  • Save zah/1273686 to your computer and use it in GitHub Desktop.

Select an option

Save zah/1273686 to your computer and use it in GitHub Desktop.
Text blocks (for embedded languages)
x = xml ::
<item>
<field>
</field>
</item>
scanner = ragel ::
action dgt { printf("DGT: %c\n", fc); }
action dec { printf("DEC: .\n"); }
action exp { printf("EXP: %c\n", fc); }
action exp_sign { printf("SGN: %c\n", fc); }
action number { /*NUMBER*/ }
number = (
[0-9]+ $dgt ( '.' @dec [0-9]+ $dgt )?
( [eE] ( [+\-] $exp_sign )? [0-9]+ $exp )?
) %number;
main := ( number '\n' )*;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment