File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ open Printf
2
+
3
+ let next_tok buf =
4
+ let open Sedlexing.Utf8 in
5
+ match % sedlex buf with
6
+ | "a" , Utf8 (Chars "+-×÷" ) -> sprintf " with Chars: %s" (lexeme buf)
7
+ | "b" , Utf8 ("+" | "-" | "×" | "÷" ) ->
8
+ sprintf " with or_pattern: %s" (lexeme buf)
9
+ | _ -> failwith (sprintf " Unexpected character: %s" (lexeme buf))
10
+
11
+ let % expect_test _ =
12
+ Sedlexing.Utf8. from_string " a+" |> next_tok |> print_string;
13
+ [% expect {| with Chars : a+ | }];
14
+ Sedlexing.Utf8. from_string " a÷" |> next_tok |> print_string;
15
+ [% expect {| with Chars : a÷ | }];
16
+ Sedlexing.Utf8. from_string " b+" |> next_tok |> print_string;
17
+ [% expect {| with or_pattern : b + |}];
18
+ Sedlexing.Utf8. from_string " b÷" |> next_tok |> print_string;
19
+ [% expect {| with or_pattern : b ÷ |}]
You can’t perform that action at this time.
0 commit comments