%source { #include #include #include } %common { #include "ast.h" #include "run.h" } %value "AstNode" expr <- l:list { $$ = l; } / n:number { $$ = n; } / s:symbol { $$ = s; } list <- { $$ = astnode_new_list(); } '(' ( e:expr { astnode_append(&$$, e); } )* ')' _ number <- < [0-9]+ > (! ident_char) _ { $$ = astnode_new_num(atoi($1)); } symbol <- < ident_char+ > _ { $$ = astnode_new_symbol(strdup($1)); } ident_char <- [-_a-zA-Z'+*0-9] _ <- [ \t]*