Skip to content

Matching line continuation in shell style comment #1509

@kevemueller

Description

@kevemueller

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:

# 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.

start: bmake_comment

bmake_comment: SH_COMMENT ((CONT /[^\n]*\n/)+|NEWLINE)

CONT: "\\" NEWLINE

%import common.SH_COMMENT
%import common.NEWLINE

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions