ml-lex

building a lexical analyser using ml-lex

自闭症网瘾萝莉.ら 提交于 2019-12-21 19:53:35
问题 I need to create a new instance of a lexer tied to the standard input stream. However, when I type in val lexer = makeLexer( fn n => inputLine( stdIn ) ); I get an error that I don't understand: stdIn:1.5-11.13 Error: operator and operand don't agree [tycon mismatch] operator domain: int -> string operand: int -> string option in expression: ( makeLexer is a function name present in my source code) 回答1: inputLine returns a string option , and my guess is a string is expected. What you want to

building a lexical analyser using ml-lex

半腔热情 提交于 2019-12-04 11:52:30
I need to create a new instance of a lexer tied to the standard input stream. However, when I type in val lexer = makeLexer( fn n => inputLine( stdIn ) ); I get an error that I don't understand: stdIn:1.5-11.13 Error: operator and operand don't agree [tycon mismatch] operator domain: int -> string operand: int -> string option in expression: ( makeLexer is a function name present in my source code) inputLine returns a string option , and my guess is a string is expected. What you want to do is either have makeLexer take a string option , like so: fun makeLexer NONE = <whatever you want to do