Skip to content

Commit

Permalink
Added xtext version of the grammar.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchaudhri committed Sep 25, 2018
1 parent 7bca3f5 commit 59ba1ae
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions RuleSpec/doc/grammar.xtext
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Model:
statements+=Statement*;

Statement:
Equality | IfThenElse;

Equality:
left=CONSTANT "=" (rightExp=Expression | rightStr=STRING);

IfThenElse:
"if" cond=Condition "then" ifStatements+=Statement+ ("else" elseStatements+=Statement+)? "endif";

Expression:
Addition;

Addition:
Multiplication (('+' | '-') Multiplication)*;

Multiplication:
Primary (('*' | '/' | 'div' | 'mod') Primary)*;

Primary:
CONSTANT | NUMBER |
'(' Addition ')';

Condition: Or;

Or: And ('or' disjuncts+=And)*;

And: Primary2 ('and' conjuncts+=Primary2)*;

Primary2: lit=Literal | "(" inner=Or ")" ;

Literal:
atomicFormula=AtomicFormula | "not" negatedAtomicFormula=AtomicFormula;

AtomicFormula:
"(" CONSTANT (("<" | ">" | "<=" | ">=" | "==" | "<>") (NUMBER | STRING | CONSTANT))? ")";

CONSTANT:
ID;

@Override
terminal ID:
'^'? ('a'..'z' | 'A'..'Z') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')* ('[' ('a'..'z' | '0'..'9')* ']')?;
terminal NUMBER:
INT ("." INT)?;

@Override
terminal SL_COMMENT:
'#' !('\n' | '\r')* ('\r'? '\n')?;

0 comments on commit 59ba1ae

Please sign in to comment.