Need a Little Grammar Help #1041
-
I'm working on a grammar that needs to support specification of HTTP paths in a similar manner to OpenAPI. I almost have it working, but I can't get the parser to recognize the I don't know why 'abc' or 'B' are not recognized here as SEGMENT. Grammar:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@ballcoach12 Your terminals are clashing quite heavily. In In your case, |
Beta Was this translation helpful? Give feedback.
@ballcoach12 Your terminals are clashing quite heavily. In
/abc/B
bothabc
andB
get identified asPARAM
terminals, since that's the first terminal in your terminal list that is able to tokenize these characters. Note that the tokenization and parsing phase are split and the tokenization (lexing) is performed without context (whereas the parsing phase uses context).In your case,
PARAM
,ID
,SEGMENT
andLETTER
are ambiguous during the tokenization phase. The tokenizer will never readID
, since the first-fit algorithm employed there will always readPARAM
first. A similar thing happens withSEGMENT
since there's quite an overlap in these token types.