代码之家  ›  专栏  ›  技术社区  ›  Ramon Snir

fslex未知错误

  •  1
  • Ramon Snir  · 技术社区  · 14 年前

    我的fslex有点问题,我无法解决…我只知道fslex.exe退出代码1…

    顶部的F代码是在F Interactive中测试的,所以问题不在这里(我不知道怎么做)。

    Lexer: http://pastebin.com/qnDnUh59

    Parser.fsi: http://pastebin.com/sGyLqZbN

    谢谢, 拉蒙。

    1 回复  |  直到 14 年前
        1
  •  1
  •   Juliet    14 年前

    非零错误意味着lexer失败,通常它也会描述失败。当我编译时,我得到 exited with code 1 与此同时:

    Unexpected character '\'
    
    let id = [\w'.']+ 
    ----------^
    

    lexer不喜欢引号之外的字符文本,也不理解 \w 要么。根据 FsLex source code ,fslex只理解以下转义序列:

    let escape c =
     match c with
     | '\\' -> '\\'
     | '\'' -> '\''
     | 'n' -> '\n'
     | 't' -> '\t'
     | 'b' -> '\b'
     | 'r' -> '\r'
     | c -> c
    

    这款Lexer的固定版本对我来说很好: http://pastebin.com/QGNk3VKD