antlr / antlr/antlr4-cpp

error: use of undeclared identifier 'self'

Open
#14 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
80
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Hello, I have multiple error when compiling the generated parser and lexer.
ANTLR version: **4.13.0**
Os: Macos
Command used: `antlr -Dlanguage=Cpp -o ${CMAKE_CURRENT_SOURCE_DIR}/src/LythonCompiler/Parser/ANTLR/ ${CMAKE_CURRENT_SOURCE_DIR}/src/LythonCompiler/Parser/ANTLR/Python3Parser.g4`
the error:
```
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19168:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("case"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"case\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19224:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("_"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"_\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19280:11: error: use of undeclared identifier 'self'
if (!(self.isEqualCurrentTokenText("type"))) throw FailedPredicateException(this, "self.isEqualCurrentTokenText(\"type\")");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19329:20: error: use of undeclared identifier 'self'
case 1: return self.isnotEqualCurrentTokenText("_");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19419:21: error: use of undeclared identifier 'self'
case 10: return self.isEqualCurrentTokenText("match");
^
/Users//./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19429:21: error: use of undeclared identifier 'self'
case 11: return self.isEqualCurrentTokenText("case");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19439:21: error: use of undeclared identifier 'self'
case 12: return self.isEqualCurrentTokenText("_");
^
/Users/./Documents/lython-cpp/src/LythonCompiler/Parser/ANTLR/PythonParser.cpp:19449:21: error: use of undeclared identifier 'self'
case 13: return self.isEqualCurrentTokenText("type");
```

the grammar file used is located here: https://github.com/antlr/grammars-v4/tree/master/python/python3

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported command with the Python3 grammar from grammars-v4/python/python3 and inspect the generated src/LythonCompiler/Parser/ANTLR/PythonParser.cpp around the listed predicate errors. Trace how the grammar predicates become C++ and confirm that the generated parser compiles without undeclared self references.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.