summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lexer2.mll11
-rw-r--r--src/parser2.mly21
-rw-r--r--src/pretty_print_sail2.ml5
3 files changed, 21 insertions, 16 deletions
diff --git a/src/lexer2.mll b/src/lexer2.mll
index f017667a..4acbd6e5 100644
--- a/src/lexer2.mll
+++ b/src/lexer2.mll
@@ -100,16 +100,13 @@ let kw_table =
("match", (fun _ -> Match));
("clause", (fun _ -> Clause));
("dec", (fun _ -> Dec));
- ("def", (fun _ -> Def));
("operator", (fun _ -> Op));
("default", (fun _ -> Default));
("effect", (fun _ -> Effect));
- ("Effect", (fun _ -> EFFECT));
("end", (fun _ -> End));
("enum", (fun _ -> Enum));
("else", (fun _ -> Else));
("exit", (fun _ -> Exit));
- ("extern", (fun _ -> Extern));
("cast", (fun _ -> Cast));
("false", (fun _ -> False));
("forall", (fun _ -> Forall));
@@ -121,15 +118,11 @@ let kw_table =
("catch", (fun _ -> Catch));
("if", (fun x -> If_));
("in", (fun x -> In));
- ("integer", (fun _ -> Integer));
("inc", (fun _ -> Inc));
- ("IN", (fun x -> IN));
("let", (fun x -> Let_));
- ("member", (fun x -> Member));
("Int", (fun x -> Int));
("Order", (fun x -> Order));
("pure", (fun x -> Pure));
- ("rec", (fun x -> Rec));
("register", (fun x -> Register));
("return", (fun x -> Return));
("scattered", (fun x -> Scattered));
@@ -144,6 +137,10 @@ let kw_table =
("union", (fun x -> Union));
("with", (fun x -> With));
("val", (fun x -> Val));
+ ("repeat", (fun _ -> Repeat));
+ ("until", (fun _ -> Until));
+ ("while", (fun _ -> While));
+ ("do", (fun _ -> Do));
("barr", (fun x -> Barr));
("depend", (fun x -> Depend));
diff --git a/src/parser2.mly b/src/parser2.mly
index e3ac3f5a..e6c63196 100644
--- a/src/parser2.mly
+++ b/src/parser2.mly
@@ -124,18 +124,19 @@ let rec desugar_rchain chain s e =
/*Terminals with no content*/
-%token And As Assert Bitzero Bitone Bits By Match Clause Dec Def Default Effect EFFECT End Op
-%token Enum Else Extern False Forall Exist Foreach Overload Function_ If_ In IN Inc Let_ Member Int Order Cast
-%token Pure Rec Register Return Scattered Sizeof Struct Then True TwoCaret Type TYPE Typedef
-%token Undefined Union With Val Constraint Throw Try Catch Exit Integer
+%token And As Assert Bitzero Bitone By Match Clause Dec Default Effect End Op
+%token Enum Else False Forall Foreach Overload Function_ If_ In Inc Let_ Int Order Cast
+%token Pure Register Return Scattered Sizeof Struct Then True TwoCaret TYPE Typedef
+%token Undefined Union With Val Constraint Throw Try Catch Exit
%token Barr Depend Rreg Wreg Rmem Rmemt Wmem Wmv Wmvt Eamem Exmem Undef Unspec Nondet Escape
+%token Repeat Until While Do
%nonassoc Then
%nonassoc Else
%token Bar Comma Dot Eof Minus Semi Under DotDot
%token Lcurly Rcurly Lparen Rparen Lsquare Rsquare LcurlyBar RcurlyBar
-%token MinusGt LtBar LtColon SquareBar SquareBarBar
+%token MinusGt
/*Terminals with content*/
@@ -143,10 +144,10 @@ let rec desugar_rchain chain s e =
%token <int> Num
%token <string> String Bin Hex Real
-%token <string> Amp At Caret Div Eq Excl Gt Lt Plus Star EqGt Unit
+%token <string> Amp At Caret Eq Gt Lt Plus Star EqGt Unit
%token <string> Colon ExclEq
-%token <string> GtEq GtEqPlus GtGt GtGtGt GtPlus
-%token <string> LtEq LtEqPlus LtGt LtLt LtLtLt LtPlus StarStar
+%token <string> GtEq
+%token <string> LtEq
%token <string> Op0 Op1 Op2 Op3 Op4 Op5 Op6 Op7 Op8 Op9
%token <string> Op0l Op1l Op2l Op3l Op4l Op5l Op6l Op7l Op8l Op9l
@@ -715,6 +716,10 @@ exp:
else ATyp_aux(ATyp_dec,loc $startpos($6) $endpos($6))
in
mk_exp (E_for ($3, $5, $7, step, ord, $9)) $startpos $endpos }
+ | Repeat exp Until exp
+ { mk_exp (E_loop (Until, $4, $2)) $startpos $endpos }
+ | While exp Do exp
+ { mk_exp (E_loop (While, $2, $4)) $startpos $endpos }
/* The following implements all nine levels of user-defined precedence for
operators in expressions, with both left, right and non-associative operators */
diff --git a/src/pretty_print_sail2.ml b/src/pretty_print_sail2.ml
index 4d3befb7..3fa05132 100644
--- a/src/pretty_print_sail2.ml
+++ b/src/pretty_print_sail2.ml
@@ -181,7 +181,10 @@ let rec doc_exp (E_aux (e_aux, _) as exp) =
| E_list exps -> string "E_list"
| E_cons (exp1, exp2) -> string "E_cons"
| E_record fexps -> string "E_record"
- | E_loop _ -> string "E_loop"
+ | E_loop (While, cond, exp) ->
+ separate space [string "while"; doc_exp cond; string "do"; doc_exp exp]
+ | E_loop (Until, cond, exp) ->
+ separate space [string "repeat"; doc_exp exp; string "until"; doc_exp cond]
| E_record_update (exp, fexps) -> string "E_record_update"
| E_vector_append (exp1, exp2) -> separate space [doc_atomic_exp exp1; string "@"; doc_atomic_exp exp2]
| E_case (exp, pexps) ->