Skip to content

Instantly share code, notes, and snippets.

@patrickt
Created May 5, 2010 02:33
Show Gist options
  • Save patrickt/390303 to your computer and use it in GitHub Desktop.
Save patrickt/390303 to your computer and use it in GitHub Desktop.
program = - value+ EOF?
integer = < numeric > - { $$ = number_from_long(atol(yytext)); }
float = < numeric? '.' numeric > - { $$ = number_from_double(atof(yytext)) }
boolean = "true" - { $$ = TRUE_V; }
| "false" - { $$ = FALSE_V; }
string = '"' < (!'"' .)* > '"' - { $$ = string_new(yytext, yyleng); }
sexp = OPEN_SEXPR { MILDVM->push_sexp(MILDVM) }
-
(value -)*
CLOSE_SEXPR { $$ = MILDVM->pop_sexp(MILDVM); }
-
symbol = < identifier+ > - { $$ = symbol_from_cstr_n(yytext, yyleng); }
value = (sexp | boolean | string | symbol | float | integer) { ADD_NODE($$); }
- = ( whitespace | comment )*
whitespace = SPACE | TAB | EOL
comment = ';' ( !EOL . )* EOL
numeric = (( MINUS? DIGIT ZDIGIT* ) | '0')
identifier = [A-z+] | '-'
OPEN_SEXPR = [(\[]
CLOSE_SEXPR = [)\]]
DIGIT = [1-9]
ZDIGIT = [0-9]
MINUS = '-'
SPACE = ' '
TAB = '\t'
EOL = '\r\n' | '\n' | '\r'
EOF = !.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment