summaryrefslogtreecommitdiff
path: root/src/lexer.mll
diff options
context:
space:
mode:
authorAlasdair2020-05-21 15:30:43 +0100
committerAlasdair2020-05-21 15:30:43 +0100
commit8320ddc4b19d622f8ab5ab8625dde45fccbf383b (patch)
tree4ebd634581c6ffe6c5b61ad9437692a1856a81c6 /src/lexer.mll
parent3311b7d4c5aeebacdbcd14602d7a8a75a9c1b258 (diff)
parent92b0564856fb3e20a09bead04d5c1b21eed224e1 (diff)
Merge branch 'sail2' into mono-tweaks
Diffstat (limited to 'src/lexer.mll')
-rw-r--r--src/lexer.mll12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lexer.mll b/src/lexer.mll
index 8000879e..40f4b470 100644
--- a/src/lexer.mll
+++ b/src/lexer.mll
@@ -288,8 +288,10 @@ rule token = parse
| "-" digit+ as i { (Num(Big_int.of_string i)) }
| "0b" (binarydigit+ as i) { (Bin(Util.string_of_list "" (fun s -> s) (Util.split_on_char '_' i))) }
| "0x" (hexdigit+ as i) { (Hex(Util.string_of_list "" (fun s -> s) (Util.split_on_char '_' i))) }
- | '"' { (String(
- string (Lexing.lexeme_start_p lexbuf) (Buffer.create 10) lexbuf)) }
+ | '"' { let startpos = Lexing.lexeme_start_p lexbuf in
+ let contents = string startpos (Buffer.create 10) lexbuf in
+ lexbuf.lex_start_p <- startpos;
+ String(contents) }
| eof { Eof }
| _ as c { raise (LexError(
Printf.sprintf "Unexpected character: %c" c,
@@ -331,10 +333,6 @@ and string pos b = parse
| '\\' '\n' ws { Lexing.new_line lexbuf; string pos b lexbuf }
| '\\' { assert false (*raise (Reporting.Fatal_error (Reporting.Err_syntax (pos,
"illegal backslash escape in string"*) }
- | '"' { let s = unescaped(Buffer.contents b) in
- (*try Ulib.UTF8.validate s; s
- with Ulib.UTF8.Malformed_code ->
- raise (Reporting.Fatal_error (Reporting.Err_syntax (pos,
- "String literal is not valid utf8"))) *) s }
+ | '"' { unescaped (Buffer.contents b) }
| eof { assert false (*raise (Reporting.Fatal_error (Reporting.Err_syntax (pos,
"String literal not terminated")))*) }