January 2013
Intermediate to advanced
328 pages
8h 5m
English
Because ANTLR recognizers buffer up the entire input character stream and all input tokens by default, they can’t handle input files that are bigger than a computer’s memory and can’t handle infinite streams like socket connections. To overcome this, you can use unbuffered versions of the character and token streams, which keep just a small sliding window into the streams: UnbufferedCharStream and UnbufferedTokenStream.
As a demonstration, here’s a modification of the comma-separated-value grammar from Parsing Comma-Separated Values that sums the floating-point values in a two-column file:
| | /** Rows are two real numbers: |
| | 0.9962269825793676, 0.9224608616182103 |
| | 0.91673278673353, -0.6374985722530822 ... |
Read now
Unlock full access