diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2014-04-28 11:49:52 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2014-04-28 11:49:52 +0000 |
commit | cc25e53ad310eb32d4854a1505ac3a9a917c8368 (patch) | |
tree | 101a8f24490f8ef63c75820cfd945cc4d7f669fc /parsing | |
parent | e94190206fe983154d5606a448e434aec03783d0 (diff) | |
parent | f1f362698f931494a305d48667936ffee2012b64 (diff) | |
download | ocaml-safe-string.tar.gz |
merge trunk up to commit 14699safe-string
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/safe-string@14700 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'parsing')
-rw-r--r-- | parsing/parser.mly | 37 | ||||
-rw-r--r-- | parsing/parsetree.mli | 4 | ||||
-rw-r--r-- | parsing/pprintast.ml | 12 | ||||
-rw-r--r-- | parsing/printast.ml | 4 |
4 files changed, 22 insertions, 35 deletions
diff --git a/parsing/parser.mly b/parsing/parser.mly index abe2b9ee33..55a7b5c513 100644 --- a/parsing/parser.mly +++ b/parsing/parser.mly @@ -522,9 +522,9 @@ use_file_tail: | SEMISEMI seq_expr post_item_attributes use_file_tail { Ptop_def[mkstrexp $2 $3] :: $4 } | SEMISEMI structure_item use_file_tail { Ptop_def[$2] :: $3 } - | SEMISEMI toplevel_directive SEMISEMI use_file_tail { $2 :: $4 } + | SEMISEMI toplevel_directive use_file_tail { $2 :: $3 } | structure_item use_file_tail { Ptop_def[$1] :: $2 } - | toplevel_directive SEMISEMI use_file_tail { $1 :: $3 } + | toplevel_directive use_file_tail { $1 :: $2 } ; parse_core_type: core_type EOF { $1 } @@ -1945,23 +1945,15 @@ class_longident: /* Toplevel directives */ toplevel_directive: - SHARP ident toplevel_directive_args { Ptop_dir($2, $3) } -; -toplevel_directive_arg: - | STRING { Pdir_string (fst $1) } - | INT { Pdir_int $1 } - | val_longident { Pdir_ident $1 } - | mod_longident { Pdir_ident $1 } - | keyword { - match $1 with - | "true" -> Pdir_bool true - | "false" -> Pdir_bool false - | s -> Pdir_keyword s - } -toplevel_directive_args: - | /*empty*/ { [] } - | toplevel_directive_arg toplevel_directive_args { $1 :: $2 } + SHARP ident { Ptop_dir($2, Pdir_none) } + | SHARP ident STRING { Ptop_dir($2, Pdir_string (fst $3)) } + | SHARP ident INT { Ptop_dir($2, Pdir_int $3) } + | SHARP ident val_longident { Ptop_dir($2, Pdir_ident $3) } + | SHARP ident mod_longident { Ptop_dir($2, Pdir_ident $3) } + | SHARP ident FALSE { Ptop_dir($2, Pdir_bool false) } + | SHARP ident TRUE { Ptop_dir($2, Pdir_bool true) } ; + /* Miscellaneous */ name_tag: @@ -2017,7 +2009,9 @@ additive: /* Attributes and extensions */ -keyword: +single_attr_id: + LIDENT { $1 } + | UIDENT { $1 } | AND { "and" } | AS { "as" } | ASSERT { "assert" } @@ -2068,11 +2062,6 @@ keyword: | WITH { "with" } /* mod/land/lor/lxor/lsl/lsr/asr are not supported for now */ ; -single_attr_id: - LIDENT { $1 } - | UIDENT { $1 } - | keyword { $1 } -; attr_id: single_attr_id { mkloc $1 (symbol_rloc()) } diff --git a/parsing/parsetree.mli b/parsing/parsetree.mli index 5747f51eb3..ce938dd897 100644 --- a/parsing/parsetree.mli +++ b/parsing/parsetree.mli @@ -763,12 +763,12 @@ and module_binding = type toplevel_phrase = | Ptop_def of structure - | Ptop_dir of string * directive_argument list + | Ptop_dir of string * directive_argument (* #use, #load ... *) and directive_argument = + | Pdir_none | Pdir_string of string | Pdir_int of int | Pdir_ident of Longident.t | Pdir_bool of bool - | Pdir_keyword of string diff --git a/parsing/pprintast.ml b/parsing/pprintast.ml index 28965bce3d..8b156bafd1 100644 --- a/parsing/pprintast.ml +++ b/parsing/pprintast.ml @@ -1224,12 +1224,12 @@ class printer ()= object(self:'self) pp f "~%s:%a" lbl self#simple_expr e method directive_argument f x = - match x with + (match x with + | Pdir_none -> () | Pdir_string (s) -> pp f "@ %S" s | Pdir_int (i) -> pp f "@ %d" i | Pdir_ident (li) -> pp f "@ %a" self#longident li - | Pdir_bool (b) -> pp f "@ %s" (string_of_bool b) - | Pdir_keyword s -> pp f "@ %s" s + | Pdir_bool (b) -> pp f "@ %s" (string_of_bool b)) method toplevel_phrase f x = match x with @@ -1238,8 +1238,7 @@ class printer ()= object(self:'self) self#list self#structure_item f s ; pp_close_box f (); | Ptop_dir (s, da) -> - pp f "@[<hov2>#%s@ %a@]" s - (self#list ~sep:" " self#directive_argument) da + pp f "@[<hov2>#%s@ %a@]" s self#directive_argument da end;; @@ -1253,8 +1252,7 @@ let toplevel_phrase f x = (* pp_print_list structure_item f s ; *) (* pp_close_box f (); *) | Ptop_dir (s, da) -> - pp f "@[<hov2>#%s@ %a@]" s - (default#list ~sep:" " default#directive_argument) da + pp f "@[<hov2>#%s@ %a@]" s default#directive_argument da (* pp f "@[<hov2>#%s@ %a@]" s directive_argument da *) let expression f x = diff --git a/parsing/printast.ml b/parsing/printast.ml index 15de289d54..a8a1671b96 100644 --- a/parsing/printast.ml +++ b/parsing/printast.ml @@ -838,15 +838,15 @@ let rec toplevel_phrase i ppf x = structure (i+1) ppf s; | Ptop_dir (s, da) -> line i ppf "Ptop_dir \"%s\"\n" s; - list i directive_argument ppf da; + directive_argument i ppf da; and directive_argument i ppf x = match x with + | Pdir_none -> line i ppf "Pdir_none\n" | Pdir_string (s) -> line i ppf "Pdir_string \"%s\"\n" s; | Pdir_int (i) -> line i ppf "Pdir_int %d\n" i; | Pdir_ident (li) -> line i ppf "Pdir_ident %a\n" fmt_longident li; | Pdir_bool (b) -> line i ppf "Pdir_bool %s\n" (string_of_bool b); - | Pdir_keyword s -> line i ppf "Pdir_keyword %s\n" s; ;; let interface ppf x = list 0 signature_item ppf x;; |