Skip to content

Don't assume that null characters mean EOF - #475

Merged
maxbrunsfeld merged 5 commits into
masterfrom
null-characters
Oct 31, 2019
Merged

maxbrunsfeld merged 5 commits into
masterfrom
null-characters

Conversation

@maxbrunsfeld

@maxbrunsfeld maxbrunsfeld commented Oct 31, 2019 •

Copy link
Copy Markdown
Contributor

Fixes #280

In an early design mistake years ago, I decided to make the Tree-sitter library communicate the EOF state to the generated lexing functions via a special lookahead character of '\0'. This is bad because some source code files contain '\0' (null characters) within the source.

In this PR, I'm introducing a new lexer method eof() that indicates that the lexer has reached the end of the file. As with #334, generated parsers will not actually use this new method unless you generate them with tree-sitter generate --next-abi. This is to allow them to be used with earlier versions of the Tree-sitter library.

Soon, (once Atom has been upgraded to use the newest version of the library), I'll change the default behavior of tree-sitter generate to rely on the new API.

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.

Is there a way to distinguish between EOF and the \0 character in external scanners?

1 participant