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

glondu pushed a commit to branch master
in repository cppo.

commit 1283a0a2d4e4de3df96c5228a208b845455c7ac9
Author: Stephane Glondu <st...@glondu.net>
Date:   Tue Jan 26 15:48:33 2016 +0100

    Imported Upstream version 1.3.1
---
 Makefile            |  2 +-
 cppo_parser.mly     | 66 ++++++++++++++++++++++++++++-------------------------
 test/Makefile       |  6 ++++-
 test/unmatched.cppo | 14 ++++++++++++
 test/unmatched.ref  | 15 ++++++++++++
 5 files changed, 70 insertions(+), 33 deletions(-)

diff --git a/Makefile b/Makefile
index 437962c..205face 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION = 1.3.0
+VERSION = 1.3.1
 
 ifeq "$(shell ocamlc -config |grep os_type)" "os_type: Win32"
 EXE=.exe
diff --git a/cppo_parser.mly b/cppo_parser.mly
index 1e33e5f..7817a85 100644
--- a/cppo_parser.mly
+++ b/cppo_parser.mly
@@ -27,7 +27,6 @@
 %token < Cppo_types.loc * bool * string > TEXT /* bool means "is space" */
 %token EOF
 
-
 /* Priorities for boolean expressions */
 %left OR
 %left AND
@@ -45,34 +44,39 @@
 %%
 
 main:
-  full_node main { $1 :: $2 }
-| EOF      { [] }
+| unode main { $1 :: $2 }
+| EOF        { [] }
 ;
 
-full_node:
-  CL_PAREN   { `Text ($1, false, ")") }
-| COMMA      { `Text ($1, false, ",") }
-| node       { $1 }
+unode_list0:
+| unode unode_list0  { $1 :: $2 }
+|                    { [] }
 ;
 
-node_list0:
-  node node_list0  { $1 :: $2 }
-|                  { [] }
+pnode_list0:
+| pnode pnode_list0  { $1 :: $2 }
+|                    { [] }
 ;
 
