summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair Armstrong2017-07-18 13:29:18 +0100
committerAlasdair Armstrong2017-07-18 13:29:18 +0100
commit4292253f88774f343b6643f36ec7d3cb3abd0529 (patch)
tree2313190425d3a71f92bb5a3491e801291e87d98e
parenta8bbfe826d46929450d022c37ac3c6a005340994 (diff)
Added pretty-printing support for real literals
-rw-r--r--src/lexer.mll10
-rw-r--r--src/pretty_print_sail.ml1
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lexer.mll b/src/lexer.mll
index 76f2e0a5..12640480 100644
--- a/src/lexer.mll
+++ b/src/lexer.mll
@@ -314,14 +314,14 @@ rule token = parse
| "-" (digit* as i1) "." (digit+ as i2) { (Real ("-" ^ i1 ^ "." ^ i2)) }
| digit+ as i { (Num(int_of_string i)) }
| "-" digit+ as i { (Num(int_of_string i)) }
- | "0b" (binarydigit+ as i) { (Bin(i)) }
- | "0x" (hexdigit+ as i) { (Hex(i)) }
+ | "0b" (binarydigit+ as i) { (Bin(i)) }
+ | "0x" (hexdigit+ as i) { (Hex(i)) }
| '"' { (String(
- string (Lexing.lexeme_start_p lexbuf) (Buffer.create 10) lexbuf)) }
+ string (Lexing.lexeme_start_p lexbuf) (Buffer.create 10) lexbuf)) }
| eof { Eof }
| _ as c { raise (LexError(
- Printf.sprintf "Unexpected character: %c" c,
- Lexing.lexeme_start_p lexbuf)) }
+ Printf.sprintf "Unexpected character: %c" c,
+ Lexing.lexeme_start_p lexbuf)) }
and comment pos depth = parse
diff --git a/src/pretty_print_sail.ml b/src/pretty_print_sail.ml
index a484bd1f..7544146e 100644
--- a/src/pretty_print_sail.ml
+++ b/src/pretty_print_sail.ml
@@ -103,6 +103,7 @@ let doc_lit (L_aux(l,_)) =
| L_num i -> string_of_int i
| L_hex n -> "0x" ^ n
| L_bin n -> "0b" ^ n
+ | L_real r -> r
| L_undef -> "undefined"
| L_string s -> "\"" ^ s ^ "\"")