Most keywords don't just require the correct characters to match, they have to ensure that subsequent characters *don't* match in order for it to be a keyword.
Most keywords don't just require the correct characters to match, they have to ensure that subsequent characters *don't* match in order for it to be a keyword. This enforces that rule for key-words (W) and key-operators (O) which have different non-match criteria.
Most keywords don't just require the correct characters to match, they have to ensure that subsequent characters *don't* match in order for it to be a keyword.
Most keywords don't just require the correct characters to match, they have to ensure that subsequent characters *don't* match in order for it to be a keyword. This enforces that rule for key-words (W) and key-operators (O) which have different non-match criteria.
Parses whitespace, including newlines.
Parses whitespace, including newlines. This is the default for most things
Parses all whitespace, excluding newlines.
Parses all whitespace, excluding newlines. This is only really useful in e.g. {} blocks, where we want to avoid capturing newlines so semicolon-inference would work
helper printing function
Parser for Scala syntax.
The
G
parameter that gets passed in to each rule stands for "Greedy", and determines whether or not that rule is to consume newlines after the last terminal in that rule. We need to pass it everywhere so it can go all the way to the last terminal deep inside the parse tree, which can then decide whether or not to consume whitespace.The vast majority of terminals will consume newlines; only rules which occur in {} blocks won't have their terminals consume newlines, and only the *last* terminal in the rule will be affected. That's why the parser does terminals-consume-newlines-by-default, and leaves it up to the dev to thread the
G
variable where-ever we want the opposite behavior.