Skip to content

Instantly share code, notes, and snippets.

/Error Secret

Created March 6, 2018 20:41
Show Gist options
  • Save anonymous/d378c2c1afe0576f5c5c4e93b24ffcd7 to your computer and use it in GitHub Desktop.
Save anonymous/d378c2c1afe0576f5c5c4e93b24ffcd7 to your computer and use it in GitHub Desktop.
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
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