HyriseSQLParser/lemon_example/lemon_parser.y

23 lines
474 B
Plaintext
Raw Normal View History

%include {
#include <assert.h>
#include <cstdlib>
2014-10-17 17:43:57 +02:00
#include "token_def.h"
}
%syntax_error { printf("Lemon syntax error\n"); }
2014-10-17 17:43:57 +02:00
%token_type {LexerToken*}
%extra_argument { float* result }
2014-10-17 17:43:57 +02:00
%type expr {float}
%left PLUS MINUS .
start ::= prog.
prog ::= prog print NL .
prog ::= prog print .
prog ::= .
print ::= expr(a) . { *result = a; }
2014-10-17 17:43:57 +02:00
expr(a) ::= NUMBER(b) . { a = b->fval; }
expr(a) ::= expr(b) PLUS expr(c) . { a = b + c; }