Skip to content

Commit

Permalink
"stmtterm" where identifier can't be "if"/"while"/"nop" since these a…
Browse files Browse the repository at this point in the history
…re used in statements...
  • Loading branch information
Josef552 committed Sep 26, 2024
1 parent 935542a commit 8f1347b
Show file tree
Hide file tree
Showing 2 changed files with 1,074 additions and 723 deletions.
37 changes: 35 additions & 2 deletions src/parser/timedAutomata.jison
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ item
| syncDef {$$ = $1;}
;

identifier
stmtidentifier
: TOK_ID {$$ = $1;}
| TOK_INIT {$$ = $1;}
| TOK_LABELS {$$ = $1;}
Expand All @@ -105,6 +105,25 @@ identifier
| TOK_LAYOUT {$$ = $1;}
;

identifier
: TOK_ID {$$ = $1;}
| TOK_INIT {$$ = $1;}
| TOK_LABELS {$$ = $1;}
| TOK_INVAR {$$ = $1;}
| TOK_COMMIT {$$ = $1;}
| TOK_URGENT {$$ = $1;}
| TOK_PROV {$$ = $1;}
| TOK_DO {$$ = $1;}
| TOK_THEN {$$ = $1;}
| TOK_END {$$ = $1;}
| TOK_ELSE {$$ = $1;}
| TOK_LOCAL {$$ = $1;}
| TOK_LAYOUT {$$ = $1;}
| TOK_IF {$$ = $1;}
| TOK_WHILE {$$ = $1;}
| TOK_NOP {$$ = $1;}
;

systemDef
: TOK_SYSTEM TOK_COLON identifier attributeList { $$ = {type: $1, name: $3, attributes: $4};}
| TOK_SYSTEM TOK_COLON identifier { $$ = {type: $1, name: $3};}
Expand Down Expand Up @@ -234,8 +253,22 @@ statement
| while_statement {$$ = {whileStatement: $1};}
;

stmtterm
: atomic_stmtterm {$$ = {term: $1};}
| TOK_MINUS stmtterm {$$ = {minus: $1, term: $2};}
| TOK_LPARENTHESES stmtterm TOK_RPARENTHESES {$$ = {termInParen: $2};}
| TOK_LPARENTHESES stmtterm TOK_RPARENTHESES maths stmtterm {$$ = {termInParenL: $2, maths: $4, termR: $5};}
| atomic_stmtterm maths stmtterm {$$ = {termL: $1, maths: $2, termR: $3};}
;

atomic_stmtterm
: TOK_INTEGER {$$ = {value: $1};}
| stmtidentifier {$$ = {identifier: $1};}
| stmtidentifier TOK_LBRACKET stmtterm TOK_RBRACKET {$$ = {identifier: $1, insideBrackets: $3};}
;

do_term
: term TOK_SET term {$$ = {lhs: $1, set: $2, rhs: $3};}
: stmtterm TOK_SET stmtterm {$$ = {lhs: $1, set: $2, rhs: $3};}
;

local_statement
Expand Down
Loading

0 comments on commit 8f1347b

Please sign in to comment.