如何让 Tatsu 不使用标识符名称中的右括号?

问题描述

我将 node A have config: 2 node B have config: 1 定义为:

identifier

identifier = /[A-zA-Z][A-zA-Z0-9_]*/ ; 为:

arrayType

那么为什么 Tatsu 在下面的日志中决定“ASCIIcode]”是一个标识符而不是一个身份+右括号?

arrayType = ARRAY LBRACK ~ typeList RBRACK OF componentType;

解决方法

正则表达式不正确,不符合您的意图(最好在 https://pythex.org 等网站上测试正则表达式)。

正则表达式在尝试定义小写字母范围时使用大写“A”。

您可以尝试使用:

identifier = /[a-zA-Z][a-zA-Z0-9_]*/ ;

甚至更好:

identifier = /\w[\w\d_]*/ ;