-full_node_list0:
-  full_node full_node_list0  { $1 :: $2 }
-|                            { [] }
+/* node in which opening and closing parentheses don't need to match */
+unode:
+| node          { $1 }
+| OP_PAREN      { `Text ($1, false, "(") }
+| CL_PAREN      { `Text ($1, false, ")") }
+| COMMA         { `Text ($1, false, ",") }
 ;
 
-/* TODO: make lone COMMAs valid only in "main" rule */
-/* TODO: same for parentheses */
-node:
-| OP_PAREN node_or_comma_list0 CL_PAREN
+/* node in which parentheses must be closed */
+pnode:
+| node          { $1 }
+| OP_PAREN pnode_or_comma_list0 CL_PAREN
                 { `Seq [`Text ($1, false, "(");
                         `Seq $2;
                         `Text ($3, false, ")")] }
+;
 
+/* node without parentheses handling (need to use unode or pnode) */
+node:
 | TEXT          { `Text $1 }
 
 | IDENT         { let loc, name = $1 in
@@ -93,7 +97,7 @@ node:
 | CURRENT_LINE  { `Current_line $1 }
 | CURRENT_FILE  { `Current_file $1 }
 
-| DEF full_node_list0 ENDEF
+| DEF unode_list0 ENDEF
                 { let (pos1, _), name = $1 in
 
                   (* Additional spacing is needed for cases like '+foo+'
@@ -104,7 +108,7 @@ node:
                   let _, pos2 = $3 in
                   `Def ((pos1, pos2), name, body) }
 
-| DEFUN def_args1 CL_PAREN full_node_list0 ENDEF
+| DEFUN def_args1 CL_PAREN unode_list0 ENDEF
                 { let (pos1, _), name = $1 in
                   let args = $2 in
 
@@ -136,7 +140,7 @@ node:
 | EXT
                 { `Ext $1 }
 
-| IF test full_node_list0 elif_list ENDIF
+| IF test unode_list0 elif_list ENDIF
                 { let pos1, _ = $1 in
                   let _, pos2 = $5 in
                   let loc = (pos1, pos2) in
@@ -151,11 +155,11 @@ node:
                   `Cond (loc, test, if_true, if_false)
                 }
 
-| IF test full_node_list0 elif_list error
+| IF test unode_list0 elif_list error
                 { (* BUG? ocamlyacc fails to reduce that rule but not menhir *)
                   error $1 "missing #endif" }
 
-| IFDEF full_node_list0 elif_list ENDIF
+| IFDEF unode_list0 elif_list ENDIF
                 { let (pos1, _), test = $1 in
                   let _, pos2 = $4 in
                   let loc = (pos1, pos2) in
@@ -169,7 +173,7 @@ node:
                   `Cond (loc, test, if_true, if_false)
                 }
 
-| IFDEF full_node_list0 elif_list error
+| IFDEF unode_list0 elif_list error
                 { error (fst $1) "missing #endif" }
 
 | LINE          { `Line $1 }
@@ -177,11 +181,11 @@ node:
 
 
 elif_list:
-  ELIF test full_node_list0 elif_list
+  ELIF test unode_list0 elif_list
                    { let pos1, _ = $1 in
                      let pos2 = Parsing.rhs_end_pos 4 in
                      ((pos1, pos2), $2, $3) :: $4 }
-| ELSE full_node_list0
+| ELSE unode_list0
                    { let pos1, _ = $1 in
                      let pos2 = Parsing.rhs_end_pos 2 in
                      [ ((pos1, pos2), `True, $2) ] }
@@ -189,14 +193,14 @@ elif_list:
 ;
 
 args1:
-  node_list0 COMMA args1   { $1 :: $3  }
-| node_list0               { [ $1 ] }
+  pnode_list0 COMMA args1   { $1 :: $3  }
+| pnode_list0               { [ $1 ] }
 ;
 
-node_or_comma_list0:
-| node node_or_comma_list0   { $1 :: $2 }
-| COMMA node_or_comma_list0  { `Text ($1, false, ",") :: $2 }
-|                            { [] }
+pnode_or_comma_list0:
+| pnode pnode_or_comma_list0   { $1 :: $2 }
+| COMMA pnode_or_comma_list0   { `Text ($1, false, ",") :: $2 }
+|                              { [] }
 ;
 
 def_args1:
diff --git a/test/Makefile b/test/Makefile
index 9e18cb7..f56c27f 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,4 @@
-TESTS = ext comments cond tuple paren_arg version
+TESTS = ext comments cond tuple paren_arg unmatched version
 .PHONY: all clean $(TESTS)
 
 all: $(TESTS)
@@ -29,6 +29,10 @@ paren_arg:
        ../cppo paren_arg.cppo > paren_arg.out
        diff -u paren_arg.ref paren_arg.out
 
+unmatched:
+       ../cppo unmatched.cppo > unmatched.out
+       diff -u unmatched.ref unmatched.out
+
 version:
        ../cppo -V X:123.05.2-alpha.1+foo-2.1 version.cppo > version.out
 
diff --git a/test/unmatched.cppo b/test/unmatched.cppo
new file mode 100644
index 0000000..470cbd4
--- /dev/null
+++ b/test/unmatched.cppo
@@ -0,0 +1,14 @@
+#ifdef whatever
+  (
+#else
+  let a = 1 in
+  let b = 2 in
+  (a ||
+#endif
+
+  b)
+
+#define F(x, y) (x + y)
+F(1,(2+3))
+)
+(
diff --git a/test/unmatched.ref b/test/unmatched.ref
new file mode 100644
index 0000000..d34ae7e
--- /dev/null
+++ b/test/unmatched.ref
@@ -0,0 +1,15 @@
+  
+# 4 "unmatched.cppo"
+  let a = 1 in
+  let b = 2 in
+  (a ||
+
+  
+# 9
+  b)
+
+# 12
+ (1 + (2+3)) 
+# 13
+)
+(

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

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to