summaryrefslogtreecommitdiff
path: root/parser.y
blob: 3af9a923cfee03d7e378a3b4ca8e178a02ec1b57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* vi: set ts=4 sw=4 noet ft= : */

%include {
#include "ast.h"
}

%token_type {char *}

%type start {ast *}
start(A) ::= expr(B). { A = B; }

%type expr {ast *}
expr(A) ::= LPAREN expr(B) SEP expr(C) RPAREN. { A = new_pair(B, C); }
expr(A) ::= INT(B). { A = new_int(B); }
expr(A) ::= FLOAT(B). { A = new_float(B); }
expr(A) ::= ID(B). { A = new_id(B); }