Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No EOL on last line of file #233

Closed
timofurrer opened this issue Sep 17, 2018 · 3 comments
Closed

No EOL on last line of file #233

timofurrer opened this issue Sep 17, 2018 · 3 comments

Comments

@timofurrer
Copy link
Contributor

timofurrer commented Sep 17, 2018

I have some grammer with does something like this:

_NEWLINE: ( /\r\n[\t ]*/ | /\n[\t ]*/ | COMMENT )+
_INDENT: "<INDENT>"
_DEDENT: "<DEDENT>"

foo_compound_stmt: "FOO _NEWLINE (_INDENT bar_stmt+ _DEDENT)?
bar_stmt: "BAR" STRING_NO_WS _NEWLINE

And a code sample might look like this:

FOO
    BAR something

This work perfectly fine unless the BAR something is the last line in the file without an EOL character at the end. This happens if the file is in dos format and saved under Windows ...
In this case a _NEWLINE is expected so that _DEDENT matches.

Do you have any solution for this problem?

@erezsh
Copy link
Member

erezsh commented Sep 17, 2018

The quick and easy solution is to add '\n' to the input.

There is a plan to add an EOF symbol to Lark for conceptual completeness, but I think it's not necessary for your use-case.

@timofurrer
Copy link
Contributor Author

The quick and easy solution is to add '\n' to the input.

That's what I ended up doing.

There is a plan to add an EOF symbol to Lark for conceptual completeness

Is this coming any time soon?

@erezsh
Copy link
Member

erezsh commented Sep 18, 2018

Is this coming any time soon?

Probably not, since there are many other features that are more important.

You can follow #237 to get notified on its progress.

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

No branches or pull requests

2 participants