With separate Lexer and Parser ...
class YamlLexical extends StdLexical with YamlTokens with RegexParsers {...
object YamlParser extends StdTokenParsers with YamlTokens with PackratParsers {...
... how to get the position of the parsed string into AST classes?
(... positioned(elem(...)) * ... )^^ { ... => List( Ast(startpos, parsedtext, ... subnodes ... ), ... )}
The type of
positioned
iswhich means that the parsed elements must extend
Positional
. So, for example,YamlLexical
should be:in that way, any parsed element will automatically have a
pos
which records the position in which it was parsed.