ChrisHixon / chpeg

Parsing Expression Grammar (PEG) bytecode parser/compiler library
BSD 3-Clause "New" or "Revised" License
13 stars 1 forks source link

Another compiler/parser bug, potentially #9

Closed ChrisHixon closed 2 years ago

ChrisHixon commented 2 years ago

I'm not sure that this is same bug as discussed in the C99 issue (https://github.com/ChrisHixon/chpeg/issues/2) or a new bug:

Grammar:

# VOID is not captured

Start <- VOID !.

WhiteSpace  <- [ \n\r\t]

IdChar <- [a-zA-Z0-9_]

VOID      <- 'void'       !IdChar WhiteSpace

Input: (file is "void\n")

void

Output:

---------------------------------------------------------------------------------
 Begin    Len  DefID  Flags  Def. Name / Data
---------------------------------------------------------------------------------
     4      1      1 |     | WhiteSpace "\n"

Originally posted by @ChrisHixon in https://github.com/ChrisHixon/chpeg/issues/8#issuecomment-1122030782

ChrisHixon commented 2 years ago

There's at least one thing going on that is proving hard to track down. I'm in the process of adding some more tracing/debugging... I need to see the parse tree being built and stack at every instruction.

ChrisHixon commented 2 years ago

This is not a bug... this behavior is due to the automatic parse tree 'unwrapping'.