Open eddieantonio opened 7 years ago
I encountered this error when parsing line-by-line. After debugging with Pdb, I also found that token
was "EndOfInput" even before reaching the end of input. In my case, I had no CR ('\r') or New line ('\n') character by default in the input. After adding only a new line ('\n') character at the end of the input (each line in my case), the error was resolved.
I encountered this crash while parsing random Java from GitHub. This is the crash occurred on PolarPixellateFilter.java from chrisbatt/AndroidFastImageProcessing.
UPDATE: I strongly believe this bug to be caused by
javalang
's handling of carriage returns as newlines (or lack thereof). It seems that a double-slash comment//
has innocently commented out the entire rest of this file despite a carriage return ending the comment well before the end of the file.This crashed occurred both on an Ubuntu machine and an macOS machine, both running Python 3.6.1.
It crashes in parser.py.
Popping this in pdb reveals that the token is an
EndOfInput
:However, the primary that it just parsed is nowhere near the end of input
The only weird thing about the file is that its newline character is the carriage return (yuck!), hence
javalang
believes it's all on one line. Otherwise, javac considers it syntactically-valid Java 8 source code.Replication package: javalang-crash.zip