I struggle to understand how the scala parser combinator api is supposed to be used when you already have a list of tokens (which are not characters). I've taken a look at the source code for TokenParsers, but I'm failing to understand what the "lexical" member is and how I can plugin my own Reader implementation (or another way to get my tokens consumed by the parser).
The examples available online (and in the "Programming in Scala" book by Odersky et al.) stop short of showing how to use the api with non-character tokens. Some examples show that a subclass of Parsers must set the elem parameter to the type of token, but where are the tokens coming from? Where is the Reader[MyToken] input parameter?
Just to clarify: the lexical analysis is already done. Whitespace removal, delimiters, all of that stuff has been done. I have a list of tokens and just want to use the parser combinator niceness to create an AST. The tokens look somewhat like this:
sealed abstract class MyToken {
val line : Int
val col : Int
}
case class LPAREN ( line : Int, col : Int ) extends MyToken
case class RPAREN ( line : Int, col : Int ) extends MyToken
Etc.