diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lexer.mll | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lexer.mll b/src/lexer.mll index fb33552b..2f101b8e 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -233,6 +233,7 @@ rule token = parse | "->" { MinusGt } | "=>" { EqGt(r "=>") } | "<=" { (LtEq(r"<=")) } + | "//" { line_comment (Lexing.lexeme_start_p lexbuf) lexbuf; token lexbuf } | "/*" { comment (Lexing.lexeme_start_p lexbuf) 0 lexbuf; token lexbuf } | "*/" { raise (LexError("Unbalanced comment", Lexing.lexeme_start_p lexbuf)) } | "infix" ws (digit as p) ws (operator as op) @@ -270,6 +271,11 @@ rule token = parse Lexing.lexeme_start_p lexbuf)) } +and line_comment pos = parse + | "\n" { () } + | _ { line_comment pos lexbuf } + | eof { raise (LexError("File ended before newline in comment", pos)) } + and comment pos depth = parse | "/*" { comment pos (depth+1) lexbuf } | "*/" { if depth = 0 then () |
