Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

error: use of undeclared identifier 'self'

未关闭
#14 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
cpp
领域
compilers

调研方向

使用 grammars-v4/python/python3 中的 Python3 语法复现报告的命令,并检查生成的 src/LythonCompiler/Parser/ANTLR/PythonParser.cpp 中列出的谓词错误附近的内容。跟踪语法谓词如何转换为 C++,并确认生成的解析器能够在没有未声明的自身引用的情况下编译。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
C++
星标
80
派生
33
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

antlr/antlr4-cpp 的其他 Issue

查看 antlr/antlr4-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。