All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.mihosoft.vmf.vmftext.antlr.GrammarVMF.g4 Maven / Gradle / Ivy

The newest version!
grammar GrammarVMF;


prog:   (expressions+=expr NEWLINE)*;


/**

classes:

prog {
    @Contains(opposite="parent")
    Expr[] getExpressions();
}

expr {
   @Container(opposite="expressions")
   prog getParent();
}


operatorExpr {
  Operator getOp();
}

constantExpr {
  Object getValue();
}

operator {

}

*/

expr:
        op=PREFIXUNARYOP  expression=expr  # prefixUnaryOpExpr   // extends unaryOpExpr extends operatorExpr
    |   expression=expr op=PREFIXUNARYOP   # postfixUnaryOpExpr  // extends unaryOpExpr extends operatorExpr
    |   left=expr op=BINOP right=expr      # binaryOperatorExpr  // extends operatorExpr
    |   value=INT                          # constantIntegerExpr // extends constantExpr
    |   value=BOOL                         # constantBooleanExpr // extends constantExpr
    |   '(' expr ')'                       # paranExpr           // ignore
    ;

/**
mappings:
INT             -> int
BOOL            -> boolean
BINOP           -> Operator
PREFIXUNARYOP   -> Operator
POSTFIXUNARYOP  -> Operator
*/

NEWLINE : [\r\n]+ ;
INT     : [0-9]+ ;
BINOP      : ('*'|'/'|'+'|'-');
PREFIXUNARYOP    : ('++'|'--'|'!');
POSTFIXUNARYOP    : ('++'|'--');

BOOL : 'true' | 'false';




© 2015 - 2024 Weber Informatics LLC | Privacy Policy