This is a portion of my island grammar:
listing
: LISTING (newlines listingPath)? (newlines label)? newlines caption
;
newlines
: NL+
;
And for example some input text:
~~~~~ Listing 1 content... ~~~~~ {#lst:listing-1#} ##### Explanation for listing 1. #####
This gets recognized very well. Both in the IntelliJ prototype project (I think Java runs in the background) as well as in my application with a JavaScript target.
When I replace the "newlines" rule within the "listing" rule with "NL+" or "NL" I receive a parsing error that the first \r\n after the closing listing tag "~~~~~" is a bad token. The newline doesn't get recognized.
Both versions working well with IntelliJ in the prototype project. I tested the grammars with the ANTLR preview feature.
Am I missing something or is this a possible JavaScript target bug in ANTLR4?