-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hugo Heuzard
committed
Feb 25, 2023
1 parent
6be0490
commit 4fde081
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
open Printf | ||
|
||
let next_tok buf = | ||
let open Sedlexing.Utf8 in | ||
match%sedlex buf with | ||
| "a", Utf8 (Chars "+-×÷") -> sprintf "with Chars: %s" (lexeme buf) | ||
| "b", Utf8 ("+" | "-" | "×" | "÷") -> | ||
sprintf "with or_pattern: %s" (lexeme buf) | ||
| _ -> failwith (sprintf "Unexpected character: %s" (lexeme buf)) | ||
|
||
let%expect_test _ = | ||
Sedlexing.Utf8.from_string "a+" |> next_tok |> print_string; | ||
[%expect {| with Chars: a+ |}]; | ||
Sedlexing.Utf8.from_string "a÷" |> next_tok |> print_string; | ||
[%expect {| with Chars: a÷ |}]; | ||
Sedlexing.Utf8.from_string "b+" |> next_tok |> print_string; | ||
[%expect {| with or_pattern: b+ |}]; | ||
Sedlexing.Utf8.from_string "b÷" |> next_tok |> print_string; | ||
[%expect {| with or_pattern: b÷ |}] |