[Pkg-ocaml-maint-commits] [cppo] 05/11: Imported Upstream version 1.3.0

Stéphane Glondu glondu at moszumanska.debian.org
Tue Jan 26 14:56:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository cppo.

commit 9ed803e3771a386295908e73afdb095ffccb6732
Author: Stephane Glondu <steph at glondu.net>
Date:   Tue Jan 26 15:48:20 2016 +0100

    Imported Upstream version 1.3.0
---
 Makefile            |  2 +-
 cppo_eval.ml        |  2 +-
 cppo_lexer.mll      |  1 +
 cppo_parser.mly     | 14 ++++++++++++--
 cppo_types.ml       |  8 ++++++++
 test/Makefile       |  6 +++++-
 test/paren_arg.cppo |  3 +++
 test/paren_arg.ref  |  4 ++++
 8 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 6039f72..437962c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 1.1.2
+VERSION = 1.3.0
 
 ifeq "$(shell ocamlc -config |grep os_type)" "os_type: Win32"
 EXE=.exe
diff --git a/cppo_eval.ml b/cppo_eval.ml
index f50417b..0f077a8 100644
--- a/cppo_eval.ml
+++ b/cppo_eval.ml
@@ -165,7 +165,7 @@ or into a variable with the same properties."
                `Text (_, is_space, s) -> s
              | _ ->
                  expansion_error ()
-           ) l
+           ) (Cppo_types.flatten_nodes l)
          in
          let s = String.concat "" text in
          (match Cppo_lexer.int_tuple_of_string s with
diff --git a/cppo_lexer.mll b/cppo_lexer.mll
index ea590ab..b479704 100644
--- a/cppo_lexer.mll
+++ b/cppo_lexer.mll
@@ -353,6 +353,7 @@ and ocaml_token e = parse
       { new_line e;
         TEXT (loc lexbuf, false, lexeme lexbuf) }
 
+  | "("       { e.line_start <- false; OP_PAREN (loc lexbuf) }
   | ")"       { e.line_start <- false; CL_PAREN (loc lexbuf) }
   | ","       { e.line_start <- false; COMMA (loc lexbuf) }
 
diff --git a/cppo_parser.mly b/cppo_parser.mly
index 1131499..1e33e5f 100644
--- a/cppo_parser.mly
+++ b/cppo_parser.mly
@@ -68,7 +68,12 @@ full_node_list0:
 /* TODO: make lone COMMAs valid only in "main" rule */
 /* TODO: same for parentheses */
 node:
-  TEXT          { `Text $1 }
+| OP_PAREN node_or_comma_list0 CL_PAREN
+                { `Seq [`Text ($1, false, "(");
+                        `Seq $2;
+                        `Text ($3, false, ")")] }
+
+| TEXT          { `Text $1 }
 
 | IDENT         { let loc, name = $1 in
                   `Ident (loc, name, None) }
@@ -183,12 +188,17 @@ elif_list:
 |                  { [] }
 ;
 
-
 args1:
   node_list0 COMMA args1   { $1 :: $3  }
 | node_list0               { [ $1 ] }
 ;
 
+node_or_comma_list0:
+| node node_or_comma_list0   { $1 :: $2 }
+| COMMA node_or_comma_list0  { `Text ($1, false, ",") :: $2 }
+|                            { [] }
+;
+
 def_args1:
 | arg_blank IDENT COMMA def_args1
                                { (snd $2) :: $4 }
diff --git a/cppo_types.ml b/cppo_types.ml
index 5dab3f6..a31529f 100644
--- a/cppo_types.ml
+++ b/cppo_types.ml
@@ -97,3 +97,11 @@ let make_line_directive ?(fname = true) pos =
 let parse_file = ref ((fun file -> assert false) : string -> node list)
 
 let dummy_loc = (Lexing.dummy_pos, Lexing.dummy_pos)
+
+let rec flatten_nodes (l: node list): node list =
+  List.flatten (List.map flatten_node l)
+
+and flatten_node (node: node): node list =
+  match node with
+  | `Seq l -> flatten_nodes l
+  | x -> [x]
diff --git a/test/Makefile b/test/Makefile
index 1521b86..9e18cb7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,4 @@
-TESTS = ext comments cond tuple version
+TESTS = ext comments cond tuple paren_arg version
 .PHONY: all clean $(TESTS)
 
 all: $(TESTS)
@@ -25,6 +25,10 @@ loc:
 	../cppo loc.cppo > loc.out
 	diff -u loc.ref loc.out
 
+paren_arg:
+	../cppo paren_arg.cppo > paren_arg.out
+	diff -u paren_arg.ref paren_arg.out
+
 version:
 	../cppo -V X:123.05.2-alpha.1+foo-2.1 version.cppo > version.out
 
diff --git a/test/paren_arg.cppo b/test/paren_arg.cppo
new file mode 100644
index 0000000..f4c4803
--- /dev/null
+++ b/test/paren_arg.cppo
@@ -0,0 +1,3 @@
+#define F(x, y) <x> <y>
+F((1, (2)), 34)
+F((1\,\(2\)), 34)
diff --git a/test/paren_arg.ref b/test/paren_arg.ref
new file mode 100644
index 0000000..72fe773
--- /dev/null
+++ b/test/paren_arg.ref
@@ -0,0 +1,4 @@
+# 2 "paren_arg.cppo"
+ <(1, (2))> < 34> 
+# 3
+ <(1 , (2 ))> < 34> 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/cppo.git



More information about the Pkg-ocaml-maint-commits mailing list