ANTLR 符号 table 中的这些值是什么意思?

What do these values from the ANTLR symbol table mean?

我已经将符号 table 转储到 antlr 中,并且我有一些字段我不清楚它们的含义。如果有参考,请指出。 table 有标识符,然后是 starttoken、endtoken、otherinfo。我已经按组分解了

括号是我的。 在 startToken 中,我看到它开始的行 (L:1) 和列 (:8) 以及 endtoken 中相应的结尾。开始 (s)、结束 (e) 和索引 (i) 是什么意思?看不到押韵或理由。

Otherinfo = 什么是状态?它与我所看到的任何东西都不匹配。

这里有几行,您可以感受一下输出。

1565614310 - [TokenInformation: L:1, charPosInL:8, s:8, e: 11, i: 1] - [TokenInformation: L:1, charPosInL:8, s:8, e: 11, i: 1] - State: 737 - Type: Identifier
783141366 - [TokenInformation: L:3, charPosInL:0, s:17, e: 22, i: 3] - [TokenInformation: L:29, charPosInL:0, s:832, e: 832, i: 3] - State: 777 - Type: PUBLIC
688113407 - [TokenInformation: L:3, charPosInL:0, s:17, e: 22, i: 3] - [TokenInformation: L:3, charPosInL:0, s:17, e: 22, i: 3] - State: 781 - Type: PUBLIC
1638864144 - [TokenInformation: L:3, charPosInL:22, s:39, e: 39, i: 6] - [TokenInformation: L:29, charPosInL:0, s:832, e: 832, i: 6] - State: 798 - Type: LBRACE

谢谢

我找不到打印此信息的代码,所以我只能给出一个有根据的猜测:

  • L明显是源码行
  • s: 可能是该符号的令牌的起始字符索引
  • e:可能是这个符号的标记的结束字符索引(注意:结束索引总是指向最后一个字符,而不是之后的位置,所以长度计算总是要加 1:length = end - start + 1.
  • i: 那么就是这个符号的代币索引
  • otherinfo:包含有关令牌的更多详细信息,例如令牌的状态编号和类型。

对于状态编号:请记住,解析过程由具有状态和转换的底层网络控制:ATN(增强转换网络)。

完整性:

注意:当我说到“端口”时,这是不正确的。非 Java 版本是使用 Java 变体的基本原理的重新实现。存在显着差异。