From e1d071fb1f172e3bffe976e705b229d328acd950 Mon Sep 17 00:00:00 2001 From: Rohan Jacob-Rao Date: Tue, 4 Aug 2015 17:40:49 -0700 Subject: [PATCH] Fix error in parsing int constants. --- infer/src/llvm/lLexer.mll | 8 ++++---- infer/src/llvm/lParser.mly | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/infer/src/llvm/lLexer.mll b/infer/src/llvm/lLexer.mll index 2ad880d0e..85c2d9a26 100644 --- a/infer/src/llvm/lLexer.mll +++ b/infer/src/llvm/lLexer.mll @@ -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 } diff --git a/infer/src/llvm/lParser.mly b/infer/src/llvm/lParser.mly index bb09ac13c..42f929a12 100644 --- a/infer/src/llvm/lParser.mly +++ b/infer/src/llvm/lParser.mly @@ -42,9 +42,8 @@ %token LABEL %token METADATA -%token SIZE (* CONSTANTS *) -%token CONSTINT +%token 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 }