You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to build a grammar for bmake style Makefiles. In my first run I handled line continuation outside of the grammar using a generator and then fed the grammar only single lines. I would like to improve on that by handling line continuation in the grammar and feed the whole file to the grammar.
I am struggling with the most simple thing as the SH_COMMENT:
# this is a comment \that spans multiple \lines
I am working now refining this, but can't get the continuation handling right. Continuation is a backslash directly followed by new line. Both need to be consumed and the rest of the line appended to the comment.
But I had to add the \\ into the regexp of both the SH_COMMENT as well as the line coming after the continuation. This is not precise as the comment may have \ anywhere inside it not bearing any special meaning.
Without this, I could not get the CONT match, as any preceding regexp would eat the \. I tried using with (?!\\), but I could not get that right either.
How can I get rid of adding \\ to the regexp and allow \ to appear inside the comment, and treat it special only at the end of the line?
This will not treat \ inside the comment any special.
Is this the best way to do it?
Bonus problem, how do I get the '\\n' out of the matched string. I tried _CONT and %ignore CONT, but both left the continuation characters in the parse result.
What is your question?
I am trying to build a grammar for
bmake
style Makefiles. In my first run I handled line continuation outside of the grammar using a generator and then fed the grammar only single lines. I would like to improve on that by handling line continuation in the grammar and feed the whole file to the grammar.I am struggling with the most simple thing as the SH_COMMENT:
I am working now refining this, but can't get the continuation handling right. Continuation is a backslash directly followed by new line. Both need to be consumed and the rest of the line appended to the comment.
The text was updated successfully, but these errors were encountered: