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:
36
ExprParser.g4
Normal file
36
ExprParser.g4
Normal 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 ;
|
||||
Reference in New Issue
Block a user