Skip to content

Instantly share code, notes, and snippets.

@jbulow
Created January 17, 2013 18:31
Show Gist options
  • Save jbulow/4558321 to your computer and use it in GitHub Desktop.
Save jbulow/4558321 to your computer and use it in GitHub Desktop.
.syntax meta
arg = '$' <'emit_token();'>
| .string <'emit(' $ ');'>;
output = '<' *arg '>' <'emit_nl();'>;
exp3 = .id <'meta_' $ '();'>
| .string <'read_literal(' $ ');'>
| '.id' <'read_id();'>
| '.number' <'read_number();'>
| '.string' <'read_string();'>
| '(' exp1 ')'
| '.e' <'test_flag = 1;'>
| '*' <'do {'>
exp3 <'} while (test_flag);'>
<'test_flag = 1;'>;
exp2 = ( exp3 <'if (test_flag) {'>
| output <'if (1) {'> )
*( exp3 <'error_if_false();'>
| output )
<'}'>;
exp1 = <'do {'> exp2
*( '|' <'if (test_flag) { break; }'> exp2 )
<'} while (0);'>;
stat = .id <'void meta_' $ '(void)'>
<'{'>
'=' exp1 ';'
<'}'>;
program = '.syntax' .id <'#include "support.h"'>
*stat
'.end';
.end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment