Skip to content

Commit

Permalink
aslt: remove parens around var decl names
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Mar 13, 2024
1 parent 0dd10e5 commit 35770c4
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 51 deletions.
6 changes: 1 addition & 5 deletions libASL/Semantics.g4
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ assignment_stmt:
'Stmt_Assign' OPEN_PAREN lexpr COMMA expr CLOSE_PAREN # Assign
| 'Stmt_ConstDecl' OPEN_PAREN type COMMA ident COMMA expr CLOSE_PAREN # ConstDecl
| 'Stmt_VarDecl' OPEN_PAREN type COMMA ident COMMA expr CLOSE_PAREN # VarDecl
| 'Stmt_VarDeclsNoInit' OPEN_PAREN type COMMA OPEN_BRACKET OPEN_PAREN (ident (COMMA ident)*)? CLOSE_PAREN CLOSE_BRACKET CLOSE_PAREN # VarDeclsNoInit
| 'Stmt_VarDeclsNoInit' OPEN_PAREN type COMMA OPEN_BRACKET (ident (COMMA ident)*)? CLOSE_BRACKET CLOSE_PAREN # VarDeclsNoInit
| 'Stmt_Assert' OPEN_PAREN expr CLOSE_PAREN # Assert
| 'Stmt_Throw' OPEN_PAREN message=ident+ CLOSE_PAREN # Throw;

Expand Down Expand Up @@ -88,12 +88,8 @@ CLOSE_PAREN: ')';
COMMA: ',';
OPEN_BRACKET: '[';
CLOSE_BRACKET: ']';
OPEN_CURLY: '{';
CLOSE_CURLY: '}';
SQUOTE: '\'';
QUOTE: '"';
EQUALS: '=';
COLON: ':';
SCOLON: ';';

// Ignored
Expand Down
10 changes: 9 additions & 1 deletion libASL/asl.ott
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ anyident :: '' ::= {{ phantom }}
| id :: :: AnyIdent {{ ocaml Ident [[id]] }}
| typeid :: :: AnyTypeIdent {{ ocaml Ident [[typeid]] }}

ident_list :: 'IdentList_' ::=
{{ phantom }} {{ ocaml ident list }}
{{ pp-raw es = string "[" ^^ separate (string ";") (List.map pp_raw_ident es) ^^ string "]" }}
{{ pp es = separate (string ",") (List.map pp_ident es) }}
| ident1 , .. , identn :: :: List
{{ ocaml [[ident1..identn]] }}


grammar

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -556,7 +564,7 @@ nonempty_block :: 'Block_' ::= {{ quotient-with indented_block }}

assignment_stmt :: 'Stmt_' ::= {{ quotient-with stmt }}
{{ aux _ l }}
| ty ident1 , ... , identn ; :: :: VarDeclsNoInit
| ty ident_list ; :: :: VarDeclsNoInit
| ty ident = expr ; :: :: VarDecl
| constant ty ident = expr ; :: :: ConstDecl
| lexpr = expr ; :: :: Assign
Expand Down
4 changes: 2 additions & 2 deletions tests/aslt/test_antlr.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tests building and running of the antlr grammar. requires java
(stmt (call_stmt Stmt_TCall ( (ident " Mem.set.0 ") , [ (targs (expr (integer 8))) ] , [ (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 3)) )) ; (expr (integer 8)) ; (expr (integer 0)) ; (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 1)) )) ] )))
(stmt (call_stmt Stmt_TCall ( (ident " Mem.set.0 ") , [ (targs (expr (integer 8))) ] , [ (expr Expr_TApply ( (ident " add_bits.0 ") , [ (targs (expr (integer 64))) ] , [ (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 3)) )) ; (expr (bits '0000000000000000000000000000000000000000000000000000000000001000')) ] )) ; (expr (integer 8)) ; (expr (integer 0)) ; (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 2)) )) ] )))
(stmt (assignment_stmt Stmt_Assign ( (lexpr LExpr_Array ( (lexpr LExpr_Var ( (ident " _R ") )) , (expr (integer 3)) )) , (expr Expr_TApply ( (ident " add_bits.0 ") , [ (targs (expr (integer 64))) ] , [ (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 3)) )) ; (expr (bits '0000000000000000000000000000000000000000000000000000000010000000')) ] )) )))
(stmt (assignment_stmt Stmt_VarDeclsNoInit ( (type Type_Bits ( (expr (integer 3)) )) , [ ( (ident " FPDecodeRounding5__5 ") ) ] )))
(stmt (assignment_stmt Stmt_VarDeclsNoInit ( (type Type_Bits ( (expr (integer 3)) )) , [ (ident " FPDecodeRounding5__5 ") ] )))
(stmt (assignment_stmt Stmt_Assign ( (lexpr LExpr_Var ( (ident " FPDecodeRounding5__5 ") )) , (expr Expr_TApply ( (ident " ZeroExtend.0 ") , [ (targs (expr (integer 2))) ; (targs (expr (integer 3))) ] , [ (expr Expr_Slices ( (expr Expr_Var ( (ident " FPCR ") )) , [ (slice_expr Slice_LoWd ( (expr (integer 22)) , (expr (integer 2)) )) ] )) ; (expr (integer 3)) ] )) )))
(stmt (assignment_stmt Stmt_ConstDecl ( (type Type_Bits ( (expr (integer 64)) )) , (ident " Exp9__5 ") , (expr Expr_TApply ( (ident " FixedToFP.0 ") , [ (targs (expr (integer 32))) ; (targs (expr (integer 64))) ] , [ (expr Expr_Slices ( (expr Expr_Array ( (expr Expr_Var ( (ident " _R ") )) , (expr (integer 2)) )) , [ (slice_expr Slice_LoWd ( (expr (integer 0)) , (expr (integer 32)) )) ] )) ; (expr (integer 0)) ; (expr Expr_Var ( (ident " TRUE ") )) ; (expr Expr_Var ( (ident " FPCR ") )) ; (expr Expr_TApply ( (ident " cvt_bits_uint.0 ") , [ (targs (expr (integer 3))) ] , [ (expr Expr_Var ( (ident " FPDecodeRounding5__5 ") )) ] )) ] )) )))
(stmt (assignment_stmt Stmt_Assign ( (lexpr LExpr_Array ( (lexpr LExpr_Var ( (ident " _Z ") )) , (expr (integer 0)) )) , (expr Expr_TApply ( (ident " ZeroExtend.0 ") , [ (targs (expr (integer 64))) ; (targs (expr (integer 128))) ] , [ (expr Expr_Var ( (ident " Exp9__5 ") )) ; (expr (integer 128)) ] )) )))
Expand All @@ -36,7 +36,7 @@ tests building and running of the antlr grammar. requires java
(stmt (assignment_stmt Stmt_ConstDecl ( (type Type_Bits ( (expr (integer 9)) )) , (ident " Cse2__5 ") , (expr Expr_TApply ( (ident " ZeroExtend.0 ") , [ (targs (expr (integer 8))) ; (targs (expr (integer 9))) ] , [ (expr Expr_Slices ( (expr Expr_Array ( (expr Expr_Var ( (ident " _Z ") )) , (expr (integer 0)) )) , [ (slice_expr Slice_LoWd ( (expr (integer 40)) , (expr (integer 8)) )) ] )) ; (expr (integer 9)) ] )) )))
(stmt (assignment_stmt Stmt_ConstDecl ( (type Type_Bits ( (expr (integer 9)) )) , (ident " Cse1__5 ") , (expr Expr_TApply ( (ident " ZeroExtend.0 ") , [ (targs (expr (integer 8))) ; (targs (expr (integer 9))) ] , [ (expr Expr_Slices ( (expr Expr_Array ( (expr Expr_Var ( (ident " _Z ") )) , (expr (integer 0)) )) , [ (slice_expr Slice_LoWd ( (expr (integer 48)) , (expr (integer 8)) )) ] )) ; (expr (integer 9)) ] )) )))
(stmt (assignment_stmt Stmt_ConstDecl ( (type Type_Bits ( (expr (integer 9)) )) , (ident " Cse0__5 ") , (expr Expr_TApply ( (ident " ZeroExtend.0 ") , [ (targs (expr (integer 8))) ; (targs (expr (integer 9))) ] , [ (expr Expr_Slices ( (expr Expr_Array ( (expr Expr_Var ( (ident " _Z ") )) , (expr (integer 0)) )) , [ (slice_expr Slice_LoWd ( (expr (integer 56)) , (expr (integer 8)) )) ] )) ; (expr (integer 9)) ] )) )))
(stmt (assignment_stmt Stmt_VarDeclsNoInit ( (type Type_Bits ( (expr (integer 64)) )) , [ ( (ident " result__4 ") ) ] )))
(stmt (assignment_stmt Stmt_VarDeclsNoInit ( (type Type_Bits ( (expr (integer 64)) )) , [ (ident " result__4 ") ] )))
(stmt (assignment_stmt Stmt_Assign ( (lexpr LExpr_Var ( (ident " result__4 ") )) , (expr (bits '0000000000000000000000000000000000000000000000000000000000000000')) )))
(stmt (conditional_stmt Stmt_If ( (expr Expr_TApply ( (ident " slt_bits.0 ") , [ (targs (expr (integer 9))) ] , [ (expr Expr_Var ( (ident " Cse7__5 ") )) ; (expr (bits '000010000')) ] )) ,
(stmts [
Expand Down
Loading

0 comments on commit 35770c4

Please sign in to comment.