-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: alternation parsing in various syntaxes
- Loading branch information
Showing
2 changed files
with
50 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
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,48 @@ | ||
open Import | ||
module Ast = Re_private.Ast | ||
|
||
let test f string = | ||
match f string with | ||
| Ok res -> print_dyn (Ast.to_dyn res) | ||
| Error _ -> assert false | ||
;; | ||
|
||
let%expect_test "pcre" = | ||
test Re.Pcre.re_result "(a|b|c)"; | ||
[%expect | ||
{| | ||
(Group | ||
(Set | ||
(Cast (Alternative (Cast (Alternative (Cset 97) (Cset 98))) (Cset 99))))) | ||
|}] | ||
;; | ||
|
||
let%expect_test "emacs" = | ||
test Re.Emacs.re_result {|\(a\|b\|c\)|}; | ||
[%expect | ||
{| | ||
(Group | ||
(Set | ||
(Cast (Alternative (Cast (Alternative (Cset 97) (Cset 98))) (Cset 99))))) | ||
|}] | ||
;; | ||
|
||
let%expect_test "perl" = | ||
test Re.Perl.re_result "(a|b|c)"; | ||
[%expect | ||
{| | ||
(Group | ||
(Set | ||
(Cast (Alternative (Cast (Alternative (Cset 97) (Cset 98))) (Cset 99))))) | ||
|}] | ||
;; | ||
|
||
let%expect_test "posix" = | ||
test Re.Posix.re_result "(a|b|c)"; | ||
[%expect | ||
{| | ||
(Group | ||
(Set | ||
(Cast (Alternative (Cast (Alternative (Cset 97) (Cset 98))) (Cset 99))))) | ||
|}] | ||
;; |