You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I start debugging, I can't make it pause at any rule. Here is my input text file:
int a, b, c; float func(int a, b; float c){ a = b; func(1, 2, a); return a + b - c; } float main(int a, b; float d, e, f){ float x, y; d = a / e + i + func(a, d - e, func(a, c) * f); return c * d / e * func(1, b - c + d, func(1) - f); }
The grammar is correct, i think, because it results in a correct parse tree. I don't know where the problem is. Can somebody please help me? Thanks a lot.
The text was updated successfully, but these errors were encountered:
Hi, can anyone help me at this. I have a grammar file named "MC.g4" and a "launch.json" file as follow:
`grammar MC; //MC.g4
@lexer::header {
from lexererr import *
}
@lexer::member {
def emit(self):
tk = self.type
if tk == UNCLOSE_STRING:
result = super.emit();
raise UncloseString(result.text);
elif tk == ILLEGAL_ESCAPE:
result = super.emit();
raise IllegalEscape(result.text);
elif tk == ERROR_CHAR:
result = super.emit();
raise ErrorToken(result.text);
else:
return super.emit();
}
options{
language=Python3;
}
program: manydecls EOF;
manydecls: decl manydecls | decl;
decl: vardecl | funcdecl;
vardecl: mctype listid SM;
funcdecl: mctype ID paradecl funcbody;
paradecl: LP listpara RP;
listpara: (vardecl* mctype listid)?;
funcbody: LB (vardecl|stmt)* RB;
stmt: (assignment|call|returnstmt) SM;
assignment: ID EQ exp;
call: ID LP ((exp CM)* exp)? RP;
returnstmt: 'return' exp;
exp: exp1 ADD exp | exp1;
exp1: exp2 SUB exp2 | exp2;
exp2: exp2 (MUL|DIV) exp3 | exp3;
exp3: LP exp RP | operand;
operand: INTLIT|FLOATLIT|ID|call;
mctype: INTTYPE | FLOATTYPE ;
listid: (ID CM)* ID;
INTTYPE: 'int';
FLOATTYPE: 'float' ;
ID: [a-zA-Z]+ ;
INTLIT: DIGIT+;
FLOATLIT: (DIGIT+ DOT DIGIT*|DOT DIGIT+|DIGIT+) ([eE][+-]?DIGIT+)?;
DIGIT: [0-9];
DOT: '.';
LP: '(';
RP: ')';
LB: '{';
EQ: '=';
RB: '}';
SM: ';';
CM: ',';
ADD: '+';
SUB: '-';
MUL: '*';
DIV: '/';
WS : [ \t\f\r\n]+ -> skip ; // skip spaces, tabs, newlines
ERROR_CHAR: .;
{
UNCLOSE_STRING: .;
ILLEGAL_ESCAPE: .;
//launch.json
"version": "0.2.0",
"configurations": [
{
"name": "Debug ANTLR4 grammar",
"type": "antlr-debug",
"request": "launch",
"input": "C:/Users/HP/Desktop/initial/src/test/testcases/201.txt",
"grammar": "C:/Users/HP/Desktop/initial/src/main/mc/parser/MC.g4",
"startRule": "program",
"printParseTree": true,
"visualParseTree": true
}
]
}`
When I start debugging, I can't make it pause at any rule. Here is my input text file:
int a, b, c; float func(int a, b; float c){ a = b; func(1, 2, a); return a + b - c; } float main(int a, b; float d, e, f){ float x, y; d = a / e + i + func(a, d - e, func(a, c) * f); return c * d / e * func(1, b - c + d, func(1) - f); }
The grammar is correct, i think, because it results in a correct parse tree. I don't know where the problem is. Can somebody please help me? Thanks a lot.
The text was updated successfully, but these errors were encountered: