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
0 parents
commit 76f6642
Showing
4 changed files
with
54 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,13 @@ | ||
|
||
|
||
.PHONY: entries test install all | ||
entries: | ||
ocamlbuild -cflags -I,+camlp4 entries.cmo | ||
|
||
test: | ||
camlp4rf _build/entries.cmo test.ml | ||
|
||
install: | ||
cp _build/entries.cmo ../lib/ | ||
|
||
all: entries |
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 @@ | ||
<entries.ml>: pp(camlp4rf) |
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 @@ | ||
|
||
open Camlp4.PreCast; | ||
|
||
value gram_entries = Gram.Entry.mk "gram_entries"; | ||
Gram.Entry.clear gram_entries; | ||
|
||
EXTEND Gram | ||
Syntax.implem: LAST [["ENTRIES"; x = gram_entries -> x ]]; | ||
gram_entries: [ "top" | ||
[ name = LIDENT; (items,status) = SELF -> | ||
let decl = <:str_item< value $lid:name$ = Gram.Entry.mk $str:name$ >> | ||
and clear = <:str_item< Gram.Entry.clear $lid:name$ >> | ||
in ([decl;clear::items], status) | ||
| "END"; x = Syntax.implem -> x ]]; | ||
END; |
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,25 @@ | ||
|
||
Revised parser: | ||
|
||
implem: | ||
[ [ "#"; n = a_LIDENT; dp = opt_expr; semi -> | ||
([ <:str_item< # $n$ $dp$ >> ], stopped_at _loc) | ||
| si = str_item; semi; (sil, stopped) = SELF -> ([si :: sil], stopped) | ||
| `EOI -> ([], None) | ||
] ] | ||
|
||
str_item: | ||
[ "top" ... | ||
| "module"; i = a_UIDENT; mb = module_binding0 -> | ||
<:str_item< module $i$ = $mb$ >> | ||
| "module"; "rec"; mb = module_binding -> | ||
<:str_item< module rec $mb$ >> | ||
| "module"; "type"; i = a_ident; "="; mt = module_type -> | ||
<:str_item< module type $i$ = $mt$ >> | ||
|
||
module_binding0: ... "="; me = module_expr | ||
|
||
module_expr: ... "struct"; st = str_items; "end" | ||
|
||
str_items: ... LIST0 [ st = str_item; semi -> st ] | ||
|