Skip to content

Commit

Permalink
implem only
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakken committed Jun 27, 2012
0 parents commit 76f6642
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Makefile
@@ -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
1 change: 1 addition & 0 deletions _tags
@@ -0,0 +1 @@
<entries.ml>: pp(camlp4rf)
15 changes: 15 additions & 0 deletions entries.ml
@@ -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;
25 changes: 25 additions & 0 deletions entries.notes
@@ -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 ]

0 comments on commit 76f6642

Please sign in to comment.