Files
Software-Analysis/ExprParser.g4
Mann Patel ddc469da07 Bug: self-referencing grammer fixed
fixed self referencing grammer fixed and also connected the two file ,parser and grammer. initial parser code added
2025-09-24 18:43:46 -06:00

36 lines
790 B
ANTLR

parser grammar ExprParser;
options {
tokenVocab=ExprLexer;
}
// Class Parser rules
prog : class EOF;
class:(Public | Private | Protected ) Class ID SLPAREN method+ SRPAREN;
//Method Decloration
method: Public Static Void ID LPAREN arg* RPAREN SLPAREN methodCode SRPAREN
| Private Static Void ID SLPAREN methodCode SRPAREN
| Protected Static Void ID SLPAREN methodCode SRPAREN
;
methodCode: systemOutPrint* forloop*
;
systemOutPrint
: SYSTEM DOT OUT DOT PRINT LPAREN data RPAREN SEMI;
forloop: For LPAREN arg RPAREN SLPAREN methodCode SRPAREN;
arg: String arraydef* ID
| exp SEMI exp SEMI exp
;
exp: define
| ID GreterEql INTE
| ID INCMENT
;
define : Int ID EQL INTE;
arraydef: SqLPAREN (data T)* SqRPAREN;
data: STRING ;