Skip to content

Support of as #102

Open
Open
@chengtie

Description

@chengtie

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions