我是 sml 和 ml-lex 的新手。要将字符串转换为实数,我们使用函数 real.fromstring。这是我的转换代码,其中 yytext 是字符数组或字符串。
getOpt ((Real.fromString(yytext)), 0.0);
我在 ml-lex 中使用上述语法来标记实数。
{real} => (REAL(getOpt ((Real.fromString(yytext)), 0.0)));
但我得到了错误,
math.lex.sml:5.234-5.240 Error: type constructor Assembly.option given 0 arguments, wants 1
请告诉我 fromstring 函数有什么问题。