antlr4: Ignore superflous tokens when creating ParseTrees
Asked Answered
O

1

6

I am developing a compiler for the real-time language PEARL with ANTLR4.

With ANTLR4 my ParseTree is populated with superflous tokens like e.g. semicolons for ending a grammatical unit.

Is there a way to tell ANTLR to ignore these kinds of token?

Oleary answered 3/3, 2013 at 10:36 Comment(0)
G
6

Is there a way to tell ANTLR to ignore these kind of tokens?

No, but using ANTLR4's built-in listener/visitor, there's no need to remove these tokens.

See: "skip" changes parser behavior

Gantline answered 3/3, 2013 at 11:43 Comment(1)
Yes, with the current Visitor and Listener methods, doing nothing with the token is literally the same as ignoring it.Mascle

© 2022 - 2024 — McMap. All rights reserved.