23 months ago
Improved determination of type-conv paths
| Changelog | file | annotate | diff | revisions | |
| lib/META | file | annotate | diff | revisions | |
| lib/pa_type_conv.ml | file | annotate | diff | revisions |
1.1 --- a/Changelog 1.2 +++ b/Changelog 1.3 @@ -1,3 +1,7 @@ 1.4 +2010-06-03: Improved determination of type-conv paths. 1.5 + Thanks to Jacques Le Normand <rathereasy@gmail.com> for this 1.6 + patch! 1.7 + 1.8 2009-09-19: Added missing type cases for supporting variant types. 1.9 1.10 2009-01-14: Added support for type converters that take arguments.
2.1 --- a/lib/META 2.2 +++ b/lib/META 2.3 @@ -1,9 +1,9 @@ 2.4 name = "type-conv" 2.5 -version = "1.7.0" 2.6 +version = "1.7.1" 2.7 description = "Type-conv - support library for preprocessor type conversions" 2.8 2.9 package "syntax" ( 2.10 - version = "1.7.0" 2.11 + version = "1.7.1" 2.12 requires = "camlp4" 2.13 description = "Syntax extension for type-conv" 2.14 archive(syntax, preprocessor) = "pa_type_conv.cmo"
3.1 --- a/lib/pa_type_conv.ml 3.2 +++ b/lib/pa_type_conv.ml 3.3 @@ -319,24 +319,6 @@ 3.4 3.5 open Syntax 3.6 3.7 -let found_module_name = 3.8 - Gram.Entry.of_parser "found_module_name" (fun strm -> 3.9 - match Stream.npeek 1 strm with 3.10 - | [(UIDENT name, _)] -> 3.11 - push_conv_path name; 3.12 - Stream.junk strm; 3.13 - name 3.14 - | _ -> raise Stream.Failure) 3.15 - 3.16 -let rec fetch_generator_arg paren_count strm = 3.17 - match Stream.next strm with 3.18 - | KEYWORD "(", _ -> fetch_generator_arg (paren_count + 1) strm 3.19 - | KEYWORD ")", loc -> 3.20 - if paren_count = 1 then [(EOI, loc)] 3.21 - else fetch_generator_arg (paren_count - 1) strm 3.22 - | EOI, loc -> Loc.raise loc (Stream.Error "')' missing") 3.23 - | x -> x :: fetch_generator_arg paren_count strm 3.24 - 3.25 let is_prefix ~prefix x = 3.26 let prefix_len = String.length prefix in 3.27 String.length x >= prefix_len && prefix = String.sub x 0 prefix_len 3.28 @@ -360,6 +342,25 @@ 3.29 let conv_path = get_default_path _loc in 3.30 conv_path_ref := Path (conv_path, [conv_path]) 3.31 3.32 +let found_module_name = 3.33 + Gram.Entry.of_parser "found_module_name" (fun strm -> 3.34 + match Stream.npeek 1 strm with 3.35 + | [(UIDENT name, _loc)] -> 3.36 + set_conv_path_if_not_set _loc; 3.37 + push_conv_path name; 3.38 + Stream.junk strm; 3.39 + name 3.40 + | _ -> raise Stream.Failure) 3.41 + 3.42 +let rec fetch_generator_arg paren_count strm = 3.43 + match Stream.next strm with 3.44 + | KEYWORD "(", _ -> fetch_generator_arg (paren_count + 1) strm 3.45 + | KEYWORD ")", loc -> 3.46 + if paren_count = 1 then [(EOI, loc)] 3.47 + else fetch_generator_arg (paren_count - 1) strm 3.48 + | EOI, loc -> Loc.raise loc (Stream.Error "')' missing") 3.49 + | x -> x :: fetch_generator_arg paren_count strm 3.50 + 3.51 let generator_arg = 3.52 Gram.Entry.of_parser "generator_arg" (fun strm -> 3.53 match Stream.peek strm with 3.54 @@ -415,7 +416,6 @@ 3.55 str_item: 3.56 [[ 3.57 "module"; i = found_module_name; mb = module_binding0 -> 3.58 - set_conv_path_if_not_set _loc; 3.59 pop_conv_path (); 3.60 <:str_item< module $i$ = $mb$ >> 3.61 ]];