Bug: self-referencing grammer fixed

fixed self referencing grammer fixed and also connected the two file ,parser and grammer. initial parser code added
This commit is contained in:
Mann Patel
2025-09-24 18:43:46 -06:00
parent a746021ce0
commit ddc469da07
8 changed files with 1900 additions and 10 deletions

36
ExprParser.g4 Normal file
View File

@@ -0,0 +1,36 @@
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 ;