sml - building a lexical analyser using ml-lex -
i need create new instance of lexer tied standard input stream.
however, when type in
val lexer = makelexer( fn n => inputline( stdin ) ); i error don't understand:
stdin:1.5-11.13 error: operator , operand don't agree [tycon mismatch] operator domain: int -> string operand: int -> string option in expression: (makelexer function name present in source code)
inputline returns string option, , guess string expected.
what want either have makelexer take string option, so:
fun makelexer none = <whatever want when stream empty> | makelexer (some s) = <the normal body makelexer, working on string s> or change line to:
val lexer = makelexer( fn n => valof ( inputline( stdin ) ) ); valof takes option type , unpacks it.
note that, since inputline returns none when stream empty, it's better idea use first approach, rather second.
Comments
Post a Comment