-
-
Save anonymous/d378c2c1afe0576f5c5c4e93b24ffcd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File "lexer.ml", line 14, characters 29-39: | |
Error: This expression has type 'a -> 'b | |
but an expression was expected of type 'c Stream.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec lex = parser | |
| [< ' (' ' | '\n' | '\r' | '\t'); stream >] -> lex stream | |
| [< ' ('A' .. 'Z' | 'a' .. 'z' as c); stream >] -> | |
let buffer = Buffer.create 1 in | |
Buffer.add_char buffer c; | |
lex_ident buffer stream | |
| [< ' ('0' .. '9' as c); stream >] -> | |
let buffer = Buffer.create 1 in | |
Buffer.add_char buffer c; | |
lex_number buffer stream | |
| [< ' ('#'); stream >] -> | |
lex_comment stream | |
| [< 'c; stream >] -> | |
[< 'Token.Kwd c; lex stream >] <<<< ERROR HERE >>>> | |
| [< >] -> [< >] | |
and lex_number buffer = parser | |
| [< ' ('0' .. '9' | '.' as c); stream >] -> | |
Buffer.add_char buffer c; | |
lex_number buffer stream | |
| [< stream=lex >] -> | |
[< 'Token.Number (float_of_string (Buffer.contents buffer)); stream >] | |
and lex_ident buffer = parser | |
| [< ' ('A' .. 'Z' | 'a' .. 'z' | '0' .. '9' as c); stream >] -> | |
Buffer.add_char buffer c; | |
lex_ident buffer stream | |
| [< stream=lex >] -> | |
match Buffer.contents buffer with | |
| "def" -> [< 'Token.Def; stream >] | |
| "extern" -> [< 'Token.Extern; stream >] | |
| id -> [< 'Token.Ident id; stream >] | |
and lex_comment buffer <<<< WRONG ARG # HERE >>>> = parser | |
| [< ' ('\n'); stream=lex >] -> stream | |
| [< 'c; e=lex_comment >] -> e | |
| [< >] -> [< >] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment