You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I wanted to lower the priority of this issue, but somehow wasn't allowed to do so in the bug filing form)
A RegexParsers parser should skip whitespaces. It does so by omitting them in advance of each parsing step (so for example the literal("bla") parser at first skips all the whitespaces and then parses the literal "bla").
A string s is implicitly converted to a literal(s) parser. So writing
class MyParser extends RegexParsers {
def text = "first"|"second"
}
will parse "first" or "second" with arbitrary whitespaces in front of them.
A character c is implicitly converted to accept(c). accept() is defined in Parsers and not in RegexParsers, so the whitespaced aren't skipped here.
class MyParser extends RegexParsers {
def text = 'f'|'s'
}
will parse "f" or "s" but only if there aren't whitespaces in front of it.
This is somehow inconsistent and it took me a long time to realize it when I tried to write a string parser like
def string = '"' ~ stringcharacters ~ '"'
I think RegexParsers should override the parsers from its parent class and also skip whitespaces in front of them.
The text was updated successfully, but these errors were encountered:
I just tried making a scanner and discovered this issue. I tried to work around it by creating a separate scanner object with different whitespace behavior but haven't been able to get this to work. Is there an intended way to handle whitespace in string/char literals?
(I wanted to lower the priority of this issue, but somehow wasn't allowed to do so in the bug filing form)
A RegexParsers parser should skip whitespaces. It does so by omitting them in advance of each parsing step (so for example the literal("bla") parser at first skips all the whitespaces and then parses the literal "bla").
A string s is implicitly converted to a literal(s) parser. So writing
class MyParser extends RegexParsers {
def text = "first"|"second"
}
will parse "first" or "second" with arbitrary whitespaces in front of them.
A character c is implicitly converted to accept(c). accept() is defined in Parsers and not in RegexParsers, so the whitespaced aren't skipped here.
class MyParser extends RegexParsers {
def text = 'f'|'s'
}
will parse "f" or "s" but only if there aren't whitespaces in front of it.
This is somehow inconsistent and it took me a long time to realize it when I tried to write a string parser like
I think RegexParsers should override the parsers from its parent class and also skip whitespaces in front of them.
The text was updated successfully, but these errors were encountered: