我将identifier
定义为:
identifier = /[A-zA-Z][A-zA-Z0-9_]*/ ;
CCD_ 2为:
arrayType = ARRAY LBRACK ~ typeList RBRACK OF componentType;
那么,为什么Tatsu在下面的日志中决定"ASCIIcode]"是一个标识符,而不是身份+右括号?
≡'['
ASCIIcode] Of ASCIIcode;
≡LBRACK↙arrayType↙unpackedStructuredType↙structuredType↙type↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙typeList↙arrayType↙unpackedStructuredType↙structuredType↙type↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙indexType↙typeList↙arrayType↙unpackedStructuredType↙structuredType↙type↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙simpleType↙indexType↙typeList↙arrayType↙unpackedStructuredType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙scalarType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙LPAREN↙scalarType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢'('
ASCIIcode] Of ASCIIcode;
≢LPAREN↙scalarType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢scalarType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙constant↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙unsignedNumber↙constant↙subrangeType↙simpleType↙indexType↙typeList↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙unsignedInteger↙unsignedNumber↙constant↙subrangeType↙simpleType↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢'' /d+/
ASCIIcode] Of ASCIIcode;
↙unsignedReal↙unsignedNumber↙constant↙subrangeType↙simpleType↙indexType↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢'' /d+/
ASCIIcode] Of ASCIIcode;
≢unsignedNumber↙constant↙subrangeType↙simpleType↙indexType↙typeList↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙PLUS↙sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢'+'
ASCIIcode] Of ASCIIcode;
≢PLUS↙sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙MINUS↙sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢'-'
ASCIIcode] Of ASCIIcode;
≢MINUS↙sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙ ~99:15
ASCIIcode] Of ASCIIcode;
≢sign↙constant↙subrangeType↙simpleType↙indexType↙typeList↙arrayType↙ ~99:15
ASCIIcode] Of ASCIIcode;
↙identifier↙constant↙subrangeType↙simpleType↙indexType↙typeList↙ ~99:15
ASCIIcode] Of ASCIIcode;
≡'ASCIIcode]' /[A-zA-Z][A-zA-Z0-9_]*/
Of ASCIIcode;
正则表达式是不正确的,这与您的意图无关(最好在以下网站上测试正则表达式https://pythex.org)。
正则表达式使用大写";A";当试图定义小写字母范围时。
您可以尝试使用:
identifier = /[a-zA-Z][a-zA-Z0-9_]*/ ;
甚至更好:
identifier = /w[wd_]*/ ;