Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging not pause at breakpoint #92

Closed
thanhson208s opened this issue Sep 4, 2019 · 1 comment
Closed

Debugging not pause at breakpoint #92

thanhson208s opened this issue Sep 4, 2019 · 1 comment

Comments

@thanhson208s
Copy link

thanhson208s commented Sep 4, 2019

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.

@hackathlete
Copy link

Hello, I think this is a duplicate of issue #74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants