forked from ocaml-ppx/ppx_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
250 additions
and
8 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
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,57 @@ | ||
(library | ||
(public_name ppx_tools) | ||
(synopsis "Tools for authors of ppx rewriters and other syntactic tools") | ||
(wrapped false) | ||
(modules ast_convenience ast_mapper_class) | ||
(libraries compiler-libs.common)) | ||
|
||
(library | ||
(name ppx_metaquot) | ||
(public_name ppx_tools.metaquot) | ||
(synopsis "Meta-quotation: Parsetree manipulation using concrete syntax") | ||
(wrapped false) | ||
(kind ppx_rewriter) | ||
(modules ppx_metaquot) | ||
(ppx.driver (main Ppx_metaquot.Main.main)) | ||
(ppx_runtime_libraries ppx_tools) | ||
(libraries compiler-libs.common ppx_tools ast_lifter)) | ||
|
||
(executable | ||
(name genlifter) | ||
(modules genlifter) | ||
(libraries compiler-libs.common ppx_tools)) | ||
|
||
(executable | ||
(name dumpast) | ||
(modules dumpast) | ||
(libraries compiler-libs.common compiler-libs.bytecomp ast_lifter)) | ||
|
||
(executable | ||
(name ppx_metaquot_main) | ||
(modules ppx_metaquot_main) | ||
(libraries ppx_metaquot)) | ||
|
||
(executable | ||
(name rewriter) | ||
(modules rewriter) | ||
(libraries compiler-libs.common)) | ||
|
||
(rule | ||
(with-stdout-to ast_lifter.ml | ||
(run ./genlifter.exe -I +compiler-libs Parsetree.expression))) | ||
|
||
(library | ||
(name ast_lifter) | ||
(public_name ppx_tools.ast_lifter) | ||
(wrapped false) | ||
(modules ast_lifter) | ||
(flags :standard -w -17) | ||
(libraries compiler-libs.common)) | ||
|
||
(install | ||
(section libexec) | ||
(files | ||
(genlifter.exe as genlifter) | ||
(dumpast.exe as dumpast) | ||
(ppx_metaquot_main.exe as ppx_metaquot) | ||
(rewriter.exe as rewriter))) |
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,15 @@ | ||
opam-version: "2.0" | ||
synopsis: "Tools for authors of ppx rewriters and other syntactic tools" | ||
maintainer: "[email protected]" | ||
authors: "Alain Frisch <[email protected]>" | ||
license: "MIT" | ||
tags: [ "syntax" ] | ||
homepage: "https://github.com/ocaml-ppx/ppx_tools" | ||
bug-reports: "https://github.com/ocaml-ppx/ppx_tools/issues" | ||
dev-repo: "git://github.com/ocaml-ppx/ppx_tools.git" | ||
build: ["dune" "build" "-p" name "-j" jobs | ||
"@runtest" {with-test}] | ||
depends: [ | ||
"ocaml" {>= "4.05.0" & < "4.06.0"} | ||
"dune" {>= "1.6"} | ||
] |
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,3 @@ | ||
(test | ||
(name test_metaquot_lit) | ||
(preprocess (staged_pps ppx_tools.metaquot))) |
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,80 @@ | ||
let () = | ||
match [%expr [%lit.integer "10"]] with | ||
| { pexp_desc = Pexp_constant (Pconst_integer ("10", None)); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match Ast_helper.Exp.constant (Ast_helper.Const.integer "10") with | ||
| [%expr [%lit.integer? "0"]] -> assert false | ||
| [%expr [%lit.integer? "10"]] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.integer "10"] [@suffix Some 'l']] with | ||
| { pexp_desc = Pexp_constant (Pconst_integer ("10", Some 'l')); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match | ||
Ast_helper.Exp.constant (Ast_helper.Const.integer "10" ~suffix:'l') | ||
with | ||
| [%expr [%lit.integer? "10"] [@suffix? None]] -> assert false | ||
| [%expr [%lit.integer? "10"] [@suffix? Some 'l']] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.char 'c']] with | ||
| { pexp_desc = Pexp_constant (Pconst_char 'c'); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match Ast_helper.Exp.constant (Ast_helper.Const.char 'c') with | ||
| [%expr [%lit.char? 'a']] -> assert false | ||
| [%expr [%lit.char? 'c']] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.string "s"]] with | ||
| { pexp_desc = Pexp_constant (Pconst_string ("s", None)); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match Ast_helper.Exp.constant (Ast_helper.Const.string "s") with | ||
| [%expr [%lit.string? ""]] -> assert false | ||
| [%expr [%lit.string? "s"]] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.string "s"] [@quotation_delimiter Some "t"]] with | ||
| { pexp_desc = Pexp_constant (Pconst_string ("s", Some "t")); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match | ||
Ast_helper.Exp.constant | ||
(Ast_helper.Const.string ~quotation_delimiter:"t" "s") with | ||
| [%expr [%lit.string? "s"] [@quotation_delimiter? None]] -> assert false | ||
| [%expr [%lit.string? "s"] [@quotation_delimiter? Some "t"]] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.float "1.0"]] with | ||
| { pexp_desc = Pexp_constant (Pconst_float ("1.0", None)); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match Ast_helper.Exp.constant (Ast_helper.Const.float "1.0") with | ||
| [%expr [%lit.float? "0.0"]] -> assert false | ||
| [%expr [%lit.float? "1.0"]] -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match [%expr [%lit.float "1.0"] [@suffix Some 'f']] with | ||
| { pexp_desc = Pexp_constant (Pconst_float ("1.0", Some 'f')); _ } -> () | ||
| _ -> assert false | ||
|
||
let () = | ||
match Ast_helper.Exp.constant (Ast_helper.Const.float "1.0" ~suffix:'f') with | ||
| [%expr [%lit.float? "1.0"] [@suffix? None]] -> assert false | ||
| [%expr [%lit.float? "1.0"] [@suffix? Some 'f']] -> () | ||
| _ -> assert false |