This is an automated email from the git hooks/post-receive script. glondu pushed a commit to branch master in repository cppo.
commit e0454ff56c5dc219c6ffff93d4df0c7cfacc1036 Author: Stephane Glondu <st...@glondu.net> Date: Tue Jan 26 15:48:04 2016 +0100 Imported Upstream version 1.2.1 --- cppo_eval.ml | 2 +- cppo_lexer.mll | 26 ++++++++++++++++++++++++-- test/Makefile | 6 ++++++ test/cond.ref | 17 +++++++++++++++++ test/loc.cppo | 8 ++++++++ test/loc.ref | 21 +++++++++++++++++++++ test/tuple.ref | 20 ++++++++++++++++++++ 7 files changed, 97 insertions(+), 3 deletions(-) diff --git a/cppo_eval.ml b/cppo_eval.ml index bb09c0e..f50417b 100644 --- a/cppo_eval.ml +++ b/cppo_eval.ml @@ -451,7 +451,7 @@ and expand_node ?(top = false) g env0 x = with Not_found -> None in let g = - if top && def <> None then + if top && def <> None || g.call_loc == dummy_loc then { g with call_loc = loc } else g in diff --git a/cppo_lexer.mll b/cppo_lexer.mll index 94d4c47..ea590ab 100644 --- a/cppo_lexer.mll +++ b/cppo_lexer.mll @@ -102,6 +102,26 @@ let add_char env c = let get env = Buffer.contents env.buf let long_loc e = (e.token_start, pos2 e.lexbuf) + +let cppo_directives = [ + "define"; + "elif"; + "else"; + "endif"; + "error"; + "if"; + "ifdef"; + "ifndef"; + "include"; + "undef"; + "warning"; +] + +let is_reserved_directive = + let tbl = Hashtbl.create 20 in + List.iter (fun s -> Hashtbl.add tbl s ()) cppo_directives; + fun s -> Hashtbl.mem tbl s + } (* standard character classes used for macro identifiers *) @@ -271,8 +291,10 @@ and directive e = parse add e (lexeme lexbuf); TEXT (long_loc e, true, get e) } - | blank* ['a'-'z']+ - { e.in_directive <- false; + | blank* (['a'-'z']+ as s) + { if is_reserved_directive s then + error (loc lexbuf) "cppo directive with missing or wrong arguments"; + e.in_directive <- false; add e (lexeme lexbuf); TEXT (long_loc e, false, get e) } diff --git a/test/Makefile b/test/Makefile index cfbbcb3..1521b86 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,9 +15,15 @@ comments: cond: ../cppo cond.cppo > cond.out + diff -u cond.ref cond.out tuple: ../cppo tuple.cppo > tuple.out + diff -u tuple.ref tuple.out + +loc: + ../cppo loc.cppo > loc.out + diff -u loc.ref loc.out version: ../cppo -V X:123.05.2-alpha.1+foo-2.1 version.cppo > version.out diff --git a/test/cond.ref b/test/cond.ref new file mode 100644 index 0000000..a9e2902 --- /dev/null +++ b/test/cond.ref @@ -0,0 +1,17 @@ + + +# 7 "cond.cppo" + banana + + +# 17 + apricot + + +# 28 + nest + + + +# 45 + sea urchin diff --git a/test/loc.cppo b/test/loc.cppo new file mode 100644 index 0000000..d7c2c52 --- /dev/null +++ b/test/loc.cppo @@ -0,0 +1,8 @@ +#define loc __FILE__ __LINE__ +loc +X(loc) +X(loc) +X(Y(loc)) + +#define F(x) loc +F() diff --git a/test/loc.ref b/test/loc.ref new file mode 100644 index 0000000..bb6c6b2 --- /dev/null +++ b/test/loc.ref @@ -0,0 +1,21 @@ +# 2 "loc.cppo" + "loc.cppo" 2 +# 3 +X( +# 3 + "loc.cppo" 3 +# 3 +) +X( +# 4 + "loc.cppo" 4 +# 4 +) +X(Y( +# 5 + "loc.cppo" 5 +# 5 + )) + +# 8 + "loc.cppo" 8 diff --git a/test/tuple.ref b/test/tuple.ref new file mode 100644 index 0000000..23b2e46 --- /dev/null +++ b/test/tuple.ref @@ -0,0 +1,20 @@ + +# 5 "tuple.cppo" + pistachios + + +# 9 + trees + + +# 16 + waves + + + +# 28 + bees + + +# 34 + steamboat -- 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