I am completely new to Scala. Right now I'm trying to use the parser port that I wrote in standard ML before Scala and had a problem with the following code:
abstract class Token case class Zero extends Token case class At extends Token //... object Tokenizer { def tokenize(seq : List[Char]) : List[Token] = seq match { case List() => error("Empty input") case '0' :: rest => Zero :: tokenize(rest) case '@' :: rest => At :: tokenize(rest)
In SML, I would not need to declare the return type of the tokenize () method, but it seems to need Scala, and it is somehow dissatisfied with the type I provided (it complains that Zero, At are invalid types and that they should be of type token instead). Note: I also want patten to match the token list at a later point in time during the parsing phase.
I did a few searches on the Internet and on stackoverflow to see if a similar question had been raised before (it looked so trivial), but for some reason I could not find anything. I am pretty sure that something is wrong with me, please feel free to enlighten me :)
source share