I’ve been studying the P4 Language Specification, and noticed that it is said:
The grammar is actually ambiguous, so the lexer and the parser must collaborate for parsing the language. In particular, the lexer must be able to distinguish two kinds of identifiers:
- Type names previously introduced (
TYPE_IDENTIFIER
tokens)- Regular identifiers (
IDENTIFIER
token)
I wonder if some examples could be given to illustrate such ambiguities?
In a language tool project I’m currently working on, we would like to modify the P4 grammar a little bit so it doesn’t have to distinguish between TYPE_IDENTIFIER
and IDENTIFIER
in the parsing phase. For the P4 language experts here, do you think this is achievable? And could you give us some suggestions on what you think is the best way to approach this?
Thanks!