Skip to content

Support backslash line continuations in lark.lark - #1626

Open
Sanjays2402 wants to merge 1 commit into
lark-parser:masterfrom
Sanjays2402:fix/lark-lark-line-continuation
Open

Support backslash line continuations in lark.lark#1626
Sanjays2402 wants to merge 1 commit into
lark-parser:masterfrom
Sanjays2402:fix/lark-lark-line-continuation

Conversation

@Sanjays2402

Copy link
Copy Markdown

Fixes #1620.

lark.lark (the meta-grammar used to parse Lark grammars) does not accept backslash-newline line continuations, even though grammars parsed by Lark support them. Loading a grammar that uses a line continuation via Lark.open_from_package('lark', 'lark.lark', ...) raises UnexpectedCharacters.

start: "a" \\
       "b"

Change

  • Add a BACKSLASH terminal matching \\[ ]*\n and %ignore it, mirroring how WS_INLINE and COMMENT are handled.
  • Add test_line_breaks_in_lark_lark covering the case.

Verification

Run against the new test:

  • without the lark.lark change: fails with UnexpectedCharacters
  • with the change: passes

The lark.lark meta-grammar did not accept backslash-newline line
continuations, even though grammars parsed by lark support them.
Add a BACKSLASH terminal and ignore it, plus a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

could lark.lark be missing "\" end of line things

1 participant