4 let comment_level = ref 0
5 let string_buf = Buffer.create 100
8 let alpha = ['a'-'z' 'A'-'Z']
10 let newline = '\n' | '\r' | "\n\r"
15 (* Track line number *)
17 Lexing.new_line lexbuf;
62 INT (int_of_string int)
65 | (alpha (alpha | num | '_')* as id) {
73 | "function" -> FUNCTION
86 and string_literal = parse
87 (* Keep escaped quote marks as part of the string literal *)
89 Buffer.add_char string_buf '"';
94 let string = Buffer.contents string_buf in
95 Buffer.reset string_buf;
101 Buffer.add_char string_buf c;
102 string_literal lexbuf
105 (* TODO: Error: unterminated comment? or we don't care? *)
108 (* Track line number *)
110 Lexing.new_line lexbuf;
121 match !comment_level with
123 | n when n > 0 -> comment lexbuf
127 (* Drop comment contents *)