What exactly is the difference between StandardTokenParsers and JavaTokenParsers? What is one good for and what is the other good for?
In StandardTokenParsers I can define my keywords using lexical.reserved, but how exactly does that help开发者_运维技巧 me?
BR Troels
The body of JavaTokenParsers is actually fairly simple and gives you a good feel for what's going on. Specifically, JavaTokenParsers inherits from the RegexParsers which gives you a lot of flexibility in defining matches; the JavaTokenParsers defines a few sample regexes for matching identifiers, numbers, etc. I don't use the StandardTokenParsers much, as the RegexParsers give me more sanity... You need to more or less define hard character matches with them, as opposed to using Regular Expressions.
There is another important difference. StandardTokenParsers parses Token instances, whereas JavaTokenParsers parses Char. You'll see that in the error messages when parsing fails. StandardTokenParsers reports the complete offending Token, JavaTokenParsers only the first character.
精彩评论