Open
Description
I'm new to sedlex. I'm translating a lexer in ocamllex to sedlex. By ocamllex, I have e.g.,
rule token = parse
| FLOAT as float "%" { DOUBLE ((float_of_string float) /. 100. ) }
Now, I need to use some string operations to achieve it:
let rec token buf =
match%sedlex buf with
| FLOAT, "%" ->
let x = Sedlexing.Utf8.lexeme buf in
let x = String.sub x 0 (String.length x -1) in
DOUBLE ((float_of_string x) /. 100. )
I'm wondering if we could simplify that, e.g., by using as
like in ocamllex.
Metadata
Metadata
Assignees
Labels
No labels