Fix error in parsing int constants.

master
Rohan Jacob-Rao 9 years ago
parent 66aecca31f
commit e1d071fb1f

@ -68,11 +68,11 @@ rule token = parse
| "label" { LABEL }
| "metadata" { METADATA }
| pos_int as size { SIZE (int_of_string size) }
| pos_int as size { CONSTANT_INT (int_of_string size) }
(* CONSTANTS *)
| "true" { CONSTINT 1 }
| "false" { CONSTINT 0 }
| intlit as i { CONSTINT (int_of_string i) }
| "true" { CONSTANT_INT 1 }
| "false" { CONSTANT_INT 0 }
| intlit as i { CONSTANT_INT (int_of_string i) }
(* floating point constants *)
| "null" { NULL }

@ -42,9 +42,8 @@
%token LABEL
%token METADATA
%token <int> SIZE
(* CONSTANTS *)
%token <int> CONSTINT
%token <int> CONSTANT_INT
%token NULL
(* INSTRUCTIONS *)
@ -162,13 +161,13 @@ typ:
| tp = element_typ { tp }
(*| X86_MMX { () }*)
| tp = vector_typ { tp }
| LSQBRACK sz = SIZE X tp = element_typ RSQBRACK { Tarray (sz, tp) } (* array type *)
| LSQBRACK sz = CONSTANT_INT X tp = element_typ RSQBRACK { Tarray (sz, tp) } (* array type *)
| LABEL { Tlabel }
| METADATA { Tmetadata }
(* TODO structs *)
vector_typ:
| LANGLE sz = SIZE X tp = element_typ RANGLE { Tvector (sz, tp) }
| LANGLE sz = CONSTANT_INT X tp = element_typ RANGLE { Tvector (sz, tp) }
element_typ:
| width = INT { Tint width }
@ -196,7 +195,7 @@ instr:
| BR LABEL lbl=variable { UncondBranch lbl }
| BR BIT op=operand COMMA LABEL lbl1=variable COMMA LABEL lbl2=variable { CondBranch (op, lbl1, lbl2) }
(* Memory access operations *)
| var=variable EQUALS ALLOCA tp=typ (*COMMA ALIGN sz=SIZE*) { Alloc (var, tp, 1, 1) }
| var=variable EQUALS ALLOCA tp=typ (*COMMA ALIGN sz=CONSTANT_INT*) { Alloc (var, tp, 1, 1) }
| var = variable EQUALS LOAD tp = ptr_typ ptr = variable { Load (var, tp, ptr) }
| STORE val_tp = typ value = operand COMMA ptr_tp = ptr_typ var = variable { Store (value, val_tp, var) }
(* don't yet know why val_tp and ptr_tp would be different *)
@ -248,5 +247,5 @@ variable:
| num = NUMBERED_LOCAL { Local (Number num) }
constant:
| i = CONSTINT { Cint i }
| i = CONSTANT_INT { Cint i }
| NULL { Cnull }

Loading…
Cancel
Save