Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of as #102

Open
chengtie opened this issue Aug 12, 2021 · 1 comment · May be fixed by #112
Open

Support of as #102

chengtie opened this issue Aug 12, 2021 · 1 comment · May be fixed by #112

Comments

@chengtie
Copy link

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.

@chengtie chengtie changed the title Don't have as anymore Support of as Aug 12, 2021
@hhugo
Copy link
Contributor

hhugo commented Aug 12, 2021

Duplicate of #5

@dyzsr dyzsr linked a pull request Sep 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants