Anyone familiar with the Brag library, I’m having a peculiar issue. It seems when I have an identifier at the end of a pattern consisting of optional identifiers, the last identifier loses source line and column information (while keeping position and span). Consider these three rules:
p-program : [p-line] (/NEWLINE [p-line])*
p-line : [p-statement] (/";" [p-statement])* [p-comment]
p-comment : COMMENT
When I have only a comment on a line, p-line
loses that info. When I have other statements, it is fine. This is a problem for me because I use the line number to create a unique function representing each line. This doesn’t make any sense to me and I couldn’t find any explicit reference to the issue in the Brag documentation.
I found one workaround by changing the p-line
rule to
p-line : [p-statement] (/";" [p-statement])* [p-comment] \| p-comment
but I’m still hoping to understand what is causing the issue, and am worried that it may complicate the grammar as my language grows.
@schinn.ben has joined the channel