# for profiling add -p -inline 0
# but 'make forprofiling' below does that for you.
# This flag is also used in subdirectories so don't change its name here.
+# To enable backtrace support for native code, you need to put -g in OPTFLAGS
+# to also link with -g, but even in 3.11 the backtrace support seems buggy so
+# not worth it.
OPTFLAGS=
# the following is essential for Coccinelle to compile under gentoo
# but is now defined above in this file
.PHONY:: all all.opt byte opt top clean distclean configure
.PHONY:: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt) subdirs subdirs.opt
-all: byte
- $(MAKE) preinstall
+all: Makefile.config byte preinstall
opt: all.opt
-all.opt: opt-compil
- $(MAKE) preinstall
+all.opt: opt-compil preinstall
-world:
+world: preinstall
$(MAKE) byte
- $(MAKE) opt
- $(MAKE) preinstall
+ $(MAKE) opt-compil
byte: .depend
$(MAKE) subdirs
configure:
./configure
+Makefile.config:
+ @echo "Makefile.config is missing. Have you run ./configure?"
+ @exit 1
+
tools:
$(MAKE) -C tools
##############################################################################
# Pre-Install (customization of spatch frontend script)
##############################################################################
-.PHONY:: preinstall preinstall-def preinstall-byte preinstall-opt
-preinstall: preinstall-def preinstall-byte preinstall-opt
+preinstall: scripts/spatch scripts/spatch.opt scripts/spatch.byte
# user will use spatch to run spatch.opt (native)
-preinstall-def:
+scripts/spatch:
cp scripts/spatch.sh scripts/spatch.tmp2
sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.tmp2 > scripts/spatch.tmp
sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.tmp > scripts/spatch
rm -f scripts/spatch.tmp2 scripts/spatch.tmp
# user will use spatch to run spatch (bytecode)
-preinstall-byte:
- cp scripts/spatch.sh scripts/spatch.tmp3
- sed "s|\.opt||" scripts/spatch.tmp3 > scripts/spatch.tmp2
- sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.tmp2 > scripts/spatch.tmp
- sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.tmp > scripts/spatch.byte
- rm -f scripts/spatch.tmp3 scripts/spatch.tmp2 scripts/spatch.tmp
+scripts/spatch.byte:
+ cp scripts/spatch.sh scripts/spatch.byte.tmp3
+ sed "s|\.opt||" scripts/spatch.byte.tmp3 > scripts/spatch.byte.tmp2
+ sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.byte.tmp2 \
+ > scripts/spatch.byte.tmp
+ sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.byte.tmp \
+ > scripts/spatch.byte
+ rm -f scripts/spatch.byte.tmp3 \
+ scripts/spatch.byte.tmp2 \
+ scripts/spatch.byte.tmp
# user will use spatch.opt to run spatch.opt (native)
-preinstall-opt:
+scripts/spatch.opt:
cp scripts/spatch.sh scripts/spatch.opt.tmp2
- sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.opt.tmp2 > scripts/spatch.opt.tmp
- sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.opt.tmp > scripts/spatch.opt
+ sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.opt.tmp2 \
+ > scripts/spatch.opt.tmp
+ sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.opt.tmp \
+ > scripts/spatch.opt
rm -f scripts/spatch.opt.tmp scripts/spatch.opt.tmp2
clean::
$(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
$(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
@if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi
- @echo ""
- @echo "You can also install spatch by copying the program spatch"
- @echo "(available in this directory) anywhere you want and"
- @echo "give it the right options to find its configuration files."
- @echo ""
install-python:
mkdir -p $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
$(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
$(INSTALL_LIB) dllpycaml_stubs.so $(DESTDIR)$(LIBDIR)
-install:
+install: install-common
@if test -x spatch -a ! -x spatch.opt ; then \
$(MAKE) install-byte;fi
@if test ! -x spatch -a -x spatch.opt ; then \
$(MAKE) install-byte; $(MAKE) install-opt;fi
@if test ! -x spatch -a ! -x spatch.opt ; then \
echo "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi
+ @echo ""
+ @echo "\tYou can also install spatch by copying the program spatch"
+ @echo "\t(available in this directory) anywhere you want and"
+ @echo "\tgive it the right options to find its configuration files."
+ @echo ""
# user will use spatch to run spatch.opt (native)
-install-def: install-common
+install-def:
$(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
$(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch
# user will use spatch to run spatch (bytecode)
-install-byte: install-common
+install-byte:
$(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR)
$(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch
# user will use spatch.opt to run spatch.opt (native)
-install-opt: install-common
+install-opt:
$(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
$(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt
BINSRC=spatch env.sh env.csh standard.h standard.iso \
*.txt \
- docs/options.pdf docs/grammar/cocci_syntax.pdf docs/spatch.1 \
- docs/cocci-python.txt \
+ docs/manual/options.pdf docs/manual/cocci_syntax.pdf docs/spatch.1 \
+ docs/manual/cocci-python.txt \
demos/foo.* demos/simple.*
# $(PYLIB) python/coccilib/ demos/printloc.*
BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
# Procedure to do each time:
# cvs update
# make sure that ocaml is the distribution ocaml of /usr/bin, not ~pad/...
-# modify globals/config.ml
+# modify globals/config.ml.in
# cd globals/; cvs commit -m"new version" (do not commit from the root!)
# ./configure --without-python
# make package
rm -f $(WEBSITE)/LATEST* $(WEBSITE)/coccinelle-latest.tgz
cp changes.txt $(WEBSITE)/changes-$(VERSION).txt
cd $(WEBSITE); touch LATEST_IS_$(VERSION); ln -s $(PACKAGE).tgz coccinelle-latest.tgz
+ cp readme.txt $(WEBSITE)
#TXT=$(wildcard *.txt)
darcsweb:
# @echo pull from ~/public_html/darcs/c-coccinelle and c-commons and lib-xxx
-DARCSFORESTS=commons \
+DARCSFORESTS=commons ocamlsexp \
parsing_c parsing_cocci engine
update_darcs:
- parsing_cocci/ (parsing SmPL, isomorphism handling)
- engine/ (ast_cocci to ctl, sgrep)
- ctl/ (symbolic model checker)
-- popl/ popl09/
- tools/
- standard.iso
- parsing_c/ (parsing C, unparsing C, type checking, control flow, C diff)
- engine/ (pattern matching and transforming, unparsing, ctl integration)
-- cocci.ml (driver)
-- main.ml, testing.ml
-- emacs/cocci.el
+- main.ml, cocci.ml (driver), testing.ml
+- configure, txt files, Makefiles
- globals/
-- extra/
-- tools/
-- scripts/
-- commons/ (utility functions)
+- extra/, tools/, scripts/
+- commons/ (utility functions, e.g. for logging, profiling, regression testing)
+- editors/emacs/cocci.el
- standard.h
* Rene Rydhof Hansen <rrhansen@diku.dk>
- Original version of the model checker in ctl/
-- emacs/cocci-ediff.el
+- editors/emacs/cocci-ediff.el
- scripts/extractor.awk
* Henrik stuart <henrik@hstuart.dk>
-*- org -*-
+* 0.1.8
+
+** Language:
+
+** Features:
+- Metavariables now capture the cpp code contained within their definitions
+- When - fragments are separated by ... or nest boundaries in the semantic
+ patch, but end up matching adjacent source code, the comments, cpp code
+ and whitespace that are between them are not deleted.
+- better parsing of C: do expansion of macros only when needed when
+ have actually a parse error and also leverage the definition of macros
+ in the parsed file (or in a optional_standard.h file passed as a parameter).
+ This should reduce the need for many hardcoded definitions in standard.h
+- new semantics for the -macro_file option, by default now expand macros
+ only when necessary. To force use the -macro_file_builtins option instead.
+- a new -extract_macros command line action to help the parser. Works with
+ the -macro_file option. e.g.
+ $ ./spatch -extract_macros ~/linux > /tmp/alldefs.h
+ $ ./spatch -macro_file /tmp/alldefs.h -sp_file foo.cocci -dir ~/linux
+- removed -D macro_file option, not consistent with what -D usually means
+- reattempt to be more efficient for statement metavariables that are just
+ placeholders (ie, no modification, no reuse)
+- triples now returned from ctl in sorted order. The main key is the
+ state. On the other hand, the state order does not always agree with the
+ order of appearance in the code.
+- spatch is now less verbose on the things it does yet handle. Less confusing
+ for new users.
+- slightly better error report. Thanks to Derek Jones for the suggestion.
+- added the options -linux_spacing and -smpl_spacing. -linux_spacing
+ causes spatch to follow the spacing conventions of Linux, while
+ -smpl_spacing causes spatch to follow the spacing in the semantic patch.
+ -linux_spacing is the default.
+- more informative error reporting for the already tagged token case.
+ Thanks to Erik Hovland for the suggestion.
+
+** Bugfix:
+- better parsing of declare macro at toplevel and in structure.
+ cf -text xfield
+- allowing back typedef names for fieldname
+- better printing of else in generated code
+- slightly better type inference for binary operators.
+- clear out declarer names and iterator names between SmPL files (for
+ -testall)
+- better parsing and type checking of macro type aliases. Cf -test macro_int16.
+ Thanks to Li Yingtong for pointing out the problem.
+- make insert_virtual_positions tail rec, avoid stack overflow pb.
+ Thanks to Diego Liziero <diegoliz@gmail.com> for pointing out the
+ problem.
+- Better type inference for arithmetic binary operators
+ Thanks to Li Yingtong for pointing out the problem.
+- Better type inference for constants
+ Thanks to Li Yingtong for pointing out the problem.
+- move computing of adjacency information for semantic patches to after
+ application of isomorphisms, because isomorphisms can introduce "..."
+- compute adjacency information for negated ...
+- record with each transformation site the set of indices of the witness
+ trees that caused the transformation site to come about. Whitespace and
+ comments between remove tokens associated with disjoint witness trees is
+ not removed.
+- correct treatment of function pointer typed parameters in the SmPL ast0
+ visitor.
+- better parsing error message and error recovery when comments are not ended,
+ when some macros have a weird body, and when some switch have a weird
+ Body.
+ Thanks to Derek Jones for pointing out the problem.
+- better detection and passing of "dangerous" ifdefs, cf -test
+ double_switch.
+- dropped the separation of decls and body in Seq. This gives better
+ positioning of the bindings of metavariables shared between them.
+ Thanks to Erik Hovland for an example that shows the problem.
+
+** Internals:
+- supress warning in compiling ocamlsexp (warning caused by a new behavior
+ of cpp used internally in processing files in ocamlsexp/)
+
* 0.1.7
** Language:
** Language:
- long long added to SmPL
+** Documentation:
+- add grammar reference and spatch command line options reference
+
** Features:
- can match patterns of the form unsigned T or signed T, where T is a
metavariable
- isomorphisms don't apply under signed/unsigned, to prevent the creation
of things like unsigned signed int. Need a better solution for this.
+
* 0.1.3
** Features:
module CCI = Ctlcocci_integration
module TAC = Type_annoter_c
+module Ast_to_flow = Control_flow_c_build
+
(*****************************************************************************)
(* This file is a kind of driver. It gathers all the important functions
* from coccinelle in one place. The different entities in coccinelle are:
let show_or_not_trans_info2 trans_info =
+ (* drop witness tree indices for printing *)
+ let trans_info =
+ List.map (function (index,trans_info) -> trans_info) trans_info in
if !Flag.show_transinfo then begin
if null trans_info then pr2 "transformation info is empty"
else begin
let check_macro_in_sp_and_adjust tokens =
let tokens = Common.union_all tokens in
tokens +> List.iter (fun s ->
- if Hashtbl.mem !Parsing_hacks._defs s
+ if Hashtbl.mem !Parse_c._defs s
then begin
- pr2 "warning: macro in semantic patch was in macro definitions";
- pr2 ("disabling macro expansion for " ^ s);
- Hashtbl.remove !Parsing_hacks._defs s
+ if !Flag_cocci.verbose_cocci then begin
+ pr2 "warning: macro in semantic patch was in macro definitions";
+ pr2 ("disabling macro expansion for " ^ s);
+ end;
+ Hashtbl.remove !Parse_c._defs s
end
)
(* r(ule), c(element in C code), e(nvironment) *)
+let findk f l =
+ let rec loop k = function
+ [] -> None
+ | x::xs ->
+ if f x
+ then Some (x, function n -> k (n :: xs))
+ else loop (function vs -> k (x :: vs)) xs in
+ loop (function x -> x) l
+
let merge_env new_e old_e =
- List.fold_left
- (function old_e ->
- function (e,rules) as elem ->
- let (same,diff) = List.partition (function (e1,_) -> e =*= e1) old_e in
- match same with
- [] -> elem :: old_e
- | [(_,old_rules)] -> (e,Common.union_set rules old_rules) :: diff
- | _ -> failwith "duplicate environment entries")
- old_e new_e
+ let (ext,old_e) =
+ List.fold_left
+ (function (ext,old_e) ->
+ function (e,rules) as elem ->
+ match findk (function (e1,_) -> e =*= e1) old_e with
+ None -> (elem :: ext,old_e)
+ | Some((_,old_rules),k) ->
+ (ext,k (e,Common.union_set rules old_rules)))
+ ([],old_e) new_e in
+ old_e @ (List.rev ext)
let apply_python_rule r cache newes e rules_that_have_matched
rules_that_have_ever_matched =
(* applying the rule *)
(match r.ruletype with
Ast_cocci.Normal ->
- let children_e = ref [] in
-
(* looping over the functions and toplevel elements in
.c and .h *)
- concat_headers_and_c !ccs +> List.iter (fun (c,f) ->
- if c.flow <> None
- then
- (* does also some side effects on c and r *)
- let processed =
- process_a_ctl_a_env_a_toplevel r
- relevant_bindings c f in
- match processed with
- | None -> ()
- | Some newbindings ->
- newbindings +> List.iter (fun newbinding ->
- children_e :=
- Common.insert_set newbinding !children_e)
- ); (* end iter cs *)
-
- !children_e
+ List.rev
+ (concat_headers_and_c !ccs +>
+ List.fold_left (fun children_e (c,f) ->
+ if c.flow <> None
+ then
+ (* does also some side effects on c and r *)
+ let processed =
+ process_a_ctl_a_env_a_toplevel r
+ relevant_bindings c f in
+ match processed with
+ | None -> children_e
+ | Some newbindings ->
+ newbindings +>
+ List.fold_left
+ (fun children_e newbinding ->
+ if List.mem newbinding children_e
+ then children_e
+ else newbinding :: children_e)
+ children_e
+ else children_e)
+ [])
| Ast_cocci.Generated ->
process_a_generated_a_env_a_toplevel r
relevant_bindings !ccs;
let check_duplicate_modif2 xs =
(* opti: let groups = Common.groupBy (fun (a,resa) (b,resb) -> a =$= b) xs *)
- pr2 ("Check duplication for " ^ i_to_s (List.length xs) ^ " files");
+ if !Flag_cocci.verbose_cocci
+ then pr2 ("Check duplication for " ^ i_to_s (List.length xs) ^ " files");
+
let groups = Common.group_assoc_bykey_eff xs in
groups +> Common.map_filter (fun (file, xs) ->
match xs with
-Release coccinelle-0.1.7
-
-** Language:
- - initialize and finalize script code, cf demos/initial_final.cocci
-
-** Features:
- - -iso_limit option to limit the depth of isomorphism application
- - with the dir option, the include path is implicitly set to the "include"
- subdirectory of the specified directory, if the option -I is not used.
- - give a seed for the name of a fresh identifier
- - better handling of cpp "constructed" identifiers as in a##b, that in
- the futur will make it easier to match over those idents.
- cf tests/pb_parsing_macro.c. Thanks to Ali-Erdem Ozcan for pointing
- out the problem. A new "parsing hack hint" is also available:
- YACFE_IDENT_BUILDER, cf standard.h.
-
-** Bugfix:
- - drop excessive "optimization" in ctl generation for while and for loops
- - allow . as the name of the directory
- - for type inference for an assignment, take the type of the right-hand
- side expression, not the type of the assigned variable
- - allow for with a declartion in the first header element, as in C++
- (partial support)
- - allow for matching against variable declarations that include only
- storage, eg static, but no type at all.
- - allow for matching against types that contain both short/long and int
- - allow the type metavariable in the SmPL code "unsigned T" to match a T
- that is a type consisting of more than one word, eg long int.
- - -ifdef_to_if option made to process nested ifdefs
- (partial support)
-
-** Internals:
- - improve and fix installation process (usable on BSD)
- - improve and fix testing process
- - apply patches from Eugeniy Meshcheryakov
- - reorganize the way we parse C identifiers, especially concatenated cpp
- identifiers as in a##b. This may lead to some regressions as we may
- not parse as much code as before.
- - removed popl/ and popl09/ and popl related stuff from official distrib.
+Release coccinelle-0.1.8
+
+** Features:
+ - Metavariables now capture the cpp code contained within their definitions
+ - When - fragments are separated by ... or nest boundaries in the semantic
+ patch, but end up matching adjacent source code, the comments, cpp code
+ and whitespace that are between them are not deleted.
+ - better parsing of C: do expansion of macros only when needed when
+ have actually a parse error and also leverage the definition of macros
+ in the parsed file (or in a optional_standard.h file passed as a parameter).
+ This should reduce the need for many hardcoded definitions in standard.h
+ - new semantics for the -macro_file option, by default now expand macros
+ only when necessary. To force use the -macro_file_builtins option instead.
+ - a new -extract_macros command line action to help the parser. Works with
+ the -macro_file option. e.g.
+ $ ./spatch -extract_macros ~/linux > /tmp/alldefs.h
+ $ ./spatch -macro_file /tmp/alldefs.h -sp_file foo.cocci -dir ~/linux
+ - removed -D macro_file option, not consistent with what -D usually means
+ - reattempt to be more efficient for statement metavariables that are just
+ placeholders (ie, no modification, no reuse)
+ - triples now returned from ctl in sorted order. The main key is the
+ state. On the other hand, the state order does not always agree with the
+ order of appearance in the code.
+ - spatch is now less verbose on the things it does yet handle. Less confusing
+ for new users.
+ - slightly better error report. Thanks to Derek Jones for the suggestion.
+ - added the options -linux_spacing and -smpl_spacing. -linux_spacing
+ causes spatch to follow the spacing conventions of Linux, while
+ -smpl_spacing causes spatch to follow the spacing in the semantic patch.
+ -linux_spacing is the default.
+ - more informative error reporting for the already tagged token case.
+ Thanks to Erik Hovland for the suggestion.
+
+** Bugfix:
+ - better parsing of declare macro at toplevel and in structure.
+ cf -text xfield
+ - allowing back typedef names for fieldname
+ - better printing of else in generated code
+ - slightly better type inference for binary operators.
+ - clear out declarer names and iterator names between SmPL files (for
+ -testall)
+ - better parsing and type checking of macro type aliases. Cf -test macro_int16.
+ Thanks to Li Yingtong for pointing out the problem.
+ - make insert_virtual_positions tail rec, avoid stack overflow pb.
+ Thanks to Diego Liziero <diegoliz@gmail.com> for pointing out the
+ problem.
+ - Better type inference for arithmetic binary operators
+ Thanks to Li Yingtong for pointing out the problem.
+ - Better type inference for constants
+ Thanks to Li Yingtong for pointing out the problem.
+ - move computing of adjacency information for semantic patches to after
+ application of isomorphisms, because isomorphisms can introduce "..."
+ - compute adjacency information for negated ...
+ - record with each transformation site the set of indices of the witness
+ trees that caused the transformation site to come about. Whitespace and
+ comments between remove tokens associated with disjoint witness trees is
+ not removed.
+ - correct treatment of function pointer typed parameters in the SmPL ast0
+ visitor.
+ - better parsing error message and error recovery when comments are not ended,
+ when some macros have a weird body, and when some switch have a weird
+ Body.
+ Thanks to Derek Jones for pointing out the problem.
+ - better detection and passing of "dangerous" ifdefs, cf -test
+ double_switch.
+ - dropped the separation of decls and body in Seq. This gives better
+ positioning of the bindings of metavariables shared between them.
+ Thanks to Erik Hovland for an example that shows the problem.
+
+** Internals:
+ - supress warning in compiling ocamlsexp (warning caused by a new behavior
+ of cpp used internally in processing files in ocamlsexp/)
SRC+=ocamlextra/enum.ml ocamlextra/dynArray.ml
SRC+=ocamlextra/suffix_tree.ml ocamlextra/suffix_tree_ext.ml
-SYSLIBS=str.cma unix.cma
+SYSLIBS=str.cma bigarray.cma unix.cma
INCLUDEDIRS=ocamlextra ocollection
SUBDIRS=ocamlextra ocollection
# ocaml, when it is available, which speeds up compilation. So
# if you want the fast version of the ocaml chain tools, set this var
# or setenv it to ".opt" in your startup script.
-#OPTBIN= #.opt
+OPTBIN ?= #.opt
OCAMLCFLAGS ?= -g -dtypes
flush stdout
+
+
+
+
+let _chan_pr2 = ref (None: out_channel option)
+
+let out_chan_pr2 ?(newline=true) s =
+ match !_chan_pr2 with
+ | None -> ()
+ | Some chan ->
+ output_string chan (s ^ (if newline then "\n" else ""));
+ flush chan
+
+
let pr2 s =
prerr_string !_prefix_pr;
do_n !_tab_level_print (fun () -> prerr_string " ");
prerr_string s;
prerr_string "\n";
- flush stderr
+ flush stderr;
+ out_chan_pr2 s;
+ ()
let pr2_no_nl s =
prerr_string !_prefix_pr;
do_n !_tab_level_print (fun () -> prerr_string " ");
prerr_string s;
- flush stderr
+ flush stderr;
+ out_chan_pr2 ~newline:false s;
+ ()
+
let pr_xxxxxxxxxxxxxxxxx () =
pr "-----------------------------------------------------------------------"
let _already_printed = Hashtbl.create 101
let disable_pr2_once = ref false
-let pr2_once s =
+
+let xxx_once f s =
if !disable_pr2_once then pr2 s
else
if not (Hashtbl.mem _already_printed s)
then begin
Hashtbl.add _already_printed s true;
- pr2 ("(ONCE) " ^ s);
+ f ("(ONCE) " ^ s);
end
+let pr2_once s = xxx_once pr2 s
+
+(* ---------------------------------------------------------------------- *)
+let mk_pr2_wrappers aref =
+ let fpr2 s =
+ if !aref
+ then pr2 s
+ else
+ (* just to the log file *)
+ out_chan_pr2 s
+ in
+ let fpr2_once s =
+ if !aref
+ then pr2_once s
+ else
+ xxx_once out_chan_pr2 s
+ in
+ fpr2, fpr2_once
+
(* ---------------------------------------------------------------------- *)
(* could also be in File section *)
| Some infile -> redirect_stdin infile f
+(* cf end
+let with_pr2_to_string f =
+*)
+
(* ---------------------------------------------------------------------- *)
let pp s = Format.print_string s
-
-
-(* julia: convert something printed using format to print into a string *)
-let format_to_string f =
- let o = open_out "/tmp/out" in
- Format.set_formatter_out_channel o;
- let _ = f() in
- Format.print_flush();
- Format.set_formatter_out_channel stdout;
- close_out o;
- let i = open_in "/tmp/out" in
- let lines = ref [] in
- let rec loop _ =
- let cur = input_line i in
- lines := cur :: !lines;
- loop() in
- (try loop() with End_of_file -> ());
- close_in i;
- String.concat "\n" (List.rev !lines)
-
-
-
let mk_str_func_of_assoc_conv xs =
let swap (x,y) = (y,x) in
List.assoc a xs
)
+
+
+(* julia: convert something printed using format to print into a string *)
+(* now at bottom of file
+let format_to_string f =
+ ...
+*)
+
+
+
(*****************************************************************************)
(* Macro *)
(*****************************************************************************)
reference := old;
res
+let save_excursion_and_disable reference f =
+ save_excursion reference (fun () ->
+ reference := false;
+ f ()
+ )
+
+let save_excursion_and_enable reference f =
+ save_excursion reference (fun () ->
+ reference := true;
+ f ()
+ )
let memoized h k f =
Gc.set {(Gc.get ()) with Gc.stack_limit = 100 * 1024 * 1024}
+
+
(* if process a big set of files then dont want get overflow in the middle
* so for this we are ready to spend some extra time at the beginning that
* could save far more later.
then
cmd_to_list
("find " ^ x ^
- " -noleaf -type f | grep -v /.hg/ |grep -v /CVS/ | grep -v /.git/"
+ " -noleaf -type f | grep -v /.hg/ |grep -v /CVS/ | grep -v /.git/ |grep -v /_darcs/"
)
+> List.filter (fun s -> s =~ regex)
else [x]
-let (full_charpos_to_pos2: filename -> (int * int) array ) = fun filename ->
+let full_charpos_to_pos2 = fun filename ->
+
+ let size = (filesize filename + 2) in
- let arr = Array.create (filesize filename + 2) (0,0) in
+ let arr = Array.create size (0,0) in
let chan = open_in filename in
column = snd (table.(x.charpos));
}
+
+
+let full_charpos_to_pos_large2 = fun filename ->
+
+ let size = (filesize filename + 2) in
+
+ (* old: let arr = Array.create size (0,0) in *)
+ let arr1 = Bigarray.Array1.create
+ Bigarray.int Bigarray.c_layout size in
+ let arr2 = Bigarray.Array1.create
+ Bigarray.int Bigarray.c_layout size in
+ Bigarray.Array1.fill arr1 0;
+ Bigarray.Array1.fill arr2 0;
+
+ let chan = open_in filename in
+
+ let charpos = ref 0 in
+ let line = ref 0 in
+
+ let rec full_charpos_to_pos_aux () =
+ try
+ let s = (input_line chan) in
+ incr line;
+
+ (* '... +1 do' cos input_line dont return the trailing \n *)
+ for i = 0 to (slength s - 1) + 1 do
+ (* old: arr.(!charpos + i) <- (!line, i); *)
+ arr1.{!charpos + i} <- (!line);
+ arr2.{!charpos + i} <- i;
+ done;
+ charpos := !charpos + slength s + 1;
+ full_charpos_to_pos_aux();
+
+ with End_of_file ->
+ for i = !charpos to (* old: Array.length arr *)
+ Bigarray.Array1.dim arr1 - 1 do
+ (* old: arr.(i) <- (!line, 0); *)
+ arr1.{i} <- !line;
+ arr2.{i} <- 0;
+ done;
+ ();
+ in
+ begin
+ full_charpos_to_pos_aux ();
+ close_in chan;
+ (fun i -> arr1.{i}, arr2.{i})
+ end
+let full_charpos_to_pos_large a =
+ profile_code "Common.full_charpos_to_pos_large"
+ (fun () -> full_charpos_to_pos_large2 a)
+
+
+let complete_parse_info_large filename table x =
+ { x with
+ file = filename;
+ line = fst (table (x.charpos));
+ column = snd (table (x.charpos));
+ }
+
(*---------------------------------------------------------------------------*)
(* Decalage is here to handle stuff such as cpp which include file and who
* can make shift.
| _ -> failwith "md5sum_of_string wrong output"
+
+let with_pr2_to_string f =
+ let file = new_temp_file "pr2" "out" in
+ redirect_stdout_stderr file f;
+ cat file
+
+(* julia: convert something printed using format to print into a string *)
+let format_to_string f =
+ let (nm,o) = Filename.open_temp_file "format_to_s" ".out" in
+ Format.set_formatter_out_channel o;
+ let _ = f() in
+ Format.print_newline();
+ Format.print_flush();
+ Format.set_formatter_out_channel stdout;
+ close_out o;
+ let i = open_in nm in
+ let lines = ref [] in
+ let rec loop _ =
+ let cur = input_line i in
+ lines := cur :: !lines;
+ loop() in
+ (try loop() with End_of_file -> ());
+ close_in i;
+ command2 ("rm -f " ^ nm);
+ String.concat "\n" (List.rev !lines)
+
+
+
(*****************************************************************************)
(* Misc/test *)
(*****************************************************************************)
(* The following functions first indent _tab_level_print spaces.
* They also add the _prefix_pr, for instance used in MPI to show which
* worker is talking.
+ * update: for pr2, it can also print into a log file.
*
* The use of 2 in pr2 is because 2 is under UNIX the second descriptor
* which corresponds to stderr.
*)
val _prefix_pr : string ref
+
val pr : string -> unit
-val pr2 : string -> unit
val pr_no_nl : string -> unit
-val pr2_no_nl : string -> unit
val pr_xxxxxxxxxxxxxxxxx : unit -> unit
+
+(* pr2 print on stderr, but can also in addition print into a file *)
+val _chan_pr2: out_channel option ref
+val pr2 : string -> unit
+val pr2_no_nl : string -> unit
val pr2_xxxxxxxxxxxxxxxxx : unit -> unit
(* use Dumper.dump *)
val _already_printed : (string, bool) Hashtbl.t
val pr2_once : string -> unit
+val mk_pr2_wrappers: bool ref -> (string -> unit) * (string -> unit)
+
+
val redirect_stdout_stderr : filename -> (unit -> unit) -> unit
val redirect_stdin : filename -> (unit -> unit) -> unit
val redirect_stdin_opt : filename option -> (unit -> unit) -> unit
+val with_pr2_to_string: (unit -> unit) -> string list
+
val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
val printf : ('a, out_channel, unit) format -> 'a
val eprintf : ('a, out_channel, unit) format -> 'a
(* emacs spirit *)
val save_excursion : 'a ref -> (unit -> 'b) -> 'b
+val save_excursion_and_disable : bool ref -> (unit -> 'b) -> 'b
+val save_excursion_and_enable : bool ref -> (unit -> 'b) -> 'b
(* emacs spirit *)
val unwind_protect : (unit -> 'a) -> (exn -> 'b) -> 'a
val complete_parse_info :
filename -> (int * int) array -> parse_info -> parse_info
+val full_charpos_to_pos_large:
+ filename -> (int -> (int * int))
+
+val complete_parse_info_large :
+ filename -> (int -> (int * int)) -> parse_info -> parse_info
+
(* return line x col x str_line from a charpos. This function is quite
* expensive so don't use it to get the line x col from every token in
* a file. Instead use full_charpos_to_pos.
);
()
-let _tmpfile = "/tmp/pad_glimpseindex_files.list"
let glimpseindex_files files indexdir =
check_have_glimpse ();
Common.command2(spf "mkdir -p %s" indexdir);
+
+ let tmpfile = Common.new_temp_file "glimpse" "list" in
+ (* "/tmp/pad_glimpseindex_files.list" *)
- Common.uncat files _tmpfile;
+ Common.uncat files tmpfile;
Common.command2
- (spf "cat %s | %s" _tmpfile (glimpse_cmd indexdir));
+ (spf "cat %s | %s" tmpfile (glimpse_cmd indexdir));
()
#!/usr/bin/perl
+
+# Author: Yoann Padioleau
+
######################################################################
# Prelude
######################################################################
# assume standard: diff
# assume standard: perl
-#TODO python 2.5 and perhaps a --disable-python
+#TODO check python 2.5 ?
#old: --with-menhir=/path/to/menhirLib or `ocamlfind query menhirLib`
my $project =
"coccinelle";
my $projectcmdline =
- "spatch -cocci_file demos/simple.cocci demos/simple.c";
+ "spatch -sp_file demos/simple.cocci demos/simple.c";
######################################################################
# Options
$error += check_config(
"make -v 2>&1 |grep Make|",
- "GNU Make 3\.[0-9]+", #version 3.81
+ "GNU Make [^0-9]*3\.[0-9]+.*", #version 3.79.1, 3.81
"make (gnu version) is present.",
"The program gnu make is missing or is not a good version.
We need 3.XX",
";
} else {
+#pad: before the message was saying (make depend); make all
+# I found this confusing so I removed it.
+
pr2 "
----------------------------------------------------------------------
All seems fine for $project.
To compile $project type:
- (make depend); make all
-or alternatively, for the optimized version:
- (make depend); make all.opt
+ \$ make depend
+ \$ make all
+
+Or alternatively, for the optimized version:
+ \$ make all.opt
If you want both, you could use:
- (make depend); make world
+ \$ make world
+
To install type:
- make install
+ \$ make install
Then, to test $project simply type:
- $projectcmdline
+ \$ $projectcmdline
";
Printf.printf "triples: %d\n" !triples;
print_state "final result" res;
*)
- res)
+ List.sort compare res)
else
(if !Flag_ctl.verbose_ctl_engine
then Common.pr2 "missing something required";
(* ********************************************************************** *)
end
;;
-
--- /dev/null
+int main()
+{
+ int x;
+
+ x = foo();
+ x = foo_new();
+ x = bar();
+}
--- /dev/null
+@initialize:python@
+import re
+m = re.compile('_new$')
+
+@r_init@
+expression E;
+identifier id;
+position p;
+@@
+
+E = id@p();
+
+@script:python@
+id << r_init.id;
+@@
+
+print "COCCI: Analyzing %s" % id
+if m.search(id.ident) != None:
+ print "COCCI: %s matchs '_new$'" % id
+else:
+ print "COCCI: %s discarded" % id
+ cocci.include_match(False)
+
+
+@r_do@
+expression E;
+identifier id;
+position r_init.p;
+@@
+
+E = id@p();
++ if (E == NULL)
++ goto err;
-SUBDIRS=grammar
+SUBDIR=manual
-TEX=options.tex
-PDF=$(TEX:.tex=.pdf)
-AUX=$(TEX:.tex=.aux)
-LOG=$(TEX:.tex=.log)
+.PHONY: all clean distclean
-.PHONY: all clean distclean $(SUBDIRS)
-.SUFFIXES: .pdf .tex
-
-all: $(PDF) $(SUBDIRS)
-
-$(SUBDIRS):
- make -C $@
-
-$(PDF): $(TEX)
- pdflatex $<
+all:
+ make -C $(SUBDIR)
clean:
- make -C $(SUBDIRS) clean
- rm -f $(AUX) $(LOG)
+ make -C $(SUBDIR) clean
distclean:
- make -C $(SUBDIRS) distclean
- rm -f $(PDF)
+ make -C $(SUBDIR) distclean
+
+
+++ /dev/null
-TEX=cocci_syntax.tex
-WEB=/var/www/localhost/htdocs/coccinelle/
-EMNWEB=~/website/docs/
-
-PDF=$(TEX:.tex=.pdf)
-HTML=$(TEX:.tex=.html)
-
-
-.phony: all html clean check
-
-all: $(TEX)
- pdflatex $<
- pdflatex $<
-
-html: $(HTML)
-
-clean:
- rm -f *.aux *.dvi *.haux *.htoc *.log *.out *~
-
-distclean: clean
- rm -f *.pdf *.html *.gif *.css
-
-check: $(HTML)
- checklink $<
-
-world: all html
-
-universe: world install
-
-install:
- cp *.css *.gif *.html $(WEB)
- cp $(PDF) $(WEB)
- chown apache:apache -R $(WEB)
- chmod a-w -R $(WEB)
-
-emn_install: world
- cp *.css *.gif *.html $(EMNWEB)
- cp $(PDF) $(EMNWEB)
-
-############################################
-############################################
-
-.SUFFIXES: .html .tex
-
-.tex.html:
-# For Gentoo: /usr/lib64/hevea
-# For Ubuntu family: /usr/share/hevea
-# For default installation
- @if [ -f /usr/lib64/hevea/xxdate.exe ]; then \
- hevea -exec /usr/lib64/hevea/xxdate.exe $< ; \
- hevea -exec /usr/lib64/hevea/xxdate.exe $< ; \
- elif [ -f /usr/share/hevea/xxdate.exe ]; then \
- hevea -exec /usr/share/hevea/xxdate.exe $< ; \
- hevea -exec /usr/share/hevea/xxdate.exe $< ; \
- elif [ -f /usr/local/lib/hevea/xxdate.exe ]; then \
- hevea -exec /usr/local/lib/hevea/xxdate.exe $< ; \
- hevea -exec /usr/local/lib/hevea/xxdate.exe $< ; \
- else \
- echo -e "\n\n *** Hevea: Unable to find xxdate.exe ***\n\n"; \
- fi
- hacha -o index.html cocci_syntax.html
+++ /dev/null
-\documentclass{report}
-
-
-\usepackage{listing}
-
-\title{\spatch and \sgrep manual}
-
-\tableofcontents
-
-%##############################################################################
-\chapter{Introduction}
-
-%_semantic_ patch and grep
-%next-gen
-
-%semantic patch/match
-%SmPL
-%%SMPL => semantic match and patch language ?
-
-%sed on steroids
-
-%features
-
-%abstract away
-% -
-% -
-% -
-% -
-% -
-
-%submit idea/patch/ or even semantic patch :) to xxx@xxx
-
-%##############################################################################
-\chapter{Building \spatch and \sgrep}
-
-\section{Requirements}
-
-\section{Getting}
-
-\section{Compiling}
-%requirements
-
-\section{Running}
-
-
-
-
-%##############################################################################
-\chapter{Tutorial}
-
-%toy.c, toy.spatch
-
-\section{SmPL piece by pieces}
-
-%very simple ex
-%bigger ex, show different C constructs.
-%%abstract space
-%
-%+
-%-
-%* (a kind of -)
-%
-%first run
-%first process/workflow ?
-%
-%
-%then metavar
-%sed on steroids
-%%abstract xxx
-
-% show vs perl
-
-%then context!!
-
-%
-%then typed metavar.
-%
-%then iso
-%
-%
-%
-%then '...' and multi usage (in arg, struct, statement)
-%%abstract yyy
-%
-%
-%
-%then multi rules and multi usage
-
-
-
-%##############################################################################
-\chapter{Advanced features}
-
-\subsection{Multi files}
-
-\subsection{Position}
-%src: a mail from julia
-
-%Tu peux maintenant mettre des positions partout. C'est interdit d'heriter
-%une position a travers une regle qui fait une modif.
-%
-%Tu peux declarer une position avec des contraintes, eg
-%
-%position p1 != {x.p2, y.p3};
-%
-%Entre les premiers @@ d'une regle, tu peux mettre "expression" et avoir
-%une meilleure parsing. Ca permet par exemple de faire:
-%
-%<... f() ...> + <... g() ...>
-%
-%pour decrire un + qui a f() et g() quelquepart comme arguements.
-%
-%Pour les }, j'ai mis un champ "is_fake" dans les noeuds, avec is_loop,
-%etc.
-
-\subsection{Embeded Python scripting}
-
-\subsection{More on ...}
-
-exists annotation on rule
-
-'when any' and shortest path
-
-
-when strict
-
-
-%##############################################################################
-\chapter{Examples}
-%put additionnal commented scripts ?
-
-
-
-%##############################################################################
-\chapter{Developing a semantic patch}
-
-%best practices
-
-\subsection{Emacs mode}
-
-\subsection{Basic worflow}
-
-\subsection{Linux workflow and git}
-
-%git diff
-%git revert
-
-%multi patch ?
-
-\subsection{Debugging a semantic patch/match}
-
-
-%##############################################################################
-\chapter{\spatch/\sgrep command line options}
-
-%cpp
-
-%iso
-%rules
-
-%##############################################################################
-\chapter{Other tools}
-
-%partial-match?
-
-%cocci-ediff ?
-
-%coccigui
-
-
-
-%org-mode ?
-
-%patchparse
-
-
-%patch handling (splitter, mailer, maintainer)
-
-
-
-
-
-%##############################################################################
-\chapter{Reference}
-%put grammar ?
-
-
-%context!!
-
-%well-formedness
-
-%limitations
-% goto
-% ...
-
-
-%lexical conventions
-% superset of C
-%plus
-% blanks, column!!!
-%comments, c vs cocci comments
-%identifiers
-
-
-\section{Toplevel}
-
-\section{Metavariables}
-%typed metavar
-%scoped metavar and rules
-
-\section{Variables}
-
-\section{Types}
-
-\section{Expressions}
-
-%funcall and ...
-
-%cf also position trick
-
-\section{Statements}
-
-%declaration
-
-%type definition
-% struct iso
-
-
-
-\section{Rules}
-
-
-\section{Isomorphisms}
-
-%named iso
-
-
-%iso file
-%extra file standard.h
-
-%implicit iso
-
-
-\section{cpp quircks}
-
-%declarator
-%declarer
-
-%also extra file standard.h
-
-%##############################################################################
-\appendix
-
-
-
-%index (reversed)
-%index of concepts ? keywords ?
--- /dev/null
+##############################################################################
+# Variables
+##############################################################################
+
+MAINSRC=main.tex
+SRC=$(wildcard *.tex)
+
+#tools:
+# latex, pdflatex
+# xfig
+# emacs, auctex, ediff
+# darcs
+# latexdiff
+
+##############################################################################
+# Top rules
+##############################################################################
+.PHONY: all clean distclean
+.SUFFIXES: .pdf .tex
+
+all: manual.pdf cocci_syntax.pdf options.pdf
+
+manual.pdf: $(SRC)
+ pdflatex main.tex
+ pdflatex main.tex
+ mv main.pdf manual.pdf
+
+
+
+
+cocci_syntax.pdf: main_grammar.tex cocci_syntax.tex macros_listing_cocci.tex macros_grammar.tex macros_common.tex examples.tex tips.tex
+ pdflatex main_grammar.tex
+ pdflatex main_grammar.tex
+ mv main_grammar.pdf cocci_syntax.pdf
+
+options.pdf: main_options.tex spatch_options.tex macros_options.tex
+ pdflatex main_options.tex
+ pdflatex main_options.tex
+ mv main_options.pdf options.pdf
+
+
+
+
+distclean:: clean
+ rm -f manual.pdf cocci_syntax.pdf options.pdf
+
+
+# lindig trick
+#RERUN = Rerun (LaTeX|to get cross-references right)
+#
+#pdf: $(PDF)
+#
+#%.pdf: %.tex
+# $(PDFLATEX) $<
+# if egrep -s '$(RERUN)' $*.log ;then $(PDFLATEX) $<; fi
+# if egrep -s '$(RERUN)' $*.log ;then $(PDFLATEX) $<; fi
+
+##############################################################################
+# Html version
+##############################################################################
+.PHONY: html check
+
+.SUFFIXES: .html .tex
+
+TEX=cocci_syntax.tex
+WEB=/var/www/localhost/htdocs/coccinelle/
+EMNWEB=~/website/docs/
+
+PDF=$(TEX:.tex=.pdf)
+HTML=$(TEX:.tex=.html)
+
+html: $(HTML)
+
+clean::
+ rm -f *.aux *.dvi *.haux *.htoc *.log *.out *~
+
+distclean:: clean
+ rm -f *.pdf *.html *.gif *.css
+
+check: $(HTML)
+ checklink $<
+
+world: all html
+
+universe: world install
+
+install:
+ cp *.css *.gif *.html $(WEB)
+ cp $(PDF) $(WEB)
+ chown apache:apache -R $(WEB)
+ chmod a-w -R $(WEB)
+
+emn_install: world
+ cp *.css *.gif *.html $(EMNWEB)
+ cp $(PDF) $(EMNWEB)
+
+
+
+
+.tex.html:
+# For Gentoo: /usr/lib64/hevea
+# For Ubuntu family: /usr/share/hevea
+# For default installation
+ @if [ -f /usr/lib64/hevea/xxdate.exe ]; then \
+ hevea -exec /usr/lib64/hevea/xxdate.exe $< ; \
+ hevea -exec /usr/lib64/hevea/xxdate.exe $< ; \
+ elif [ -f /usr/share/hevea/xxdate.exe ]; then \
+ hevea -exec /usr/share/hevea/xxdate.exe $< ; \
+ hevea -exec /usr/share/hevea/xxdate.exe $< ; \
+ elif [ -f /usr/local/lib/hevea/xxdate.exe ]; then \
+ hevea -exec /usr/local/lib/hevea/xxdate.exe $< ; \
+ hevea -exec /usr/local/lib/hevea/xxdate.exe $< ; \
+ else \
+ echo -e "\n\n *** Hevea: Unable to find xxdate.exe ***\n\n"; \
+ fi
+ hacha -o index.html cocci_syntax.html
+
+
+##############################################################################
+# Install
+##############################################################################
+
+
+##############################################################################
+# Developer rules
+##############################################################################
+
+LATEXDIFFOPT=--type=CTRADITIONAL
+
+#if multi files ? sed sur les \input{} ? ou create in another dir ?
+latexdiff:
+ latexdiff $(LATEXDIFFOPT) main-old.tex main.tex > main-diff.tex
+ make MAINSRC=main-diff
+ rm -f main-diff.aux
+
+replacediff:
+ cp main-old.tex main-older.tex
+ cp main.tex main-old.tex
+
+clean::
+ rm -f main-diff.*
+
+update:
+
+commit:
+
+
+##############################################################################
+# Generic rules
+##############################################################################
+FORMAT=letter
+
+%.ps: %.dvi
+ dvips -P cmz $< -o $@ -t $(FORMAT)
+
+clean::
+ rm -f *.aux \
+ *.bbl \
+ *.blg \
+ *.dvi \
+ *.log \
+ *.out \
+ *.toc
+
--- /dev/null
+\chapter{Advanced Features}
-\documentclass{article}
-%\usepackage[latin9]{inputenc}
-\usepackage{hevea}
-\usepackage{fullpage}
-\usepackage{alltt}
-\usepackage{xspace}
-\usepackage[pdfborder={0 0 0}]{hyperref}
-\usepackage{listings}
-\usepackage[usenames,dvipsnames]{color}
-\usepackage{times}
-\usepackage[T1]{fontenc}
-\usepackage{multirow}
-
-\lstset{basicstyle=\ttfamily,numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,language=C,commentstyle=\color{OliveGreen},keywordstyle=\color{blue},stringstyle=\color{BrickRed}}
-
-%
-% You must prefix the +/- lines of
-% cocci files with @+/@- respectively.
-% This will enable the automatic coloration.
-%
-% Note: You need at least the following version of hevea
-% http://hevea.inria.fr/distri/unstable/hevea-2008-12-17.tar.gz
-%
-\ifhevea % For HTML generation
-\lstdefinelanguage{Cocci}{
-morekeywords={idexpression,expression,statement,identifier,type,
-parameter,list,when,strict,any,forall,local,position,typedef},
-keywordstyle=\color{OliveGreen}\bfseries,
-sensitive=false,
-moredelim=[is][\color{blue}]{@M}{@M},
-moredelim=[il][\color{OliveGreen}]{@+},
-moredelim=[il][\color{BrickRed}]{@-}}
-
-\lstdefinelanguage{PatchC}[ANSI]{C}{
-stringstyle=\color{black},
-moredelim=[il][\color{OliveGreen}]{@+},
-moredelim=[il][\color{BrickRed}]{@-},
-moredelim=[il][\color{Plum}]{@M}}
-
-\else % For DVI/PS/PDF generation
-\lstdefinelanguage{Cocci}{
-morekeywords={idexpression,expression,statement,identifier,type,
-parameter,list,when,strict,any,forall,local,position,typedef},
-keywordstyle=\color{OliveGreen}\bfseries,
-sensitive=false,
-moredelim=*[is][\color{blue}]{@M}{@M},
-moredelim=[il][\color{OliveGreen}]{@+},
-moredelim=[il][\color{BrickRed}]{@-}}
-
-\lstdefinelanguage{PatchC}[ANSI]{C}{
-stringstyle=\color{black},
-moredelim=[il][\color{OliveGreen}]{@+},
-moredelim=[il][\color{BrickRed}]{@-},
-moredelim=[il][\color{Plum}]{@M}}
-\fi
-
-\newif\iflanguagestyle
-\languagestylefalse
-\input{grammar}
-
-\newcommand{\sizecodebis}[0]{\scriptsize}
-
-\newcommand{\mita}[1]{\mbox{\it{{#1}}}}
-\newcommand{\mtt}[1]{\mbox{\tt{{#1}}}}
-\newcommand{\msf}[1]{\mbox{\sf{{#1}}}}
-\newcommand{\stt}[1]{\mbox{\scriptsize\tt{{#1}}}}
-\newcommand{\ssf}[1]{\mbox{\scriptsize\sf{{#1}}}}
-\newcommand{\sita}[1]{\mbox{\scriptsize\it{{#1}}}}
-\newcommand{\mrm}[1]{\mbox{\rm{{#1}}}}
-\newcommand{\mth}[1]{\({#1}\)}
-\newcommand{\entails}[2]{\begin{array}{@{}c@{}}{#1}\\\hline{#2}\end{array}}
-\newcommand{\ttlb}{\mbox{\tt \char'173}}
-\newcommand{\ttrb}{\mbox{\tt \char'175}}
-\newcommand{\ttmid}{\mbox{\tt \char'174}}
-\newcommand{\tttld}{\mbox{\tt \char'176}}
-
-\newcommand{\fixme}[1]{{\color{red} #1}}
-
-\ifhevea
-\newcommand{\phantom}{}
-\newcommand{\air}{ }
-\else
-\newcommand{\air}{\phantom{xxx}}
-\fi
-
-\title{The SmPL Grammar (version 0.1.4)}
-\author{Research group on Coccinelle}
-\date{\today}
-
-\begin{document}
-\maketitle
%\section{The SmPL Grammar}
as \T{id}, \T{const}, etc. These refer to the sets suggested by
the name, {\em i.e.}, \T{id} refers to the set of possible
C-language identifiers, while \T{const} refers to the set of
-possible C-language constants. \ifhevea A PDF version of this
-documentation is available at
-\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.pdf}.\else
+possible C-language constants.
+%
+\ifhevea
+A PDF version of this documentation is available at
+\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.pdf}.
+\else
A HTML version of this documentation is available online at
-\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.html}. \fi
+\url{http://www.emn.fr/x-info/coccinelle/docs/cocci_syntax.html}.
+\fi
%% \ifhevea A PDF
%% version of this documentation is available at
\CASE{<.*>}
\end{grammar}
-\include{examples}
-\include{tips}
-\end{document}
%%% Local Variables:
%%% mode: LaTeX
-%%% TeX-master: "cocci_syntax"
+%%% TeX-master: "main_grammar"
%%% coding: latin-9
%%% TeX-PDF-mode: t
%%% ispell-local-dictionary: "american"
--- /dev/null
+Coccinelle manual - Julia Lawall, Yoann Padioleau
+
+Copyright (C) 2009, Julia Lawall, Yoann Padioleau
+
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3.
+ A copy of the license is included in the file license.txt
--- /dev/null
+%##############################################################################
+\chapter{Installing Coccinelle}
+%##############################################################################
+%\chapter{Building \spatch and \sgrep}
+
+\section{Requirements}
+%coupling: with install.txt
+
+\section{Getting Coccinelle}
+
+\section{Compiling Coccinelle}
+%coupling: with install.txt
+
+\section{Running Coccinelle}
+%coupling: with readme.txt
+
--- /dev/null
+\chapter{Introduction}
+%src: cocci website, LWN article
+
+Coccinelle is a tool to help automate repetitive
+source-to-source style-preserving program transformations
+on C source code, like for instance to perform some refactorings.
+%coupling: readme.txt
+Coccinelle is presented as a command line tool called \spatch that takes
+as input the name of a file containing the specification of a program
+transformation, called a {\em semantic patch}, and a set of C files,
+and then performs the transformation on all those C files.
+%synopsis ?
+
+To make it easy to express those transformations,
+Coccinelle proposes a WYSISWYG approach where the C programmer
+can leverage the things he already knows: the C syntax
+and the patch syntax. Indeed, with Coccinelle transformations
+are written in specific language called SmPL, for
+Semantic Patch Language, which as the name suggests is very
+close to the syntax of a patch, but which does not
+work at a line level, than traditional patches do.
+but a more high level, or semantic level.
+
+Here is an example of a simple program transformation.
+To replace every calls to \verb+foo+ of any expression $x$
+to a call to \verb+bar+, create a semantic patch file \verb+ex1.cocci+
+(semantic patches usually ends with the \verb+.cocci+ filename extension)
+containing:
+\begin{verbatim}
+@@ expression x; @@
+
+- foo(x)
++ bar(x)
+
+\end{verbatim}
+
+Then to ``apply'' the specified program transformation to a set of C files,
+simply do:
+\begin{verbatim}
+$ spatch -sp_file ex1.cocci *.c
+\end{verbatim}
+%command line:
+
+%can do inplace, or with git, cf chapter on developing ...
+
+%Other approaches
+%instead of
+%expressing the transformation on the internal representation
+%of a C frontend, for instance the abstract syntax tree
+%used internally by gcc, which would require for the user
+%to learn how to use this internal data structure,
+
+%if can find and transform, can also find, so semantic grep.
+
+%vs regexp
+%vs ast
+
+%features:
+%src: darcs manual
--- /dev/null
+\chapter{Isomorphisms and \texttt{standard.iso}}
+
--- /dev/null
+
+ GNU Free Documentation License
+ Version 1.3, 3 November 2008
+
+
+ Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
+ <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+0. PREAMBLE
+
+The purpose of this License is to make a manual, textbook, or other
+functional and useful document "free" in the sense of freedom: to
+assure everyone the effective freedom to copy and redistribute it,
+with or without modifying it, either commercially or noncommercially.
+Secondarily, this License preserves for the author and publisher a way
+to get credit for their work, while not being considered responsible
+for modifications made by others.
+
+This License is a kind of "copyleft", which means that derivative
+works of the document must themselves be free in the same sense. It
+complements the GNU General Public License, which is a copyleft
+license designed for free software.
+
+We have designed this License in order to use it for manuals for free
+software, because free software needs free documentation: a free
+program should come with manuals providing the same freedoms that the
+software does. But this License is not limited to software manuals;
+it can be used for any textual work, regardless of subject matter or
+whether it is published as a printed book. We recommend this License
+principally for works whose purpose is instruction or reference.
+
+
+1. APPLICABILITY AND DEFINITIONS
+
+This License applies to any manual or other work, in any medium, that
+contains a notice placed by the copyright holder saying it can be
+distributed under the terms of this License. Such a notice grants a
+world-wide, royalty-free license, unlimited in duration, to use that
+work under the conditions stated herein. The "Document", below,
+refers to any such manual or work. Any member of the public is a
+licensee, and is addressed as "you". You accept the license if you
+copy, modify or distribute the work in a way requiring permission
+under copyright law.
+
+A "Modified Version" of the Document means any work containing the
+Document or a portion of it, either copied verbatim, or with
+modifications and/or translated into another language.
+
+A "Secondary Section" is a named appendix or a front-matter section of
+the Document that deals exclusively with the relationship of the
+publishers or authors of the Document to the Document's overall
+subject (or to related matters) and contains nothing that could fall
+directly within that overall subject. (Thus, if the Document is in
+part a textbook of mathematics, a Secondary Section may not explain
+any mathematics.) The relationship could be a matter of historical
+connection with the subject or with related matters, or of legal,
+commercial, philosophical, ethical or political position regarding
+them.
+
+The "Invariant Sections" are certain Secondary Sections whose titles
+are designated, as being those of Invariant Sections, in the notice
+that says that the Document is released under this License. If a
+section does not fit the above definition of Secondary then it is not
+allowed to be designated as Invariant. The Document may contain zero
+Invariant Sections. If the Document does not identify any Invariant
+Sections then there are none.
+
+The "Cover Texts" are certain short passages of text that are listed,
+as Front-Cover Texts or Back-Cover Texts, in the notice that says that
+the Document is released under this License. A Front-Cover Text may
+be at most 5 words, and a Back-Cover Text may be at most 25 words.
+
+A "Transparent" copy of the Document means a machine-readable copy,
+represented in a format whose specification is available to the
+general public, that is suitable for revising the document
+straightforwardly with generic text editors or (for images composed of
+pixels) generic paint programs or (for drawings) some widely available
+drawing editor, and that is suitable for input to text formatters or
+for automatic translation to a variety of formats suitable for input
+to text formatters. A copy made in an otherwise Transparent file
+format whose markup, or absence of markup, has been arranged to thwart
+or discourage subsequent modification by readers is not Transparent.
+An image format is not Transparent if used for any substantial amount
+of text. A copy that is not "Transparent" is called "Opaque".
+
+Examples of suitable formats for Transparent copies include plain
+ASCII without markup, Texinfo input format, LaTeX input format, SGML
+or XML using a publicly available DTD, and standard-conforming simple
+HTML, PostScript or PDF designed for human modification. Examples of
+transparent image formats include PNG, XCF and JPG. Opaque formats
+include proprietary formats that can be read and edited only by
+proprietary word processors, SGML or XML for which the DTD and/or
+processing tools are not generally available, and the
+machine-generated HTML, PostScript or PDF produced by some word
+processors for output purposes only.
+
+The "Title Page" means, for a printed book, the title page itself,
+plus such following pages as are needed to hold, legibly, the material
+this License requires to appear in the title page. For works in
+formats which do not have any title page as such, "Title Page" means
+the text near the most prominent appearance of the work's title,
+preceding the beginning of the body of the text.
+
+The "publisher" means any person or entity that distributes copies of
+the Document to the public.
+
+A section "Entitled XYZ" means a named subunit of the Document whose
+title either is precisely XYZ or contains XYZ in parentheses following
+text that translates XYZ in another language. (Here XYZ stands for a
+specific section name mentioned below, such as "Acknowledgements",
+"Dedications", "Endorsements", or "History".) To "Preserve the Title"
+of such a section when you modify the Document means that it remains a
+section "Entitled XYZ" according to this definition.
+
+The Document may include Warranty Disclaimers next to the notice which
+states that this License applies to the Document. These Warranty
+Disclaimers are considered to be included by reference in this
+License, but only as regards disclaiming warranties: any other
+implication that these Warranty Disclaimers may have is void and has
+no effect on the meaning of this License.
+
+2. VERBATIM COPYING
+
+You may copy and distribute the Document in any medium, either
+commercially or noncommercially, provided that this License, the
+copyright notices, and the license notice saying this License applies
+to the Document are reproduced in all copies, and that you add no
+other conditions whatsoever to those of this License. You may not use
+technical measures to obstruct or control the reading or further
+copying of the copies you make or distribute. However, you may accept
+compensation in exchange for copies. If you distribute a large enough
+number of copies you must also follow the conditions in section 3.
+
+You may also lend copies, under the same conditions stated above, and
+you may publicly display copies.
+
+
+3. COPYING IN QUANTITY
+
+If you publish printed copies (or copies in media that commonly have
+printed covers) of the Document, numbering more than 100, and the
+Document's license notice requires Cover Texts, you must enclose the
+copies in covers that carry, clearly and legibly, all these Cover
+Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
+the back cover. Both covers must also clearly and legibly identify
+you as the publisher of these copies. The front cover must present
+the full title with all words of the title equally prominent and
+visible. You may add other material on the covers in addition.
+Copying with changes limited to the covers, as long as they preserve
+the title of the Document and satisfy these conditions, can be treated
+as verbatim copying in other respects.
+
+If the required texts for either cover are too voluminous to fit
+legibly, you should put the first ones listed (as many as fit
+reasonably) on the actual cover, and continue the rest onto adjacent
+pages.
+
+If you publish or distribute Opaque copies of the Document numbering
+more than 100, you must either include a machine-readable Transparent
+copy along with each Opaque copy, or state in or with each Opaque copy
+a computer-network location from which the general network-using
+public has access to download using public-standard network protocols
+a complete Transparent copy of the Document, free of added material.
+If you use the latter option, you must take reasonably prudent steps,
+when you begin distribution of Opaque copies in quantity, to ensure
+that this Transparent copy will remain thus accessible at the stated
+location until at least one year after the last time you distribute an
+Opaque copy (directly or through your agents or retailers) of that
+edition to the public.
+
+It is requested, but not required, that you contact the authors of the
+Document well before redistributing any large number of copies, to
+give them a chance to provide you with an updated version of the
+Document.
+
+
+4. MODIFICATIONS
+
+You may copy and distribute a Modified Version of the Document under
+the conditions of sections 2 and 3 above, provided that you release
+the Modified Version under precisely this License, with the Modified
+Version filling the role of the Document, thus licensing distribution
+and modification of the Modified Version to whoever possesses a copy
+of it. In addition, you must do these things in the Modified Version:
+
+A. Use in the Title Page (and on the covers, if any) a title distinct
+ from that of the Document, and from those of previous versions
+ (which should, if there were any, be listed in the History section
+ of the Document). You may use the same title as a previous version
+ if the original publisher of that version gives permission.
+B. List on the Title Page, as authors, one or more persons or entities
+ responsible for authorship of the modifications in the Modified
+ Version, together with at least five of the principal authors of the
+ Document (all of its principal authors, if it has fewer than five),
+ unless they release you from this requirement.
+C. State on the Title page the name of the publisher of the
+ Modified Version, as the publisher.
+D. Preserve all the copyright notices of the Document.
+E. Add an appropriate copyright notice for your modifications
+ adjacent to the other copyright notices.
+F. Include, immediately after the copyright notices, a license notice
+ giving the public permission to use the Modified Version under the
+ terms of this License, in the form shown in the Addendum below.
+G. Preserve in that license notice the full lists of Invariant Sections
+ and required Cover Texts given in the Document's license notice.
+H. Include an unaltered copy of this License.
+I. Preserve the section Entitled "History", Preserve its Title, and add
+ to it an item stating at least the title, year, new authors, and
+ publisher of the Modified Version as given on the Title Page. If
+ there is no section Entitled "History" in the Document, create one
+ stating the title, year, authors, and publisher of the Document as
+ given on its Title Page, then add an item describing the Modified
+ Version as stated in the previous sentence.
+J. Preserve the network location, if any, given in the Document for
+ public access to a Transparent copy of the Document, and likewise
+ the network locations given in the Document for previous versions
+ it was based on. These may be placed in the "History" section.
+ You may omit a network location for a work that was published at
+ least four years before the Document itself, or if the original
+ publisher of the version it refers to gives permission.
+K. For any section Entitled "Acknowledgements" or "Dedications",
+ Preserve the Title of the section, and preserve in the section all
+ the substance and tone of each of the contributor acknowledgements
+ and/or dedications given therein.
+L. Preserve all the Invariant Sections of the Document,
+ unaltered in their text and in their titles. Section numbers
+ or the equivalent are not considered part of the section titles.
+M. Delete any section Entitled "Endorsements". Such a section
+ may not be included in the Modified Version.
+N. Do not retitle any existing section to be Entitled "Endorsements"
+ or to conflict in title with any Invariant Section.
+O. Preserve any Warranty Disclaimers.
+
+If the Modified Version includes new front-matter sections or
+appendices that qualify as Secondary Sections and contain no material
+copied from the Document, you may at your option designate some or all
+of these sections as invariant. To do this, add their titles to the
+list of Invariant Sections in the Modified Version's license notice.
+These titles must be distinct from any other section titles.
+
+You may add a section Entitled "Endorsements", provided it contains
+nothing but endorsements of your Modified Version by various
+parties--for example, statements of peer review or that the text has
+been approved by an organization as the authoritative definition of a
+standard.
+
+You may add a passage of up to five words as a Front-Cover Text, and a
+passage of up to 25 words as a Back-Cover Text, to the end of the list
+of Cover Texts in the Modified Version. Only one passage of
+Front-Cover Text and one of Back-Cover Text may be added by (or
+through arrangements made by) any one entity. If the Document already
+includes a cover text for the same cover, previously added by you or
+by arrangement made by the same entity you are acting on behalf of,
+you may not add another; but you may replace the old one, on explicit
+permission from the previous publisher that added the old one.
+
+The author(s) and publisher(s) of the Document do not by this License
+give permission to use their names for publicity for or to assert or
+imply endorsement of any Modified Version.
+
+
+5. COMBINING DOCUMENTS
+
+You may combine the Document with other documents released under this
+License, under the terms defined in section 4 above for modified
+versions, provided that you include in the combination all of the
+Invariant Sections of all of the original documents, unmodified, and
+list them all as Invariant Sections of your combined work in its
+license notice, and that you preserve all their Warranty Disclaimers.
+
+The combined work need only contain one copy of this License, and
+multiple identical Invariant Sections may be replaced with a single
+copy. If there are multiple Invariant Sections with the same name but
+different contents, make the title of each such section unique by
+adding at the end of it, in parentheses, the name of the original
+author or publisher of that section if known, or else a unique number.
+Make the same adjustment to the section titles in the list of
+Invariant Sections in the license notice of the combined work.
+
+In the combination, you must combine any sections Entitled "History"
+in the various original documents, forming one section Entitled
+"History"; likewise combine any sections Entitled "Acknowledgements",
+and any sections Entitled "Dedications". You must delete all sections
+Entitled "Endorsements".
+
+
+6. COLLECTIONS OF DOCUMENTS
+
+You may make a collection consisting of the Document and other
+documents released under this License, and replace the individual
+copies of this License in the various documents with a single copy
+that is included in the collection, provided that you follow the rules
+of this License for verbatim copying of each of the documents in all
+other respects.
+
+You may extract a single document from such a collection, and
+distribute it individually under this License, provided you insert a
+copy of this License into the extracted document, and follow this
+License in all other respects regarding verbatim copying of that
+document.
+
+
+7. AGGREGATION WITH INDEPENDENT WORKS
+
+A compilation of the Document or its derivatives with other separate
+and independent documents or works, in or on a volume of a storage or
+distribution medium, is called an "aggregate" if the copyright
+resulting from the compilation is not used to limit the legal rights
+of the compilation's users beyond what the individual works permit.
+When the Document is included in an aggregate, this License does not
+apply to the other works in the aggregate which are not themselves
+derivative works of the Document.
+
+If the Cover Text requirement of section 3 is applicable to these
+copies of the Document, then if the Document is less than one half of
+the entire aggregate, the Document's Cover Texts may be placed on
+covers that bracket the Document within the aggregate, or the
+electronic equivalent of covers if the Document is in electronic form.
+Otherwise they must appear on printed covers that bracket the whole
+aggregate.
+
+
+8. TRANSLATION
+
+Translation is considered a kind of modification, so you may
+distribute translations of the Document under the terms of section 4.
+Replacing Invariant Sections with translations requires special
+permission from their copyright holders, but you may include
+translations of some or all Invariant Sections in addition to the
+original versions of these Invariant Sections. You may include a
+translation of this License, and all the license notices in the
+Document, and any Warranty Disclaimers, provided that you also include
+the original English version of this License and the original versions
+of those notices and disclaimers. In case of a disagreement between
+the translation and the original version of this License or a notice
+or disclaimer, the original version will prevail.
+
+If a section in the Document is Entitled "Acknowledgements",
+"Dedications", or "History", the requirement (section 4) to Preserve
+its Title (section 1) will typically require changing the actual
+title.
+
+
+9. TERMINATION
+
+You may not copy, modify, sublicense, or distribute the Document
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, or distribute it is void, and
+will automatically terminate your rights under this License.
+
+However, if you cease all violation of this License, then your license
+from a particular copyright holder is reinstated (a) provisionally,
+unless and until the copyright holder explicitly and finally
+terminates your license, and (b) permanently, if the copyright holder
+fails to notify you of the violation by some reasonable means prior to
+60 days after the cessation.
+
+Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, receipt of a copy of some or all of the same material does
+not give you any rights to use it.
+
+
+10. FUTURE REVISIONS OF THIS LICENSE
+
+The Free Software Foundation may publish new, revised versions of the
+GNU Free Documentation License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in
+detail to address new problems or concerns. See
+http://www.gnu.org/copyleft/.
+
+Each version of the License is given a distinguishing version number.
+If the Document specifies that a particular numbered version of this
+License "or any later version" applies to it, you have the option of
+following the terms and conditions either of that specified version or
+of any later version that has been published (not as a draft) by the
+Free Software Foundation. If the Document does not specify a version
+number of this License, you may choose any version ever published (not
+as a draft) by the Free Software Foundation. If the Document
+specifies that a proxy can decide which future versions of this
+License can be used, that proxy's public statement of acceptance of a
+version permanently authorizes you to choose that version for the
+Document.
+
+11. RELICENSING
+
+"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
+World Wide Web server that publishes copyrightable works and also
+provides prominent facilities for anybody to edit those works. A
+public wiki that anybody can edit is an example of such a server. A
+"Massive Multiauthor Collaboration" (or "MMC") contained in the site
+means any set of copyrightable works thus published on the MMC site.
+
+"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
+license published by Creative Commons Corporation, a not-for-profit
+corporation with a principal place of business in San Francisco,
+California, as well as future copyleft versions of that license
+published by that same organization.
+
+"Incorporate" means to publish or republish a Document, in whole or in
+part, as part of another Document.
+
+An MMC is "eligible for relicensing" if it is licensed under this
+License, and if all works that were first published under this License
+somewhere other than this MMC, and subsequently incorporated in whole or
+in part into the MMC, (1) had no cover texts or invariant sections, and
+(2) were thus incorporated prior to November 1, 2008.
+
+The operator of an MMC Site may republish an MMC contained in the site
+under CC-BY-SA on the same site at any time before August 1, 2009,
+provided the MMC is eligible for relicensing.
+
+
+ADDENDUM: How to use this License for your documents
+
+To use this License in a document you have written, include a copy of
+the License in the document and put the following copyright and
+license notices just after the title page:
+
+ Copyright (c) YEAR YOUR NAME.
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.3
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+ A copy of the license is included in the section entitled "GNU
+ Free Documentation License".
+
+If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
+replace the "with...Texts." line with this:
+
+ with the Invariant Sections being LIST THEIR TITLES, with the
+ Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
+
+If you have Invariant Sections without Cover Texts, or some other
+combination of the three, merge those two alternatives to suit the
+situation.
+
+If your document contains nontrivial examples of program code, we
+recommend releasing these examples in parallel under your choice of
+free software license, such as the GNU General Public License,
+to permit their use in free software.
--- /dev/null
+\newcommand{\spatch}{\texttt{spatch}\xspace}
+\newcommand{\sgrep}{\texttt{sgrep}\xspace}
+
+\newcommand{\cpp}{\texttt{cpp}\xspace}
+
+
+\newcommand{\cocciversion}{0.1.8\xspace}
--- /dev/null
+
+% Very convenient to add comments on the paper. Just set the boolean
+% to false before sending the paper:
+\newboolean{showcomments}
+\setboolean{showcomments}{true}
+\ifthenelse{\boolean{showcomments}}
+{ \newcommand{\mynote}[2]{
+ \fbox{\bfseries\sffamily\scriptsize#1}
+ {\small$\blacktriangleright$\textsf{\emph{#2}}$\blacktriangleleft$}}}
+{ \newcommand{\mynote}[2]{}}
+
+\newcommand\jl[1]{\mynote{Julia}{#1}}
+
+
+
+\newcommand{\sizecodebis}[0]{\scriptsize}
+
+\newcommand{\mita}[1]{\mbox{\it{{#1}}}}
+\newcommand{\mtt}[1]{\mbox{\tt{{#1}}}}
+\newcommand{\msf}[1]{\mbox{\sf{{#1}}}}
+\newcommand{\stt}[1]{\mbox{\scriptsize\tt{{#1}}}}
+\newcommand{\ssf}[1]{\mbox{\scriptsize\sf{{#1}}}}
+\newcommand{\sita}[1]{\mbox{\scriptsize\it{{#1}}}}
+\newcommand{\mrm}[1]{\mbox{\rm{{#1}}}}
+\newcommand{\mth}[1]{\({#1}\)}
+\newcommand{\entails}[2]{\begin{array}{@{}c@{}}{#1}\\\hline{#2}\end{array}}
+\newcommand{\ttlb}{\mbox{\tt \char'173}}
+\newcommand{\ttrb}{\mbox{\tt \char'175}}
+\newcommand{\ttmid}{\mbox{\tt \char'174}}
+\newcommand{\tttld}{\mbox{\tt \char'176}}
+
+\newcommand{\fixme}[1]{{\color{red} #1}}
+
+
+%------------------------------------------------------------------------------
+%%%Squeeze space in bibliographybg
+% \let\oldthebibliography=\thebibliography
+% \let\endoldthebibliography=\endthebibliography
+% \renewenvironment{thebibliography}[1]{%
+% \begin{oldthebibliography}{#1}%
+% \setlength{\parskip}{0ex}%
+% \setlength{\itemsep}{0ex}%
+% }%
+% {%
+% \end{oldthebibliography}%
+% }
+
+
+%------------------------------------------------------------------------------
+
+%christian lindig tricks:
+% http://www.st.cs.uni-saarland.de/~lindig/tex.html
+
+%\newif\ifdraft\drafttrue
+
+%see overfull
+%\ifdraft
+%\overfullrule3pt
+%\fi
+
+
+
+%\def\<#1>{\texttt{#1}}
+%Now I can write \<some code here>, which feels more natural
+% in the editor than \texttt{some code here}.
--- /dev/null
+\lstset{basicstyle=\ttfamily,numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt,language=C,commentstyle=\color{OliveGreen},keywordstyle=\color{blue},stringstyle=\color{BrickRed}}
+
+%
+% You must prefix the +/- lines of
+% cocci files with @+/@- respectively.
+% This will enable the automatic coloration.
+%
+% Note: You need at least the following version of hevea
+% http://hevea.inria.fr/distri/unstable/hevea-2008-12-17.tar.gz
+%
+\ifhevea % For HTML generation
+\lstdefinelanguage{Cocci}{
+morekeywords={idexpression,expression,statement,identifier,type,
+parameter,list,when,strict,any,forall,local,position,typedef},
+keywordstyle=\color{OliveGreen}\bfseries,
+sensitive=false,
+moredelim=[is][\color{blue}]{@M}{@M},
+moredelim=[il][\color{OliveGreen}]{@+},
+moredelim=[il][\color{BrickRed}]{@-}}
+
+\lstdefinelanguage{PatchC}[ANSI]{C}{
+stringstyle=\color{black},
+moredelim=[il][\color{OliveGreen}]{@+},
+moredelim=[il][\color{BrickRed}]{@-},
+moredelim=[il][\color{Plum}]{@M}}
+
+\else % For DVI/PS/PDF generation
+\lstdefinelanguage{Cocci}{
+morekeywords={idexpression,expression,statement,identifier,type,
+parameter,list,when,strict,any,forall,local,position,typedef},
+keywordstyle=\color{OliveGreen}\bfseries,
+sensitive=false,
+moredelim=*[is][\color{blue}]{@M}{@M},
+moredelim=[il][\color{OliveGreen}]{@+},
+moredelim=[il][\color{BrickRed}]{@-}}
+
+\lstdefinelanguage{PatchC}[ANSI]{C}{
+stringstyle=\color{black},
+moredelim=[il][\color{OliveGreen}]{@+},
+moredelim=[il][\color{BrickRed}]{@-},
+moredelim=[il][\color{Plum}]{@M}}
+\fi
+
+\newif\iflanguagestyle
+\languagestylefalse
--- /dev/null
+
+\newcommand{\minimum}[2]{\paragraph*{\makebox[0in][r]{\FilledBigDiamondshape\,\,} {{#1}}} {#2}}
+\newcommand{\normal}[2]{\paragraph*{\makebox[0in][r]{\BigLowerDiamond\,\,} {{#1}}} {#2}}
+\newcommand{\rare}[2]{\paragraph*{\makebox[0in][r]{\BigDiamondshape\,\,} {{#1}}} {#2}}
+\newcommand{\developer}[2]{\paragraph*{{#1}} {#2}}
+
--- /dev/null
+\documentclass{report}
+
+%******************************************************************************
+% Prelude
+%******************************************************************************
+%------------------------------------------------------------------------------
+% Packages
+%------------------------------------------------------------------------------
+
+\usepackage{ifthen}
+\usepackage{hevea}
+
+\usepackage{times}
+\usepackage{fullpage}
+
+\usepackage[T1]{fontenc}
+
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+% fancy symbol, but require latex-extra-fonts (huge) package
+\usepackage[geometry]{ifsym}
+
+
+
+\usepackage{graphics}
+\usepackage[pdftex]{graphicx}
+
+
+\usepackage{epsfig}
+\usepackage{subfigure}
+\usepackage{wrapfig}
+
+\usepackage[all]{xy}
+
+
+\usepackage{fancyvrb}
+\usepackage{moreverb}
+\usepackage{alltt}
+
+\usepackage{boxedminipage}
+
+\usepackage{xspace}
+\usepackage{endnotes}
+
+\usepackage{multirow}
+%\usepackage{colortbl} % conflict with color package below
+
+\usepackage{listings}
+%\usepackage{code/lgrind}
+
+\usepackage[pdfborder={0 0 0}]{hyperref}
+%\usepackage{url}
+
+\usepackage[usenames,dvipsnames]{color}
+
+%------------------------------------------------------------------------------
+% Shortcuts
+%------------------------------------------------------------------------------
+
+\input{macros_common}
+%e.g:
+% \newcommand{\mita}[1]{\mbox{\it{{#1}}}}
+
+\input{macros_options}
+
+\input{macros_listing_cocci} % order is important
+\input{macros_grammar}
+
+
+%------------------------------------------------------------------------------
+% Globals
+%------------------------------------------------------------------------------
+\input{macros}
+%e.g:
+% \newcommand{\avgcorrect}{96\%\xspace} % if consider all files
+% \newcommand{\MyTool}{aComment\xspace}
+% \newcommand{\bugsfound}{XXX\xspace}
+
+
+%******************************************************************************
+% Title
+%******************************************************************************
+\begin{document}
+%don't want date printed
+\date{}
+
+%------------------------------------------------------------------------------
+\title{
+{\Huge \bf Coccinelle}\\
+{User's manual}\\
+{release \cocciversion}\\
+}
+%\title{\spatch and \sgrep manual}
+
+\author{
+Julia Lawall and Yoann Padioleau \\
+{(with contributions from
+Rene Rydhof Hansen,
+Nicolas Palix,
+Henrik Stuart)
+}
+}
+%src: Xavier Leroy manual
+
+\date{\today}
+
+\maketitle
+\tableofcontents
+
+%******************************************************************************
+% Body
+%******************************************************************************
+
+\chapter*{Foreword}
+
+This manual documents the release \cocciversion of Coccinelle.
+It is organized as follows:
+\begin{itemize}
+ \item Part~\ref{part:usermanual} is an introduction to Coccinelle
+ \item Part~\ref{part:refmanual} is the reference description
+ of Coccinelle, its language and command line tool.
+\end{itemize}
+
+\section*{Conventions}
+
+\section*{Copyright}
+
+%coupling: copyright.txt
+Coccinelle is copyright \copyright 2005, 2006, 2007, 2008, 2009
+University of Copenhagen DIKU and Ecole des Mines de Nantes.
+
+Coccinelle is open source and can be freely redistributed under the
+terms of the GNU General Public License version 2. See the file
+\verb+license.txt+ in the distribution for licensing information.
+
+The present documentation is copyright 2008, 2009 Yoann Padioleau
+and Julia Lawall and distributed under the terms of the
+GNU Free Documentation License version 1.3.
+
+\section*{Availability}
+
+Coccinelle can be freely downloaded
+from \verb+http://www.emn.fr/x-info/coccinelle+.
+This website contains also additional information.
+
+
+\part{User Manual}
+\label{part:usermanual}
+
+\input{introduction}
+
+\input{installing}
+
+\input{tutorial}
+
+\chapter{Examples}
+\input{examples}
+\input{tips}
+
+
+\input{isomorphisms}
+
+\input{parsing}
+
+
+\input{workflow}
+
+\input{advanced}
+
+
+
+
+\part{Reference Manual}
+\label{part:refmanual}
+
+\chapter{SmPL grammar}
+
+\input{cocci_syntax}
+
+\chapter{\spatch command line options}
+
+%coupling: ../spatch.1
+\input{spatch_options}
+
+%******************************************************************************
+% Appendix
+%******************************************************************************
+
+%index
+
+{\small
+\bibliographystyle{acm}
+\bibliography{main}
+}
+
+
+%******************************************************************************
+% Postlude
+%******************************************************************************
+
+\end{document}
--- /dev/null
+\documentclass{article}
+
+\usepackage{times}
+\usepackage{fullpage}
+
+\usepackage[T1]{fontenc}
+%\usepackage[latin9]{inputenc}
+
+\usepackage{ifthen}
+\usepackage{hevea}
+
+\usepackage{alltt}
+\usepackage{xspace}
+\usepackage[pdfborder={0 0 0}]{hyperref}
+\usepackage{listings}
+\usepackage[usenames,dvipsnames]{color}
+\usepackage{multirow}
+
+\input{macros_listing_cocci}
+\input{macros_grammar}
+\input{macros_common}
+
+
+\ifhevea
+\newcommand{\phantom}{}
+\newcommand{\air}{ }
+\else
+\newcommand{\air}{\phantom{xxx}}
+\fi
+
+\title{The SmPL Grammar (version 0.1.4)}
+\author{Research group on Coccinelle}
+\date{\today}
+
+\begin{document}
+\maketitle
+
+
+\input{cocci_syntax}
+
+\include{examples}
+\include{tips}
+
+\end{document}
+
--- /dev/null
+\documentclass{article}
+
+\usepackage{ifthen}
+
+\usepackage{fullpage}
+\usepackage{amsmath}
+\usepackage{amssymb}
+
+% fancy symbol, but require latex-extra-fonts (huge) package
+\usepackage[geometry]{ifsym}
+
+\input{macros_options}
+
+\title{Coccinelle Usage (version 0.1.7)}
+
+\begin{document}
+\maketitle
+
+\input{spatch_options}
+
+\end{document}
--- /dev/null
+\chapter{Parsing C, \cpp, and \texttt{standard.h}}
\ No newline at end of file
-\documentclass{article}
-\usepackage{fullpage}
-\usepackage{amsmath}
-\usepackage{amssymb}
-\usepackage{ifthen}
-\usepackage[geometry]{ifsym}
-\title{Coccinelle Usage (version 0.1.4)}
-\newcommand{\minimum}[2]{\paragraph*{\makebox[0in][r]{\FilledBigDiamondshape\,\,} {{#1}}} {#2}}
-\newcommand{\normal}[2]{\paragraph*{\makebox[0in][r]{\BigLowerDiamond\,\,} {{#1}}} {#2}}
-\newcommand{\rare}[2]{\paragraph*{\makebox[0in][r]{\BigDiamondshape\,\,} {{#1}}} {#2}}
-\newcommand{\developer}[2]{\paragraph*{{#1}} {#2}}
-
-% Very convenient to add comments on the paper. Just set the boolean
-% to false before sending the paper:
-\newboolean{showcomments}
-\setboolean{showcomments}{true}
-\ifthenelse{\boolean{showcomments}}
-{ \newcommand{\mynote}[2]{
- \fbox{\bfseries\sffamily\scriptsize#1}
- {\small$\blacktriangleright$\textsf{\emph{#2}}$\blacktriangleleft$}}}
-{ \newcommand{\mynote}[2]{}}
-
-\newcommand\jl[1]{\mynote{Julia}{#1}}
-
-\begin{document}
-\maketitle
-
\section{Introduction}
This document describes the options provided by Coccinelle. The options
\subsection{Selecting C files}
-An argument that ends in {\tt .c} is assumed to be a C file to process. A
-directory can be specified with the option {\bf -dir}, described below.
-Normally, only one C file or one directory is specified. If multiple files
-are specified, they are treated in parallel, {\em i.e.}, the first semantic
-patch rule is applied to all functions in all files, then the second
-semantic patch rule is applied to all functions in all files, etc. If a
-directory is specified then no files may be specified and only the
+An argument that ends in {\tt .c} is assumed to be a C file to process.
+Normally, only one C file or one directory is specified. If multiple C
+files are specified, they are treated in parallel, {\em i.e.}, the first
+semantic patch rule is applied to all functions in all files, then the
+second semantic patch rule is applied to all functions in all files, etc.
+If a directory is specified then no files may be specified and only the
rightmost directory specified is used.
-\minimum{-dir}{ Specify a directory containing C files to process. By
- default, the include path will be set to the ``include'' subdirectory of
- this directory. A different include path can be specified using the
- option {\bf -I}.}
-
\normal{-include\_headers}{ This option causes header files to be processed
independently. This option only makes sense if a directory is specified
using {\bf -dir}.}
http://webglimpse.net/. In conjunction with the option {\bf -patch\_cocci}
this option prints the regular expression that will be passed to glimpse.}
+\rare{-dir}{ Specify a directory containing C files to process. By
+ default, the include path will be set to the ``include'' subdirectory of
+ this directory. A different include path can be specified using the
+ option {\bf -I}. {\bf -dir} only considers the rightmost directory in
+ the argument list. This behavior is convenient for creating a script
+ that always works on a single directory, but allows the user of the
+ script to override the provided directory with another one. Spatch
+ collects the files in the directory using {\tt find} and does not follow
+ symbolic links.}
+
\developer{-kbuild\_info $\langle$file$\rangle$}{ The specified file
contains information about which sets of files should be considered in
parallel.}
Coccinelle to file{\tt{.c}} to the file file{\tt{.res}} representing the
expected result.}
+\developer{-expected\_score\_file $\langle$file$\rangle$}{
+which score file to compare with in the testall run}
+
\subsection{Parsing C files}
\rare{-show\_c}{Show the C code that is being processed.}
\rare{-type\_error\_msg}{Show information about where the C type checker
was not able to determine the type of an expression.}
+\rare{-int\_bits $\langle$n$\rangle$, -long\_bits
+$\langle$n$\rangle$}{Provide integer size information. n is the number of
+bits in an unsigned integer or unsigned long, respectively. If only the
+option {\bf -int\_bits} is used, unsigned longs will be assumed to have
+twice as many bits as unsigned integers. If only the option {\bf
+-long\_bits} is used, unsigned ints will be assumed to have half as many
+bits as unsigned integers. This information is only used in determining
+the types of integer constants, according to the ANSI C standard (C89). If
+neither is provided, the type of an integer constant is determined by the
+sequence of ``u'' and ``l'' annotations following the constant. If there
+is none, the constant is assumed to be a signed integer. If there is only
+``u'', the constant is assumed to be an unsigned integer, etc.}
+
\developer{-use\_cache} Use preparsed versions of the C files that are
stored in a cache.
\subsubsection*{Macros and other preprocessor code}
-\normal{-D $\langle$file$\rangle$, -macro\_file $\langle$file$\rangle$}{
+\normal{-macro\_file $\langle$file$\rangle$}{
Extra macro definitions to be taken into account when parsing the C
files.}
-\rare{-ifdef\_to\_if}{ This option constructs represents an \#ifdef in
-the source code as a conditional in the control-flow graph. This option is
-unsafe, as it makes the source code unparsable when \#ifdef is used in a
-way that does not directly convert to a conditional. Nevertheless, it can
-be useful when \#ifdef is used in a well-structured way.}
+\normal{-macro\_file\_builtins $\langle$file$\rangle$}{
+ Builtin macro definitions to be taken into account when parsing the C
+ files.}
+
+\rare{-ifdef\_to\_if,-no\_ifdef\_to\_if}{
+The option {\bf -ifdef\_to\_if}
+represents an {\tt \#ifdef} in the source code as a conditional in the
+control-flow graph when doing so represents valid code. {\bf
+-no\_ifdef\_to\_if} disables this feature. {\bf -ifdef\_to\_if} is the
+default.
+}
\rare{-use\_if0\_code}{ Normally code under \#if 0 is ignored. If this
option is set then the code is considered, just like the code under any
Normally, the only output is a diff printed to standard output.
+\normal{-linux\_spacing, -smpl\_spacing}{Control the spacing within the code
+ added by the semantic patch. The option {\bf -linux\_spacing} causes
+ spatch to follow the conventions of Linux, regardless of the spacing in
+ the semantic patch. This is the default. The option {\bf
+ -smpl\_spacing} causes spatch to follow the spacing given in the semantic
+ patch, within individual lines.}
+
\rare{-o $\langle$file$\rangle$}{ The output file.}
\rare{-inplace}{ Modify the input file.}
\developer{-pad, -hrule $\langle$dir$\rangle$, -xxx, -l1}{}
-\end{document}
--- /dev/null
+\chapter{Tutorial}
+
--- /dev/null
+\chapter{Developing a Semantic Patch}
+
+%editing semantic patch, emacs mode
+
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
.\" respectively. Also \fR for roman.
+.\" pad: src: deputy man page
.SH NAME
spatch \- apply a semantic patch file to a set of C files
let option_default = false in
let mcode r (_,_,kind,metapos) =
match kind with
- Ast.MINUS(_,_) -> true
+ Ast.MINUS(_,_,_,_) -> true
| Ast.PLUS -> failwith "not possible"
| Ast.CONTEXT(_,info) -> not (info = Ast.NOTHING) in
let do_nothing r k e = k e in
let option_default = 0 in
let stmt_count r k s =
match Ast.unwrap s with
- Ast.Seq(_,_,_,_) | Ast.FunDecl(_,_,_,_,_) -> (k s) + 1
+ Ast.Seq(_,_,_) | Ast.FunDecl(_,_,_,_) -> (k s) + 1
| _ -> k s in
let donothing r k e = k e in
let mcode r x = 0 in
(match Ast.unwrap ast with
Ast.MetaStmt(_,_,_,_) -> (s,[])
| _ -> (s,[Ast.Other s]))
- | Ast.Seq(lbrace,decls,body,rbrace) ->
+ | Ast.Seq(lbrace,body,rbrace) ->
let index = count_nested_braces s in
- let (de,dea) = get_before decls [Ast.WParen(lbrace,index)] in
- let (bd,_) = get_before body dea in
- (Ast.rewrap s (Ast.Seq(lbrace,de,bd,rbrace)),
- [Ast.WParen(rbrace,index)])
+ let (bd,_) = get_before body [Ast.WParen(lbrace,index)] in
+ (Ast.rewrap s (Ast.Seq(lbrace,bd,rbrace)),[Ast.WParen(rbrace,index)])
| Ast.Define(header,body) ->
let (body,_) = get_before body [] in
(Ast.rewrap s (Ast.Define(header,body)), [Ast.Other s])
| Ast.OptCase(case_line) -> failwith "not supported")
cases in
(Ast.rewrap s (Ast.Switch(header,lb,cases,rb)),[Ast.Other s])
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
- let (de,dea) = get_before decls [] in
- let (bd,_) = get_before body dea in
- (Ast.rewrap s (Ast.FunDecl(header,lbrace,de,bd,rbrace)),[])
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
+ let (bd,_) = get_before body [] in
+ (Ast.rewrap s (Ast.FunDecl(header,lbrace,bd,rbrace)),[])
| _ ->
Pretty_print_cocci.statement "" s; Format.print_newline();
failwith "get_before_e: not supported"
(Ast.MetaStmt(nm,keep,Ast.SequencibleAfterDots a,i)))),[])
| Ast.MetaStmt(_,_,_,_) -> (s,[])
| _ -> (s,[Ast.Other s]))
- | Ast.Seq(lbrace,decls,body,rbrace) ->
+ | Ast.Seq(lbrace,body,rbrace) ->
let index = count_nested_braces s in
- let (bd,bda) = get_after body [Ast.WParen(rbrace,index)] in
- let (de,_) = get_after decls bda in
- (Ast.rewrap s (Ast.Seq(lbrace,de,bd,rbrace)),
+ let (bd,_) = get_after body [Ast.WParen(rbrace,index)] in
+ (Ast.rewrap s (Ast.Seq(lbrace,bd,rbrace)),
[Ast.WParen(lbrace,index)])
| Ast.Define(header,body) ->
let (body,_) = get_after body a in
| Ast.OptCase(case_line) -> failwith "not supported")
cases in
(Ast.rewrap s (Ast.Switch(header,lb,cases,rb)),[Ast.Other s])
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
- let (bd,bda) = get_after body [] in
- let (de,_) = get_after decls bda in
- (Ast.rewrap s (Ast.FunDecl(header,lbrace,de,bd,rbrace)),[])
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
+ let (bd,_) = get_after body [] in
+ (Ast.rewrap s (Ast.FunDecl(header,lbrace,bd,rbrace)),[])
| _ -> failwith "get_after_e: not supported"
let preprocess_dots sl =
Ast.CONTEXT(pos,Ast.BEFOREAFTER(bef,_)) ->
Ast.CONTEXT(pos,Ast.BEFORE(bef))
| Ast.CONTEXT(pos,_) -> Ast.CONTEXT(pos,Ast.NOTHING)
- | Ast.MINUS(_,_) | Ast.PLUS -> failwith "not possible") in
+ | Ast.MINUS(_,_,_,_) | Ast.PLUS -> failwith "not possible") in
let middle_metamatch =
matcher
(match d with
Ast.CONTEXT(pos,_) -> Ast.CONTEXT(pos,Ast.NOTHING)
- | Ast.MINUS(_,_) | Ast.PLUS -> failwith "not possible") in
+ | Ast.MINUS(_,_,_,_) | Ast.PLUS -> failwith "not possible") in
let last_metamatch =
matcher
(match d with
Ast.CONTEXT(pos,Ast.BEFOREAFTER(_,aft)) ->
Ast.CONTEXT(pos,Ast.AFTER(aft))
| Ast.CONTEXT(_,_) -> d
- | Ast.MINUS(_,_) | Ast.PLUS -> failwith "not possible") in
+ | Ast.MINUS(_,_,_,_) | Ast.PLUS -> failwith "not possible") in
let rest_nodes =
ctl_and CTL.NONSTRICT middle_metamatch prelabel_pred in
let prelabel_pred =
CTL.Pred (Lib_engine.PrefixLabel(label_var),CTL.Control) in
let matcher d = make_match None guard (make_meta_rule_elem d fvinfo) in
- let pure_d =
+ let ender =
+ match (d,after) with
+ (Ast.CONTEXT(pos,Ast.NOTHING),(Tail|End|VeryEnd)) ->
+ (* just match the root. don't care about label; always ok *)
+ make_raw_match None false ast
+ | (Ast.MINUS(pos,inst,adj,[]),(Tail|End|VeryEnd)) ->
(* don't have to put anything before the beginning, so don't have to
distinguish the first node. so don't have to bother about paths,
just use the label. label ensures that found nodes match up with
what they should because it is in the lhs of the andany. *)
- match d with
- Ast.MINUS(pos,[]) -> true
- | Ast.CONTEXT(pos,Ast.NOTHING) -> true
- | _ -> false in
- let ender =
- match (pure_d,after) with
- (true,Tail) | (true,End) | (true,VeryEnd) ->
- (* the label sharing makes it safe to use AndAny *)
CTL.HackForStmt(CTL.FORWARD,CTL.NONSTRICT,
ctl_and CTL.NONSTRICT label_pred
(make_raw_match label false ast),
let rest_metamatch =
matcher
(match d with
- Ast.MINUS(pos,_) -> Ast.MINUS(pos,[])
+ Ast.MINUS(pos,inst,adj,_) -> Ast.MINUS(pos,inst,adj,[])
| Ast.CONTEXT(pos,_) -> Ast.CONTEXT(pos,Ast.NOTHING)
| Ast.PLUS -> failwith "not possible") in
let rest_nodes = ctl_and CTL.NONSTRICT rest_metamatch prelabel_pred in
is absent *)
let new_mc =
match (retmc,semmc) with
- (Ast.MINUS(_,l1),Ast.MINUS(_,l2)) when !Flag.sgrep_mode2 ->
+ (Ast.MINUS(_,inst1,adj1,l1),Ast.MINUS(_,_,_,l2))
+ when !Flag.sgrep_mode2 ->
(* in sgrep mode, we can propagate the - *)
- Some (Ast.MINUS(Ast.NoPos,l1@l2))
- | (Ast.MINUS(_,l1),Ast.MINUS(_,l2))
+ Some (Ast.MINUS(Ast.NoPos,inst1,adj1,l1@l2))
+ | (Ast.MINUS(_,_,_,l1),Ast.MINUS(_,_,_,l2))
| (Ast.CONTEXT(_,Ast.BEFORE(l1)),
Ast.CONTEXT(_,Ast.AFTER(l2))) ->
Some (Ast.CONTEXT(Ast.NoPos,Ast.BEFORE(l1@l2)))
| (Ast.CONTEXT(_,Ast.BEFORE(_)),Ast.CONTEXT(_,Ast.NOTHING))
| (Ast.CONTEXT(_,Ast.NOTHING),Ast.CONTEXT(_,Ast.NOTHING)) ->
Some retmc
- | (Ast.CONTEXT(_,Ast.NOTHING),Ast.CONTEXT(_,Ast.AFTER(l))) ->
+ | (Ast.CONTEXT(_,Ast.NOTHING),
+ Ast.CONTEXT(_,Ast.AFTER(l))) ->
Some (Ast.CONTEXT(Ast.NoPos,Ast.BEFORE(l)))
| _ -> None in
let ret = Ast.make_mcode "return" in
quantified minus_quantified label llabel slabel guard in
dots_done := true;
make_seq_after term after)
- | Ast.Seq(lbrace,decls,body,rbrace) ->
- let (lbfvs,b1fvs,b2fvs,b3fvs,rbfvs) =
+ | Ast.Seq(lbrace,body,rbrace) ->
+ let (lbfvs,b1fvs,b2fvs,rbfvs) =
match
seq_fvs quantified
- [Ast.get_fvs lbrace;Ast.get_fvs decls;
+ [Ast.get_fvs lbrace;
Ast.get_fvs body;Ast.get_fvs rbrace]
with
- [(lbfvs,b1fvs);(_,b2fvs);(_,b3fvs);(rbfvs,_)] ->
- (lbfvs,b1fvs,b2fvs,b3fvs,rbfvs)
+ [(lbfvs,b1fvs);(_,b2fvs);(rbfvs,_)] ->
+ (lbfvs,b1fvs,b2fvs,rbfvs)
| _ -> failwith "not possible" in
- let (mlbfvs,mb1fvs,mb2fvs,mb3fvs,mrbfvs) =
+ let (mlbfvs,mb1fvs,mb2fvs,mrbfvs) =
match
seq_fvs minus_quantified
- [Ast.get_mfvs lbrace;Ast.get_mfvs decls;
+ [Ast.get_mfvs lbrace;
Ast.get_mfvs body;Ast.get_mfvs rbrace]
with
- [(lbfvs,b1fvs);(_,b2fvs);(_,b3fvs);(rbfvs,_)] ->
- (lbfvs,b1fvs,b2fvs,b3fvs,rbfvs)
+ [(lbfvs,b1fvs);(_,b2fvs);(rbfvs,_)] ->
+ (lbfvs,b1fvs,b2fvs,rbfvs)
| _ -> failwith "not possible" in
let pv = count_nested_braces stmt in
let lv = get_label_ctr() in
paren_pred)) in
let new_quantified2 =
Common.union_set b1fvs (Common.union_set b2fvs quantified) in
- let new_quantified3 = Common.union_set b3fvs new_quantified2 in
let new_mquantified2 =
Common.union_set mb1fvs (Common.union_set mb2fvs minus_quantified) in
- let new_mquantified3 = Common.union_set mb3fvs new_mquantified2 in
let pattern_as_given =
let new_quantified2 = Common.union_set [pv] new_quantified2 in
- let new_quantified3 = Common.union_set [pv] new_quantified3 in
quantify true [pv;lv]
(quantify guard b1fvs
(make_seq
[start_brace;
quantify guard b2fvs
- (statement_list decls
- (After
- (quantify guard b3fvs
- (statement_list body
- (After (make_seq_after end_brace after))
- new_quantified3 new_mquantified3
- (Some (lv,ref true)) (* label mostly useful *)
- llabel slabel true guard)))
+ (statement_list body
+ (After (make_seq_after end_brace after))
new_quantified2 new_mquantified2
(Some (lv,ref true)) llabel slabel false guard)])) in
if ends_in_return body
ctl_au
(make_match empty_rbrace)
(ctl_ax (* skip the destination label *)
- (quantify guard b3fvs
+ (quantify guard b2fvs
(statement_list body End
- new_quantified3 new_mquantified3 None llabel slabel
+ new_quantified2 new_mquantified2 None llabel slabel
true guard)))] in
let pattern3 =
let new_quantified2 = Common.union_set [pv] new_quantified2 in
- let new_quantified3 = Common.union_set [pv] new_quantified3 in
quantify true [pv;lv]
(quantify guard b1fvs
(make_seq
(* want AF even for sgrep *)
(CTL.AF(CTL.FORWARD,CTL.STRICT,end_brace))))
(quantify guard b2fvs
- (statement_list decls
- (After
- (quantify guard b3fvs
- (statement_list body Tail
- (*After
- (make_seq_after
- nopv_end_brace after)*)
- new_quantified3 new_mquantified3
- None llabel slabel true guard)))
+ (statement_list body Tail
new_quantified2 new_mquantified2
(Some (lv,ref true))
llabel slabel false guard))])) in
- ctl_or pattern_as_given
- (match Ast.unwrap decls with
- Ast.DOTS([]) -> ctl_or pattern2 pattern3
- | Ast.DOTS(l) -> pattern3
- | _ -> failwith "circles and stars not supported")
+ ctl_or pattern_as_given (ctl_or pattern2 pattern3)
else pattern_as_given
| Ast.IfThen(ifheader,branch,aft) ->
ifthen ifheader branch aft after quantified minus_quantified
| Ast.Dots((_,i,d,_),whencodes,bef,aft) ->
let dot_code =
match d with
- Ast.MINUS(_,_) ->
+ Ast.MINUS(_,_,_,_) ->
(* no need for the fresh metavar, but ... is a bit weird as a
variable name *)
Some(make_match (make_meta_rule_elem d ([],[],[])))
wrapper
(end_control_structure b1fvs switch_header body
after_pred (Some(ctl_ex after_pred)) None aft after label guard)
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
- let (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,b4fvs,rbfvs) =
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
+ let (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,rbfvs) =
match
seq_fvs quantified
- [Ast.get_fvs header;Ast.get_fvs lbrace;Ast.get_fvs decls;
+ [Ast.get_fvs header;Ast.get_fvs lbrace;
Ast.get_fvs body;Ast.get_fvs rbrace]
with
- [(hfvs,b1fvs);(lbfvs,b2fvs);(_,b3fvs);(_,b4fvs);(rbfvs,_)] ->
- (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,b4fvs,rbfvs)
+ [(hfvs,b1fvs);(lbfvs,b2fvs);(_,b3fvs);(rbfvs,_)] ->
+ (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,rbfvs)
| _ -> failwith "not possible" in
- let (mhfvs,mb1fvs,mlbfvs,mb2fvs,mb3fvs,mb4fvs,mrbfvs) =
+ let (mhfvs,mb1fvs,mlbfvs,mb2fvs,mb3fvs,mrbfvs) =
match
seq_fvs quantified
- [Ast.get_mfvs header;Ast.get_mfvs lbrace;Ast.get_mfvs decls;
+ [Ast.get_mfvs header;Ast.get_mfvs lbrace;
Ast.get_mfvs body;Ast.get_mfvs rbrace]
with
- [(hfvs,b1fvs);(lbfvs,b2fvs);(_,b3fvs);(_,b4fvs);(rbfvs,_)] ->
- (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,b4fvs,rbfvs)
+ [(hfvs,b1fvs);(lbfvs,b2fvs);(_,b3fvs);(rbfvs,_)] ->
+ (hfvs,b1fvs,lbfvs,b2fvs,b3fvs,rbfvs)
| _ -> failwith "not possible" in
let function_header = quantify guard hfvs (make_match header) in
let start_brace = quantify guard lbfvs (make_match lbrace) in
let new_quantified3 =
Common.union_set b1fvs
(Common.union_set b2fvs (Common.union_set b3fvs quantified)) in
- let new_quantified4 = Common.union_set b4fvs new_quantified3 in
let new_mquantified3 =
Common.union_set mb1fvs
(Common.union_set mb2fvs
(Common.union_set mb3fvs minus_quantified)) in
- let new_mquantified4 = Common.union_set mb4fvs new_mquantified3 in
let fn_nest =
- match (Ast.undots decls,Ast.undots body,
+ match (Ast.undots body,
contains_modif rbrace or contains_pos rbrace) with
- ([],[body],false) ->
+ ([body],false) ->
(match Ast.unwrap body with
Ast.Nest(stmt_dots,[],multi,_,_) ->
if multi
statement_list stmt_dots
(* discards match on right brace, but don't need it *)
(Guard (make_seq_after end_brace after))
- new_quantified4 new_mquantified4
+ new_quantified3 new_mquantified3
None llabel slabel true guard)
| Some (Common.Right whencode) ->
(* try to be more efficient for the case where the body is just
| Ast.WhenNot(sl) ->
let x =
statement_list sl Tail
- new_quantified4 new_mquantified4
+ new_quantified3 new_mquantified3
label llabel slabel true true in
ctl_or prev x
| Ast.WhenNotTrue(_) | Ast.WhenNotFalse(_) ->
Ast.WhenAlways(s) ->
let x =
statement s Tail
- new_quantified4 new_mquantified4
+ new_quantified3 new_mquantified3
label llabel slabel true in
ctl_and prev x
| Ast.WhenNot(sl) -> prev
make_seq
[start_brace;
quantify guard b3fvs
- (statement_list decls
- (After
- (quantify guard b4fvs
- (statement_list body
- (After (make_seq_after end_brace after))
- new_quantified4 new_mquantified4
- None llabel slabel true guard)))
+ (statement_list body
+ (After (make_seq_after end_brace after))
new_quantified3 new_mquantified3 None llabel slabel
false guard)] in
quantify guard b1fvs
let mcode r (_,_,kind,_) =
match kind with
- Ast.MINUS(_,_) -> true
+ Ast.MINUS(_,_,_,_) -> true
| Ast.PLUS -> failwith "not possible"
| Ast.CONTEXT(_,info) -> not (info = Ast.NOTHING)
(* modifications on return are managed in some other way *)
Ast.Return(_,_) | Ast.ReturnExpr(_,_,_) when tail -> []
| _ -> if testfn ast then rule_elem ast else [])
- | Ast.Seq(lbrace,decls,body,rbrace) ->
- let body_info =
- conj
- (statement_list testfn mcode false decls)
- (statement_list testfn mcode tail body) in
+ | Ast.Seq(lbrace,body,rbrace) ->
+ let body_info = statement_list testfn mcode tail body in
if testfn lbrace or testfn rbrace
then conj_wrapped [lbrace;rbrace] body_info
else body_info
| Ast.Dots(_,whencodes,_,_) -> []
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
- let body_info =
- conj
- (statement_list testfn mcode false decls)
- (statement_list testfn mcode true body) in
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
+ let body_info = statement_list testfn mcode true body in
if testfn header or testfn lbrace or testfn rbrace
then conj (rule_elem header) body_info
else body_info
(sua =*= sub && saopt =*= sbopt && List.length sta =|= List.length stb)
>&&>
Common.zip sta stb +> List.fold_left
- (fun acc ((xfielda, iia), (xfieldb, iib)) ->
- let iix = iia in
+ (fun acc ((fielda), (fieldb)) ->
acc >>= (fun xs ->
- match xfielda, xfieldb with
- | EmptyField, EmptyField -> return ((EmptyField, iix)::xs)
+ match fielda, fieldb with
+ | EmptyField iia, EmptyField iib ->
+ let iix = iia in
+ return ((EmptyField iix)::xs)
| DeclarationField (FieldDeclList (fa, iipta)),
DeclarationField (FieldDeclList (fb, iiptb)) ->
) (return [])
>>= (fun fx ->
return (((DeclarationField
- (FieldDeclList (List.rev fx,iipt))), iix)::xs)
+ (FieldDeclList (List.rev fx,iipt))))::xs)
)
| _ -> fail
)
(*****************************************************************************)
(* Wrappers *)
(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_matcher.verbose_matcher
(*****************************************************************************)
(* Helpers *)
let mcode_contain_plus = function
| A.CONTEXT (_,A.NOTHING) -> false
| A.CONTEXT _ -> true
- | A.MINUS (_,[]) -> false
- | A.MINUS (_,x::xs) -> true
+ | A.MINUS (_,_,_,[]) -> false
+ | A.MINUS (_,_,_,x::xs) -> true
| A.PLUS -> raise Impossible
let mcode_simple_minus = function
- | A.MINUS (_,[]) -> true
+ | A.MINUS (_,_,_,[]) -> true
| _ -> false
let minusizer =
("fake","fake"),
- {A.line = 0; column =0; A.strbef=[]; A.straft=[];},
- (A.MINUS(A.DontCarePos, [])),
+ {A.line = 0; A.column =0; A.strbef=[]; A.straft=[];},
+ (A.MINUS(A.DontCarePos,[],-1,[])),
A.NoMetaPos
let generalize_mcode ia =
| A.PLUS -> raise Impossible
| A.CONTEXT (A.NoPos,x) ->
A.CONTEXT (A.DontCarePos,x)
- | A.MINUS (A.NoPos,x) ->
- A.MINUS (A.DontCarePos,x)
+ | A.MINUS (A.NoPos,inst,adj,x) ->
+ A.MINUS (A.DontCarePos,inst,adj,x)
| A.CONTEXT ((A.FixPos _|A.DontCarePos), _)
- | A.MINUS ((A.FixPos _|A.DontCarePos), _)
+ | A.MINUS ((A.FixPos _|A.DontCarePos), _, _, _)
->
raise Impossible
in
ref (Some ((Lib_parsing_c.al_type returnType),local),
Ast_c.NotTest) in
let ident = name in
- let idexpr = (B.Ident (ident), typ),Ast_c.noii in
- F.DefineExpr
- ((B.Assignment (idexpr, B.SimpleAssign, e),
- Ast_c.noType()), [iini])
+ let idexpr =
+ Ast_c.mk_e_bis (B.Ident (ident)) typ Ast_c.noii
+ in
+ let assign =
+ Ast_c.mk_e
+ (B.Assignment (idexpr,B.SimpleAssign, e)) [iini] in
+ F.DefineExpr assign
+
| _ -> F.Decl decl
)
| _ -> F.Decl decl
))
in
(match term ia1, ib with
- | A.Int x, B.Int y ->
+ | A.Int x, B.Int (y,_) ->
X.value_format_flag (fun use_value_equivalence ->
if use_value_equivalence
then
-
(* ------------------------------------------------------------------------- *)
and (ident_cpp: info_ident -> (A.ident, B.name) matcher) =
- fun infoidb ida idb ->
+ fun infoidb ida idb ->
match idb with
| B.RegularName (s, iis) ->
let iis = tuple_of_list1 iis in
(B.RegularName (s, [iis]))
))
| B.CppConcatenatedName _ | B.CppVariadicName _ |B.CppIdentBuilder _
- -> raise Todo
+ ->
+ (* This should be moved to the Id case of ident. Metavariables
+ should be allowed to be bound to such variables. But doing so
+ would require implementing an appropriate distr function *)
+ fail
and (ident: info_ident -> (A.ident, string * Ast_c.info) matcher) =
fun infoidb ida ((idb, iib) as ib) ->
[iisb;lpb;rpb;iiendb;iifakestart] ++ iistob))
))))))))
- | _, (B.MacroDecl _ |B.DeclList _) -> fail
+ | _, (B.MacroDecl _ |B.DeclList _) -> fail
)
and (struct_field: (A.declaration, B.field) matcher) = fun fa fb ->
- let (xfield, iifield) = fb in
- match xfield with
+ match fb with
| B.DeclarationField (B.FieldDeclList (onefield_multivars,iiptvirg)) ->
let iiptvirgb = tuple_of_list1 iiptvirg in
return (
(fa),
((B.DeclarationField
- (B.FieldDeclList ([onevar, iivirg], [iiptvirgb]))),
- iifield)
+ (B.FieldDeclList ([onevar, iivirg], [iiptvirgb])))
+ )
)
| _ -> raise Impossible
)
pr2_once "PB: More that one variable in decl. Have to split";
fail
)
- | B.EmptyField ->
- let _iiptvirgb = tuple_of_list1 iifield in
+ | B.EmptyField _iifield ->
fail
- | B.MacroStructDeclTodo -> fail
+ | B.MacroDeclField _ ->
+ raise Todo
+
| B.CppDirectiveStruct directive -> fail
| B.IfdefStruct directive -> fail
let (satbis_to_trans_info:
- (nodei * Lib_engine.metavars_binding2 * Lib_engine.predicate) list ->
- (nodei * Lib_engine.metavars_binding * Ast_cocci.rule_elem) list) =
+ (int list *
+ (nodei * Lib_engine.metavars_binding2 * Lib_engine.predicate)) list ->
+ (int list *
+ (nodei * Lib_engine.metavars_binding * Ast_cocci.rule_elem)) list) =
fun xs ->
- xs +> List.fold_left (fun prev (nodei, binding2, pred) ->
- match pred with
- | Lib_engine.Match (rule_elem) ->
- if !Flag.track_iso_usage then show_isos rule_elem;
- (nodei, metavars_binding2_to_binding binding2, rule_elem)
- ::prev
+ xs +> List.fold_left (fun prev (index,(nodei, binding2, pred)) ->
+ match pred with
+ | Lib_engine.Match (rule_elem) ->
+ if !Flag.track_iso_usage then show_isos rule_elem;
+ (index,
+ (nodei, metavars_binding2_to_binding binding2, rule_elem))
+ ::prev
(* see BindGood in asttotctl2 *)
- | Lib_engine.BindGood (_) -> prev
- | _ -> raise Impossible
- ) []
+ | Lib_engine.BindGood (_) -> prev
+ | _ -> raise Impossible
+ ) []
(*****************************************************************************)
Lib_engine.model ->
(Lib_engine.ctlcocci * (pred list list)) ->
(Lib_engine.mvar list*Lib_engine.metavars_binding) ->
- (Lib_engine.transformation_info * bool * Lib_engine.metavars_binding *
- Lib_engine.metavars_binding list)) =
+ (Lib_engine.numbered_transformation_info * bool *
+ Lib_engine.metavars_binding * Lib_engine.metavars_binding list)) =
fun (flow, label, states) ctl (used_after, binding) ->
let binding2 = metavars_binding_to_binding2 binding in
let (triples,(trans_info2, returned_any_states, used_after_envs)) =
Lib_engine.model ->
(Lib_engine.ctlcocci * (pred list list)) ->
(Lib_engine.mvar list * Lib_engine.metavars_binding) ->
- (Lib_engine.transformation_info * bool * Lib_engine.metavars_binding *
- Lib_engine.metavars_binding list)
+ (Lib_engine.numbered_transformation_info * bool *
+ Lib_engine.metavars_binding * Lib_engine.metavars_binding list)
val print_bench : unit -> unit
let debug_engine = ref false
+let verbose_matcher = ref true
+
(* false = simpler formulas, only for debugging *)
let useEU = ref true
let allow_inconsistent_paths = ref false
let show_misc = ref true
+
+
+let show_transinfo = ref false
+
type transformation_info =
(nodei * metavars_binding * Ast_cocci.rule_elem) list
+type numbered_transformation_info =
+ (int list * (nodei * metavars_binding * Ast_cocci.rule_elem)) list
+
(*****************************************************************************)
(* comparing binding *)
| Ast_cocci.CONTEXT (pos, xs) ->
assert (pos =*= Ast_cocci.NoPos || pos =*= Ast_cocci.DontCarePos);
Ast_cocci.CONTEXT (posmck, xs)
- | Ast_cocci.MINUS (pos, xs) ->
+ | Ast_cocci.MINUS (pos, inst, adj, xs) ->
assert (pos =*= Ast_cocci.NoPos || pos =*= Ast_cocci.DontCarePos);
- Ast_cocci.MINUS (posmck, xs)
+ Ast_cocci.MINUS (posmck, inst, adj, xs)
let tag_mck_pos_mcode (x,info,mck,pos) posmck stuff = fun tin ->
let collect_used_after used_after envs =
List.map (List.filter (function (v,vl) -> List.mem v used_after)) envs
+(* ----------------------------------------------------------------------- *)
+(* distinguish between distinct witness trees, each gets an index n *)
+
+let numberify trees =
+ let trees =
+ Common.fold_left_with_index
+ (function acc -> function xs -> function n ->
+ (List.map (function x -> (n,x)) xs) @ acc)
+ [] trees in
+ List.fold_left
+ (function res ->
+ function (n,x) ->
+ let (same,diff) = List.partition (function (ns,xs) -> x = xs) res in
+ match same with
+ [(ns,xs)] -> (n::ns,xs)::diff
+ | _ -> ([n],x)::res)
+ [] trees
+
(* ----------------------------------------------------------------------- *)
(* entry point *)
let process used_after inherited_env l =
- extra_counter := 0;
let (trees, fresh_envs) =
List.split (List.map (process_tree inherited_env) l) in
- (Common.uniq(List.concat trees), collect_used_after used_after fresh_envs)
+ let trees = numberify trees in
+ (trees, collect_used_after used_after fresh_envs)
(Ograph_extended.nodei *
(Ast_cocci.meta_name * Lib_engine.metavar_binding_kind2) list *
Lib_engine.predicate) list list ->
- (Ograph_extended.nodei *
- (Ast_cocci.meta_name * Lib_engine.metavar_binding_kind2) list *
- Lib_engine.predicate) list *
+ (int list *
+ (Ograph_extended.nodei *
+ (Ast_cocci.meta_name * Lib_engine.metavar_binding_kind2)
+ list *
+ Lib_engine.predicate)) list *
(Ast_cocci.meta_name * Lib_engine.metavar_binding_kind2) list list
let col = Ast_c.col_of_info ii in
let str = Ast_c.str_of_info ii in
match mck with
- Ast_cocci.MINUS(pos,repl) ->
+ Ast_cocci.MINUS(pos,inst,adj,repl) ->
(match extract_sgrep_marker repl with
(NoMark,_) -> mck
| (BefMark(marker),repl) ->
Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
marker file line col;
- Ast_cocci.MINUS(pos,repl)
+ Ast_cocci.MINUS(pos,inst,adj,repl)
| (AftMark(marker),repl) ->
Printf.printf "Match on line %s ending at %s: line %d offset %d\n"
marker file line (col + String.length str);
- Ast_cocci.MINUS(pos,repl)
+ Ast_cocci.MINUS(pos,inst,adj,repl)
| (BefAftMark(bmarker,amarker),repl) ->
Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
bmarker file line col;
Printf.printf "Match on line %s ending at %s: line %d offset %d\n"
amarker file line (col + String.length str);
- Ast_cocci.MINUS(pos,repl))
+ Ast_cocci.MINUS(pos,inst,adj,repl))
| Ast_cocci.CONTEXT(pos,Ast_cocci.NOTHING) -> mck
| Ast_cocci.CONTEXT(pos,Ast_cocci.BEFORE(bef)) ->
(match extract_sgrep_marker bef with
Printf.printf "Match on line %s starting at %s: line %d offset %d\n"
marker file line col;
(match extract_sgrep_marker aft with
- (NoMark,_) -> Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft))
+ (NoMark,_) ->
+ Ast_cocci.CONTEXT(pos,Ast_cocci.BEFOREAFTER(bef,aft))
| (AftMark(marker),[]) ->
Printf.printf
"Match on line %s ending at %s: line %d offset %d\n"
optional_qualifier_iso : bool;
value_format_iso : bool;
current_rule_name : string; (* used for errors *)
+ index : int list (* witness tree indices *)
}
module XTRANS = struct
let check_pos info mck pos =
match mck with
| Ast_cocci.PLUS -> raise Impossible
- | Ast_cocci.CONTEXT (Ast_cocci.FixPos (i1,i2),_)
- | Ast_cocci.MINUS (Ast_cocci.FixPos (i1,i2),_) ->
+ | Ast_cocci.CONTEXT (Ast_cocci.FixPos (i1,i2),_)
+ | Ast_cocci.MINUS (Ast_cocci.FixPos (i1,i2),_,_,_) ->
pos <= i2 && pos >= i1
- | Ast_cocci.CONTEXT (Ast_cocci.DontCarePos,_)
- | Ast_cocci.MINUS (Ast_cocci.DontCarePos,_) ->
+ | Ast_cocci.CONTEXT (Ast_cocci.DontCarePos,_)
+ | Ast_cocci.MINUS (Ast_cocci.DontCarePos,_,_,_) ->
true
| _ ->
match info with
let tag_with_mck mck ib = fun tin ->
let cocciinforef = ib.Ast_c.cocci_tag in
- let (oldmcode, oldenv) = !cocciinforef in
+ let (oldmcode, oldenv) = Ast_c.mcode_and_env_of_cocciref cocciinforef in
let mck =
(* coccionly:
);
match (oldmcode,mck) with
- | (Ast_cocci.CONTEXT(_,Ast_cocci.NOTHING), _)
+ | (Ast_cocci.CONTEXT(_,Ast_cocci.NOTHING), _)
| (_, Ast_cocci.CONTEXT(_,Ast_cocci.NOTHING))
->
- cocciinforef := (mck, tin.binding);
+ let update_inst inst = function
+ Ast_cocci.MINUS (pos,_,adj,any_xxs) ->
+ Ast_cocci.MINUS (pos,inst,adj,any_xxs)
+ | mck -> mck in
+ cocciinforef := Some (update_inst tin.extra.index mck, tin.binding);
ib
+ | (Ast_cocci.MINUS(old_pos,old_inst,old_adj,[]),
+ Ast_cocci.MINUS(new_pos,new_inst,new_adj,[]))
+ when old_pos = new_pos && oldenv =*= tin.binding
+ (* no way to combine adjacency information, just drop one *)
+ ->
+ cocciinforef := Some
+ (Ast_cocci.MINUS
+ (old_pos,Common.union_set old_inst new_inst,old_adj,[]),
+ tin.binding);
+ (if !Flag_matcher.show_misc
+ then pr2 "already tagged but only removed, so safe");
+ ib
+
| _ ->
- if (oldmcode, oldenv) =*= (mck, tin.binding)
- then begin
- if !Flag_matcher.show_misc
- then pr2 "already tagged but with same mcode, so safe";
- ib
- end
- else
(* coccionly:
if !Flag.sgrep_mode2
then ib (* safe *)
else
*)
begin
- (* coccionly:
- Format.set_formatter_out_channel stderr;
- Common.pr2 "SP mcode ";
- Pretty_print_cocci.print_mcodekind oldmcode;
- Format.print_newline();
- Common.pr2 "C code mcode ";
- Pretty_print_cocci.print_mcodekind mck;
- Format.print_newline();
- Format.print_flush();
- *)
- failwith
+ (* coccionly:
+ pad: if dont want cocci write:
+ failwith
(match Ast_c.pinfo_of_info ib with
Ast_c.FakeTok _ -> "already tagged fake token"
+ *)
+ let pm str mcode env =
+ Printf.sprintf
+ "%s modification:\n%s\nAccording to environment:\n%s\n"
+ str
+ (Common.format_to_string
+ (function _ ->
+ Pretty_print_cocci.print_mcodekind mcode))
+ (String.concat "\n"
+ (List.map
+ (function ((r,vr),vl) ->
+ Printf.sprintf " %s.%s -> %s" r vr
+ (Common.format_to_string
+ (function _ ->
+ Pretty_print_engine.pp_binding_kind vl)))
+ env)) in
+ flush stdout; flush stderr;
+ Common.pr2
+ ("\n"^ (pm "previous" oldmcode oldenv) ^ "\n" ^
+ (pm "current" mck tin.binding));
+ failwith
+ (match Ast_c.pinfo_of_info ib with
+ Ast_c.FakeTok _ ->
+ Common.sprintf "%s: already tagged fake token\n"
+ tin.extra.current_rule_name
| _ ->
- Common.sprintf "%s: already tagged token:\n%s"
+ Printf.sprintf
+ "%s: already tagged token:\nC code context\n%s"
tin.extra.current_rule_name
(Common.error_message (Ast_c.file_of_info ib)
(Ast_c.str_of_info ib, Ast_c.opos_of_info ib)))
let distribute_mck mcodekind distributef expr tin =
match mcodekind with
- | Ast_cocci.MINUS (pos,any_xxs) ->
+ | Ast_cocci.MINUS (pos,_,adj,any_xxs) ->
+ let inst = tin.extra.index in
distributef (
- (fun ib -> tag_with_mck (Ast_cocci.MINUS (pos,any_xxs)) ib tin),
- (fun ib -> tag_with_mck (Ast_cocci.MINUS (pos,[])) ib tin),
- (fun ib -> tag_with_mck (Ast_cocci.MINUS (pos,[])) ib tin),
- (fun ib -> tag_with_mck (Ast_cocci.MINUS (pos,any_xxs)) ib tin)
+ (fun ib ->
+ tag_with_mck (Ast_cocci.MINUS (pos,inst,adj,any_xxs)) ib tin),
+ (fun ib ->
+ tag_with_mck (Ast_cocci.MINUS (pos,inst,adj,[])) ib tin),
+ (fun ib ->
+ tag_with_mck (Ast_cocci.MINUS (pos,inst,adj,[])) ib tin),
+ (fun ib ->
+ tag_with_mck (Ast_cocci.MINUS (pos,inst,adj,any_xxs)) ib tin)
) expr
| Ast_cocci.CONTEXT (pos,any_befaft) ->
(match any_befaft with
let get_pos mck =
match mck with
| Ast_cocci.PLUS -> raise Impossible
- | Ast_cocci.CONTEXT (Ast_cocci.FixPos (i1,i2),_)
- | Ast_cocci.MINUS (Ast_cocci.FixPos (i1,i2),_) ->
+ | Ast_cocci.CONTEXT (Ast_cocci.FixPos (i1,i2),_)
+ | Ast_cocci.MINUS (Ast_cocci.FixPos (i1,i2),_,_,_) ->
Ast_cocci.FixPos (i1,i2)
- | Ast_cocci.CONTEXT (Ast_cocci.DontCarePos,_)
- | Ast_cocci.MINUS (Ast_cocci.DontCarePos,_) ->
+ | Ast_cocci.CONTEXT (Ast_cocci.DontCarePos,_)
+ | Ast_cocci.MINUS (Ast_cocci.DontCarePos,_,_,_) ->
Ast_cocci.DontCarePos
| _ -> failwith "weird: dont have position info for the mcodekind"
let (transform2: string (* rule name *) -> string list (* dropped_isos *) ->
Lib_engine.metavars_binding (* inherited bindings *) ->
- Lib_engine.transformation_info -> F.cflow -> F.cflow) =
+ Lib_engine.numbered_transformation_info -> F.cflow -> F.cflow) =
fun rule_name dropped_isos binding0 xs cflow ->
let extra = {
optional_qualifier_iso = not(List.mem "optional_qualifier" dropped_isos);
value_format_iso = not(List.mem "value_format" dropped_isos);
current_rule_name = rule_name;
+ index = [];
} in
(* find the node, transform, update the node, and iter for all elements *)
- xs +> List.fold_left (fun acc (nodei, binding, rule_elem) ->
+ xs +> List.fold_left (fun acc (index, (nodei, binding, rule_elem)) ->
(* subtil: not cflow#nodes but acc#nodes *)
let node = acc#nodes#assoc nodei in
if !Flag.show_transinfo
then pr2 "transform one node";
-
+
let tin = {
- XTRANS.extra = extra;
+ XTRANS.extra = {extra with index = index};
XTRANS.binding = binding0@binding;
XTRANS.binding0 = []; (* not used - everything constant for trans *)
} in
val transform :
string (* rule name *) -> string list (* dropped isos *) ->
Lib_engine.metavars_binding -> (* inherited bindings *)
- Lib_engine.transformation_info ->
+ Lib_engine.numbered_transformation_info ->
Control_flow_c.cflow -> Control_flow_c.cflow (* could be unit *)
let show_binding_in_out = ref false
let show_dependencies = ref false
+let verbose_cocci = ref true
+
let windows = ref false
let popl = ref false
-let ifdef_to_if = ref false
+let ifdef_to_if = ref true(*false*)
type include_options =
I_UNSPECIFIED | I_NO_INCLUDES | I_NORMAL_INCLUDES | I_ALL_INCLUDES
-let version = "0.1.7"
+let version = "0.1.8"
let path =
try (Sys.getenv "COCCINELLE_HOME")
make
make install
-Note: 'make' will compile the bytecode version by default.
- You could use 'make all.opt' to have the optimized version.
- If you compile both, 'make install' will take care of that
- and install both, spatch and spatch.opt.
- If you use only one of them, 'make install' will install
- the one you have compiled, either spatch ou spatch.opt,
- under the front-end spatch. You could use 'make world' to
- compile the bytecode and the native code version.
+
+
+
+'make' will compile the bytecode version by default.
+You could use 'make all.opt' to have the optimized version.
+If you compile both, 'make install' will take care of that
+and install both, spatch and spatch.opt.
+If you use only one of them, 'make install' will install
+the one you have compiled, either spatch ou spatch.opt,
+under the front-end spatch. You could use 'make world' to
+compile the bytecode and the optimized code version.
+
+We provide the files generated by menhir in the tarball.
+However, 'make distclean' will remove them. You could
+either restore them from the tarball or install menhir.
+Using 'make clean' should be safe with regards to these files.
let inplace_modif = ref false (* but keeps a .cocci_orig *)
let outplace_modif = ref false (* generates a .cocci_res *)
-(* could be avoided by using Common.files_of_dir_or_files instead *)
+(* somehow obsolete now *)
let dir = ref false
let include_headers = ref false
let kbuild_info = ref ""
+let macro_file = ref ""
+
(* test mode *)
let test_mode = ref false
let test_all = ref false
let test_okfailed = ref false
let test_regression_okfailed = ref false
+let expected_score_file = ref ""
(* action mode *)
(* works with -test but also in "normal" spatch mode *)
let compare_with_expected = ref false
-
let distrib_index = ref (None : int option)
let distrib_max = ref (None : int option)
let mod_distrib = ref false
FC.show_ctl_text;
FC.show_binding_in_out;
+ FC.verbose_cocci;
+
+ Flag_parsing_c.show_parsing_error;
+
+ Flag_parsing_c.verbose_lexing;
+ Flag_parsing_c.verbose_parsing;
+ Flag_parsing_c.verbose_type;
+ Flag_parsing_c.verbose_cfg;
+ Flag_parsing_c.verbose_unparsing;
+ Flag_parsing_c.verbose_visit;
+
+ Flag_matcher.verbose_matcher;
+ Flag_matcher.debug_engine;
+
+ Flag_parsing_c.debug_unparsing;
+
Flag_parsing_cocci.show_SP;
Flag_parsing_cocci.show_iso_failures;
+
Flag_ctl.verbose_ctl_engine;
Flag_ctl.verbose_match;
- Flag_matcher.debug_engine;
- Flag_parsing_c.debug_unparsing;
- Flag_parsing_c.verbose_type;
- Flag_parsing_c.verbose_parsing;
+
+
])
(* some information that is useful in seeing why a semantic patch doesn't
let debug_profile = (
[
Flag.show_misc;
+ Flag.show_transinfo;
+
FC.show_diff;
FC.show_cocci;
FC.show_binding_in_out;
FC.show_dependencies;
- Flag.show_transinfo;
+
Flag_parsing_cocci.show_iso_failures;
+
+ FC.verbose_cocci;
+
+ Flag_parsing_c.verbose_cfg;
+ Flag_parsing_c.verbose_unparsing;
+ Flag_parsing_c.verbose_visit;
+
+ Flag_matcher.verbose_matcher;
+
+ Flag_parsing_c.show_parsing_error;
],
[
"-iso_file", Arg.Set_string Config.std_iso,
" <file> (default=" ^ !Config.std_iso ^")";
- "-macro_file", Arg.Set_string Config.std_h,
+ "-macro_file", Arg.Set_string macro_file,
+ " <file>";
+ "-macro_file_builtins", Arg.Set_string Config.std_h,
" <file> (default=" ^ !Config.std_h ^ ")";
"-all_includes",
" guess what";
"-date", Arg.Unit (fun () ->
- pr2 "version: $Date: 2009/04/15 18:01:55 $";
+ pr2 "version: $Date: 2009/05/08 16:15:31 $";
raise (Common.UnixExit 0)
),
" guess what";
"aliases and obsolete options",
"",
[
+ "-sp", Arg.Set_string cocci_file, " short option of -sp_file";
+ "-iso", Arg.Set_string Config.std_iso, " short option of -iso_file";
+
"-cocci_file", Arg.Set_string cocci_file,
" <file> the semantic patch file";
- "-c", Arg.Set_string cocci_file, " short option of -cocci_file";
- "-iso", Arg.Set_string Config.std_iso, " short option of -iso_file";
- "-D", Arg.Set_string Config.std_h, " short option of -macro_file";
+ "-c", Arg.Set_string cocci_file, " short option of -sp_file";
];
"most useful show options",
"-filter_msg", Arg.Set Flag_parsing_c.filter_msg ,
" filter some cpp message when the macro is a \"known\" cpp construct";
"-filter_define_error",Arg.Set Flag_parsing_c.filter_define_error," ";
+ "-filter_msg_define_error",Arg.Set Flag_parsing_c.filter_msg_define_error,
+ " filter the error msg";
"-filter_passed_level", Arg.Set_int Flag_parsing_c.filter_passed_level," ";
(* debug cfg doesn't seem to have any effect, so drop it as an option *)
(* "-debug_cfg", Arg.Set Flag_parsing_c.debug_cfg , " "; *)
"-l1", Arg.Clear Flag_parsing_c.label_strategy_2, " ";
"-ifdef_to_if", Arg.Set FC.ifdef_to_if,
" convert ifdef to if (experimental)";
+ "-no_ifdef_to_if", Arg.Clear FC.ifdef_to_if,
+ " convert ifdef to if (experimental)";
+
+ "-disable_multi_pass", Arg.Set Flag_parsing_c.disable_multi_pass, " ";
"-noif0_passing", Arg.Clear Flag_parsing_c.if0_passing,
" ";
any way of printing things out *)
"-allow_inconsistent_paths",
Arg.Set Flag_matcher.allow_inconsistent_paths,
- "if this flag is set don't check for inconsistent paths; dangerous";
+ " if this flag is set don't check for inconsistent paths; dangerous";
+ "-int_bits", Arg.Int Flag_parsing_c.set_int_bits,
+ " the number of bits in an unsigned int";
+ "-long_bits", Arg.Int Flag_parsing_c.set_long_bits,
+ " the number of bits in an unsigned long";
+ "-linux_spacing", Arg.Unit Flag_parsing_c.set_linux_spacing,
+ " spacing of + code follows the conventions of Linux";
+ "-smpl_spacing", Arg.Unit Flag_parsing_c.set_smpl_spacing,
+ " spacing of + code follows the semantic patch";
];
"misc options",
" option to set if launch spatch in ocamldebug";
"-disable_once", Arg.Set Common.disable_pr2_once,
" to print more messages";
+ "-show_trace_profile", Arg.Set Common.show_trace_profile,
+ " show trace";
"-save_tmp_files", Arg.Set Common.save_tmp_files, " ";
];
"-compare_with_expected", Arg.Set compare_with_expected,
" use also file.res";
+ "-expected_score_file", Arg.Set_string expected_score_file,
+ " which score file to compare with in -testall";
"-relax_include_path", Arg.Set FC.relax_include_path,
" ";
let all_options =
short_options ++ List.concat (List.map Common.thd3 other_options)
-
(* I don't want the -help and --help that are appended by Arg.align *)
let arg_align2 xs =
let main_action xs =
match xs with
| x::xs ->
- adjust_stdin x (fun () ->
- if !cocci_file =$= ""
- then failwith "I need a cocci file, use -sp_file <file>";
-
- if !dir && !Flag.patch =*= None
- then
- (match xs with
- | [] -> Flag.patch := Some x
- | _ ->
- pr2
- ("warning: patch output can only be created when only one\n"^
- "directory is specified or when the -patch flag is used")
- );
-
- let infiles =
- Common.profile_code "Main.infiles computation" (fun () ->
- match !dir, !kbuild_info, !Flag.use_glimpse with
- (* glimpse *)
- | false, _, true ->
- failwith "-use_glimpse works only with -dir"
- | true, s, true when s <> "" ->
- failwith "-use_glimpse does not work with -kbuild"
- | true, "", true ->
- if not (null xs)
- then failwith "-use_glimpse can accept only one dir";
-
- Flag.dir := x;
- let files =
- match glimpse_filter (!cocci_file, !Config.std_iso) x with
- None ->
- Common.cmd_to_list (* same as "true, "", _" case *)
- (if !include_headers
- (* FIXME : Could we remove xs ?
- -use_glimpse requires a singleton.
- This is checked some lines before.
- then ("find "^(join " " (x::xs))^" -name \"*.[ch]\"")
- else ("find "^(join " " (x::xs))^" -name \"*.c\""))
- *)
- then ("find "^ x ^" -name \"*.[ch]\"")
- else ("find "^ x ^" -name \"*.c\""))
- | Some files -> files in
- files +> List.map (fun x -> [x])
- (* normal *)
- | false, _, _ -> [x::xs]
- | true, "", _ ->
- Common.cmd_to_list
- (if !include_headers
- then ("find "^(join " " (x::xs))^" -name \"*.[ch]\"")
+
+ (* a more general solution would be to use
+ * Common.files_of_dir_or_files (x::xs)
+ * as some elements in xs may also be directories, or individual
+ * files.
+ *)
+ if Common.is_directory x
+ then dir := true;
+
+ adjust_stdin x (fun () ->
+ if !cocci_file =$= ""
+ then failwith "I need a cocci file, use -sp_file <file>";
+
+ if !dir && !Flag.patch =*= None
+ then
+ (match xs with
+ | [] -> Flag.patch := Some x
+ | _ ->
+ pr2
+ ("warning: patch output can only be created when only one\n"^
+ "directory is specified or when the -patch flag is used")
+ );
+
+ let infiles =
+ Common.profile_code "Main.infiles computation" (fun () ->
+ match !dir, !kbuild_info, !Flag.use_glimpse with
+ (* glimpse *)
+ | false, _, true ->
+ failwith "-use_glimpse works only with -dir"
+ | true, s, true when s <> "" ->
+ failwith "-use_glimpse does not work with -kbuild"
+ | true, "", true ->
+ if not (null xs)
+ then failwith "-use_glimpse can accept only one dir";
+
+ Flag.dir := x;
+ let files =
+ match glimpse_filter (!cocci_file, !Config.std_iso) x with
+ None ->
+ Common.cmd_to_list (* same as "true, "", _" case *)
+ (if !include_headers
+ (* FIXME : Could we remove xs ?
+ -use_glimpse requires a singleton.
+ This is checked some lines before.
+ then ("find "^(join " " (x::xs))^" -name \"*.[ch]\"")
+ else ("find "^(join " " (x::xs))^" -name \"*.c\""))
+ *)
+ then ("find "^ x ^" -name \"*.[ch]\"")
+ else ("find "^ x ^" -name \"*.c\""))
+ | Some files -> files in
+ files +> List.map (fun x -> [x])
+ (* normal *)
+ | false, _, _ -> [x::xs]
+ | true, "", _ ->
+ Common.cmd_to_list
+ (if !include_headers
+ then ("find "^(join " " (x::xs))^" -name \"*.[ch]\"")
else ("find "^(join " " (x::xs))^" -name \"*.c\""))
- +> List.map (fun x -> [x])
-
- (* kbuild *)
- | true, kbuild_info_file,_ ->
- let dirs =
- Common.cmd_to_list ("find "^(join " " (x::xs))^" -type d")
- in
- let info = Kbuild.parse_kbuild_info kbuild_info_file in
- let groups = Kbuild.files_in_dirs dirs info in
-
- groups +> List.map (function Kbuild.Group xs -> xs)
- )
- in
-
- let infiles =
- match (!distrib_index,!distrib_max) with
- (None,None) -> infiles
- | (Some index,Some max) ->
- (if index >= max
- then
- failwith "index starts at 0, and so must be less than max");
- if !mod_distrib
- then
+ +> List.map (fun x -> [x])
+
+ (* kbuild *)
+ | true, kbuild_info_file,_ ->
+ let dirs =
+ Common.cmd_to_list ("find "^(join " " (x::xs))^" -type d")
+ in
+ let info = Kbuild.parse_kbuild_info kbuild_info_file in
+ let groups = Kbuild.files_in_dirs dirs info in
+
+ groups +> List.map (function Kbuild.Group xs -> xs)
+ )
+ in
+
+ let infiles =
+ match (!distrib_index,!distrib_max) with
+ (None,None) -> infiles
+ | (Some index,Some max) ->
+ (if index >= max
+ then
+ failwith "index starts at 0, and so must be less than max");
+ if !mod_distrib
+ then
+ let rec loop ct = function
+ [] -> []
+ | x::xs ->
+ if (ct mod max) =|= index
+ then x::(loop (ct+1) xs)
+ else loop (ct+1) xs in
+ loop 0 infiles
+ else
+ begin
+ let all_files = List.length infiles in
+ let regions = (all_files + (max - 1)) / max in
+ let this_min = index * regions in
+ let this_max = (index+1) * regions in
let rec loop ct = function
- [] -> []
+ [] -> []
| x::xs ->
- if (ct mod max) =|= index
+ if this_min <= ct && ct < this_max
then x::(loop (ct+1) xs)
else loop (ct+1) xs in
loop 0 infiles
- else
- begin
- let all_files = List.length infiles in
- let regions = (all_files + (max - 1)) / max in
- let this_min = index * regions in
- let this_max = (index+1) * regions in
- let rec loop ct = function
- [] -> []
- | x::xs ->
- if this_min <= ct && ct < this_max
- then x::(loop (ct+1) xs)
- else loop (ct+1) xs in
- loop 0 infiles
- end
- | _ -> failwith "inconsistent distribution information" in
-
- let outfiles =
- Common.profile_code "Main.outfiles computation" (fun () ->
- let cocci_infos =
- Cocci.pre_engine (!cocci_file, !Config.std_iso) in
- let res =
- infiles +> List.map (fun cfiles ->
- pr2 ("HANDLING: " ^ (join " " cfiles));
- Common.timeout_function_opt !FC.timeout (fun () ->
- Common.report_if_take_time 10 (join " " cfiles) (fun () ->
+ end
+ | _ -> failwith "inconsistent distribution information" in
+
+ let outfiles =
+ Common.profile_code "Main.outfiles computation" (fun () ->
+ let cocci_infos =
+ Cocci.pre_engine (!cocci_file, !Config.std_iso) in
+ let res =
+ infiles +> List.map (fun cfiles ->
+ pr2 ("HANDLING: " ^ (join " " cfiles));
+ Common.timeout_function_opt !FC.timeout (fun () ->
+ Common.report_if_take_time 10 (join " " cfiles) (fun () ->
(* Unix.sleep 1; *)
- try
- (* this is the main call *)
- Cocci.full_engine cocci_infos cfiles
- with
- | Common.UnixExit x -> raise (Common.UnixExit x)
- | e ->
- if !dir
- then begin
- pr2 ("EXN:" ^ Printexc.to_string e);
- [] (* *)
- end
- else raise e))) in
- Cocci.post_engine cocci_infos;
- res
- ) +> List.concat
- in
-
- Common.profile_code "Main.result analysis" (fun () ->
-
- Ctlcocci_integration.print_bench();
+ try
+ (* this is the main call *)
+ Cocci.full_engine cocci_infos cfiles
+ with
+ | Common.UnixExit x -> raise (Common.UnixExit x)
+ | e ->
+ if !dir
+ then begin
+ pr2 ("EXN:" ^ Printexc.to_string e);
+ [] (* *)
+ end
+ else raise e))) in
+ Cocci.post_engine cocci_infos;
+ res
+ ) +> List.concat
+ in
+
+ Common.profile_code "Main.result analysis" (fun () ->
+
+ Ctlcocci_integration.print_bench();
+
+ let outfiles = Cocci.check_duplicate_modif outfiles in
+
+ outfiles +> List.iter (fun (infile, outopt) ->
+ outopt +> Common.do_option (fun outfile ->
+ if !inplace_modif
+ then begin
+ Common.command2 ("cp "^infile^" "^infile^".cocci_orig");
+ Common.command2 ("cp "^outfile^" "^infile);
+ end;
+
+ if !outplace_modif
+ then Common.command2 ("cp "^outfile^" "^infile^".cocci_res");
- let outfiles = Cocci.check_duplicate_modif outfiles in
-
- outfiles +> List.iter (fun (infile, outopt) ->
- outopt +> Common.do_option (fun outfile ->
- if !inplace_modif
- then begin
- Common.command2 ("cp "^infile^" "^infile^".cocci_orig");
- Common.command2 ("cp "^outfile^" "^infile);
- end;
-
- if !outplace_modif
- then Common.command2 ("cp "^outfile^" "^infile^".cocci_res");
-
- if !output_file =$= ""
- then begin
- let tmpfile = "/tmp/"^Common.basename infile in
- pr2 (spf "One file modified. Result is here: %s" tmpfile);
- Common.command2 ("cp "^outfile^" "^tmpfile);
- end
- ));
- if !output_file <> "" then
- (match outfiles with
- | [infile, Some outfile] when infile =$= x && null xs ->
- Common.command2 ("cp " ^outfile^ " " ^ !output_file);
- | [infile, None] when infile =$= x && null xs ->
- Common.command2 ("cp " ^infile^ " " ^ !output_file);
- | _ ->
- failwith
- ("-o can not be applied because there is multiple " ^
- "modified files");
- );
-
- if !compare_with_expected
- then Testing.compare_with_expected outfiles))
+ if !output_file =$= ""
+ then begin
+ let tmpfile = "/tmp/"^Common.basename infile in
+ pr2 (spf "One file modified. Result is here: %s" tmpfile);
+ Common.command2 ("cp "^outfile^" "^tmpfile);
+ end
+ ));
+ if !output_file <> "" then
+ (match outfiles with
+ | [infile, Some outfile] when infile =$= x && null xs ->
+ Common.command2 ("cp " ^outfile^ " " ^ !output_file);
+ | [infile, None] when infile =$= x && null xs ->
+ Common.command2 ("cp " ^infile^ " " ^ !output_file);
+ | _ ->
+ failwith
+ ("-o can not be applied because there is multiple " ^
+ "modified files");
+ );
+
+ if !compare_with_expected
+ then Testing.compare_with_expected outfiles))
| [] -> raise Impossible
let args = ref [] in
+ (* Gc.set {(Gc.get ()) with Gc.stack_limit = 1024 * 1024};*)
+
(* this call can set up many global flag variables via the cmd line *)
arg_parse2 (Arg.align all_options) (fun x -> args := x::!args) usage_msg;
+ (* julia hack so that one can override directories specified on
+ * the command line. *)
(if !dir
then
let chosen_dir =
else List.hd !args in
if !FC.include_path =*= None
then FC.include_path := Some (Filename.concat chosen_dir "include"));
+
args := List.rev !args;
if !cocci_file <> "" && (not (!cocci_file =~ ".*\\.\\(sgrep\\|spatch\\)$"))
then Config.std_h := Common.adjust_ext_if_needed !Config.std_h ".h";
if !Config.std_h <> ""
- then Parse_c.init_defs !Config.std_h;
+ then Parse_c.init_defs_builtins !Config.std_h;
+
+ if !macro_file <> ""
+ then Parse_c.init_defs_macros !macro_file;
(* must be done after Arg.parse, because Common.profile is set by it *)
| [] when !test_all ->
FC.include_path := Some "tests/include";
- Testing.testall ()
+ if !expected_score_file <> ""
+ then Testing.testall ~expected_score_file:!expected_score_file ()
+ else Testing.testall ()
| [] when !test_regression_okfailed ->
Testing.test_regression_okfailed ()
end
end
+
+let main_with_better_error_report () =
+ if !Common.debugger then main ()
+ else
+ try
+ main ()
+ with
+ | Unix.Unix_error (_, "stat", filename) ->
+ pr2 (spf "ERROR: File %s does not exist" filename);
+ raise (UnixExit (-1))
+
+
(*****************************************************************************)
-let _ =
+let start =
Common.main_boilerplate (fun () ->
- main ();
+ main_with_better_error_report ();
Ctlcocci_integration.print_bench();
)
##############################################################################
# Generic variables
##############################################################################
-OCAMLCFLAGS=-g -dtypes
+OCAMLCFLAGS ?=-g -dtypes
OPTFLAGS=
OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
##############################################################################
#dont use -custom, it makes the bytecode unportable.
-OCAMLCFLAGS= -g -dtypes # -w A
+OCAMLCFLAGS ?= -g -dtypes # -w A
#-for-pack Sexplib
# This flag is also used in subdirectories so don't change its name here.
# special handling, fun that they use cpp whereas they claim camplp4 can do everything
pre_sexp.cmo: pre_sexp.ml
- $(OCAMLC) -pp cpp -c $<
+ $(OCAMLC) -pp "cpp -w" -c $<
pre_sexp.cmx: pre_sexp.ml
- $(OCAMLOPT) -pp cpp -c $<
+ $(OCAMLOPT) -pp "cpp -w" -c $<
# need also -pp cpp here
depend:: beforedepend
- $(OCAMLDEP) -pp cpp *.mli *.ml > .depend
+ $(OCAMLDEP) -pp "cpp -w" *.mli *.ml > .depend
distclean: clean
rm -f .depend
# - type_cocci.ml ast_cocci.ml # + unparse_hrule
SRC= flag_parsing_c.ml parsing_stat.ml \
- token_c.ml ast_c.ml control_flow_c.ml type_c.ml \
+ token_c.ml ast_c.ml control_flow_c.ml \
visitor_c.ml lib_parsing_c.ml \
- ast_to_flow.ml \
+ control_flow_c_build.ml \
pretty_print_c.ml \
semantic_c.ml lexer_parser.ml parser_c.ml lexer_c.ml \
- token_helpers.ml parsing_hacks.ml \
+ token_helpers.ml token_views_c.ml \
+ cpp_token_c.ml parsing_hacks.ml \
unparse_cocci.ml unparse_c.ml unparse_hrule.ml \
- parse_c.ml \
+ parse_c.ml type_c.ml \
cpp_ast_c.ml \
type_annoter_c.ml comment_annotater_c.ml \
compare_c.ml \
#LIBS=../commons/commons.cma
#INCLUDES= -I ../commons
-SYSLIBS= str.cma unix.cma
+SYSLIBS= str.cma unix.cma num.cma
##############################################################################
# Generic variables
clean::
rm -f $(TARGET).top
-
-
lexer_c.ml: lexer_c.mll
$(OCAMLLEX) $<
clean::
beforedepend::
+distclean::
+ rm -f .depend
+
depend:: beforedepend
$(OCAMLDEP) *.mli *.ml > .depend
(* forunparser: *)
type posl = int * int (* line-col, for MetaPosValList, for position variables *)
+ (* with sexp *)
(* the virtual position is set in Parsing_hacks.insert_virtual_positions *)
type virtual_position = Common.parse_info * int (* character offset *)
+ (* with sexp *)
type parse_info =
(* Present both in ast and list of tokens *)
* are used to be able to use '=' to compare big ast portions.
*)
| AbstractLineTok of Common.parse_info (* local to the abstracted thing *)
+ (* with sexp *)
type info = {
pinfo : parse_info;
(* this cocci_tag can be changed, which is how we can express some program
* transformations by tagging the tokens involved in this transformation.
*)
- cocci_tag: (Ast_cocci.mcodekind * metavars_binding) ref;
+ cocci_tag: (Ast_cocci.mcodekind * metavars_binding) option ref;
(* set in comment_annotater_c.ml *)
comments_tag: comments_around ref;
(* wrap2 is like wrap, except that I use it often for separator such
* as ','. In that case the info is associated to the argument that
- * follows, so in 'a,b' I will have in the list [(a,[]); (b,[','])]. *)
+ * follows, so in 'a,b' I will have in the list [(a,[]); (b,[','])].
+ *
+ * wrap3 is like wrap, except that I use it in case sometimes it
+ * will be empty because the info will be included in a nested
+ * entity (e.g. for Ident in expr because it's inlined in the name)
+ * so user should never assume List.length wrap3 > 0.
+ *)
and 'a wrap = 'a * il
and 'a wrap2 = 'a * il
+and 'a wrap3 = 'a * il (* * evotype*)
(* ------------------------------------------------------------------------- *)
(* Name *)
(* was called 'ident' before, but 'name' is I think better
* as concatenated strings can be used not only for identifiers and for
* declarators, but also for fields, for labels, etc.
+ *
+ * Note: because now the info is embeded in the name, the info for
+ * expression like Ident, or types like Typename, are not anymore
+ * stored in the expression or type. Hence if you assume this,
+ * which was true before, you are now wrong. So never write code like
+ * let (unwrape,_), ii = e and use 'ii' believing it contains
+ * the local ii to e. If you want to do that, use the appropiate
+ * wrapper get_local_ii_of_expr_inlining_ii_of_name.
*)
and name =
| RegularName of string wrap
and fullType = typeQualifier * typeC
- and typeC = typeCbis wrap
+ and typeC = typeCbis wrap (* todo reput wrap3 *)
and typeCbis =
| BaseType of baseType
(* -------------------------------------- *)
and structUnion = Struct | Union
and structType = field list
- and field = fieldbis wrap
- and fieldbis =
+ and field =
| DeclarationField of field_declaration
(* gccext: *)
- | EmptyField
+ | EmptyField of info
(* cppext: *)
- | MacroStructDeclTodo
+ | MacroDeclField of (string * argument wrap2 list)
+ wrap (* optional ';'*)
(* cppext: *)
| CppDirectiveStruct of cpp_directive
(* ------------------------------------------------------------------------- *)
(* C expression *)
(* ------------------------------------------------------------------------- *)
-and expression = (expressionbis * exp_info ref (* semantic: *)) wrap
+and expression = (expressionbis * exp_info ref (* semantic: *)) wrap3
and exp_info = exp_type option * test
and exp_type = fullType (* Type_c.completed_and_simplified *) * local
and local = LocalVar of parse_info | NotLocalVar (* cocci: *)
| Cast of fullType * expression
(* gccext: *)
- | StatementExpr of compound wrap (* (Â ) new scope *)
+ | StatementExpr of compound wrap (* ( ) new scope *)
| Constructor of fullType * initialiser wrap2 (* , *) list
(* forunparser: *)
(* cppext: IfdefExpr TODO *)
(* cppext: normmally just expression *)
- and argument = (expression, weird_argument) either
+ and argument = (expression, weird_argument) Common.either
and weird_argument =
| ArgType of parameterType
| ArgAction of action_macro
| String of (string * isWchar)
| MultiString of string list (* can contain MacroString, todo: more info *)
| Char of (string * isWchar) (* normally it is equivalent to Int *)
- | Int of (string (* * intType*))
+ | Int of (string * intType)
| Float of (string * floatType)
and isWchar = IsWchar | IsChar
*
*)
-and statement = statementbis wrap
+and statement = statementbis wrap3
and statementbis =
| Labeled of labeled
| Compound of compound (* new scope *)
and declaration =
| DeclList of onedecl wrap2 (* , *) list wrap (* ; fakestart sto *)
(* cppext: *)
- | MacroDecl of (string * argument wrap2 list) wrap
+ | MacroDecl of (string * argument wrap2 list) wrap (* fakestart *)
and onedecl =
{ v_namei: (name * (info (* = *) * initialiser) option) option;
and definition = definitionbis wrap (* ( ) { } fakestart sto *)
and definitionbis =
{ f_name: name;
- f_type: functionType; (* todo? a functionType2 ? *)
+ f_type: functionType; (* less? a functionType2 ? *)
f_storage: storage;
f_body: compound;
f_attr: attribute list; (* gccext: *)
| PragmaAndCo of il
(*| Ifdef ? no, ifdefs are handled differently, cf ifdef_directive below *)
-and define = string wrap (* #define s *) * (define_kind * define_val)
+and define = string wrap (* #define s eol *) * (define_kind * define_val)
and define_kind =
| DefineVar
| DefineFunc of ((string wrap) wrap2 list) wrap (* () *)
(* ------------------------------------------------------------------------- *)
and program = toplevel list
-
(*****************************************************************************)
(* Cocci Bindings *)
(*****************************************************************************)
and comments_around = {
mbefore: Token_c.comment_like_token list;
mafter: Token_c.comment_like_token list;
-}
-(* old: can do something simpler than CComment for coccinelle, cf above.
- mbefore: comment_and_relative_pos list;
- mafter: comment_and_relative_pos list;
+
+ (* less: could remove ? do something simpler than CComment for
+ * coccinelle, cf above. *)
+ mbefore2: comment_and_relative_pos list;
+ mafter2: comment_and_relative_pos list;
+ }
and comment_and_relative_pos = {
minfo: Common.parse_info;
* cppbetween: bool; touse? if false positive
* is_alone_in_line: bool; (*for labels, to avoid false positive*)
*)
- }
+ }
and comment = Common.parse_info
and com = comment list ref
-*)
-
+ (* with sexp *)
(*****************************************************************************)
let noInstr = (ExprStatement (None), [])
let noTypedefDef () = None
-
let emptyMetavarsBinding =
([]: metavars_binding)
-let emptyAnnot =
+let emptyAnnotCocci =
(Ast_cocci.CONTEXT (Ast_cocci.NoPos,Ast_cocci.NOTHING),
emptyMetavarsBinding)
+let emptyAnnot =
+ (None: (Ast_cocci.mcodekind * metavars_binding) option)
+
+(* compatibility mode *)
+let mcode_and_env_of_cocciref aref =
+ match !aref with
+ | Some x -> x
+ | None -> emptyAnnotCocci
+
+
let emptyComments= {
mbefore = [];
mafter = [];
+ mbefore2 = [];
+ mafter2 = [];
}
let unwrap2 = fst
-
let unwrap_expr ((unwrap_e, typ), iie) = unwrap_e
let rewrap_expr ((_old_unwrap_e, typ), iie) newe = ((newe, typ), iie)
+let unwrap_typeC (qu, (typeC, ii)) = typeC
+let rewrap_typeC (qu, (typeC, ii)) newtypeC = (qu, (newtypeC, ii))
+
+let unwrap_typeCbis (typeC, ii) = typeC
+
+let unwrap_st (unwrap_st, ii) = unwrap_st
+
+(* ------------------------------------------------------------------------- *)
+let mk_e unwrap_e ii = (unwrap_e, noType()), ii
+let mk_e_bis unwrap_e ty ii = (unwrap_e, ty), ii
+
+let mk_ty typeC ii = nQ, (typeC, ii)
+let mk_tybis typeC ii = (typeC, ii)
+
+let mk_st unwrap_st ii = (unwrap_st, ii)
+
+(* ------------------------------------------------------------------------- *)
+let get_ii_typeC_take_care (typeC, ii) = ii
+let get_ii_st_take_care (st, ii) = ii
+let get_ii_expr_take_care (e, ii) = ii
+
+let get_st_and_ii (st, ii) = st, ii
+let get_ty_and_ii (qu, (typeC, ii)) = qu, (typeC, ii)
+let get_e_and_ii (e, ii) = e, ii
+
+
+(* ------------------------------------------------------------------------- *)
let get_type_expr ((unwrap_e, typ), iie) = !typ
let set_type_expr ((unwrap_e, oldtyp), iie) newtyp =
oldtyp := newtyp
| Some (ft,local), _test -> Some local
| None, _ -> None
-
-
-let unwrap_typeC (qu, (typeC, ii)) = typeC
-let rewrap_typeC (qu, (typeC, ii)) newtypeC = (qu, (newtypeC, ii))
-
-
(* ------------------------------------------------------------------------- *)
let rewrap_str s ii =
{ii with pinfo =
let rewrap_pinfo pi ii =
{ii with pinfo = pi}
+
+
(* info about the current location *)
let get_pi = function
OriginTok pi -> pi
(* original info *)
let get_opi = function
OriginTok pi -> pi
- | ExpandedTok (pi,_) -> pi
+ | ExpandedTok (pi,_) -> pi (* diff with get_pi *)
| FakeTok (_,_) -> failwith "no position information"
| AbstractLineTok pi -> pi
let get_orig_info f ii =
match ii.pinfo with
OriginTok pi -> f pi
- | ExpandedTok (pi,_) -> f pi
+ | ExpandedTok (pi,_) -> f pi (* diff with get_info *)
| FakeTok (_,(pi,_)) -> f pi
| AbstractLineTok pi -> f pi
let line_of_info ii = get_orig_info (function x -> x.Common.line) ii
let col_of_info ii = get_orig_info (function x -> x.Common.column) ii
let file_of_info ii = get_orig_info (function x -> x.Common.file) ii
-let mcode_of_info ii = fst (!(ii.cocci_tag))
+let mcode_of_info ii = fst (mcode_and_env_of_cocciref ii.cocci_tag)
let pinfo_of_info ii = ii.pinfo
let parse_info_of_info ii = get_pi ii.pinfo
(* cocci: *)
let is_test (e : expression) =
- let (_,info) = unwrap e in
+ let (_,info), _ = e in
let (_,test) = !info in
test =*= Test
Common.line = magic_real_number;
Common.column = magic_real_number}) in
{mbefore = []; (* duplicates mafter of the previous token *)
- mafter = List.map al_com (keep_cpp x.mafter)}
+ mafter = List.map al_com (keep_cpp x.mafter);
+ mbefore2=[];
+ mafter2=[];
+ }
let al_info_cpp tokenindex x =
{ pinfo =
(* Helpers, could also be put in lib_parsing_c.ml instead *)
(*****************************************************************************)
-let rec stmt_elems_of_sequencable xs =
- xs +> Common.map (fun x ->
- match x with
- | StmtElem e -> [e]
- | CppDirectiveStmt _
- | IfdefStmt _
- ->
- pr2_once ("stmt_elems_of_sequencable: filter a directive");
- []
- | IfdefStmt2 (_ifdef, xxs) ->
- pr2 ("stmt_elems_of_sequencable: IfdefStm2 TODO?");
- xxs +> List.map (fun xs ->
- let xs' = stmt_elems_of_sequencable xs in
- xs'
- ) +> List.flatten
- ) +> List.flatten
-
-
-
-
(* should maybe be in pretty_print_c ? *)
let s_of_inc_file inc_file =
+> List.map (fun (Attribute s, ii) -> s)
+> Common.join ","
+
+(* ------------------------------------------------------------------------- *)
let str_of_name ident =
match ident with
| RegularName (s,ii) -> s
(xs +> List.map (fun ((x,iix), iicomma) -> x) +> Common.join ",") ^
")"
-let info_of_name ident =
- match ident with
- | RegularName (s,ii) -> List.hd ii
+let get_s_and_ii_of_name name =
+ match name with
+ | RegularName (s, iis) -> s, iis
+ | CppIdentBuilder ((s, iis), xs) -> s, iis
+ | CppVariadicName (s,iis) ->
+ let (iop, iis) = Common.tuple_of_list2 iis in
+ s, [iis]
| CppConcatenatedName xs ->
(match xs with
| [] -> raise Impossible
- | ((x,ii1),ii2)::xs ->
- List.hd ii1
+ | ((s,iis),noiiop)::xs ->
+ s, iis
)
- | CppVariadicName (s, ii) ->
- let (iihash, iis) = Common.tuple_of_list2 ii in
- iihash
- | CppIdentBuilder ((s,iis),xs) ->
- List.hd iis
-let get_s_and_ii_of_name name =
- match name with
- | RegularName (s, iis) -> s, List.hd iis
- | _ -> raise Todo
+let get_s_and_info_of_name name =
+ let (s,ii) = get_s_and_ii_of_name name in
+ s, List.hd ii
+
+let info_of_name name =
+ let (s,ii) = get_s_and_ii_of_name name in
+ List.hd ii
+
+let ii_of_name name =
+ let (s,ii) = get_s_and_ii_of_name name in
+ ii
+
+let get_local_ii_of_expr_inlining_ii_of_name e =
+ let (ebis,_),ii = e in
+ match ebis, ii with
+ | Ident name, noii ->
+ assert(null noii);
+ ii_of_name name
+ | RecordAccess (e, name), ii ->
+ ii @ ii_of_name name
+ | RecordPtAccess (e, name), ii ->
+ ii @ ii_of_name name
+ | _, ii -> ii
+
+
+let get_local_ii_of_tybis_inlining_ii_of_name ty =
+ match ty with
+ | TypeName (name, _typ), [] -> ii_of_name name
+ | _, ii -> ii
+
+(* only Label and Goto have name *)
+let get_local_ii_of_st_inlining_ii_of_name st =
+ match st with
+ | Labeled (Label (name, st)), ii -> ii_of_name name @ ii
+ | Jump (Goto name), ii ->
+ let (i1, i3) = Common.tuple_of_list2 ii in
+ [i1] @ ii_of_name name @ [i3]
+ | _, ii -> ii
+
+
+
+(* ------------------------------------------------------------------------- *)
let name_of_parameter param =
param.p_namei +> Common.map_option (str_of_name)
info.Ast_c.comments_tag :=
{ Ast_c.mbefore = before';
Ast_c.mafter = after';
+ mbefore2 = [];
+ mafter2 = [];
};
);
Visitor_c.kexpr_s = (fun (k,bigf) e ->
match e with
(* todo: should also do something for multistrings *)
- | (Constant (String (s,kind)), typ), [ii]
+ | (Constant (String (s,kind)), typ), [ii]
when Common.string_match_substring cvs_keyword_regexp s ->
let newstr = cvs_compute_newstr s in
(Constant (String (newstr,kind)), typ), [rewrap_str newstr ii]
* if they are in different nodes. Solved by using shared ref
* and allow the "already-tagged" token.
*)
- | SeqStart of statement * int * info
+ | SeqStart of fullstatement * int * info
| SeqEnd of int * info
- | ExprStatement of statement * (expression option) wrap
+ | ExprStatement of fullstatement * (expression option) wrap
- | IfHeader of statement * expression wrap
+ | IfHeader of fullstatement * expression wrap
| Else of info
- | WhileHeader of statement * expression wrap
- | DoHeader of statement * info
+ | WhileHeader of fullstatement * expression wrap
+ | DoHeader of fullstatement * info
| DoWhileTail of expression wrap
- | ForHeader of statement *
+ | ForHeader of fullstatement *
(exprStatement wrap * exprStatement wrap * exprStatement wrap)
wrap
- | SwitchHeader of statement * expression wrap
- | MacroIterHeader of statement * (string * argument wrap2 list) wrap
+ | SwitchHeader of fullstatement * expression wrap
+ | MacroIterHeader of fullstatement * (string * argument wrap2 list) wrap
(* Used to mark the end of if, while, dowhile, for, switch. Later we
* will be able to "tag" some cocci code on this node.
*)
| EndStatement of info option (* fake_info *)
- | Return of statement * unit wrap
- | ReturnExpr of statement * expression wrap
+ | Return of fullstatement * unit wrap
+ | ReturnExpr of fullstatement * expression wrap
(* ------------------------ *)
| IfdefHeader of ifdef_directive
| MacroTop of string * argument wrap2 list * il
(* ------------------------ *)
- | Case of statement * expression wrap
- | Default of statement * unit wrap
+ | Case of fullstatement * expression wrap
+ | Default of fullstatement * unit wrap
- | Continue of statement * unit wrap
- | Break of statement * unit wrap
+ | Continue of fullstatement * unit wrap
+ | Break of fullstatement * unit wrap
(* no counter part in cocci *)
| CaseRange of fullstatement * (expression * expression) wrap
| Goto of fullstatement * name * unit wrap (* goto *)
- | Asm of statement * asmbody wrap
- | MacroStmt of statement * unit wrap
+ | Asm of fullstatement * asmbody wrap
+ | MacroStmt of fullstatement * unit wrap
(* ------------------------ *)
(* some control nodes *)
open Oassoc
open Oassocb
+module Lib = Lib_parsing_c
+
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_cfg
(*****************************************************************************)
(* todo?: compute target level with goto (but rare that different I think)
| DeadCode of Common.parse_info option
| CaseNoSwitch of Common.parse_info
| OnlyBreakInSwitch of Common.parse_info
+ | WeirdSwitch of Common.parse_info
| NoEnclosingLoop of Common.parse_info
| GotoCantFindLabel of string * Common.parse_info
| NoExit of Common.parse_info
begin
st +> Visitor_c.vk_statement { Visitor_c.default_visitor_c with
Visitor_c.kstatement = (fun (k, bigf) st ->
- match st with
- | Labeled (Ast_c.Label (name, _st)),ii ->
+ match Ast_c.unwrap_st st with
+ | Labeled (Ast_c.Label (name, _st)) ->
+ let ii = Ast_c.get_ii_st_take_care st in
(* at this point I put a lbl_0, but later I will put the
* good labels. *)
let s = Ast_c.str_of_name name in
(* not k _st !!! otherwise in lbl1: lbl2: i++; we miss lbl2 *)
k st;
end
- | st -> k st
+ | _st -> k st
)
};
!h;
compound_caller = Statement;
}
in
-
+ let ii = Ast_c.get_ii_st_take_care stmt in
+
(* ------------------------- *)
- match stmt with
+ match Ast_c.unwrap_st stmt with
(* coupling: the Switch case copy paste parts of the Compound case *)
- | Ast_c.Compound statxs, ii ->
+ | Ast_c.Compound statxs ->
(* flow_to_ast: *)
let (i1, i2) = tuple_of_list2 ii in
(* ------------------------- *)
- | Labeled (Ast_c.Label (name, st)), ii ->
+ | Labeled (Ast_c.Label (name, st)) ->
let s = Ast_c.str_of_name name in
let ilabel = xi.labels_assoc#find s in
let node = mk_node (unwrap (!g#nodes#find ilabel)) lbl [] (s ^ ":") in
aux_statement (Some ilabel, xi_lbl) st
- | Jump (Ast_c.Goto name), ii ->
- let s = Ast_c.str_of_name name in
+ | Jump (Ast_c.Goto name) ->
+ let s = Ast_c.str_of_name name in
(* special_cfg_ast: *)
let newi = !g +> add_node (Goto (stmt, name, ((),ii))) lbl ("goto "^s^":")
in
!g#add_arc ((newi, ilabel), Direct);
None
- | Jump (Ast_c.GotoComputed e), ii ->
+ | Jump (Ast_c.GotoComputed e) ->
raise (Error (ComputedGoto))
(* ------------------------- *)
- | Ast_c.ExprStatement opte, ii ->
+ | Ast_c.ExprStatement opte ->
(* flow_to_ast: old: when opte = None, then do not add in CFG. *)
let s =
match opte with
| None -> "empty;"
| Some e ->
- let ((unwrap_e, typ), ii) = e in
- (match unwrap_e with
- | FunCall (((Ident (namef), _typ), _ii), _args) ->
- Ast_c.str_of_name namef ^ "(...)"
- | Assignment (((Ident (namevar), _typ), _ii), SimpleAssign, e) ->
- Ast_c.str_of_name namevar ^ " = ... ;"
- | Assignment
- (((RecordAccess (((Ident (namevar), _typ), _ii), field), _typ2),
- _ii2),
- SimpleAssign,
- e) ->
- let sfield = Ast_c.str_of_name field in
- Ast_c.str_of_name namevar ^ "." ^ sfield ^ " = ... ;"
-
+ (match Ast_c.unwrap_expr e with
+ | FunCall (e, _args) ->
+ (match Ast_c.unwrap_expr e with
+ | Ident namef ->
+ Ast_c.str_of_name namef ^ "(...)"
+ | _ -> "statement"
+ )
+ | Assignment (e1, SimpleAssign, e2) ->
+ (match Ast_c.unwrap_expr e1 with
+ | Ident namevar ->
+ Ast_c.str_of_name namevar ^ " = ... ;"
+ | RecordAccess(e, field) ->
+ (match Ast_c.unwrap_expr e with
+ | Ident namevar ->
+ let sfield = Ast_c.str_of_name field in
+ Ast_c.str_of_name namevar ^ "." ^ sfield ^ " = ... ;"
+ | _ -> "statement"
+ )
+ | _ -> "statement"
+ )
| _ -> "statement"
- )
+ )
in
let newi = !g +> add_node (ExprStatement (stmt, (opte, ii))) lbl s in
!g +> add_arc_opt (starti, newi);
(* ------------------------- *)
- | Selection (Ast_c.If (e, st1, (Ast_c.ExprStatement (None), []))), ii ->
+ | Selection (Ast_c.If (e, st1, st2)) ->
+
+ let iist2 = Ast_c.get_ii_st_take_care st2 in
+ (match Ast_c.unwrap_st st2 with
+ | Ast_c.ExprStatement (None) when null iist2 ->
(* sometome can have ExprStatement None but it is a if-then-else,
* because something like if() xx else ;
* so must force to have [] in the ii associated with ExprStatement
!g +> add_arc_opt (finalthen, lasti);
Some lasti
-
- | Selection (Ast_c.If (e, st1, st2)), ii ->
+ | _unwrap_st2 ->
(* starti -> newi ---> newfakethen -> ... -> finalthen --> lasti
* | |
* |-> newfakeelse -> ... -> finalelse -|
!g +> add_arc_opt (finalelse, lasti);
Some lasti
end)
-
+ )
(* ------------------------- *)
- | Selection (Ast_c.Switch (e, st)), ii ->
+ | Selection (Ast_c.Switch (e, st)) ->
let (i1,i2,i3, iifakeend) = tuple_of_list4 ii in
let ii = [i1;i2;i3] in
* information build inside the compound case: the nodei of {
*)
let finalthen =
- match st with
- | Ast_c.Compound statxs, ii ->
- let statxs = Ast_c.stmt_elems_of_sequencable statxs in
+ match Ast_c.unwrap_st st with
+ | Ast_c.Compound statxs ->
+
+ let statxs = Lib.stmt_elems_of_sequencable statxs in
(* todo? we should not allow to match a stmt that corresponds
* to a compound of a switch, so really SeqStart (stmt, ...)
* between start to end.
* todo? except if the case[range] coverthe whole spectrum
*)
- if not (statxs +> List.exists (function
- | (Labeled (Ast_c.Default _), _) -> true
- | _ -> false
+ if not (statxs +> List.exists (fun x ->
+ match Ast_c.unwrap_st x with
+ | Labeled (Ast_c.Default _) -> true
+ | _ -> false
))
then begin
(* when there is no default, then a valid path is
}
in
aux_statement (None (* no starti *), newxi) st
- | x -> raise Impossible
+ | _x ->
+ (* apparently gcc allows some switch body such as
+ * switch (i) case 0 : printf("here\n");
+ * cf tests-bis/switch_no_body.c
+ * but I don't think it's worthwile to handle
+ * such pathological and rare case. Not worth
+ * the complexity. Safe to assume a coumpound.
+ *)
+ raise (Error (WeirdSwitch (pinfo_of_ii [i1])))
in
!g +> add_arc_opt (finalthen, newendswitch);
res
- | Labeled (Ast_c.Case (_, _)), ii
- | Labeled (Ast_c.CaseRange (_, _, _)), ii ->
+ | Labeled (Ast_c.Case (_, _))
+ | Labeled (Ast_c.CaseRange (_, _, _)) ->
incr counter_for_switch;
let switchrank = !counter_for_switch in
let node, st =
- match stmt with
+ match Ast_c.get_st_and_ii stmt with
| Labeled (Ast_c.Case (e, st)), ii ->
(Case (stmt, (e, ii))), st
| Labeled (Ast_c.CaseRange (e, e2, st)), ii ->
aux_statement (Some newi, xi_lbl) st
- | Labeled (Ast_c.Default st), ii ->
+ | Labeled (Ast_c.Default st) ->
incr counter_for_switch;
let switchrank = !counter_for_switch in
(* ------------------------- *)
- | Iteration (Ast_c.While (e, st)), ii ->
+ | Iteration (Ast_c.While (e, st)) ->
(* starti -> newi ---> newfakethen -> ... -> finalthen -
* |---|-----------------------------------|
* |-> newfakelse
* (whereas While cant return None). But if return None, certainly
* some deadcode.
*)
- | Iteration (Ast_c.DoWhile (st, e)), ii ->
+ | Iteration (Ast_c.DoWhile (st, e)) ->
(* starti -> doi ---> ... ---> finalthen (opt) ---> whiletaili
* |--------- newfakethen ---------------| |---> newfakelse
*)
let is_zero =
match Ast_c.unwrap_expr e with
- | Constant (Int "0") -> true
+ | Constant (Int ("0",_)) -> true
| _ -> false
in
- | Iteration (Ast_c.For (e1opt, e2opt, e3opt, st)), ii ->
+ | Iteration (Ast_c.For (e1opt, e2opt, e3opt, st)) ->
let (i1,i2,i3, iifakeend) = tuple_of_list4 ii in
let ii = [i1;i2;i3] in
* lexer, now they are returned as Twhile so less pbs. But not perfect.
* update: now I recognize the list_for_each macro so no more problems.
*)
- | Iteration (Ast_c.MacroIteration (s, es, st)), ii ->
+ | Iteration (Ast_c.MacroIteration (s, es, st)) ->
let (i1,i2,i3, iifakeend) = tuple_of_list4 ii in
let ii = [i1;i2;i3] in
(* ------------------------- *)
- | Jump ((Ast_c.Continue|Ast_c.Break) as x),ii ->
+ | Jump ((Ast_c.Continue|Ast_c.Break) as x) ->
let context_info =
match xi.ctx with
SwitchInfo (startbrace, loopendi, braces, parent_lbl) ->
| NoInfo -> raise Impossible
)
- | Jump ((Ast_c.Return | Ast_c.ReturnExpr _) as kind), ii ->
+ | Jump ((Ast_c.Return | Ast_c.ReturnExpr _) as kind) ->
(match xi.exiti, xi.errorexiti with
| None, None -> raise (Error (NoExit (pinfo_of_ii ii)))
| Some exiti, Some errorexiti ->
(* ------------------------- *)
- | Ast_c.Decl decl, ii ->
+ | Ast_c.Decl decl ->
let s =
match decl with
| (Ast_c.DeclList
Some newi
(* ------------------------- *)
- | Ast_c.Asm body, ii ->
+ | Ast_c.Asm body ->
let newi = !g +> add_node (Asm (stmt, ((body,ii)))) lbl "asm;" in
!g +> add_arc_opt (starti, newi);
Some newi
- | Ast_c.MacroStmt, ii ->
+ | Ast_c.MacroStmt ->
let newi = !g +> add_node (MacroStmt (stmt, ((),ii))) lbl "macro;" in
!g +> add_arc_opt (starti, newi);
Some newi
(* ------------------------- *)
- | Ast_c.NestedFunc def, ii ->
+ | Ast_c.NestedFunc def ->
raise (Error NestedFunc)
)
in
- let topstatement = Ast_c.Compound compound, iicompound in
+ let topstatement = Ast_c.mk_st (Ast_c.Compound compound) iicompound in
let headi = !g +> add_node
(FunHeader ({
* the toplevel macro statement as in @@ toplevel_declarator MACRO_PARAM;@@
* and so I would not need this hack and instead I would to a cleaner
* match in cocci_vs_c_3.ml of a A.MacroTop vs B.MacroTop
+ *
+ * todo: update: now I do what I just described, so can remove this code ?
*)
let specialdeclmacro_to_stmt (s, args, ii) =
let (iis, iiopar, iicpar, iiptvirg) = tuple_of_list4 ii in
let ident = Ast_c.RegularName (s, [iis]) in
- let identfinal = (Ast_c.Ident (ident), Ast_c.noType()), [] in
- let f = (Ast_c.FunCall (identfinal, args), Ast_c.noType()), [iiopar;iicpar] in
- let stmt = Ast_c.ExprStatement (Some f), [iiptvirg] in
+ let identfinal = Ast_c.mk_e (Ast_c.Ident (ident)) Ast_c.noii in
+ let f = Ast_c.mk_e (Ast_c.FunCall (identfinal, args)) [iiopar;iicpar] in
+ let stmt = Ast_c.mk_st (Ast_c.ExprStatement (Some f)) [iiptvirg] in
stmt, (f, [iiptvirg])
raise (Error(Define(pinfo_of_ii ii)))
| Ast_c.DefineTodo ->
raise (Error(Define(pinfo_of_ii ii)))
+
+(* old:
+ | Ast_c.DefineText (s, ii) ->
+ let endi = !g +> add_node EndNode lbl_0 "[end]" in
+ !g#add_arc ((headeri, endi),Direct);
+ | Ast_c.DefineInit _ ->
+ let endi = !g +> add_node EndNode lbl_0 "[end]" in
+ !g#add_arc ((headeri, endi),Direct);
+ | Ast_c.DefineTodo ->
+ let endi = !g +> add_node EndNode lbl_0 "[end]" in
+ !g#add_arc ((headeri, endi),Direct);
+*)
);
Some !g
| SeqEnd _ -> () (* todo?: certaines '}' deviennent orphelins *)
| x ->
(match Control_flow_c.extract_fullstatement node with
- | Some (st, ii) -> raise (Error (DeadCode (Some (pinfo_of_ii ii))))
+ | Some st ->
+ let ii = Ast_c.get_ii_st_take_care st in
+ raise (Error (DeadCode (Some (pinfo_of_ii ii))))
| _ -> pr2 "CFG: orphelin nodes, maybe something weird happened"
)
)
pr2 ("FLOW: case without corresponding switch: " ^ error_from_info info)
| OnlyBreakInSwitch info ->
pr2 ("FLOW: only break are allowed in switch: " ^ error_from_info info)
+ | WeirdSwitch info ->
+ pr2 ("FLOW: weird switch: " ^ error_from_info info)
| NoEnclosingLoop (info) ->
pr2 ("FLOW: can't find enclosing loop: " ^ error_from_info info)
| GotoCantFindLabel (s, info) ->
| NoExit info ->
pr2 ("FLOW: can't find exit or error exit: " ^ error_from_info info)
| DuplicatedLabel s ->
- pr2 ("FLOW: duplicate label" ^ s)
+ pr2 ("FLOW: duplicate label " ^ s)
| NestedFunc ->
pr2 ("FLOW: not handling yet nested function")
| ComputedGoto ->
| DeadCode of Common.parse_info option
| CaseNoSwitch of Common.parse_info
| OnlyBreakInSwitch of Common.parse_info
+ | WeirdSwitch of Common.parse_info
| NoEnclosingLoop of Common.parse_info
| GotoCantFindLabel of string * Common.parse_info
| NoExit of Common.parse_info
open Ast_c
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_cpp_ast
+let pr2_debug,pr2_debug_once =
+ Common.mk_pr2_wrappers Flag_parsing_c.debug_cpp_ast
+
(*****************************************************************************)
(* Cpp Ast Manipulations *)
(*****************************************************************************)
files +> List.iter (fun file ->
let base = Filename.basename file in
- pr2 file;
+ pr2_debug file;
Hashtbl.add _hcandidates base file;
);
()
let res = Hashtbl.find_all _hcandidates base in
(match res with
| [file] ->
- pr2 ("CPPAST: find header in other dir: " ^ file);
+ pr2_debug ("CPPAST: find header in other dir: " ^ file);
res
| [] ->
[]
(* ---------------------------------------------------------------------- *)
let trace_cpp_process depth mark inc_file =
- pr2 (spf "%s>%s %s"
+ pr2_debug (spf "%s>%s %s"
(Common.repeat "-" depth +> Common.join "")
mark
(s_of_inc_file_bis inc_file));
cpp_option list -> Common.dirname -> Ast_c.program -> Ast_c.program) =
fun ?(depth_limit=None) iops dirname ast ->
- pr2_xxxxxxxxxxxxxxxxx();
+ if !Flag_parsing_c.debug_cpp_ast
+ then pr2_xxxxxxxxxxxxxxxxx();
+
let already_included = ref [] in
let rec aux stack dirname ast =
--- /dev/null
+(* Yoann Padioleau
+ *
+ * Copyright (C) 2007, 2008 Ecole des Mines de Nantes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License (GPL)
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * file license.txt for more details.
+ *)
+
+open Common
+
+module TH = Token_helpers
+
+open Parser_c
+open Token_views_c
+
+(*****************************************************************************)
+(* Prelude *)
+(*****************************************************************************)
+
+(* cpp functions working at the token level. Cf cpp_ast_c for cpp functions
+ * working at the AST level (which is very unusual but makes sense in
+ * the coccinelle context for instance).
+ *
+ * Note that as I use a single lexer to work both at the C and cpp level
+ * there are some inconveniencies.
+ * For instance 'for' is a valid name for a macro parameter and macro
+ * body, but is interpreted in a special way by our single lexer, and
+ * so at some places where I expect a TIdent I need also to
+ * handle special cases and accept Tfor, Tif, etc at those places.
+ *
+ * There are multiple issues related to those keywords incorrect tokens.
+ * Those keywords can be:
+ * - (1) in the name of the macro as in #define inline
+ * - (2) in a parameter of the macro as in #define foo(char) char x;
+ * - (3) in an argument to a macro call as in IDENT(if);
+ * Case 1 is easy to fix in define_ident.
+ * Case 2 is easy to fix in define_parse where detect such toks in
+ * the parameter and then replace their occurence in the body in a Tident.
+ * Case 3 is only an issue when the expanded token is not really use
+ * as usual but use for instance in concatenation as in a ## if
+ * when expanded. In the case the grammar this time will not be happy
+ * so this is also easy to fix in cpp_engine.
+ *
+ *)
+
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
+
+(*****************************************************************************)
+(* Types *)
+(*****************************************************************************)
+
+
+(* ------------------------------------------------------------------------- *)
+(* mimic standard.h *)
+(* ------------------------------------------------------------------------- *)
+
+type define_def = string * define_param * define_body
+ and define_param =
+ | NoParam
+ | Params of string list
+ and define_body =
+ | DefineBody of Parser_c.token list
+ | DefineHint of parsinghack_hint
+
+ and parsinghack_hint =
+ | HintIterator
+ | HintDeclarator
+ | HintMacroString
+ | HintMacroStatement
+ | HintAttribute
+ | HintMacroIdentBuilder
+
+
+
+(* cf also data/test.h *)
+let assoc_hint_string = [
+ "YACFE_ITERATOR" , HintIterator;
+ "YACFE_DECLARATOR" , HintDeclarator;
+ "YACFE_STRING" , HintMacroString;
+ "YACFE_STATEMENT" , HintMacroStatement;
+ "YACFE_ATTRIBUTE" , HintAttribute;
+ "YACFE_IDENT_BUILDER" , HintMacroIdentBuilder;
+
+ "MACROSTATEMENT" , HintMacroStatement; (* backward compatibility *)
+]
+
+
+let (parsinghack_hint_of_string: string -> parsinghack_hint option) = fun s ->
+ Common.assoc_option s assoc_hint_string
+
+let (is_parsinghack_hint: string -> bool) = fun s ->
+ parsinghack_hint_of_string s <> None
+
+let (token_from_parsinghack_hint:
+ (string * Ast_c.info) -> parsinghack_hint -> Parser_c.token) =
+ fun (s,ii) hint ->
+ match hint with
+ | HintIterator ->
+ Parser_c.TMacroIterator (s, ii)
+ | HintDeclarator ->
+ Parser_c.TMacroDecl (s, ii)
+ | HintMacroString ->
+ Parser_c.TMacroString (s, ii)
+ | HintMacroStatement ->
+ Parser_c.TMacroStmt (s, ii)
+ | HintAttribute ->
+ Parser_c.TMacroAttr (s, ii)
+ | HintMacroIdentBuilder ->
+ Parser_c.TMacroIdentBuilder (s, ii)
+
+
+
+
+
+
+(*****************************************************************************)
+(* Expansion helpers *)
+(*****************************************************************************)
+
+(* In some cases we can have macros like IDENT(if) that expands to some
+ * 'int xxx_if(void)', but as the lexer will currently generate a Tif for
+ * the expanded code, that may not be accepted as a token after a ##
+ * in the grammar. Hence this function to remap some tokens. This is because
+ * we should not use a single lexer for both working at the C level and
+ * cpp level.
+ *
+ * update: it can also rename some TypedefIdent into TIdent, possibly
+ * because of bad interaction with add_typedef_root in parsing_hacks.
+ *)
+let rec remap_keyword_tokens xs =
+ match xs with
+ | [] -> []
+ | [x] -> [x]
+ | x::y::xs ->
+ (match x, y with
+ | Parser_c.TCppConcatOp _, Parser_c.TIdent _ ->
+ x::y::remap_keyword_tokens xs
+ | Parser_c.TIdent _, Parser_c.TCppConcatOp _ ->
+ x::y::remap_keyword_tokens xs
+
+ | Parser_c.TCppConcatOp (i1), y ->
+
+ let s = TH.str_of_tok y in
+ let ii = TH.info_of_tok y in
+ if s ==~ Common.regexp_alpha
+ then begin
+ pr2 (spf "remaping: %s to an ident in expanded code" s);
+ x::(Parser_c.TIdent (s, ii))::remap_keyword_tokens xs
+ end
+ else
+ x::y::remap_keyword_tokens xs
+
+ | x, Parser_c.TCppConcatOp (i1) ->
+ let s = TH.str_of_tok x in
+ let ii = TH.info_of_tok x in
+ if s ==~ Common.regexp_alpha
+ then begin
+ pr2 (spf "remaping: %s to an ident in expanded code" s);
+ (Parser_c.TIdent (s, ii))::remap_keyword_tokens (y::xs)
+ end
+ else
+ x::y::remap_keyword_tokens xs
+
+ | _, _ ->
+ x::remap_keyword_tokens (y::xs)
+ )
+
+
+
+(* To expand the parameter of the macro. The env corresponds to the actual
+ * code that is binded to the parameters of the macro.
+ * Recurse ? fixpoint ? the expansion may also contain macro.
+ * Or to macro expansion in a strict manner, that is process first
+ * the parameters, expands macro in params, and then process enclosing
+ * macro call.
+ *
+ * note: do the concatenation job of a##b here ?
+ * normally this should be done in the grammar. Here just expand
+ * tokens. The only thing we handle here is we may have to remap
+ * some tokens.
+ *
+ * todo: handle stringification here ? if #n
+ *
+ * todo? but could parsing_hacks then pass over the remapped tokens,
+ * for instance transform some of the back into some TypedefIdent
+ * so cpp_engine may be fooled?
+ *)
+let rec (cpp_engine: (string , Parser_c.token list) assoc ->
+ Parser_c.token list -> Parser_c.token list) =
+ fun env xs ->
+ xs +> List.map (fun tok ->
+ (* expand only TIdent ? no cos the parameter of the macro
+ * can actually be some 'register' so may have to look for
+ * any tokens candidates for the expansion.
+ * Only subtelity is maybe dont expand the TDefineIdent.
+ * update: in fact now the caller (define_parse) will have done
+ * the job right and already replaced the macro parameter with a TIdent.
+ *)
+ match tok with
+ | TIdent (s,i1) when List.mem_assoc s env -> Common.assoc s env
+ | x -> [x]
+ )
+ +> List.flatten
+ +> remap_keyword_tokens
+
+
+
+(* ------------------------------------------------------------------------- *)
+(* apply macro, using standard.h or other defs *)
+(* ------------------------------------------------------------------------- *)
+
+(* Thanks to this function many stuff are not anymore hardcoded in ocaml code.
+ * At some point there were hardcoded in a standard.h file but now I
+ * can even generate them on the fly on demand when there is actually
+ * a parsing problem.
+ *
+ * No need to take care to not substitute the macro name itself
+ * that occurs in the macro definition because the macro name is
+ * after fix_token_define a TDefineIdent, no more a TIdent.
+ *)
+
+let rec apply_macro_defs
+ ~msg_apply_known_macro
+ ~msg_apply_known_macro_hint
+ defs xs =
+ let rec apply_macro_defs xs =
+ match xs with
+ | [] -> ()
+
+ (* old: "but could do more, could reuse same original token
+ * so that have in the Ast a Dbg, not a MACROSTATEMENT"
+ *
+ * | PToken ({tok = TIdent (s,i1)} as id)::xs
+ * when s = "MACROSTATEMENT" ->
+ *
+ * msg_macro_statement_hint s;
+ * id.tok <- TMacroStmt(TH.info_of_tok id.tok);
+ * find_macro_paren xs
+ *
+ * let msg_macro_statement_hint s =
+ * incr Stat.nMacroHint;
+ * ()
+ *
+ *)
+
+ (* recognized macro of standard.h (or other) *)
+ | PToken ({tok = TIdent (s,i1)} as id)::Parenthised (xxs,info_parens)::xs
+ when Hashtbl.mem defs s ->
+
+ msg_apply_known_macro s;
+ let (s, params, body) = Hashtbl.find defs s in
+
+ (match params with
+ | NoParam ->
+ pr2 ("WEIRD: macro without param used before parenthize: " ^ s);
+ (* ex: PRINTP("NCR53C400 card%s detected\n" ANDP(((struct ... *)
+
+ (match body with
+ | DefineBody bodymacro ->
+ set_as_comment (Token_c.CppMacro) id;
+ id.new_tokens_before <- bodymacro;
+ | DefineHint hint ->
+ msg_apply_known_macro_hint s;
+ id.tok <- token_from_parsinghack_hint (s,i1) hint;
+ )
+ | Params params ->
+ (match body with
+ | DefineBody bodymacro ->
+
+ (* bugfix: better to put this that before the match body,
+ * cos our macrostatement hint can have variable number of
+ * arguments and so it's ok if it does not match exactly
+ * the number of arguments. *)
+ if List.length params != List.length xxs
+ then begin
+ pr2_once ("WEIRD: macro with wrong number of arguments: " ^ s);
+ (* old: id.new_tokens_before <- bodymacro; *)
+
+ (* update: if wrong number, then I just pass this macro *)
+ [Parenthised (xxs, info_parens)] +>
+ iter_token_paren (set_as_comment Token_c.CppMacro);
+ set_as_comment Token_c.CppMacro id;
+
+ ()
+ end
+ else
+
+ let xxs' = xxs +> List.map (fun x ->
+ (tokens_of_paren_ordered x) +> List.map (fun x ->
+ TH.visitor_info_of_tok Ast_c.make_expanded x.tok
+ )
+ ) in
+ id.new_tokens_before <-
+ (* !!! cpp expansion job here !!! *)
+ cpp_engine (Common.zip params xxs') bodymacro;
+
+ (* important to do that after have apply the macro, otherwise
+ * will pass as argument to the macro some tokens that
+ * are all TCommentCpp
+ *)
+ [Parenthised (xxs, info_parens)] +>
+ iter_token_paren (set_as_comment Token_c.CppMacro);
+ set_as_comment Token_c.CppMacro id;
+
+ | DefineHint (HintMacroStatement as hint) ->
+ (* important to do that after have apply the macro, otherwise
+ * will pass as argument to the macro some tokens that
+ * are all TCommentCpp
+ *
+ * note: such macrostatement can have a variable number of
+ * arguments but here we don't care, we just pass all the
+ * parameters.
+ *)
+
+ (match xs with
+ | PToken ({tok = TPtVirg _} as id2)::_ ->
+ pr2_once
+ ("macro stmt with trailing ';', passing also ';' for: "^
+ s);
+ (* sometimes still want pass its params ... as in
+ * DEBUGPOLL(static unsigned int prev_mask = 0);
+ *)
+
+ msg_apply_known_macro_hint s;
+ id.tok <- token_from_parsinghack_hint (s,i1) hint;
+ [Parenthised (xxs, info_parens)] +>
+ iter_token_paren (set_as_comment Token_c.CppMacro);
+ set_as_comment Token_c.CppMacro id2;
+
+ | _ ->
+ msg_apply_known_macro_hint s;
+ id.tok <- token_from_parsinghack_hint (s,i1) hint;
+ [Parenthised (xxs, info_parens)] +>
+ iter_token_paren (set_as_comment Token_c.CppMacro);
+ )
+
+
+ | DefineHint hint ->
+ msg_apply_known_macro_hint s;
+ id.tok <- token_from_parsinghack_hint (s,i1) hint;
+ )
+ );
+ apply_macro_defs xs
+
+ | PToken ({tok = TIdent (s,i1)} as id)::xs
+ when Hashtbl.mem defs s ->
+
+ msg_apply_known_macro s;
+ let (_s, params, body) = Hashtbl.find defs s in
+
+ (match params with
+ | Params params ->
+ pr2 ("WEIRD: macro with params but no parens found: " ^ s);
+ (* dont apply the macro, perhaps a redefinition *)
+ ()
+ | NoParam ->
+ (match body with
+ | DefineBody [newtok] ->
+ (* special case when 1-1 substitution, we reuse the token *)
+ id.tok <- (newtok +> TH.visitor_info_of_tok (fun _ ->
+ TH.info_of_tok id.tok))
+ | DefineBody bodymacro ->
+ set_as_comment Token_c.CppMacro id;
+ id.new_tokens_before <- bodymacro;
+ | DefineHint hint ->
+ msg_apply_known_macro_hint s;
+ id.tok <- token_from_parsinghack_hint (s,i1) hint;
+ )
+ );
+ apply_macro_defs xs
+
+
+
+
+ (* recurse *)
+ | (PToken x)::xs -> apply_macro_defs xs
+ | (Parenthised (xxs, info_parens))::xs ->
+ xxs +> List.iter apply_macro_defs;
+ apply_macro_defs xs
+ in
+ apply_macro_defs xs
+
+
+
+
+(*****************************************************************************)
+(* The parsing hack for #define *)
+(*****************************************************************************)
+
+(* To parse macro definitions I need to do some tricks
+ * as some information can be get only at the lexing level. For instance
+ * the space after the name of the macro in '#define foo (x)' is meaningful
+ * but the grammar can not get this information. So define_ident below
+ * look at such space and generate a special TOpardefine. In a similar
+ * way macro definitions can contain some antislash and newlines
+ * and the grammar need to know where the macro ends (which is
+ * a line-level and so low token-level information). Hence the
+ * function 'define_line' below and the TDefEol.
+ *
+ * update: TDefEol is handled in a special way at different places,
+ * a little bit like EOF, especially for error recovery, so this
+ * is an important token that should not be retagged!
+ *
+ *
+ * ugly hack, a better solution perhaps would be to erase TDefEOL
+ * from the Ast and list of tokens in parse_c.
+ *
+ * note: I do a +1 somewhere, it's for the unparsing to correctly sync.
+ *
+ * note: can't replace mark_end_define by simply a fakeInfo(). The reason
+ * is where is the \n TCommentSpace. Normally there is always a last token
+ * to synchronize on, either EOF or the token of the next toplevel.
+ * In the case of the #define we got in list of token
+ * [TCommentSpace "\n"; TDefEOL] but if TDefEOL is a fakeinfo then we will
+ * not synchronize on it and so we will not print the "\n".
+ * A solution would be to put the TDefEOL before the "\n".
+ *
+ * todo?: could put a ExpandedTok for that ?
+ *)
+let mark_end_define ii =
+ let ii' =
+ { Ast_c.pinfo = Ast_c.OriginTok { (Ast_c.parse_info_of_info ii) with
+ Common.str = "";
+ Common.charpos = Ast_c.pos_of_info ii + 1
+ };
+ cocci_tag = ref Ast_c.emptyAnnot;
+ comments_tag = ref Ast_c.emptyComments;
+ }
+ in
+ TDefEOL (ii')
+
+(* put the TDefEOL at the good place *)
+let rec define_line_1 acc xs =
+ match xs with
+ | [] -> List.rev acc
+ | TDefine ii::xs ->
+ let line = Ast_c.line_of_info ii in
+ let acc = (TDefine ii) :: acc in
+ define_line_2 acc line ii xs
+ | TCppEscapedNewline ii::xs ->
+ pr2 "WEIRD: a \\ outside a #define";
+ let acc = (TCommentSpace ii) :: acc in
+ define_line_1 acc xs
+ | x::xs -> define_line_1 (x::acc) xs
+
+and define_line_2 acc line lastinfo xs =
+ match xs with
+ | [] ->
+ (* should not happened, should meet EOF before *)
+ pr2 "PB: WEIRD";
+ List.rev (mark_end_define lastinfo::acc)
+ | x::xs ->
+ let line' = TH.line_of_tok x in
+ let info = TH.info_of_tok x in
+
+ (match x with
+ | EOF ii ->
+ let acc = (mark_end_define lastinfo) :: acc in
+ let acc = (EOF ii) :: acc in
+ define_line_1 acc xs
+ | TCppEscapedNewline ii ->
+ if (line' <> line) then pr2 "PB: WEIRD: not same line number";
+ let acc = (TCommentSpace ii) :: acc in
+ define_line_2 acc (line+1) info xs
+ | x ->
+ if line' =|= line
+ then define_line_2 (x::acc) line info xs
+ else define_line_1 (mark_end_define lastinfo::acc) (x::xs)
+ )
+
+let rec define_ident acc xs =
+ match xs with
+ | [] -> List.rev acc
+ | TDefine ii::xs ->
+ let acc = TDefine ii :: acc in
+ (match xs with
+ | TCommentSpace i1::TIdent (s,i2)::TOPar (i3)::xs ->
+ (* Change also the kind of TIdent to avoid bad interaction
+ * with other parsing_hack tricks. For instant if keep TIdent then
+ * the stringication algo can believe the TIdent is a string-macro.
+ * So simpler to change the kind of the ident too.
+ *)
+ (* if TOParDefine sticked to the ident, then
+ * it's a macro-function. Change token to avoid ambiguity
+ * between #define foo(x) and #define foo (x)
+ *)
+ let acc = (TCommentSpace i1) :: acc in
+ let acc = (TIdentDefine (s,i2)) :: acc in
+ let acc = (TOParDefine i3) :: acc in
+ define_ident acc xs
+
+ | TCommentSpace i1::TIdent (s,i2)::xs ->
+ let acc = (TCommentSpace i1) :: acc in
+ let acc = (TIdentDefine (s,i2)) :: acc in
+ define_ident acc xs
+
+ (* bugfix: ident of macro (as well as params, cf below) can be tricky
+ * note, do we need to subst in the body of the define ? no cos
+ * here the issue is the name of the macro, as in #define inline,
+ * so obviously the name of this macro will not be used in its
+ * body (it would be a recursive macro, which is forbidden).
+ *)
+
+ | TCommentSpace i1::t::xs ->
+
+ let s = TH.str_of_tok t in
+ let ii = TH.info_of_tok t in
+ if s ==~ Common.regexp_alpha
+ then begin
+ pr2 (spf "remaping: %s to an ident in macro name" s);
+ let acc = (TCommentSpace i1) :: acc in
+ let acc = (TIdentDefine (s,ii)) :: acc in
+ define_ident acc xs
+ end
+ else begin
+ pr2 "WEIRD: weird #define body";
+ define_ident acc xs
+ end
+
+ | _ ->
+ pr2 "WEIRD: weird #define body";
+ define_ident acc xs
+ )
+ | x::xs ->
+ let acc = x :: acc in
+ define_ident acc xs
+
+
+
+let fix_tokens_define2 xs =
+ define_ident [] (define_line_1 [] xs)
+
+let fix_tokens_define a =
+ Common.profile_code "C parsing.fix_define" (fun () -> fix_tokens_define2 a)
+
+
+
+(*****************************************************************************)
+(* for the cpp-builtin, standard.h, part 0 *)
+(*****************************************************************************)
+
+let macro_body_to_maybe_hint body =
+ match body with
+ | [] -> DefineBody body
+ | [TIdent (s,i1)] ->
+ (match parsinghack_hint_of_string s with
+ | Some hint -> DefineHint hint
+ | None -> DefineBody body
+ )
+ | xs -> DefineBody body
+
+
+let rec define_parse xs =
+ match xs with
+ | [] -> []
+ | TDefine i1::TIdentDefine (s,i2)::TOParDefine i3::xs ->
+ (* note: the macro could be badly written and have no closing ')' for
+ * its param, which would make us go too far away, but I don't think
+ * it's important to handle such an error *)
+ let (tokparams, _, xs) =
+ xs +> Common.split_when (function TCPar _ -> true | _ -> false) in
+ let (body, _, xs) =
+ xs +> Common.split_when (function TDefEOL _ -> true | _ -> false) in
+ let params =
+ tokparams +> Common.map_filter (function
+ | TComma _ -> None
+ | TIdent (s, _) -> Some s
+
+ (* TODO *)
+ | TDefParamVariadic (s, _) -> Some s
+ (* TODO *)
+ | TEllipsis _ -> Some "..."
+
+ | x ->
+ (* bugfix: param of macros can be tricky *)
+ let s = TH.str_of_tok x in
+ if s ==~ Common.regexp_alpha
+ then begin
+ pr2 (spf "remaping: %s to a macro parameter" s);
+ Some s
+ end
+ else
+ error_cant_have x
+ ) in
+ (* bugfix: also substitute to ident in body so cpp_engine will
+ * have an easy job.
+ *)
+ let body = body +> List.map (fun tok ->
+ match tok with
+ | TIdent _ -> tok
+ | _ ->
+ let s = TH.str_of_tok tok in
+ let ii = TH.info_of_tok tok in
+ if s ==~ Common.regexp_alpha && List.mem s params
+ then begin
+ pr2 (spf "remaping: %s to an ident in macro body" s);
+ TIdent (s, ii)
+ end
+ else tok
+ ) +> List.map (TH.visitor_info_of_tok Ast_c.make_expanded) in
+ let def = (s, (s, Params params, macro_body_to_maybe_hint body)) in
+ def::define_parse xs
+
+ | TDefine i1::TIdentDefine (s,i2)::xs ->
+ let (body, _, xs) =
+ xs +> Common.split_when (function TDefEOL _ -> true | _ -> false) in
+ let body = body +> List.map
+ (TH.visitor_info_of_tok Ast_c.make_expanded) in
+ let def = (s, (s, NoParam, macro_body_to_maybe_hint body)) in
+ def::define_parse xs
+
+ (* cf tests-bis/define_plus.c *)
+ | TDefine i1::xs ->
+ let line = Ast_c.line_of_info i1 in
+ pr2 (spf "WEIRD: no ident in define at line %d" line);
+ define_parse xs
+
+ | x::xs -> define_parse xs
+
+
+
+let extract_cpp_define xs =
+ let cleaner = xs +> List.filter (fun x ->
+ not (TH.is_comment x)
+ ) in
+ define_parse cleaner
+
+
+
+
--- /dev/null
+(*
+ * Do stuff involving cpp macros, like expanding some macros,
+ * or try to parse well the body of the define by finding the end of
+ * define virtual end-of-line token.
+ *)
+
+(* corresponds to what is in the yacfe configuration file (e.g. standard.h) *)
+type define_def = string * define_param * define_body
+ and define_param =
+ | NoParam
+ | Params of string list
+ and define_body =
+ | DefineBody of Parser_c.token list
+ | DefineHint of parsinghack_hint
+
+ (* strongly corresponds to the TMacroXxx in the grammar and lexer and the
+ * MacroXxx in the ast.
+ *)
+ and parsinghack_hint =
+ | HintIterator
+ | HintDeclarator
+ | HintMacroString
+ | HintMacroStatement
+ | HintAttribute
+ | HintMacroIdentBuilder
+
+(* This function work by side effect and may generate new tokens
+ * in the new_tokens_before field of the token_extended in the
+ * paren_grouped list. So don't forget to recall
+ * Token_views_c.rebuild_tokens_extented after this call, as well
+ * as probably parsing_hacks.insert_virtual_positions as new tokens
+ * are generated.
+ *)
+val apply_macro_defs:
+ msg_apply_known_macro:(string -> unit) ->
+ msg_apply_known_macro_hint:(string -> unit) ->
+ (string, define_def) Hashtbl.t ->
+ Token_views_c.paren_grouped list -> unit
+
+(* generate virtual end-of-line token *)
+val fix_tokens_define :
+ Parser_c.token list -> Parser_c.token list
+
+val extract_cpp_define :
+ Parser_c.token list -> (string, define_def) Common.assoc
+
(*****************************************************************************)
-(* convenient globals to pass to parse_c.init_defs *)
+(* convenient globals. *)
(*****************************************************************************)
let path = ref
(try (Sys.getenv "YACFE_HOME")
with Not_found-> "/home/pad/c-yacfe"
)
-let std_h = ref (Filename.concat !path "data/standard.h")
-let common_h = ref (Filename.concat !path "data/common_macros.h")
+
+(*****************************************************************************)
+(* macros *)
+(*****************************************************************************)
+
+let macro_dir = "config/macros/"
+let mk_macro_path ~cocci_path file =
+ Filename.concat cocci_path (macro_dir ^ file)
+
+
+(* to pass to parse_c.init_defs *)
+let std_h = ref (mk_macro_path ~cocci_path:!path "standard.h")
+let common_h = ref (mk_macro_path ~cocci_path:!path "common_macros.h")
let cmdline_flags_macrofile () =
[
- "-macro_file", Arg.Set_string std_h,
+ "-macro_file_builtins", Arg.Set_string std_h,
" <file> (default=" ^ !std_h ^ ")";
]
" <file> (default=" ^ !std_envir ^ ")";
]
+(*****************************************************************************)
+(* show *)
+(*****************************************************************************)
+
+let show_parsing_error = ref true
(*****************************************************************************)
(* verbose *)
let verbose_lexing = ref true
let verbose_parsing = ref true
let verbose_type = ref true
+let verbose_cfg = ref true
let verbose_annotater = ref true
+let verbose_unparsing = ref true
+let verbose_visit = ref true
+let verbose_cpp_ast = ref true
let filter_msg = ref false
let filter_msg_define_error = ref false
let pretty_print_type_info = ref false
let pretty_print_comment_info = ref false
+let pretty_print_typedef_value = ref false
(* cocci specific *)
let show_flow_labels = ref true
let debug_typedef = ref false
let debug_cpp = ref false
+let debug_cpp_ast = ref false
+
let debug_unparsing = ref false
let debug_cfg = ref false
let cpp_directive_passing = ref false
let ifdef_directive_passing = ref false
-let disable_two_pass = ref false
+let disable_multi_pass = ref false
let disable_add_typedef = ref false
let if0_passing = ref true
"-noadd_typedef_root", Arg.Clear add_typedef_root, " ";
"-noadd_typedef", Arg.Set disable_add_typedef, " ";
- "-disable_two_pass", Arg.Set disable_two_pass, " ";
+ "-disable_multi_pass", Arg.Set disable_multi_pass, " ";
]
(*****************************************************************************)
]
(*****************************************************************************)
+(* for lexing of integer constants *)
+(*****************************************************************************)
+
+let int_thresholds =
+ ref (None :
+ (int (*int_sz*) * int (*long_sz*) *
+ Big_int.big_int (*uint threshold*) *
+ Big_int.big_int (*long threshold*) *
+ Big_int.big_int (*ulong threshold*)) option)
+
+let set_int_bits n =
+ match !int_thresholds with
+ None ->
+ (*assume long is 2*int; this can be corrected by a subsequent long_bits*)
+ let uint_threshold = Big_int.power_int_positive_int 2 (n-1) in
+ let long_threshold = Big_int.power_int_positive_int 2 n in
+ let ulong_threshold = Big_int.power_int_positive_int 2 ((2*n)-1) in
+ int_thresholds :=
+ Some (n,2*n,uint_threshold,long_threshold,ulong_threshold)
+ | Some(int_sz,long_sz,uint_threshold,long_threshold,ulong_threshold) ->
+ let uint_threshold = Big_int.power_int_positive_int 2 (n-1) in
+ let long_threshold = Big_int.power_int_positive_int 2 n in
+ int_thresholds :=
+ Some (n,long_sz,uint_threshold,long_threshold,ulong_threshold)
+
+let set_long_bits n =
+ match !int_thresholds with
+ None ->
+ (*assume int is 1/2*int; this can be corrected by a subsequent int_bits*)
+ set_int_bits (n/2)
+ | Some(int_sz,long_sz,uint_threshold,long_threshold,ulong_threshold) ->
+ let ulong_threshold = Big_int.power_int_positive_int 2 (n-1) in
+ int_thresholds :=
+ Some (int_sz,n,uint_threshold,long_threshold,ulong_threshold)
+
+(*****************************************************************************)
+(* unparsing strategy *)
+(*****************************************************************************)
+
+type spacing = LINUX | SMPL
+let spacing = ref LINUX
+
+let set_linux_spacing _ = spacing := LINUX (*follow the conventions of Linux*)
+let set_smpl_spacing _ = spacing := SMPL (*use spacing from the SP*)
+
+(*****************************************************************************)
(*****************************************************************************)
(* Wrappers *)
(*****************************************************************************)
-let pr2 s =
- if !Flag_parsing_c.verbose_lexing
- then Common.pr2 s
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_lexing
(*****************************************************************************)
let error_radix s =
("numeric " ^ s ^ " constant contains digits beyond the radix:")
+(* functions for figuring out the type of integers *)
+
+let is_long_dec s int uint long ulong =
+ match !Flag_parsing_c.int_thresholds with
+ None -> int
+ | Some (_,_,uint_threshold,long_threshold,ulong_threshold) ->
+ let bn = Big_int.big_int_of_string s in
+ if Big_int.ge_big_int bn ulong_threshold
+ then ulong
+ else
+ if Big_int.ge_big_int bn long_threshold
+ then long
+ else
+ if Big_int.ge_big_int bn uint_threshold
+ then long
+ else int
+
+let is_long_ho s int uint long ulong drop bpd count =
+ match !Flag_parsing_c.int_thresholds with
+ None -> int
+ | Some (uint_sz,ulong_sz,_,_,_) ->
+ let len = String.length s in
+ (* this assumes that all of the hex/oct digits are significant *)
+ (* drop is 2 for hex (0x) and 1 for oct (0) *)
+ let s = String.sub s drop (len - drop) in
+ let len =
+ ((len-drop) * bpd) -
+ (count (int_of_string("0x"^(String.sub s 0 1)))) in
+ if len < uint_sz
+ then int
+ else
+ if len = uint_sz
+ then uint
+ else
+ if len < ulong_sz
+ then long
+ else ulong
+
+let is_long_oct s int uint long ulong =
+ is_long_ho s int uint long ulong 1 3
+ (* stupid, but probably more efficient than taking logs *)
+ (function 0 -> 3 | 1 -> 2 | n when n < 4 -> 1 | _ -> 0)
+let is_long_hex s int uint long ulong =
+ is_long_ho s int uint long ulong 2 4
+ (* stupid, but probably more efficient than taking logs *)
+ (function 0 -> 4 | 1 -> 3 | n when n < 4 -> 2 | n when n < 8 -> 1
+ | _ -> 0)
+
+let sint = (Signed,CInt)
+let uint = (UnSigned,CInt)
+let slong = (Signed,CLong)
+let ulong = (UnSigned,CLong)
+
}
(*****************************************************************************)
}
- (* Take care of the order ? No because lex try the longest match. The
+ (* Take care of the order ? No because lex tries the longest match. The
* strange diff between decimal and octal constant semantic is not
* understood too by refman :) refman:11.1.4, and ritchie.
- *
- * todo: attach type info to constant, like for float
*)
- | (( decimal | hexa | octal)
- ( ['u' 'U']
- | ['l' 'L']
- | (['l' 'L'] ['u' 'U'])
- | (['u' 'U'] ['l' 'L'])
- | (['u' 'U'] ['l' 'L'] ['l' 'L'])
- | (['l' 'L'] ['l' 'L'])
- )?
- ) as x { TInt (x, tokinfo lexbuf) }
-
+ | decimal as x
+ { TInt ((x, is_long_dec x sint slong slong ulong), tokinfo lexbuf) }
+ | hexa as x
+ { TInt ((x, is_long_hex x sint uint slong ulong), tokinfo lexbuf) }
+ | octal as x
+ { TInt ((x, is_long_oct x sint uint slong ulong), tokinfo lexbuf) }
+ | ((decimal as s) ['u' 'U']) as x
+ { TInt ((x, is_long_dec s uint uint ulong ulong), tokinfo lexbuf) }
+ | ((hexa as s) ['u' 'U']) as x
+ { TInt ((x, is_long_hex s uint uint ulong ulong), tokinfo lexbuf) }
+ | ((octal as s) ['u' 'U']) as x
+ { TInt ((x, is_long_oct s uint uint ulong ulong), tokinfo lexbuf) }
+ | (( decimal as s) ['l' 'L']) as x
+ { TInt ((x, is_long_dec s slong slong slong ulong), tokinfo lexbuf) }
+ | ((hexa as s) ['l' 'L']) as x
+ { TInt ((x, is_long_hex s slong slong slong ulong), tokinfo lexbuf) }
+ | ((octal as s) ['l' 'L']) as x
+ { TInt ((x, is_long_oct s slong slong slong ulong), tokinfo lexbuf) }
+ | ((( decimal | hexa | octal) ['l' 'L'] ['u' 'U'])
+ | (( decimal | hexa | octal) ['u' 'U'] ['l' 'L'])) as x
+ { TInt ((x, (UnSigned,CLong)), tokinfo lexbuf) }
+ | (( decimal | hexa | octal) ['l' 'L'] ['l' 'L']) as x
+ { TInt ((x, (Signed,CLongLong)), tokinfo lexbuf) }
+ | (( decimal | hexa | octal) ['u' 'U'] ['l' 'L'] ['l' 'L']) as x
+ { TInt ((x, (UnSigned,CLongLong)), tokinfo lexbuf) }
| (real ['f' 'F']) as x { TFloat ((x, CFloat), tokinfo lexbuf) }
| (real ['l' 'L']) as x { TFloat ((x, CLongDouble), tokinfo lexbuf) }
(* noteopti: *)
| [^ '*']+ { let s = tok lexbuf in s ^ comment lexbuf }
| [ '*'] { let s = tok lexbuf in s ^ comment lexbuf }
+ | eof { pr2 "LEXER: end of file in comment"; "*/"}
| _
{ let s = tok lexbuf in
pr2 ("LEXER: unrecognised symbol in comment:"^s);
(* parse_typedef_fix *)
let _handle_typedef = ref true
+let _always_look_typedef = ref false
+
(* parse_typedef_fix2 *)
let enable_typedef () = _handle_typedef := true
let disable_typedef () = _handle_typedef := false
let (_typedef : (string, identkind) Common.scoped_h_env ref) =
ref (Common.empty_scoped_h_env ())
-let is_typedef s = if !_handle_typedef then
+let is_typedef s = if !_handle_typedef || !_always_look_typedef then
(match (Common.optionise (fun () -> Common.lookup_h_env s !_typedef)) with
| Some TypeDefI -> true
| Some IdentI -> false
*)
open Common
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
+
(*****************************************************************************)
(* Abstract line *)
(*****************************************************************************)
function i -> ctr := !ctr + 1; Ast_c.al_info_cpp !ctr i));
Visitor_c.kexpr_s = (fun (k,_) e ->
- let (e', ty),ii' = k e in
+ let (e', ty), ii' = k e in
(e', Ast_c.noType()(*ref !ty*)), ii' (* keep type - jll *)
);
let (s, ii2) = xx in
s
)
+
+
+
+(* only used in ast_to_flow, so move it ? *)
+let rec stmt_elems_of_sequencable xs =
+ xs +> Common.map (fun x ->
+ match x with
+ | Ast_c.StmtElem e -> [e]
+ | Ast_c.CppDirectiveStmt _
+ | Ast_c.IfdefStmt _
+ ->
+ pr2_once ("stmt_elems_of_sequencable: filter a directive");
+ []
+ | Ast_c.IfdefStmt2 (_ifdef, xxs) ->
+ pr2 ("stmt_elems_of_sequencable: IfdefStm2 TODO?");
+ xxs +> List.map (fun xs ->
+ let xs' = stmt_elems_of_sequencable xs in
+ xs'
+ ) +> List.flatten
+ ) +> List.flatten
+
+
+
(*****************************************************************************)
(* Wrappers *)
(*****************************************************************************)
-let pr2 s =
- if !Flag_parsing_c.verbose_parsing
- then Common.pr2 s
-
-let pr2_once s =
- if !Flag_parsing_c.verbose_parsing
- then Common.pr2_once s
+let pr2_err, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
(*****************************************************************************)
(* Helpers *)
let file = TH.file_of_tok tok in
if !Flag_parsing_c.verbose_parsing
then Common.error_message file (token_to_strpos tok)
- else ("error in " ^ file ^ "set verbose_parsing for more info")
+ else ("error in " ^ file ^ "; set verbose_parsing for more info")
let print_bad line_error (start_line, end_line) filelines =
(* called by parse_print_error_heuristic *)
let tokens2 file =
- let table = Common.full_charpos_to_pos file in
+ let table = Common.full_charpos_to_pos_large file in
Common.with_open_infile file (fun chan ->
let lexbuf = Lexing.from_channel chan in
(* could assert pinfo.filename = file ? *)
match Ast_c.pinfo_of_info ii with
Ast_c.OriginTok pi ->
- Ast_c.OriginTok (Common.complete_parse_info file table pi)
+ Ast_c.OriginTok (Common.complete_parse_info_large file table pi)
| Ast_c.ExpandedTok (pi,vpi) ->
- Ast_c.ExpandedTok((Common.complete_parse_info file table pi),vpi)
+ Ast_c.ExpandedTok((Common.complete_parse_info_large file table pi),vpi)
| Ast_c.FakeTok (s,vpi) -> Ast_c.FakeTok (s,vpi)
| Ast_c.AbstractLineTok pi -> failwith "should not occur"
})
let lexer_function =
(fun _ ->
if TH.is_eof !cur_tok
- then (pr2 "LEXER: ALREADY AT END"; !cur_tok)
+ then (pr2_err "LEXER: ALREADY AT END"; !cur_tok)
else
let v = Common.pop2 all_tokens in
cur_tok := v;
| CReservedKwd (type | decl | qualif | flow | misc | attr)
*)
-let ident_to_typename ident =
- (Ast_c.nQ, (Ast_c.TypeName (ident, Ast_c.noTypedefDef()), Ast_c.noii))
+let ident_to_typename ident : Ast_c.fullType =
+ Ast_c.mk_ty (Ast_c.TypeName (ident, Ast_c.noTypedefDef())) Ast_c.noii
(* parse_typedef_fix4 *)
let xs = Common.hash_to_list v in
if List.length xs >= 2
then begin
- pr2 ("CONFLICT:" ^ k);
+ pr2_err ("CONFLICT:" ^ k);
let sorted = xs +> List.sort (fun (ka,va) (kb,vb) ->
if !va =|= !vb then
(match ka, kb with
let sorted = List.rev sorted in
match sorted with
| [CTypedef, i1;CIdent, i2] ->
- pr2 ("transforming some ident in typedef");
+ pr2_err ("transforming some ident in typedef");
push2 k ident_to_type;
| _ ->
- pr2 ("TODO:other transforming?");
+ pr2_err ("TODO:other transforming?");
end
);
Visitor_c.kdefineval_s = (fun (k,bigf) x ->
match x with
| Ast_c.DefineExpr e ->
- (match e with
- | (Ast_c.Ident (ident), _), _ii ->
+ (match Ast_c.unwrap_expr e with
+ | Ast_c.Ident (ident) ->
let s = Ast_c.str_of_name ident in
if List.mem s !ident_to_type
then
| _ -> k x
);
Visitor_c.kexpr_s = (fun (k, bigf) x ->
- match x with
+ match Ast_c.get_e_and_ii x with
| (Ast_c.SizeOfExpr e, tref), isizeof ->
let i1 = tuple_of_list1 isizeof in
- (match e with
+ (match Ast_c.get_e_and_ii e with
| (Ast_c.ParenExpr e, _), iiparen ->
- (match e with
+ let (i2, i3) = tuple_of_list2 iiparen in
+ (match Ast_c.get_e_and_ii e with
| (Ast_c.Ident (ident), _), _ii ->
let s = Ast_c.str_of_name ident in
if List.mem s !ident_to_type
then
let t = ident_to_typename ident in
- let (i2, i3) = tuple_of_list2 iiparen in
- (Ast_c.SizeOfType t, tref), [i1;i2;i3]
+ (Ast_c.SizeOfType t, tref),[i1;i2;i3]
else k x
| _ -> k x
)
(* Error recovery *)
(*****************************************************************************)
+let is_define_passed passed =
+ let xs = passed +> List.rev +> List.filter TH.is_not_comment in
+ if List.length xs >= 2
+ then
+ (match Common.head_middle_tail xs with
+ | Parser_c.TDefine _, _, Parser_c.TDefEOL _ ->
+ true
+ | _ -> false
+ )
+ else begin
+ pr2_err "WEIRD: length list of error recovery tokens < 2 ";
+ false
+ end
+
+let is_defined_passed_bis last_round =
+ let xs = last_round +> List.filter TH.is_not_comment in
+ match xs with
+ | Parser_c.TDefine _::_ -> true
+ | _ -> false
+
+(* ---------------------------------------------------------------------- *)
+
+
(* todo: do something if find Parser_c.Eof ? *)
let rec find_next_synchro next already_passed =
* first { I found, so quite sure we will not loop. *)
let last_round = List.rev already_passed in
- let is_define =
- let xs = last_round +> List.filter TH.is_not_comment in
- match xs with
- | Parser_c.TDefine _::_ -> true
- | _ -> false
- in
- if is_define
+ if is_defined_passed_bis last_round
then find_next_synchro_define (last_round ++ next) []
else
and find_next_synchro_define next already_passed =
match next with
| [] ->
- pr2 "ERROR-RECOV: end of file while in recovery mode";
+ pr2_err "ERROR-RECOV: end of file while in recovery mode";
already_passed, []
| (Parser_c.TDefEOL i as v)::xs ->
- pr2 ("ERROR-RECOV: found sync end of #define, line "^i_to_s(TH.line_of_tok v));
+ pr2_err ("ERROR-RECOV: found sync end of #define, line "^i_to_s(TH.line_of_tok v));
v::already_passed, xs
| v::xs ->
find_next_synchro_define xs (v::already_passed)
and find_next_synchro_orig next already_passed =
match next with
| [] ->
- pr2 "ERROR-RECOV: end of file while in recovery mode";
+ pr2_err "ERROR-RECOV: end of file while in recovery mode";
already_passed, []
| (Parser_c.TCBrace i as v)::xs when TH.col_of_tok v =|= 0 ->
- pr2 ("ERROR-RECOV: found sync '}' at line "^i_to_s (TH.line_of_tok v));
+ pr2_err ("ERROR-RECOV: found sync '}' at line "^i_to_s (TH.line_of_tok v));
(match xs with
| [] -> raise Impossible (* there is a EOF token normally *)
(* still useful: now parser.mly allow empty ';' so normally no pb *)
| Parser_c.TPtVirg iptvirg::xs ->
- pr2 "ERROR-RECOV: found sync bis, eating } and ;";
+ pr2_err "ERROR-RECOV: found sync bis, eating } and ;";
(Parser_c.TPtVirg iptvirg)::v::already_passed, xs
| Parser_c.TIdent x::Parser_c.TPtVirg iptvirg::xs ->
- pr2 "ERROR-RECOV: found sync bis, eating ident, }, and ;";
+ pr2_err "ERROR-RECOV: found sync bis, eating ident, }, and ;";
(Parser_c.TPtVirg iptvirg)::(Parser_c.TIdent x)::v::already_passed,
xs
| Parser_c.TCommentSpace sp::Parser_c.TIdent x::Parser_c.TPtVirg iptvirg
::xs ->
- pr2 "ERROR-RECOV: found sync bis, eating ident, }, and ;";
+ pr2_err "ERROR-RECOV: found sync bis, eating ident, }, and ;";
(Parser_c.TCommentSpace sp)::
(Parser_c.TPtVirg iptvirg)::
(Parser_c.TIdent x)::
| Parser_c.TCommentNewline sp::Parser_c.TIdent x::Parser_c.TPtVirg iptvirg
::xs ->
- pr2 "ERROR-RECOV: found sync bis, eating ident, }, and ;";
+ pr2_err "ERROR-RECOV: found sync bis, eating ident, }, and ;";
(Parser_c.TCommentNewline sp)::
(Parser_c.TPtVirg iptvirg)::
(Parser_c.TIdent x)::
v::already_passed, xs
)
| v::xs when TH.col_of_tok v =|= 0 && TH.is_start_of_something v ->
- pr2 ("ERROR-RECOV: found sync col 0 at line "^ i_to_s(TH.line_of_tok v));
+ pr2_err ("ERROR-RECOV: found sync col 0 at line "^ i_to_s(TH.line_of_tok v));
already_passed, v::xs
| v::xs ->
find_next_synchro_orig xs (v::already_passed)
-
+
+(*****************************************************************************)
+(* Macro problem recovery *)
+(*****************************************************************************)
+module TV = Token_views_c
+
+let candidate_macros_in_passed2 passed defs_optional =
+ let res = ref [] in
+ let res2 = ref [] in
+
+ passed +> List.iter (function
+ | Parser_c.TIdent (s,_)
+ (* bugfix: may have to undo some infered things *)
+ | Parser_c.TMacroIterator (s,_)
+ | Parser_c.TypedefIdent (s,_)
+ ->
+ (match Common.hfind_option s defs_optional with
+ | Some def ->
+ if s ==~ Parsing_hacks.regexp_macro
+ then
+ (* pr2 (spf "candidate: %s" s); *)
+ Common.push2 (s, def) res
+ else
+ Common.push2 (s, def) res2
+ | None -> ()
+ )
+
+ | _ -> ()
+ );
+ if null !res
+ then !res2
+ else !res
+
+let candidate_macros_in_passed a b =
+ Common.profile_code "MACRO managment" (fun () ->
+ candidate_macros_in_passed2 a b)
+
+
+
+let find_optional_macro_to_expand2 ~defs toks =
+
+ let defs = Common.hash_of_list defs in
+
+ let toks = toks +> Common.map (function
+
+ (* special cases to undo *)
+ | Parser_c.TMacroIterator (s, ii) ->
+ if Hashtbl.mem defs s
+ then Parser_c.TIdent (s, ii)
+ else Parser_c.TMacroIterator (s, ii)
+
+ | Parser_c.TypedefIdent (s, ii) ->
+ if Hashtbl.mem defs s
+ then Parser_c.TIdent (s, ii)
+ else Parser_c.TypedefIdent (s, ii)
+
+ | x -> x
+ ) in
+
+ let tokens = toks in
+ Parsing_hacks.fix_tokens_cpp ~macro_defs:defs tokens
+
+ (* just calling apply_macro_defs and having a specialized version
+ * of the code in fix_tokens_cpp is not enough as some work such
+ * as the passing of the body of attribute in Parsing_hacks.find_macro_paren
+ * will not get the chance to be run on the new expanded tokens.
+ * Hence even if it's expensive, it's currently better to
+ * just call directly fix_tokens_cpp again here.
+
+ let tokens2 = ref (tokens +> Common.acc_map TV.mk_token_extended) in
+ let cleaner = !tokens2 +> Parsing_hacks.filter_cpp_stuff in
+ let paren_grouped = TV.mk_parenthised cleaner in
+ Cpp_token_c.apply_macro_defs
+ ~msg_apply_known_macro:(fun s -> pr2 (spf "APPLYING: %s" s))
+ ~msg_apply_known_macro_hint:(fun s -> pr2 "hint")
+ defs paren_grouped;
+ (* because the before field is used by apply_macro_defs *)
+ tokens2 := TV.rebuild_tokens_extented !tokens2;
+ Parsing_hacks.insert_virtual_positions
+ (!tokens2 +> Common.acc_map (fun x -> x.TV.tok))
+ *)
+let find_optional_macro_to_expand ~defs a =
+ Common.profile_code "MACRO managment" (fun () ->
+ find_optional_macro_to_expand2 ~defs a)
+
+
+
(*****************************************************************************)
(* Include/Define hacks *)
(*****************************************************************************)
let rec comment_until_defeol xs =
match xs with
- | [] -> failwith "cant find end of define token TDefEOL"
+ | [] ->
+ (* job not done in Cpp_token_c.define_parse ? *)
+ failwith "cant find end of define token TDefEOL"
| x::xs ->
(match x with
| Parser_c.TDefEOL i ->
(*****************************************************************************)
let parse_cpp_define_file2 file =
- let toks = tokens ~profile:false file in
- let toks = Parsing_hacks.fix_tokens_define toks in
- Parsing_hacks.extract_cpp_define toks
+ Common.save_excursion Flag_parsing_c.verbose_lexing (fun () ->
+ Flag_parsing_c.verbose_lexing := false;
+ let toks = tokens ~profile:false file in
+ let toks = Cpp_token_c.fix_tokens_define toks in
+ Cpp_token_c.extract_cpp_define toks
+ )
let parse_cpp_define_file a =
Common.profile_code_exclusif "HACK" (fun () -> parse_cpp_define_file2 a)
+
+
+let (_defs : (string, Cpp_token_c.define_def) Hashtbl.t ref) =
+ ref (Hashtbl.create 101)
+
+let (_defs_builtins : (string, Cpp_token_c.define_def) Hashtbl.t ref) =
+ ref (Hashtbl.create 101)
+
+
(* can not be put in parsing_hack, cos then mutually recursive problem as
* we also want to parse the standard.h file.
*)
-let init_defs std_h =
+let init_defs_macros std_h =
if not (Common.lfile_exists std_h)
then pr2 ("warning: Can't find default macro file: " ^ std_h)
else begin
pr2 ("init_defs: " ^ std_h);
- Parsing_hacks._defs := Common.hash_of_list (parse_cpp_define_file std_h);
+ _defs := Common.hash_of_list (parse_cpp_define_file std_h);
+ end
+
+let init_defs_builtins file_h =
+ if not (Common.lfile_exists file_h)
+ then pr2 ("warning: Can't find macro file: " ^ file_h)
+ else begin
+ pr2 ("init_defs_builtins: " ^ file_h);
+ _defs_builtins :=
+ Common.hash_of_list (parse_cpp_define_file file_h);
end
mutable passed : Parser_c.token list;
mutable passed_clean : Parser_c.token list;
}
-let clone_tokens_stat tr =
+
+let mk_tokens_state toks =
+ {
+ rest = toks;
+ rest_clean = (toks +> List.filter TH.is_not_comment);
+ current = (List.hd toks);
+ passed = [];
+ passed_clean = [];
+ }
+
+
+
+let clone_tokens_state tr =
{ rest = tr.rest;
rest_clean = tr.rest_clean;
current = tr.current;
passed = tr.passed;
passed_clean = tr.passed_clean;
}
-let copy_tokens_stat ~src ~dst =
+let copy_tokens_state ~src ~dst =
dst.rest <- src.rest;
dst.rest_clean <- src.rest_clean;
dst.current <- src.current;
dst.passed_clean <- src.passed_clean;
()
+(* todo? agglomerate the x##b ? *)
let rec filter_noise n xs =
match n, xs with
| _, [] -> []
*)
let rec lexer_function ~pass tr = fun lexbuf ->
match tr.rest with
- | [] -> pr2 "ALREADY AT END"; tr.current
+ | [] -> pr2_err "ALREADY AT END"; tr.current
| v::xs ->
tr.rest <- xs;
tr.current <- v;
*)
| Parser_c.TDefine (tok) ->
if not (LP.current_context () =*= LP.InTopLevel) &&
- (!Flag_parsing_c.cpp_directive_passing || (pass =|= 2))
+ (!Flag_parsing_c.cpp_directive_passing || (pass >= 2))
then begin
incr Stat.nDefinePassing;
pr2_once ("CPP-DEFINE: inside function, I treat it as comment");
| Parser_c.TInclude (includes, filename, inifdef, info) ->
if not (LP.current_context () =*= LP.InTopLevel) &&
- (!Flag_parsing_c.cpp_directive_passing || (pass =|= 2))
+ (!Flag_parsing_c.cpp_directive_passing || (pass >= 2))
then begin
incr Stat.nIncludePassing;
pr2_once ("CPP-INCLUDE: inside function, I treat it as comment");
end
+let max_pass = 4
+
let get_one_elem ~pass tr (file, filelines) =
if not (LP.is_enabled_typedef()) && !Flag_parsing_c.debug_typedef
- then pr2 "TYPEDEF:_handle_typedef=false. Not normal if dont come from exn";
+ then pr2_err "TYPEDEF:_handle_typedef=false. Not normal if dont come from exn";
(* normally have to do that only when come from an exception in which
* case the dt() may not have been done
Common.profile_code_exclusif "YACC" (fun () ->
Left (Parser_c.celem (lexer_function ~pass tr) lexbuf_fake)
)
- with e -> begin
- if (pass =|= 1 && !Flag_parsing_c.disable_two_pass)|| (pass =|= 2)
- then begin
- (match e with
- (* Lexical is not anymore launched I think *)
- | Lexer_c.Lexical s ->
- pr2 ("lexical error " ^s^ "\n =" ^ error_msg_tok tr.current)
- | Parsing.Parse_error ->
- pr2 ("parse error \n = " ^ error_msg_tok tr.current)
- | Semantic_c.Semantic (s, i) ->
- pr2 ("semantic error " ^s^ "\n ="^ error_msg_tok tr.current)
- | e -> raise e
- )
- end;
+ with e ->
LP.restore_typedef_state();
(* must keep here, before the code that adjusts the tr fields *)
let line_error = TH.line_of_tok tr.current in
-
+
+ let passed_before_error = tr.passed in
+ let current = tr.current in
(* error recovery, go to next synchro point *)
let (passed', rest') = find_next_synchro tr.rest tr.passed in
let info_of_bads = Common.map_eff_rev TH.info_of_tok tr.passed in
- Right (info_of_bads, line_error, tr.passed)
- end
+ Right (info_of_bads, line_error,
+ tr.passed, passed_before_error,
+ current, e)
)
(* -------------------------------------------------- *)
LP.lexer_reset_typedef();
Parsing_hacks.ifdef_paren_cnt := 0;
+
let toks_orig = tokens file in
- let toks = Parsing_hacks.fix_tokens_define toks_orig in
- let toks = Parsing_hacks.fix_tokens_cpp toks in
-
- let tr = {
- rest = toks;
- rest_clean = (toks +> List.filter TH.is_not_comment);
- current = (List.hd toks);
- passed = [];
- passed_clean = [];
- } in
+ let toks = Cpp_token_c.fix_tokens_define toks_orig in
+ let toks = Parsing_hacks.fix_tokens_cpp ~macro_defs:!_defs_builtins toks in
+ (* expand macros on demand trick, preparation phase *)
+ let macros =
+ Common.profile_code "MACRO mgmt prep 1" (fun () ->
+ let macros = Hashtbl.copy !_defs in
+ (* include also builtins as some macros may generate some builtins too
+ * like __decl_spec or __stdcall
+ *)
+ !_defs_builtins +> Hashtbl.iter (fun s def ->
+ Hashtbl.replace macros s def;
+ );
+ macros
+ )
+ in
+ Common.profile_code "MACRO mgmt prep 2" (fun () ->
+ let local_macros = parse_cpp_define_file file in
+ local_macros +> List.iter (fun (s, def) ->
+ Hashtbl.replace macros s def;
+ );
+ );
+ let tr = mk_tokens_state toks in
let rec loop tr =
let checkpoint = TH.line_of_tok tr.current in
let checkpoint_file = TH.file_of_tok tr.current in
- let tr_save = clone_tokens_stat tr in
-
(* call the parser *)
let elem =
- let pass1 = get_one_elem ~pass:1 tr (file, filelines) in
+ let pass1 =
+ Common.profile_code "Parsing: 1st pass" (fun () ->
+ get_one_elem ~pass:1 tr (file, filelines)
+ ) in
match pass1 with
| Left e -> Left e
- | Right res ->
- if !Flag_parsing_c.disable_two_pass
- then Right res
+ | Right (info,line_err, passed, passed_before_error, cur, exn) ->
+ if !Flag_parsing_c.disable_multi_pass
+ then pass1
else begin
- pr2 "parsing pass2: try again";
- copy_tokens_stat ~src:tr_save ~dst: tr;
- let pass2 = get_one_elem ~pass:2 tr (file, filelines) in
- pass2
+ Common.profile_code "Parsing: multi pass" (fun () ->
+
+ pr2_err "parsing pass2: try again";
+ let toks = List.rev passed ++ tr.rest in
+ let new_tr = mk_tokens_state toks in
+ copy_tokens_state ~src:new_tr ~dst:tr;
+ let passx = get_one_elem ~pass:2 tr (file, filelines) in
+
+ (match passx with
+ | Left e -> passx
+ | Right (info,line_err,passed,passed_before_error,cur,exn) ->
+ let candidates =
+ candidate_macros_in_passed passed macros
+ in
+ if is_define_passed passed || null candidates
+ then passx
+ else begin
+ (* todo factorize code *)
+
+ pr2_err "parsing pass3: try again";
+ let toks = List.rev passed ++ tr.rest in
+ let toks' =
+ find_optional_macro_to_expand ~defs:candidates toks in
+ let new_tr = mk_tokens_state toks' in
+ copy_tokens_state ~src:new_tr ~dst:tr;
+ let passx = get_one_elem ~pass:3 tr (file, filelines) in
+
+ (match passx with
+ | Left e -> passx
+ | Right (info,line_err,passed,passed_before_error,cur,exn) ->
+ pr2_err "parsing pass4: try again";
+
+ let candidates =
+ candidate_macros_in_passed passed macros in
+
+ let toks = List.rev passed ++ tr.rest in
+ let toks' =
+ find_optional_macro_to_expand ~defs:candidates toks in
+ let new_tr = mk_tokens_state toks' in
+ copy_tokens_state ~src:new_tr ~dst:tr;
+ let passx = get_one_elem ~pass:4 tr (file, filelines) in
+ passx
+ )
+ end
+ )
+ )
end
in
let checkpoint2 = TH.line_of_tok tr.current in (* <> line_error *)
let checkpoint2_file = TH.file_of_tok tr.current in
- let was_define =
- (match elem with
- | Left _ -> false
- | Right (_, line_error, _) ->
- let was_define =
- let xs = tr.passed +> List.rev +> List.filter TH.is_not_comment in
- if List.length xs >= 2
- then
- (match Common.head_middle_tail xs with
- | Parser_c.TDefine _, _, Parser_c.TDefEOL _ ->
- true
- | _ -> false
- )
- else begin
- pr2 "WEIRD: length list of error recovery tokens < 2 ";
- false
- end
- in
- (if was_define && !Flag_parsing_c.filter_msg_define_error
- then ()
- else
- (* bugfix: *)
- if (checkpoint_file =$= checkpoint2_file) &&
- checkpoint_file =$= file
- then print_bad line_error (checkpoint, checkpoint2) filelines
- else pr2 "PB: bad: but on tokens not from original file"
- );
- was_define
- ) in
-
-
let diffline =
if (checkpoint_file =$= checkpoint2_file) && (checkpoint_file =$= file)
then (checkpoint2 - checkpoint)
| Left e ->
stat.Stat.correct <- stat.Stat.correct + diffline;
e
- | Right (info_of_bads, line_error, toks_of_bads) ->
+ | Right (info_of_bads, line_error, toks_of_bads,
+ _passed_before_error, cur, exn) ->
+
+ let was_define = is_define_passed tr.passed in
+
+ if was_define && !Flag_parsing_c.filter_msg_define_error
+ then ()
+ else begin
+
+ (match exn with
+ | Lexer_c.Lexical _
+ | Parsing.Parse_error
+ | Semantic_c.Semantic _ -> ()
+ | e -> raise e
+ );
+
+ if !Flag_parsing_c.show_parsing_error
+ then begin
+ (match exn with
+ (* Lexical is not anymore launched I think *)
+ | Lexer_c.Lexical s ->
+ pr2 ("lexical error " ^s^ "\n =" ^ error_msg_tok cur)
+ | Parsing.Parse_error ->
+ pr2 ("parse error \n = " ^ error_msg_tok cur)
+ | Semantic_c.Semantic (s, i) ->
+ pr2 ("semantic error " ^s^ "\n ="^ error_msg_tok cur)
+ | e -> raise Impossible
+ );
+ (* bugfix: *)
+ if (checkpoint_file =$= checkpoint2_file) &&
+ checkpoint_file =$= file
+ then print_bad line_error (checkpoint, checkpoint2) filelines
+ else pr2 "PB: bad: but on tokens not from original file"
+ end;
+
+
+ let pbline =
+ toks_of_bads
+ +> Common.filter (TH.is_same_line_or_close line_error)
+ +> Common.filter TH.is_ident_like
+ in
+ let error_info =
+ (pbline +> List.map TH.str_of_tok), line_error
+ in
+ stat.Stat.problematic_lines <-
+ error_info::stat.Stat.problematic_lines;
+
+ end;
+
if was_define && !Flag_parsing_c.filter_define_error
then stat.Stat.correct <- stat.Stat.correct + diffline
else stat.Stat.bad <- stat.Stat.bad + diffline;
- let pbline =
- toks_of_bads
- +> Common.filter (TH.is_same_line_or_close line_error)
- +> Common.filter TH.is_ident_like
- in
- let error_info =
- (pbline +> List.map TH.str_of_tok), line_error
- in
- stat.Stat.problematic_lines <-
- error_info::stat.Stat.problematic_lines;
-
Ast_c.NotParsedCorrectly info_of_bads
in
(*****************************************************************************)
let (cstatement_of_string: string -> Ast_c.statement) = fun s ->
- Common.write_file ("/tmp/__cocci.c") ("void main() { \n" ^ s ^ "\n}");
- let program = parse_c_and_cpp ("/tmp/__cocci.c") +> fst in
+ let tmpfile = Common.new_temp_file "cocci_stmt_of_s" "c" in
+ Common.write_file tmpfile ("void main() { \n" ^ s ^ "\n}");
+ let program = parse_c_and_cpp tmpfile +> fst in
program +> Common.find_some (fun (e,_) ->
match e with
| Ast_c.Definition ({Ast_c.f_body = [Ast_c.StmtElem st]},_) -> Some st
)
let (cexpression_of_string: string -> Ast_c.expression) = fun s ->
- Common.write_file ("/tmp/__cocci.c") ("void main() { \n" ^ s ^ ";\n}");
- let program = parse_c_and_cpp ("/tmp/__cocci.c") +> fst in
+ let tmpfile = Common.new_temp_file "cocci_expr_of_s" "c" in
+ Common.write_file tmpfile ("void main() { \n" ^ s ^ ";\n}");
+ let program = parse_c_and_cpp tmpfile +> fst in
program +> Common.find_some (fun (e,_) ->
match e with
| Ast_c.Definition ({Ast_c.f_body = compound},_) ->
(match compound with
- | [Ast_c.StmtElem (Ast_c.ExprStatement (Some e),ii)] -> Some e
+ | [Ast_c.StmtElem st] ->
+ (match Ast_c.unwrap_st st with
+ | Ast_c.ExprStatement (Some e) -> Some e
+ | _ -> None
+ )
| _ -> None
)
| _ -> None
(* the token list contains now also the comment-tokens *)
and info_item = (string * Parser_c.token list)
+(* ---------------------------------------------------------------------- *)
+(* a few globals *)
+val parse_cpp_define_file :
+ filename -> (string, Cpp_token_c.define_def) assoc
+
+(* usually correspond to what is inside your macros.h *)
+val _defs : (string, Cpp_token_c.define_def) Hashtbl.t ref
+(* usually correspond to what is inside your standard.h *)
+val _defs_builtins : (string, Cpp_token_c.define_def) Hashtbl.t ref
+
+val init_defs_macros : filename -> unit
+val init_defs_builtins : filename -> unit
+
+
(* ---------------------------------------------------------------------- *)
(* This is the main function *)
val parse_print_error_heuristic:
val parse_cache:
filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
-
-(* ---------------------------------------------------------------------- *)
-val parse_cpp_define_file :
- filename -> (string, Parsing_hacks.define_def) assoc
-
-val init_defs : filename -> unit
-
-
-
-
-
(* ---------------------------------------------------------------------- *)
(* used also for the standard.h file *)
val tokens: ?profile:bool -> filename -> Parser_c.token list
then Common.warning ("PARSING: " ^ s) v
else v
-
-let pr2 s =
- if !Flag_parsing_c.verbose_parsing
- then Common.pr2 s
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
(*****************************************************************************)
(* Parse helpers functions *)
typeD = (ty,iit);
inlineD = (inline,iinl);
} ->
- (
- ((qu, iiq),
+ let ty',iit' =
(match ty with
| (None,None,None) ->
(* generate fake_info, otherwise type_annotater can crash in
BaseType(IntType (Si (Signed, [Short,CShort; Long, CLong; LongLong, CLongLong] +> List.assoc x))), iit
| (Some UnSigned, Some x, (None| Some (BaseType (IntType (Si (_,CInt))))))->
BaseType(IntType (Si (UnSigned, [Short,CShort; Long, CLong; LongLong, CLongLong] +> List.assoc x))), iit
- | (Some sign, None, (Some (BaseType (IntType CChar)))) -> BaseType(IntType (Si (sign, CChar2))), iit
- | (None, Some Long,(Some(BaseType(FloatType CDouble)))) -> BaseType (FloatType (CLongDouble)), iit
+ | (Some sign, None, (Some (BaseType (IntType CChar)))) ->
+ BaseType(IntType (Si (sign, CChar2))), iit
+ | (None, Some Long,(Some(BaseType(FloatType CDouble)))) ->
+ BaseType (FloatType (CLongDouble)), iit
| (Some _,_, Some _) ->
(*mine*)
* {....} and never with a typedef cos now we parse short uint i
* as short ident ident => parse error (cos after first short i
* pass in dt() mode) *)
- ))
+
+ )
+ in
+ ((qu, iiq),
+ (ty', iit'))
,((st, inline),iist++iinl)
- )
+
let fixDeclSpecForParam = function ({storageD = (st,iist)} as r) ->
let ((qu,ty) as v,_st) = fixDeclSpecForDecl r in
(Semantic ("storage class specified for parameter of function",
fake_pi))
+let fixDeclSpecForMacro = function ({storageD = (st,iist)} as r) ->
+ let ((qu,ty) as v,_st) = fixDeclSpecForDecl r in
+ match st with
+ | NoSto -> v
+ | _ ->
+ raise
+ (Semantic ("storage class specified for macro type decl",
+ fake_pi))
+
+
let fixDeclSpecForFuncDef x =
let (returnType,storage) = fixDeclSpecForDecl x in
(match fst (unwrap storage) with
* argument (in the typedef)
*)
let (fixOldCDecl: fullType -> fullType) = fun ty ->
- match snd ty with
- | ((FunctionType (fullt, (params, (b, iib)))),iifunc) ->
+ match Ast_c.unwrap_typeC ty with
+ | FunctionType (fullt, (params, (b, iib))) ->
(* stdC: If the prototype declaration declares a parameter for a
* function that you are defining (it is part of a function
* definition), then you must write a name within the declarator.
* Otherwise, you can omit the name. *)
(match params with
- | [{p_namei = None; p_type = ((_qua, (BaseType Void,_)))},_] ->
- ty
+ | [{p_namei = None; p_type = ty2},_] ->
+ (match Ast_c.unwrap_typeC ty2 with
+ | BaseType Void ->
+ ty
+ | _ ->
+ pr2 ("SEMANTIC:parameter name omitted, but I continue");
+ ty
+ )
+
| params ->
(params +> List.iter (fun (param,_) ->
match param with
| {p_namei = None} ->
(* if majuscule, then certainly macro-parameter *)
- pr2 ("SEMANTIC:parameter name omitted, but I continue");
+ pr2 ("SEMANTIC:parameter name omitted, but I continue");
| _ -> ()
));
- ty)
+ ty
+ )
(* todo? can we declare prototype in the decl or structdef,
... => length <> but good kan meme *)
let fixFunc (typ, compound, old_style_opt) =
let (cp,iicp) = compound in
- match typ with
- | (name,
- (nQ, (FunctionType (fullt, (params,bool)),iifunc)),
- (st,iist),
- attrs)
- ->
+ let (name, ty, (st,iist), attrs) = typ in
+
+ let (qu, tybis) = ty in
+
+ match Ast_c.unwrap_typeC ty with
+ | FunctionType (fullt, (params,abool)) ->
+ let iifunc = Ast_c.get_ii_typeC_take_care tybis in
+
let iistart = Ast_c.fakeInfo () in
- assert (nQ =*= nullQualif);
+ assert (qu =*= nullQualif);
+
(match params with
- | [{p_namei= None; p_type =((_qua, (BaseType Void,_)))}, _] -> ()
+ | [{p_namei= None; p_type = ty2}, _] ->
+ (match Ast_c.unwrap_typeC ty2 with
+ | BaseType Void -> ()
+ | _ ->
+ (* failwith "internal errror: fixOldCDecl not good" *)
+ ()
+ )
| params ->
params +> List.iter (function
| ({p_namei = Some s}, _) -> ()
(* it must be nullQualif,cos parser construct only this*)
{f_name = name;
- f_type = (fullt, (params, bool));
+ f_type = (fullt, (params, abool));
f_storage = st;
f_body = cp;
f_attr = attrs;
LP.enable_typedef ()
-let fix_add_params_ident = function
- | ((s, (nQ, (FunctionType (fullt, (params, bool)),_)), st, _attrs)) ->
+let fix_add_params_ident x =
+ let (s, ty, st, _attrs) = x in
+ match Ast_c.unwrap_typeC ty with
+ | FunctionType (fullt, (params, bool)) ->
(match params with
- | [{p_namei=None; p_type=((_qua, (BaseType Void,_)))}, _] -> ()
+ | [{p_namei=None; p_type=ty2}, _] ->
+ (match Ast_c.unwrap_typeC ty2 with
+ | BaseType Void -> ()
+ | _ ->
+ (* failwith "internal errror: fixOldCDecl not good" *)
+ ()
+ )
| params ->
params +> List.iter (function
| ({p_namei= Some name}, _) ->
(* shortcuts *)
(*-------------------------------------------------------------------------- *)
-let mk_e e ii = ((e, Ast_c.noType()), ii)
+let mk_e e ii = Ast_c.mk_e e ii
let mk_string_wrap (s,info) = (s, [info])
/*(* the normal tokens *)*/
/*(*-----------------------------------------*)*/
-%token <string * Ast_c.info> TInt
+%token <(string * (Ast_c.sign * Ast_c.base)) * Ast_c.info> TInt
%token <(string * Ast_c.floatType) * Ast_c.info> TFloat
%token <(string * Ast_c.isWchar) * Ast_c.info> TChar
%token <(string * Ast_c.isWchar) * Ast_c.info> TString
%token <(string * Ast_c.info)> TMacroString
%token <(string * Ast_c.info)> TMacroDecl
%token <Ast_c.info> TMacroDeclConst
-%token <(string * Ast_c.info)> TMacroStructDecl
+
%token <(string * Ast_c.info)> TMacroIterator
-/*(* %token <(string * Ast_c.info)> TMacroTop *)*/
+/*(*
+%token <(string * Ast_c.info)> TMacroTop
+%token <(string * Ast_c.info)> TMacroStructDecl
+*)*/
%token <(string * Ast_c.info)> TMacroAttrStorage
* also cppext: gccext: ##args for variadic macro
*)
*/
-ident_cpp:
+identifier_cpp:
| TIdent
{ RegularName (mk_string_wrap $1) }
+ | ident_extra_cpp { $1 }
+
+ident_cpp:
+ | TIdent
+ { RegularName (mk_string_wrap $1) }
+ | TypedefIdent
+ { RegularName (mk_string_wrap $1) }
+ | ident_extra_cpp { $1 }
+
+ident_extra_cpp:
| TIdent TCppConcatOp identifier_cpp_list
{
CppConcatenatedName (
{ mk_e(Constructor ($2, List.rev $5)) ([$1;$3;$4;$7] ++ $6) }
primary_expr:
- | ident_cpp { mk_e(Ident ($1)) [] }
- | TInt { mk_e(Constant (Int (fst $1))) [snd $1] }
+ | identifier_cpp { mk_e(Ident ($1)) [] }
+ | TInt
+ { let (str,(sign,base)) = fst $1 in
+ mk_e(Constant (Int (str,Si(sign,base)))) [snd $1] }
| TFloat { mk_e(Constant (Float (fst $1))) [snd $1] }
| TString { mk_e(Constant (String (fst $1))) [snd $1] }
| TChar { mk_e(Constant (Char (fst $1))) [snd $1] }
/*(* statement *)*/
/*(*************************************************************************)*/
-statement:
+statement: statement2 { mk_st (fst $1) (snd $1) }
+
+statement2:
| labeled { Labeled (fst $1), snd $1 }
| compound { Compound (fst $1), snd $1 }
| expr_statement { ExprStatement(fst $1), snd $1 }
* and modifying below stat_or_decl_list
*)*/
| ident_cpp TDotDot
- { Label ($1, (ExprStatement None, [])), [$2] }
- | Tcase const_expr TDotDot { Case ($2, (ExprStatement None, [])), [$1;$3] }
- | Tdefault TDotDot { Default (ExprStatement None, []), [$1; $2] }
+ { Label ($1, (mk_st (ExprStatement None) Ast_c.noii)), [$2] }
+ | Tcase const_expr TDotDot
+ { Case ($2, (mk_st (ExprStatement None) Ast_c.noii)), [$1;$3] }
+ | Tdefault TDotDot
+ { Default (mk_st (ExprStatement None) Ast_c.noii), [$1; $2] }
stat_or_decl_list:
| stat_or_decl { [$1] }
/*(* gccext: to avoid conflicts, cf end_labeled above *)*/
- | end_labeled { [StmtElem (Labeled (fst $1), snd $1)] }
+ | end_labeled { [StmtElem (mk_st (Labeled (fst $1)) (snd $1))] }
/*(* old: conflicts | stat_or_decl_list stat_or_decl { $1 ++ [$2] } *)*/
| stat_or_decl stat_or_decl_list { $1 :: $2 }
stat_or_decl:
- | decl { StmtElem (Decl ($1 Ast_c.LocalDecl), []) }
+ | decl { StmtElem (mk_st (Decl ($1 Ast_c.LocalDecl)) Ast_c.noii) }
| statement { StmtElem $1 }
/*(* gccext: *)*/
- | function_definition { StmtElem (NestedFunc $1, []) }
+ | function_definition { StmtElem (mk_st (NestedFunc $1) Ast_c.noii) }
/* (* cppext: *)*/
| cpp_directive
selection:
| Tif TOPar expr TCPar statement %prec SHIFTHERE
- { If ($3, $5, (ExprStatement None, [])), [$1;$2;$4] }
+ { If ($3, $5, (mk_st (ExprStatement None) Ast_c.noii)), [$1;$2;$4] }
| Tif TOPar expr TCPar statement Telse statement
{ If ($3, $5, $7), [$1;$2;$4;$6] }
| Tswitch TOPar expr TCPar statement
/*(* so must do int * const p; if the pointer is constant, not the pointee *)*/
pointer:
- | TMul { fun x ->(nQ, (Pointer x, [$1]))}
- | TMul type_qualif_list { fun x ->($2.qualifD, (Pointer x, [$1]))}
- | TMul pointer { fun x ->(nQ, (Pointer ($2 x),[$1]))}
- | TMul type_qualif_list pointer { fun x ->($2.qualifD, (Pointer ($3 x),[$1]))}
+ | TMul { fun x -> mk_ty (Pointer x) [$1] }
+ | TMul pointer { fun x -> mk_ty (Pointer ($2 x)) [$1] }
+ | TMul type_qualif_list
+ { fun x -> ($2.qualifD, mk_tybis (Pointer x) [$1])}
+ | TMul type_qualif_list pointer
+ { fun x -> ($2.qualifD, mk_tybis (Pointer ($3 x)) [$1]) }
direct_d:
- | ident_cpp
+ | identifier_cpp
{ ($1, fun x -> x) }
| TOPar declarator TCPar /*(* forunparser: old: $2 *)*/
- { (fst $2, fun x -> (nQ, (ParenType ((snd $2) x), [$1;$3]))) }
+ { (fst $2, fun x -> mk_ty (ParenType ((snd $2) x)) [$1;$3]) }
| direct_d tocro tccro
- { (fst $1,fun x->(snd $1) (nQ,(Array (None,x), [$2;$3]))) }
+ { (fst $1,fun x->(snd $1) (mk_ty (Array (None,x)) [$2;$3])) }
| direct_d tocro const_expr tccro
- { (fst $1,fun x->(snd $1) (nQ,(Array (Some $3,x), [$2;$4])))}
+ { (fst $1,fun x->(snd $1) (mk_ty (Array (Some $3,x)) [$2;$4])) }
| direct_d topar tcpar
{ (fst $1,
fun x->(snd $1)
- (nQ,(FunctionType (x,(([],(false, [])))),[$2;$3])))
+ (mk_ty (FunctionType (x,(([],(false, []))))) [$2;$3]))
}
| direct_d topar parameter_type_list tcpar
- { (fst $1,fun x->(snd $1) (nQ,(FunctionType (x, $3), [$2;$4]))) }
+ { (fst $1,fun x->(snd $1)
+ (mk_ty (FunctionType (x, $3)) [$2;$4]))
+ }
/*(*----------------------------*)*/
direct_abstract_declarator:
| TOPar abstract_declarator TCPar /*(* forunparser: old: $2 *)*/
- { (fun x -> (nQ, (ParenType ($2 x), [$1;$3]))) }
+ { fun x -> mk_ty (ParenType ($2 x)) [$1;$3] }
| TOCro TCCro
- { fun x -> (nQ, (Array (None, x), [$1;$2]))}
+ { fun x -> mk_ty (Array (None, x)) [$1;$2] }
| TOCro const_expr TCCro
- { fun x -> (nQ, (Array (Some $2, x), [$1;$3]))}
+ { fun x -> mk_ty (Array (Some $2, x)) [$1;$3] }
| direct_abstract_declarator TOCro TCCro
- { fun x ->$1 (nQ, (Array (None, x), [$2;$3])) }
+ { fun x -> $1 (mk_ty (Array (None, x)) [$2;$3]) }
| direct_abstract_declarator TOCro const_expr TCCro
- { fun x ->$1 (nQ, (Array (Some $3,x), [$2;$4])) }
+ { fun x -> $1 (mk_ty (Array (Some $3,x)) [$2;$4]) }
| TOPar TCPar
- { fun x -> (nQ, (FunctionType (x, ([], (false, []))), [$1;$2])) }
+ { fun x -> mk_ty (FunctionType (x, ([], (false, [])))) [$1;$2] }
| topar parameter_type_list tcpar
- { fun x -> (nQ, (FunctionType (x, $2), [$1;$3]))}
+ { fun x -> mk_ty (FunctionType (x, $2)) [$1;$3] }
/*(* subtle: here must also use topar, not TOPar, otherwise if have for
* instance (xxx ( * )(xxx)) cast, then the second xxx may still be a Tident
* but we want to reduce topar, to set the InParameter so that
* "disable typedef cos special case ..." message.
*)*/
| direct_abstract_declarator topar tcpar
- { fun x ->$1 (nQ, (FunctionType (x, (([], (false, [])))),[$2;$3])) }
+ { fun x -> $1 (mk_ty (FunctionType (x, (([], (false, []))))) [$2;$3]) }
| direct_abstract_declarator topar parameter_type_list tcpar
- { fun x -> $1 (nQ, (FunctionType (x, $3), [$2;$4])) }
+ { fun x -> $1 (mk_ty (FunctionType (x, $3)) [$2;$4]) }
/*(*-----------------------------------------------------------------------*)*/
/*(* Parameters (use decl_spec not type_spec just for 'register') *)*/
/*(*----------------------------*)*/
parameter_decl: parameter_decl2 { et "param" (); $1 }
+ | attributes parameter_decl2 { et "param" (); $2 }
declaratorp:
| declarator { LP.add_ident (str_of_name (fst $1)); $1 }
storage_class_spec:
/*(* gccext: *)*/
| storage_class_spec2 { $1 }
- | storage_class_spec2 attributes_storage { $1 (* TODO *) }
+ | storage_class_spec2 attribute_storage_list { $1 (* TODO *) }
struct_decl2:
- | field_declaration { DeclarationField $1, noii }
- | TPtVirg { EmptyField, [$1] }
- | TMacroStructDecl { MacroStructDeclTodo, [] }
+ | field_declaration { DeclarationField $1 }
+ | TPtVirg { EmptyField $1 }
+
+ /*(* no conflict ? no need for a TMacroStruct ? apparently not as at struct
+ * the rule are slightly different.
+ *)*/
+ | identifier TOPar argument_list TCPar TPtVirg
+ { MacroDeclField ((fst $1, $3), [snd $1;$2;$4;$5;fakeInfo()]) }
/*(* cppext: *)*/
| cpp_directive
- { CppDirectiveStruct $1, noii }
+ { CppDirectiveStruct $1 }
| cpp_ifdef_directive/*(* struct_decl_list ... *)*/
- { IfdefStruct $1, noii }
+ { IfdefStruct $1 }
field_declaration:
define_val:
| expr { DefineExpr $1 }
| statement { DefineStmt $1 }
- | decl { DefineStmt (Decl ($1 Ast_c.NotLocalDecl), []) }
+ | decl { DefineStmt (mk_st (Decl ($1 Ast_c.NotLocalDecl)) Ast_c.noii) }
+
+/*(*old:
+ * | TypedefIdent { DefineType (nQ,(TypeName(fst $1,noTypedefDef()),[snd $1]))}
+ * get conflicts:
+ * | spec_qualif_list TMul
+ * { let (returnType, _) = fixDeclSpecForDecl $1 in DefineType returnType }
+ *)
+*/
+ | decl_spec
+ { let returnType = fixDeclSpecForMacro $1 in
+ DefineType returnType
+ }
+ | decl_spec abstract_declarator
+ { let returnType = fixDeclSpecForMacro $1 in
+ let typ = $2 returnType in
+ DefineType typ
+ }
+
+/* can be in conflict with decl_spec, maybe change fixDeclSpecForMacro
+ * to also allow storage ?
+ | storage_class_spec { DefineTodo }
+ | Tinline { DefineTodo }
+*/
+
+ /*(* a few special cases *)*/
+ | stat_or_decl stat_or_decl_list { DefineTodo }
+/*
+ | statement statement { DefineTodo }
+ | decl function_definition { DefineTodo }
+*/
+
+
+
-/*(*old: | TypedefIdent { DefineType (nQ,(TypeName(fst $1,noTypedefDef()),[snd $1]))}*)*/
- | spec_qualif_list { DefineTodo }
| function_definition { DefineFunction $1 }
| TOBraceDefineInit initialize_list gcc_comma_opt_struct TCBrace comma_opt
DefineDoWhileZero (($2,$5), [$1;$3;$4;$6])
}
- /*(* a few special cases *)*/
- | stat_or_decl stat_or_decl_list { DefineTodo }
-/*
- | statement statement { DefineTodo }
- | decl function_definition { DefineTodo }
-*/
-
| Tasm TOPar asmbody TCPar { DefineTodo }
| Tasm Tvolatile TOPar asmbody TCPar { DefineTodo }
-
/*(* aliases macro *)*/
| TMacroAttr { DefineTodo }
- | storage_class_spec { DefineTodo }
- | Tinline { DefineTodo }
| /*(* empty *)*/ { DefineEmpty }
* at the top, only decl or function definition.
*)*/
| identifier TOPar argument_list TCPar TPtVirg
- { MacroTop (fst $1, $3, [snd $1;$2;$4;$5]) }
+ {
+ Declaration (MacroDecl ((fst $1, $3), [snd $1;$2;$4;$5;fakeInfo()]))
+ (* old: MacroTop (fst $1, $3, [snd $1;$2;$4;$5]) *)
+ }
/*(* TCParEOL to fix the end-of-stream bug of ocamlyacc *)*/
| identifier TOPar argument_list TCParEOL
attributes: attribute_list { $1 }
-attributes_storage: attribute_storage_list { $1 }
/*(* gccext: which allow a trailing ',' in enum, as in perl *)*/
open Common
module TH = Token_helpers
+module TV = Token_views_c
module LP = Lexer_parser
module Stat = Parsing_stat
open Parser_c
+open TV
+
(*****************************************************************************)
(* Some debugging functions *)
(*****************************************************************************)
-let pr2 s =
- if !Flag_parsing_c.verbose_parsing
- then Common.pr2 s
-
-let pr2_once s =
- if !Flag_parsing_c.verbose_parsing
- then Common.pr2_once s
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
let pr2_cpp s =
if !Flag_parsing_c.debug_cpp
incr Stat.nIfdefFunheader;
()
+let msg_ifdef_cparen_else () =
+ incr Stat.nIfdefPassing;
+ pr2_cpp("found ifdef-cparen-else")
+
let msg_attribute s =
incr Stat.nMacroAttribute;
not (s ==~ regexp_annot)
-(* ------------------------------------------------------------------------- *)
-(* cpp part 1 for standard.h *)
-(* ------------------------------------------------------------------------- *)
-
-type define_def = string * define_param * define_body
- and define_param =
- | NoParam
- | Params of string list
- and define_body =
- | DefineBody of Parser_c.token list
- | DefineHint of parsinghack_hint
-
- and parsinghack_hint =
- | HintIterator
- | HintDeclarator
- | HintMacroString
- | HintMacroStatement
- | HintAttribute
- | HintMacroIdentBuilder
-
-
-(* cf also data/test.h *)
-let assoc_hint_string = [
- "YACFE_ITERATOR" , HintIterator;
- "YACFE_DECLARATOR" , HintDeclarator;
- "YACFE_STRING" , HintMacroString;
- "YACFE_STATEMENT" , HintMacroStatement;
- "YACFE_ATTRIBUTE" , HintAttribute;
- "YACFE_IDENT_BUILDER" , HintMacroIdentBuilder;
-
- "MACROSTATEMENT" , HintMacroStatement; (* backward compatibility *)
-]
-
-
-let (parsinghack_hint_of_string: string -> parsinghack_hint option) = fun s ->
- Common.assoc_option s assoc_hint_string
-
-let (is_parsinghack_hint: string -> bool) = fun s ->
- parsinghack_hint_of_string s <> None
-
-let (token_from_parsinghack_hint:
- (string * Ast_c.info) -> parsinghack_hint -> Parser_c.token) =
- fun (s,ii) hint ->
- match hint with
- | HintIterator ->
- Parser_c.TMacroIterator (s, ii)
- | HintDeclarator ->
- Parser_c.TMacroDecl (s, ii)
- | HintMacroString ->
- Parser_c.TMacroString (s, ii)
- | HintMacroStatement ->
- Parser_c.TMacroStmt (s, ii)
- | HintAttribute ->
- Parser_c.TMacroAttr (s, ii)
- | HintMacroIdentBuilder ->
- Parser_c.TMacroIdentBuilder (s, ii)
-
-
-
-let (_defs : (string, define_def) Hashtbl.t ref) =
- ref (Hashtbl.create 101)
-
-
-(* ------------------------------------------------------------------------- *)
-(* fuzzy parsing, different "views" over the same program *)
-(* ------------------------------------------------------------------------- *)
-
-
-(* Normally I should not use ref/mutable in the token_extended type
- * and I should have a set of functions taking a list of tokens and
- * returning a list of tokens. The problem is that to make easier some
- * functions, it is better to work on better representation, on "views"
- * over this list of tokens. But then modifying those views and get
- * back from those views to the original simple list of tokens is
- * tedious. One way is to maintain next to the view a list of "actions"
- * (I was using a hash storing the charpos of the token and associating
- * the action) but it is tedious too. Simpler to use mutable/ref. We
- * use the same idea that we use when working on the Ast_c. *)
-
-(* old: when I was using the list of "actions" next to the views, the hash
- * indexed by the charpos, there could have been some problems:
- * how my fake_pos interact with the way I tag and adjust token ?
- * because I base my tagging on the position of the token ! so sometimes
- * could tag another fakeInfo that should not be tagged ?
- * fortunately I don't use anymore this technique.
- *)
-
-(* update: quite close to the Place_c.Inxxx *)
-type context =
- InFunction | InEnum | InStruct | InInitializer | NoContext
-
-type token_extended = {
- mutable tok: Parser_c.token;
- mutable where: context;
-
- (* less: need also a after ? *)
- mutable new_tokens_before : Parser_c.token list;
-
- (* line x col cache, more easily accessible, of the info in the token *)
- line: int;
- col : int;
-}
-
-let set_as_comment cppkind x =
- if TH.is_eof x.tok
- then () (* otherwise parse_c will be lost if don't find a EOF token *)
- else
- x.tok <- TCommentCpp (cppkind, TH.info_of_tok x.tok)
-
-let mk_token_extended x =
- let (line, col) = TH.linecol_of_tok x in
- { tok = x;
- line = line; col = col;
- where = NoContext;
- new_tokens_before = [];
- }
-
-
-(* x list list, because x list separated by ',' *)
-type paren_grouped =
- | Parenthised of paren_grouped list list * token_extended list
- | PToken of token_extended
-
-type brace_grouped =
- | Braceised of
- brace_grouped list list * token_extended * token_extended option
- | BToken of token_extended
-
-(* Far better data structure than doing hacks in the lexer or parser
- * because in lexer we don't know to which ifdef a endif is related
- * and so when we want to comment a ifdef, we don't know which endif
- * we must also comment. Especially true for the #if 0 which sometimes
- * have a #else part.
- *
- * x list list, because x list separated by #else or #elif
- *)
-type ifdef_grouped =
- | Ifdef of ifdef_grouped list list * token_extended list
- | Ifdefbool of bool * ifdef_grouped list list * token_extended list
- | NotIfdefLine of token_extended list
-
-
-type 'a line_grouped =
- Line of 'a list
-
-
-type body_function_grouped =
- | BodyFunction of token_extended list
- | NotBodyLine of token_extended list
-
-
-(* ------------------------------------------------------------------------- *)
-(* view builders *)
-(* ------------------------------------------------------------------------- *)
-
-(* todo: synchro ! use more indentation
- * if paren not closed and same indentation level, certainly because
- * part of a mid-ifdef-expression.
-*)
-let rec mk_parenthised xs =
- match xs with
- | [] -> []
- | x::xs ->
- (match x.tok with
- | TOPar _ | TOParDefine _ ->
- let body, extras, xs = mk_parameters [x] [] xs in
- Parenthised (body,extras)::mk_parenthised xs
- | _ ->
- PToken x::mk_parenthised xs
- )
-
-(* return the body of the parenthised expression and the rest of the tokens *)
-and mk_parameters extras acc_before_sep xs =
- match xs with
- | [] ->
- (* maybe because of #ifdef which "opens" '(' in 2 branches *)
- pr2 "PB: not found closing paren in fuzzy parsing";
- [List.rev acc_before_sep], List.rev extras, []
- | x::xs ->
- (match x.tok with
- (* synchro *)
- | TOBrace _ when x.col =|= 0 ->
- pr2 "PB: found synchro point } in paren";
- [List.rev acc_before_sep], List.rev (extras), (x::xs)
-
- | TCPar _ | TCParEOL _ ->
- [List.rev acc_before_sep], List.rev (x::extras), xs
- | TOPar _ | TOParDefine _ ->
- let body, extrasnest, xs = mk_parameters [x] [] xs in
- mk_parameters extras
- (Parenthised (body,extrasnest)::acc_before_sep)
- xs
- | TComma _ ->
- let body, extras, xs = mk_parameters (x::extras) [] xs in
- (List.rev acc_before_sep)::body, extras, xs
- | _ ->
- mk_parameters extras (PToken x::acc_before_sep) xs
- )
-
-
-
-
-let rec mk_braceised xs =
- match xs with
- | [] -> []
- | x::xs ->
- (match x.tok with
- | TOBrace _ ->
- let body, endbrace, xs = mk_braceised_aux [] xs in
- Braceised (body, x, endbrace)::mk_braceised xs
- | TCBrace _ ->
- pr2 "PB: found closing brace alone in fuzzy parsing";
- BToken x::mk_braceised xs
- | _ ->
- BToken x::mk_braceised xs
- )
-
-(* return the body of the parenthised expression and the rest of the tokens *)
-and mk_braceised_aux acc xs =
- match xs with
- | [] ->
- (* maybe because of #ifdef which "opens" '(' in 2 branches *)
- pr2 "PB: not found closing brace in fuzzy parsing";
- [List.rev acc], None, []
- | x::xs ->
- (match x.tok with
- | TCBrace _ -> [List.rev acc], Some x, xs
- | TOBrace _ ->
- let body, endbrace, xs = mk_braceised_aux [] xs in
- mk_braceised_aux (Braceised (body,x, endbrace)::acc) xs
- | _ ->
- mk_braceised_aux (BToken x::acc) xs
- )
-
-
-
-
-let rec mk_ifdef xs =
- match xs with
- | [] -> []
- | x::xs ->
- (match x.tok with
- | TIfdef _ ->
- let body, extra, xs = mk_ifdef_parameters [x] [] xs in
- Ifdef (body, extra)::mk_ifdef xs
- | TIfdefBool (b,_, _) ->
- let body, extra, xs = mk_ifdef_parameters [x] [] xs in
-
- (* if not passing, then consider a #if 0 as an ordinary #ifdef *)
- if !Flag_parsing_c.if0_passing
- then Ifdefbool (b, body, extra)::mk_ifdef xs
- else Ifdef(body, extra)::mk_ifdef xs
-
- | TIfdefMisc (b,_,_) | TIfdefVersion (b,_,_) ->
- let body, extra, xs = mk_ifdef_parameters [x] [] xs in
- Ifdefbool (b, body, extra)::mk_ifdef xs
-
-
- | _ ->
- (* todo? can have some Ifdef in the line ? *)
- let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
- NotIfdefLine line::mk_ifdef xs
- )
-
-and mk_ifdef_parameters extras acc_before_sep xs =
- match xs with
- | [] ->
- (* Note that mk_ifdef is assuming that CPP instruction are alone
- * on their line. Because I do a span (fun x -> is_same_line ...)
- * I might take with me a #endif if this one is mixed on a line
- * with some "normal" tokens.
- *)
- pr2 "PB: not found closing ifdef in fuzzy parsing";
- [List.rev acc_before_sep], List.rev extras, []
- | x::xs ->
- (match x.tok with
- | TEndif _ ->
- [List.rev acc_before_sep], List.rev (x::extras), xs
- | TIfdef _ ->
- let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
- mk_ifdef_parameters
- extras (Ifdef (body, extrasnest)::acc_before_sep) xs
-
- | TIfdefBool (b,_,_) ->
- let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
-
- if !Flag_parsing_c.if0_passing
- then
- mk_ifdef_parameters
- extras (Ifdefbool (b, body, extrasnest)::acc_before_sep) xs
- else
- mk_ifdef_parameters
- extras (Ifdef (body, extrasnest)::acc_before_sep) xs
-
-
- | TIfdefMisc (b,_,_) | TIfdefVersion (b,_,_) ->
- let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
- mk_ifdef_parameters
- extras (Ifdefbool (b, body, extrasnest)::acc_before_sep) xs
-
- | TIfdefelse _
- | TIfdefelif _ ->
- let body, extras, xs = mk_ifdef_parameters (x::extras) [] xs in
- (List.rev acc_before_sep)::body, extras, xs
- | _ ->
- let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
- mk_ifdef_parameters extras (NotIfdefLine line::acc_before_sep) xs
- )
-
-(* --------------------------------------- *)
-
-let line_of_paren = function
- | PToken x -> x.line
- | Parenthised (xxs, info_parens) ->
- (match info_parens with
- | [] -> raise Impossible
- | x::xs -> x.line
- )
-
-
-let rec span_line_paren line = function
- | [] -> [],[]
- | x::xs ->
- (match x with
- | PToken tok when TH.is_eof tok.tok ->
- [], x::xs
- | _ ->
- if line_of_paren x =|= line
- then
- let (l1, l2) = span_line_paren line xs in
- (x::l1, l2)
- else ([], x::xs)
- )
-
-
-let rec mk_line_parenthised xs =
- match xs with
- | [] -> []
- | x::xs ->
- let line_no = line_of_paren x in
- let line, xs = span_line_paren line_no xs in
- Line (x::line)::mk_line_parenthised xs
-
-
-(* --------------------------------------- *)
-let rec mk_body_function_grouped xs =
- match xs with
- | [] -> []
- | x::xs ->
- (match x with
- | {tok = TOBrace _; col = 0} ->
- let is_closing_brace = function
- | {tok = TCBrace _; col = 0 } -> true
- | _ -> false
- in
- let body, xs = Common.span (fun x -> not (is_closing_brace x)) xs in
- (match xs with
- | ({tok = TCBrace _; col = 0 })::xs ->
- BodyFunction body::mk_body_function_grouped xs
- | [] ->
- pr2 "PB:not found closing brace in fuzzy parsing";
- [NotBodyLine body]
- | _ -> raise Impossible
- )
-
- | _ ->
- let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
- NotBodyLine line::mk_body_function_grouped xs
- )
-
-
-(* ------------------------------------------------------------------------- *)
-(* view iterators *)
-(* ------------------------------------------------------------------------- *)
-
-let rec iter_token_paren f xs =
- xs +> List.iter (function
- | PToken tok -> f tok;
- | Parenthised (xxs, info_parens) ->
- info_parens +> List.iter f;
- xxs +> List.iter (fun xs -> iter_token_paren f xs)
- )
-
-let rec iter_token_brace f xs =
- xs +> List.iter (function
- | BToken tok -> f tok;
- | Braceised (xxs, tok1, tok2opt) ->
- f tok1; do_option f tok2opt;
- xxs +> List.iter (fun xs -> iter_token_brace f xs)
- )
-
-let rec iter_token_ifdef f xs =
- xs +> List.iter (function
- | NotIfdefLine xs -> xs +> List.iter f;
- | Ifdefbool (_, xxs, info_ifdef)
- | Ifdef (xxs, info_ifdef) ->
- info_ifdef +> List.iter f;
- xxs +> List.iter (iter_token_ifdef f)
- )
-
-
-
-
-let tokens_of_paren xs =
- let g = ref [] in
- xs +> iter_token_paren (fun tok -> push2 tok g);
- List.rev !g
-
-
-let tokens_of_paren_ordered xs =
- let g = ref [] in
-
- let rec aux_tokens_ordered = function
- | PToken tok -> push2 tok g;
- | Parenthised (xxs, info_parens) ->
- let (opar, cpar, commas) =
- match info_parens with
- | opar::xs ->
- (match List.rev xs with
- | cpar::xs ->
- opar, cpar, List.rev xs
- | _ -> raise Impossible
- )
- | _ -> raise Impossible
- in
- push2 opar g;
- aux_args (xxs,commas);
- push2 cpar g;
-
- and aux_args (xxs, commas) =
- match xxs, commas with
- | [], [] -> ()
- | [xs], [] -> xs +> List.iter aux_tokens_ordered
- | xs::ys::xxs, comma::commas ->
- xs +> List.iter aux_tokens_ordered;
- push2 comma g;
- aux_args (ys::xxs, commas)
- | _ -> raise Impossible
-
- in
-
- xs +> List.iter aux_tokens_ordered;
- List.rev !g
-
-
-
-
-(* ------------------------------------------------------------------------- *)
-(* set the context info in token *)
-(* ------------------------------------------------------------------------- *)
-
-
-let rec set_in_function_tag xs =
- (* could try: ) { } but it can be the ) of a if or while, so
- * better to base the heuristic on the position in column zero.
- * Note that some struct or enum or init put also their { in first column
- * but set_in_other will overwrite the previous InFunction tag.
- *)
- match xs with
- | [] -> ()
- (* ) { and the closing } is in column zero, then certainly a function *)
- | BToken ({tok = TCPar _ })::(Braceised (body, tok1, Some tok2))::xs
- when tok1.col <> 0 && tok2.col =|= 0 ->
- body +> List.iter (iter_token_brace (fun tok ->
- tok.where <- InFunction
- ));
- set_in_function_tag xs
-
- | (BToken x)::xs -> set_in_function_tag xs
- | (Braceised (body, tok1, Some tok2))::xs
- when tok1.col =|= 0 && tok2.col =|= 0 ->
- body +> List.iter (iter_token_brace (fun tok ->
- tok.where <- InFunction
- ));
- set_in_function_tag xs
- | Braceised (body, tok1, tok2)::xs ->
- set_in_function_tag xs
-
-
-let rec set_in_other xs =
- match xs with
- | [] -> ()
- (* enum x { } *)
- | BToken ({tok = Tenum _})::BToken ({tok = TIdent _})
- ::Braceised(body, tok1, tok2)::xs
- | BToken ({tok = Tenum _})
- ::Braceised(body, tok1, tok2)::xs
- ->
- body +> List.iter (iter_token_brace (fun tok ->
- tok.where <- InEnum;
- ));
- set_in_other xs
-
- (* struct x { } *)
- | BToken ({tok = Tstruct _})::BToken ({tok = TIdent _})
- ::Braceised(body, tok1, tok2)::xs ->
- body +> List.iter (iter_token_brace (fun tok ->
- tok.where <- InStruct;
- ));
- set_in_other xs
- (* = { } *)
- | BToken ({tok = TEq _})
- ::Braceised(body, tok1, tok2)::xs ->
- body +> List.iter (iter_token_brace (fun tok ->
- tok.where <- InInitializer;
- ));
- set_in_other xs
-
- | BToken _::xs -> set_in_other xs
-
- | Braceised(body, tok1, tok2)::xs ->
- body +> List.iter set_in_other;
- set_in_other xs
-
-
-
-
-let set_context_tag xs =
- begin
- set_in_function_tag xs;
- set_in_other xs;
- end
-
(*****************************************************************************)
(* Helpers *)
(*****************************************************************************)
-(* To expand the parameter of the macro. The env corresponds to the actual
- * code that is binded to the parameters of the macro.
- * TODO? recurse ? fixpoint ? the expansion may also contain macro.
- * Or to macro expansion in a strict manner, that is process first
- * the parameters, expands macro in params, and then process enclosing
- * macro call.
- *)
-let rec (cpp_engine: (string , Parser_c.token list) assoc ->
- Parser_c.token list -> Parser_c.token list) =
- fun env xs ->
- xs +> List.map (fun tok ->
- match tok with
- | TIdent (s,i1) when List.mem_assoc s env -> Common.assoc s env
- | x -> [x]
- )
- +> List.flatten
-
-
-
-
(* ------------------------------------------------------------------------- *)
(* the pair is the status of '()' and '{}', ex: (-1,0)
* if too much ')' and good '{}'
* could do for ',' if encounter ',' at "toplevel", not inside () or {}
* then if have ifdef, then certainly can lead to a problem.
*)
-let (count_open_close_stuff_ifdef_clause: ifdef_grouped list -> (int * int)) =
+let (count_open_close_stuff_ifdef_clause: TV.ifdef_grouped list -> (int * int))=
fun xs ->
let cnt_paren, cnt_brace = ref 0, ref 0 in
- xs +> iter_token_ifdef (fun x ->
+ xs +> TV.iter_token_ifdef (fun x ->
(match x.tok with
| x when TH.is_opar x -> incr cnt_paren
| TOBrace _ -> incr cnt_brace
-(* ------------------------------------------------------------------------- *)
-(* cpp-builtin part2, macro, using standard.h or other defs *)
-(* ------------------------------------------------------------------------- *)
-
-(* Thanks to this function many stuff are not anymore hardcoded in ocaml code
- * (but they are now hardcoded in standard.h ...)
- *
- *
- *
- * No need to take care to not substitute the macro name itself
- * that occurs in the macro definition because the macro name is
- * after fix_token_define a TDefineIdent, no more a TIdent.
- *)
-
-let rec apply_macro_defs xs =
- match xs with
- | [] -> ()
- (* old: "but could do more, could reuse same original token
- * so that have in the Ast a Dbg, not a MACROSTATEMENT"
- *
- * | PToken ({tok = TIdent (s,i1)} as id)::xs
- * when s = "MACROSTATEMENT" ->
- *
- * msg_macro_statement_hint s;
- * id.tok <- TMacroStmt(TH.info_of_tok id.tok);
- * find_macro_paren xs
- *
- * let msg_macro_statement_hint s =
- * incr Stat.nMacroHint;
- * ()
- *
- *)
- (* recognized macro of standard.h (or other) *)
- | PToken ({tok = TIdent (s,i1)} as id)::Parenthised (xxs,info_parens)::xs
- when Hashtbl.mem !_defs s ->
-
- msg_apply_known_macro s;
- let (s, params, body) = Hashtbl.find !_defs s in
-
- (match params with
- | NoParam ->
- pr2 ("WEIRD: macro without param used before parenthize: " ^ s);
- (* ex: PRINTP("NCR53C400 card%s detected\n" ANDP(((struct ... *)
-
- (match body with
- | DefineBody bodymacro ->
- set_as_comment (Token_c.CppMacro) id;
- id.new_tokens_before <- bodymacro;
- | DefineHint hint ->
- msg_apply_known_macro_hint s;
- id.tok <- token_from_parsinghack_hint (s,i1) hint;
- )
- | Params params ->
- (match body with
- | DefineBody bodymacro ->
-
- (* bugfix: better to put this that before the match body,
- * cos our macrostatement hint can have variable number of
- * arguments and so it's ok if it does not match exactly
- * the number of arguments. *)
- if List.length params != List.length xxs
- then begin
- pr2_once ("WEIRD: macro with wrong number of arguments: " ^ s);
- (* old: id.new_tokens_before <- bodymacro; *)
- ()
- end
- else
-
- let xxs' = xxs +> List.map (fun x ->
- (tokens_of_paren_ordered x) +> List.map (fun x ->
- TH.visitor_info_of_tok Ast_c.make_expanded x.tok
- )
- ) in
- id.new_tokens_before <-
- cpp_engine (Common.zip params xxs') bodymacro;
-
- (* important to do that after have apply the macro, otherwise
- * will pass as argument to the macro some tokens that
- * are all TCommentCpp
- *)
- [Parenthised (xxs, info_parens)] +>
- iter_token_paren (set_as_comment Token_c.CppMacro);
- set_as_comment Token_c.CppMacro id;
-
- | DefineHint (HintMacroStatement as hint) ->
- (* important to do that after have apply the macro, otherwise
- * will pass as argument to the macro some tokens that
- * are all TCommentCpp
- *
- * note: such macrostatement can have a variable number of
- * arguments but here we don't care, we just pass all the
- * parameters.
- *)
-
- (match xs with
- | PToken ({tok = TPtVirg _} as id2)::_ ->
- pr2_once
- ("macro stmt with trailing ';', passing also ';' for: "^
- s);
- (* sometimes still want pass its params ... as in
- * DEBUGPOLL(static unsigned int prev_mask = 0);
- *)
-
- msg_apply_known_macro_hint s;
- id.tok <- token_from_parsinghack_hint (s,i1) hint;
- [Parenthised (xxs, info_parens)] +>
- iter_token_paren (set_as_comment Token_c.CppMacro);
- set_as_comment Token_c.CppMacro id2;
-
- | _ ->
- msg_apply_known_macro_hint s;
- id.tok <- token_from_parsinghack_hint (s,i1) hint;
- [Parenthised (xxs, info_parens)] +>
- iter_token_paren (set_as_comment Token_c.CppMacro);
- )
-
-
- | DefineHint hint ->
- msg_apply_known_macro_hint s;
- id.tok <- token_from_parsinghack_hint (s,i1) hint;
- )
- );
- apply_macro_defs xs
-
- | PToken ({tok = TIdent (s,i1)} as id)::xs
- when Hashtbl.mem !_defs s ->
-
- msg_apply_known_macro s;
- let (_s, params, body) = Hashtbl.find !_defs s in
-
- (match params with
- | Params params ->
- pr2 ("WEIRD: macro with params but no parens found: " ^ s);
- (* dont apply the macro, perhaps a redefinition *)
- ()
- | NoParam ->
- (match body with
- | DefineBody [newtok] ->
- (* special case when 1-1 substitution, we reuse the token *)
- id.tok <- (newtok +> TH.visitor_info_of_tok (fun _ ->
- TH.info_of_tok id.tok))
- | DefineBody bodymacro ->
- set_as_comment Token_c.CppMacro id;
- id.new_tokens_before <- bodymacro;
- | DefineHint hint ->
- msg_apply_known_macro_hint s;
- id.tok <- token_from_parsinghack_hint (s,i1) hint;
- )
- );
- apply_macro_defs xs
+let rec find_ifdef_cparen_else xs =
+ let rec aux xs =
+ xs +> List.iter (function
+ | NotIfdefLine _ -> ()
+ | Ifdef (xxs, info_ifdef_stmt) ->
+ (match xxs with
+ | [] -> raise Impossible
+ | [first] -> ()
+ | first::second::rest ->
+ (* found a closing ')' just after the #else *)
- (* recurse *)
- | (PToken x)::xs -> apply_macro_defs xs
- | (Parenthised (xxs, info_parens))::xs ->
- xxs +> List.iter apply_macro_defs;
- apply_macro_defs xs
+ (* Too bad ocaml does not support better list pattern matching
+ * a la Prolog-III where can match the end of lists.
+ *)
+ let condition =
+ if List.length first = 0 then false
+ else
+ let last_line = Common.last first in
+ match last_line with
+ | NotIfdefLine xs ->
+ if List.length xs = 0 then false
+ else
+ let last_tok = Common.last xs in
+ TH.is_cpar last_tok.tok
+ | Ifdef _ | Ifdefbool _ -> false
+ in
+ if condition then begin
+ msg_ifdef_cparen_else();
+ (* keep only first, treat the rest as comment *)
+ info_ifdef_stmt +> List.iter (set_as_comment Token_c.CppDirective);
+ (second::rest) +> List.iter
+ (iter_token_ifdef (set_as_comment Token_c.CppPassingCosWouldGetError));
+ end
+
+ );
+ List.iter aux xxs
+
+ (* no need complex analysis for ifdefbool *)
+ | Ifdefbool (_, xxs, info_ifdef_stmt) ->
+ List.iter aux xxs
+ )
+ in aux xs
+(* ------------------------------------------------------------------------- *)
+(* cpp-builtin part2, macro, using standard.h or other defs *)
+(* ------------------------------------------------------------------------- *)
+(* now in cpp_token_c.ml *)
(* ------------------------------------------------------------------------- *)
(* stringification *)
find_macro_paren xs
(*
- (* attribute cpp, __xxx id() *)
+ (* attribute cpp, __xxx id *)
| PToken ({tok = TIdent (s,i1)} as id)
- ::PToken ({tok = TIdent (s2, i2)})
- ::Parenthised(xxs,info_parens)
+ ::PToken ({tok = TIdent (s2, i2)} as id2)
::xs when s ==~ regexp_annot
->
msg_attribute s;
id.tok <- TMacroAttr (s, i1);
- find_macro_paren (Parenthised(xxs,info_parens)::xs)
+ find_macro_paren ((PToken id2)::xs); (* recurse also on id2 ? *)
- (* attribute cpp, id __xxx = *)
- | PToken ({tok = TIdent (s,i1)})
- ::PToken ({tok = TIdent (s2, i2)} as id)
- ::xs when s2 ==~ regexp_annot
+ (* attribute cpp, id __xxx *)
+ | PToken ({tok = TIdent (s,i1)} as _id)
+ ::PToken ({tok = TIdent (s2, i2)} as id2)
+ ::xs when s2 ==~ regexp_annot && (not (s ==~ regexp_typedef))
->
msg_attribute s2;
- id.tok <- TMacroAttr (s2, i2);
- find_macro_paren (xs)
+ id2.tok <- TMacroAttr (s2, i2);
+ find_macro_paren xs
+
+ | PToken ({tok = (Tstatic _ | Textern _)} as tok1)
+ ::PToken ({tok = TIdent (s,i1)} as attr)
+ ::xs when s ==~ regexp_annot
+ ->
+ pr2_cpp ("storage attribute: " ^ s);
+ attr.tok <- TMacroAttrStorage (s,i1);
+ (* recurse, may have other storage attributes *)
+ find_macro_paren (PToken (tok1)::xs)
+
+
*)
(* storage attribute *)
attr.tok <- TMacroAttrStorage (s,i1);
(* recurse, may have other storage attributes *)
find_macro_paren (PToken (tok1)::xs)
-
+
(* stringification
*
(* action *)
(* ------------------------------------------------------------------------- *)
+(* obsolete now with macro expansion ? get some regression if comment.
+ * todo: if do bad decision here, then it can influence other phases
+ * and make it hard to parse. So maybe when have a parse error, should
+ * undo some of the guess those heuristics have done, and restore
+ * the original token value.
+ *)
+
let rec find_actions = function
| [] -> ()
and find_actions_params xxs =
xxs +> List.fold_left (fun acc xs ->
let toks = tokens_of_paren xs in
- if toks +> List.exists (fun x -> TH.is_statement x.tok)
+ if toks +> List.exists (fun x -> TH.is_statement x.tok)
+ (* undo: && List.length toks > 1
+ * good for sparse, not good for linux
+ *)
then begin
xs +> iter_token_paren (fun x ->
if TH.is_eof x.tok
then
(* certainly because paren detection had a pb because of
- * some ifdef-exp
+ * some ifdef-exp. Do similar additional checking than
+ * what is done in set_as_comment.
*)
- pr2 "PB: weird, I try to tag an EOF token as action"
+ pr2 "PB: weird, I try to tag an EOF token as an action"
else
- x.tok <- TAction (TH.info_of_tok x.tok);
+ (* cf tests-bis/no_cpar_macro.c *)
+ if TH.is_eom x.tok
+ then
+ pr2 "PB: weird, I try to tag an EOM token as an action"
+ else
+ x.tok <- TAction (TH.info_of_tok x.tok);
);
true (* modified *)
end
(* main fix cpp function *)
(* ------------------------------------------------------------------------- *)
-let rebuild_tokens_extented toks_ext =
- let _tokens = ref [] in
- toks_ext +> List.iter (fun tok ->
- tok.new_tokens_before +> List.iter (fun x -> push2 x _tokens);
- push2 tok.tok _tokens
- );
- let tokens = List.rev !_tokens in
- (tokens +> acc_map mk_token_extended)
-
let filter_cpp_stuff xs =
let rec aux xs =
match xs with
let insert_virtual_positions l =
let strlen x = String.length (Ast_c.str_of_info x) in
- let rec loop prev offset = function
- [] -> []
+ let rec loop prev offset acc = function
+ [] -> List.rev acc
| x::xs ->
let ii = TH.info_of_tok x in
let inject pi =
match Ast_c.pinfo_of_info ii with
Ast_c.OriginTok pi ->
let prev = Ast_c.parse_info_of_info ii in
- x::(loop prev (strlen ii) xs)
+ loop prev (strlen ii) (x::acc) xs
| Ast_c.ExpandedTok (pi,_) ->
- inject (Ast_c.ExpandedTok (pi,(prev,offset))) ::
- (loop prev (offset + (strlen ii)) xs)
+ let x' = inject (Ast_c.ExpandedTok (pi,(prev,offset))) in
+ loop prev (offset + (strlen ii)) (x'::acc) xs
| Ast_c.FakeTok (s,_) ->
- inject (Ast_c.FakeTok (s,(prev,offset))) ::
- (loop prev (offset + (strlen ii)) xs)
+ let x' = inject (Ast_c.FakeTok (s,(prev,offset))) in
+ loop prev (offset + (strlen ii)) (x'::acc) xs
| Ast_c.AbstractLineTok _ -> failwith "abstract not expected" in
let rec skip_fake = function
- [] -> []
+ | [] -> []
| x::xs ->
let ii = TH.info_of_tok x in
match Ast_c.pinfo_of_info ii with
- Ast_c.OriginTok pi ->
+ | Ast_c.OriginTok pi ->
let prev = Ast_c.parse_info_of_info ii in
- x::(loop prev (strlen ii) xs)
+ let res = loop prev (strlen ii) [] xs in
+ x::res
| _ -> x::skip_fake xs in
- skip_fake l
+ skip_fake l
+
(* ------------------------------------------------------------------------- *)
-let fix_tokens_cpp2 tokens =
- let tokens2 = ref (tokens +> acc_map mk_token_extended) in
+let fix_tokens_cpp2 ~macro_defs tokens =
+ let tokens2 = ref (tokens +> Common.acc_map TV.mk_token_extended) in
begin
(* the order is important, if you put the action heuristic first,
* commentize_skip_start_to_end *)
not (TH.is_comment x.tok) (* could filter also #define/#include *)
) in
- let ifdef_grouped = mk_ifdef cleaner in
+ let ifdef_grouped = TV.mk_ifdef cleaner in
set_ifdef_parenthize_info ifdef_grouped;
find_ifdef_funheaders ifdef_grouped;
find_ifdef_bool ifdef_grouped;
find_ifdef_mid ifdef_grouped;
+ (* change order ? maybe cparen_else heuristic make some of the funheaders
+ * heuristics irrelevant ?
+ *)
+ find_ifdef_cparen_else ifdef_grouped;
adjust_inifdef_include ifdef_grouped;
(* macro 1 *)
let cleaner = !tokens2 +> filter_cpp_stuff in
- let paren_grouped = mk_parenthised cleaner in
- apply_macro_defs paren_grouped;
+ let paren_grouped = TV.mk_parenthised cleaner in
+ Cpp_token_c.apply_macro_defs
+ ~msg_apply_known_macro
+ ~msg_apply_known_macro_hint
+ macro_defs paren_grouped;
(* because the before field is used by apply_macro_defs *)
- tokens2 := rebuild_tokens_extented !tokens2;
+ tokens2 := TV.rebuild_tokens_extented !tokens2;
(* tagging contextual info (InFunc, InStruct, etc). Better to do
* that after the "ifdef-simplification" phase.
not (TH.is_comment x.tok) (* could filter also #define/#include *)
) in
- let brace_grouped = mk_braceised cleaner in
+ let brace_grouped = TV.mk_braceised cleaner in
set_context_tag brace_grouped;
(* macro *)
let cleaner = !tokens2 +> filter_cpp_stuff in
- let paren_grouped = mk_parenthised cleaner in
- let line_paren_grouped = mk_line_parenthised paren_grouped in
+ let paren_grouped = TV.mk_parenthised cleaner in
+ let line_paren_grouped = TV.mk_line_parenthised paren_grouped in
find_define_init_brace_paren paren_grouped;
find_string_macro_paren paren_grouped;
find_macro_lineparen line_paren_grouped;
find_macro_paren paren_grouped;
- (* actions *)
+ (* obsolete: actions ? not yet *)
let cleaner = !tokens2 +> filter_cpp_stuff in
- let paren_grouped = mk_parenthised cleaner in
+ let paren_grouped = TV.mk_parenthised cleaner in
find_actions paren_grouped;
+
- insert_virtual_positions (!tokens2 +> acc_map (fun x -> x.tok))
+ insert_virtual_positions (!tokens2 +> Common.acc_map (fun x -> x.tok))
end
-let time_hack1 a =
- Common.profile_code_exclusif "HACK" (fun () -> fix_tokens_cpp2 a)
-
-let fix_tokens_cpp a =
- Common.profile_code "C parsing.fix_cpp" (fun () -> time_hack1 a)
-
-
-
+let time_hack1 ~macro_defs a =
+ Common.profile_code_exclusif "HACK" (fun () -> fix_tokens_cpp2 ~macro_defs a)
-(*****************************************************************************)
-(* The #define tricks *)
-(*****************************************************************************)
+let fix_tokens_cpp ~macro_defs a =
+ Common.profile_code "C parsing.fix_cpp" (fun () -> time_hack1 ~macro_defs a)
-(* ugly hack, a better solution perhaps would be to erase TDefEOL
- * from the Ast and list of tokens in parse_c.
- *
- * note: I do a +1 somewhere, it's for the unparsing to correctly sync.
- *
- * note: can't replace mark_end_define by simply a fakeInfo(). The reason
- * is where is the \n TCommentSpace. Normally there is always a last token
- * to synchronize on, either EOF or the token of the next toplevel.
- * In the case of the #define we got in list of token
- * [TCommentSpace "\n"; TDefEOL] but if TDefEOL is a fakeinfo then we will
- * not synchronize on it and so we will not print the "\n".
- * A solution would be to put the TDefEOL before the "\n".
- *
- * todo?: could put a ExpandedTok for that ?
- *)
-let mark_end_define ii =
- let ii' =
- { Ast_c.pinfo = Ast_c.OriginTok { (Ast_c.parse_info_of_info ii) with
- Common.str = "";
- Common.charpos = Ast_c.pos_of_info ii + 1
- };
- cocci_tag = ref Ast_c.emptyAnnot;
- comments_tag = ref Ast_c.emptyComments;
- }
- in
- TDefEOL (ii')
-(* put the TDefEOL at the good place *)
-let rec define_line_1 acc xs =
- match xs with
- | [] -> List.rev acc
- | TDefine ii::xs ->
- let line = Ast_c.line_of_info ii in
- let acc = (TDefine ii) :: acc in
- define_line_2 acc line ii xs
- | TCppEscapedNewline ii::xs ->
- pr2 "WEIRD: a \\ outside a #define";
- let acc = (TCommentSpace ii) :: acc in
- define_line_1 acc xs
- | x::xs -> define_line_1 (x::acc) xs
-
-and define_line_2 acc line lastinfo xs =
- match xs with
- | [] ->
- (* should not happened, should meet EOF before *)
- pr2 "PB: WEIRD";
- List.rev (mark_end_define lastinfo::acc)
- | x::xs ->
- let line' = TH.line_of_tok x in
- let info = TH.info_of_tok x in
-
- (match x with
- | EOF ii ->
- let acc = (mark_end_define lastinfo) :: acc in
- let acc = (EOF ii) :: acc in
- define_line_1 acc xs
- | TCppEscapedNewline ii ->
- if (line' <> line) then pr2 "PB: WEIRD: not same line number";
- let acc = (TCommentSpace ii) :: acc in
- define_line_2 acc (line+1) info xs
- | x ->
- if line' =|= line
- then define_line_2 (x::acc) line info xs
- else define_line_1 (mark_end_define lastinfo::acc) (x::xs)
- )
-
-let rec define_ident acc xs =
- match xs with
- | [] -> List.rev acc
- | TDefine ii::xs ->
- let acc = TDefine ii :: acc in
- (match xs with
- | TCommentSpace i1::TIdent (s,i2)::TOPar (i3)::xs ->
- (* Change also the kind of TIdent to avoid bad interaction
- * with other parsing_hack tricks. For instant if keep TIdent then
- * the stringication algo can believe the TIdent is a string-macro.
- * So simpler to change the kind of the ident too.
- *)
- (* if TOParDefine sticked to the ident, then
- * it's a macro-function. Change token to avoid ambiguity
- * between #define foo(x) and #define foo (x)
- *)
- let acc = (TCommentSpace i1) :: acc in
- let acc = (TIdentDefine (s,i2)) :: acc in
- let acc = (TOParDefine i3) :: acc in
- define_ident acc xs
- | TCommentSpace i1::TIdent (s,i2)::xs ->
- let acc = (TCommentSpace i1) :: acc in
- let acc = (TIdentDefine (s,i2)) :: acc in
- define_ident acc xs
- | _ ->
- pr2 "WEIRD: weird #define body";
- define_ident acc xs
- )
- | x::xs ->
- let acc = x :: acc in
- define_ident acc xs
-
-
-
-let fix_tokens_define2 xs =
- define_ident [] (define_line_1 [] xs)
-
-let fix_tokens_define a =
- Common.profile_code "C parsing.fix_define" (fun () -> fix_tokens_define2 a)
-
(*****************************************************************************)
(* for the cpp-builtin, standard.h, part 0 *)
(*****************************************************************************)
-let macro_body_to_maybe_hint body =
- match body with
- | [] -> DefineBody body
- | [TIdent (s,i1)] ->
- (match parsinghack_hint_of_string s with
- | Some hint -> DefineHint hint
- | None -> DefineBody body
- )
- | xs -> DefineBody body
-
-
-let rec define_parse xs =
- match xs with
- | [] -> []
- | TDefine i1::TIdentDefine (s,i2)::TOParDefine i3::xs ->
- let (tokparams, _, xs) =
- xs +> Common.split_when (function TCPar _ -> true | _ -> false) in
- let (body, _, xs) =
- xs +> Common.split_when (function TDefEOL _ -> true | _ -> false) in
- let params =
- tokparams +> Common.map_filter (function
- | TComma _ -> None
- | TIdent (s, _) -> Some s
- | x -> error_cant_have x
- ) in
- let body = body +> List.map
- (TH.visitor_info_of_tok Ast_c.make_expanded) in
- let def = (s, (s, Params params, macro_body_to_maybe_hint body)) in
- def::define_parse xs
-
- | TDefine i1::TIdentDefine (s,i2)::xs ->
- let (body, _, xs) =
- xs +> Common.split_when (function TDefEOL _ -> true | _ -> false) in
- let body = body +> List.map
- (TH.visitor_info_of_tok Ast_c.make_expanded) in
- let def = (s, (s, NoParam, macro_body_to_maybe_hint body)) in
- def::define_parse xs
-
- | TDefine i1::_ ->
- pr2_gen i1;
- raise Impossible
- | x::xs -> define_parse xs
-
-
-let extract_cpp_define xs =
- let cleaner = xs +> List.filter (fun x ->
- not (TH.is_comment x)
- ) in
- define_parse cleaner
-
-
-
+(* now in cpp_token_c.ml *)
(*****************************************************************************)
(* Lexing with lookahead *)
(take_safe 1 !passed_tok <> [Tenum]))
&&
!LP._lexer_hint = Some LP.Toplevel ->
- msg_typedef s;
- LP.add_typedef_root s;
+ msg_typedef s; LP.add_typedef_root s;
TypedefIdent s
*)
(* can have sizeof on expression
| (Tsizeof::TOPar::TIdent s::TCPar::_, _) ->
- msg_typedef s;
- LP.add_typedef_root s;
+ msg_typedef s; LP.add_typedef_root s;
Tsizeof
*)
*)
(* not !LP._lexer_hint.toplevel *)
if !Flag_parsing_c.ifdef_directive_passing
- || (pass =|= 2)
+ || (pass >= 2)
then begin
if (LP.current_context () =*= LP.InInitializer)
pr2_cpp "In Initializer passing"; (* cheat: dont count in stat *)
incr Stat.nIfdefInitializer;
end else begin
- pr2_cpp("IFDEF: or related insde function. I treat it as comment");
+ pr2_cpp("IFDEF: or related inside function. I treat it as comment");
incr Stat.nIfdefPassing;
end;
TCommentCpp (Token_c.CppDirective, ii)
| (TUndef (id, ii) as x)::_, _
->
- if (pass =|= 2)
+ if (pass >= 2)
then begin
pr2_cpp("UNDEF: I treat it as comment");
TCommentCpp (Token_c.CppDirective, ii)
| (TCppDirectiveOther (ii) as x)::_, _
->
- if (pass =|= 2)
+ if (pass >= 2)
then begin
pr2_cpp ("OTHER directive: I treat it as comment");
TCommentCpp (Token_c.CppDirective, ii)
* sometimes we do some kind of lalr(k) by finding patterns. Often try to
* work on better token representation, like ifdef-paren-ized, brace-ized,
* paren-ized, so can do easier pattern matching to more easily match
- * complex cpp idiom pattern. Also try to get context info such as
- * whether the token is in a initializer as some common patterns have different
+ * complex cpp idiom pattern (cf token_views_c.ml).
+ * We also try to get more contextual information such as whether the
+ * token is in a initializer as some common patterns have different
* use depending on context.
*
*
*
* Cf the TMacroXxx in parser_c.mly and MacroXxx in ast_c.ml
*
- * Also try infer typedef.
+ * Also try to infer typedef.
*
* Also do other stuff involving cpp like expanding some macros,
* or try parse well define body by finding the end of define virtual
- * end-of-line token.
+ * end-of-line token. But now most of the code is actually in cpp_token_c.ml
+ * It is related to what is in the yacfe configuration file (e.g. standard.h)
*)
-(* corresponds to what is in the yacfe configuration file (e.g. standard.h) *)
-type define_def = string * define_param * define_body
- and define_param =
- | NoParam
- | Params of string list
- and define_body =
- | DefineBody of Parser_c.token list
- | DefineHint of parsinghack_hint
-
- (* strongly corresponds to the TMacroXxx in the grammar and lexer and the
- * MacroXxx in the ast.
- *)
- and parsinghack_hint =
- | HintIterator
- | HintDeclarator
- | HintMacroString
- | HintMacroStatement
- | HintAttribute
- | HintMacroIdentBuilder
-
val regexp_macro: Str.regexp
val regexp_annot: Str.regexp
val regexp_declare: Str.regexp
val regexp_foreach: Str.regexp
val regexp_typedef: Str.regexp
-val _defs : (string, define_def) Hashtbl.t ref
-
-(* can reset it *)
+(* can reset this global *)
val ifdef_paren_cnt: int ref
-val fix_tokens_define : Parser_c.token list -> Parser_c.token list
-val extract_cpp_define : Parser_c.token list -> (string, define_def) assoc
-
+val filter_cpp_stuff :
+ Token_views_c.token_extended list -> Token_views_c.token_extended list
+val insert_virtual_positions:
+ Parser_c.token list -> Parser_c.token list
-val fix_tokens_cpp : Parser_c.token list -> Parser_c.token list
+val fix_tokens_cpp :
+ macro_defs:(string, Cpp_token_c.define_def) Hashtbl.t ->
+ Parser_c.token list -> Parser_c.token list
(* next stream tokens -> passed stream tokens -> final next token *)
val lookahead :
*)
open Common
+
open Ast_c
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_unparsing
+
+(*****************************************************************************)
type pr_elem_func = Ast_c.info -> unit
type pr_space_func = unit -> unit
let start_block () = pr_nl(); pr_indent() in
let end_block () = pr_unindent(); pr_nl() in
- let indent_if_needed (s,_) f =
- match s with
+ let indent_if_needed st f =
+ match Ast_c.unwrap_st st with
Compound _ -> pr_space(); f()
| _ ->
(*no newline at the end - someone else will do that*)
pr_elem icp
(* ---------------------- *)
- and pp_statement = function
+ and pp_statement = fun st ->
+ match Ast_c.get_st_and_ii st with
| Labeled (Label (name, st)), ii ->
let (i2) = Common.tuple_of_list1 ii in
pr_outdent(); pp_name name; pr_elem i2; pr_nl(); pp_statement st
| Selection (If (e, st1, st2)), i1::i2::i3::is ->
pr_elem i1; pr_space(); pr_elem i2; pp_expression e; pr_elem i3;
indent_if_needed st1 (function _ -> pp_statement st1);
- (match (st2, is) with
+ (match (Ast_c.get_st_and_ii st2, is) with
| ((ExprStatement None, []), []) -> ()
| ((ExprStatement None, []), [iifakend]) -> pr_elem iifakend
- | st2, [i4;iifakend] -> pr_elem i4;
+ | _st2, [i4;iifakend] -> pr_elem i4;
indent_if_needed st2 (function _ -> pp_statement st2);
pr_elem iifakend
| x -> raise Impossible
pr_elem i1; pr_space();
pr_elem i2;
- pp_statement (ExprStatement e1opt, il1);
- pp_statement (ExprStatement e2opt, il2);
+ pp_statement (Ast_c.mk_st (ExprStatement e1opt) il1);
+ pp_statement (Ast_c.mk_st (ExprStatement e2opt) il2);
assert (null il3);
- pp_statement (ExprStatement e3opt, il3);
+ pp_statement (Ast_c.mk_st (ExprStatement e3opt) il3);
pr_elem i3;
indent_if_needed st (function _ -> pp_statement st);
pr_elem iifakend
(string * info) option -> (storage * il) option ->
fullType -> attribute list ->
unit) =
- fun ident sto ((qu, iiqu), (ty, iity)) attrs ->
- pp_base_type ((qu, iiqu), (ty, iity)) sto;
- (match (ident,ty) with
+ fun ident sto ft attrs ->
+ pp_base_type ft sto;
+ (match (ident, Ast_c.unwrap_typeC ft) with
(Some _,_) | (_,Pointer _) -> pr_space()
| _ -> ());
- pp_type_with_ident_rest ident ((qu, iiqu), (ty, iity)) attrs
+ pp_type_with_ident_rest ident ft attrs
and (pp_base_type: fullType -> (storage * il) option -> unit) =
);
fields +> List.iter
- (fun (xfield, iipttvirg_when_emptyfield) ->
+ (fun (field) ->
- match xfield with
+ match field with
| DeclarationField(FieldDeclList(onefield_multivars,iiptvirg))->
(match onefield_multivars with
| x::xs ->
let identinfo =
match nameopt with
| None -> None
- | Some name -> Some (get_s_and_ii_of_name name)
+ | Some name -> Some (get_s_and_info_of_name name)
in
pp_type_with_ident identinfo None typ Ast_c.noattr;
| None ->
pp_type typ;
| Some name ->
- let (s, is) = get_s_and_ii_of_name name in
+ let (s, is) = get_s_and_info_of_name name in
pp_type_with_ident
(Some (s, is)) None typ Ast_c.noattr;
);
); (* match x, first onefield_multivars *)
- (* for other vars *)
+ (* for other vars *)
xs +> List.iter (function
| (Simple (nameopt, typ)), iivirg ->
iivirg +> List.iter pr_elem;
let identinfo =
match nameopt with
| None -> None
- | Some name -> Some (get_s_and_ii_of_name name)
+ | Some name -> Some (get_s_and_info_of_name name)
in
pp_type_with_ident_rest identinfo typ Ast_c.noattr
iivirg +> List.iter pr_elem;
(match nameopt with
| Some name ->
- let (s,is) = get_s_and_ii_of_name name in
+ let (s,is) = get_s_and_info_of_name name in
pp_type_with_ident_rest
(Some (s, is)) typ Ast_c.noattr;
pr_elem iidot;
iiptvirg +> List.iter pr_elem;
- | MacroStructDeclTodo -> pr2 "MacroTodo"
+ | MacroDeclField ((s, es), ii) ->
+ let (iis, lp, rp, iiend, ifakestart) =
+ Common.tuple_of_list5 ii in
+ (* iis::lp::rp::iiend::ifakestart::iisto
+ iisto +> List.iter pr_elem; (* static and const *)
+ *)
+ pr_elem ifakestart;
+ pr_elem iis;
+ pr_elem lp;
+ es +> List.iter (fun (e, opt) ->
+ assert (List.length opt <= 1);
+ opt +> List.iter pr_elem;
+ pp_argument e;
+ );
+
+ pr_elem rp;
+ pr_elem iiend;
+
- | EmptyField -> iipttvirg_when_emptyfield +> List.iter pr_elem
+ | EmptyField iipttvirg_when_emptyfield ->
+ pr_elem iipttvirg_when_emptyfield
| CppDirectiveStruct cpp -> pp_directive cpp
| IfdefStruct ifdef -> pp_ifdef ifdef
assert (List.length iis =|= 2);
print_sto_qu_ty (sto, qu, iis);
- | (TypeName (name,_typ), noii) ->
+ | (TypeName (name,typ), noii) ->
assert (null noii);
- let (_s, iis) = get_s_and_ii_of_name name in
+ let (_s, iis) = get_s_and_info_of_name name in
print_sto_qu_ty (sto, qu, [iis]);
+
+ if !Flag_parsing_c.pretty_print_typedef_value
+ then begin
+ pr_elem (Ast_c.fakeInfo() +> Ast_c.rewrap_str "{*");
+ typ +> Common.do_option (fun typ ->
+ pp_type typ;
+ );
+ pr_elem (Ast_c.fakeInfo() +> Ast_c.rewrap_str "*}");
+ end;
| (TypeOfExpr (e), iis) ->
print_sto_qu (sto, qu);
fullType -> attribute list -> unit) =
fun ident (((qu, iiqu), (ty, iity)) as fullt) attrs ->
+
let print_ident ident = Common.do_option (fun (s, iis) ->
(* XXX attrs +> pp_attributes pr_elem pr_space; *)
pr_elem iis
pp_type_with_ident_rest ident t attrs;
(* ugly special case ... todo? maybe sufficient in practice *)
- | (ParenType (q1, (Pointer (q2, (FunctionType t, ii3)) ,
- [ipointer]) ), [i1;i2]) ->
- pp_type_left (q2, (FunctionType t, ii3));
- pr_elem i1;
- pr_elem ipointer;
- print_ident ident;
- pr_elem i2;
- pp_type_right (q2, (FunctionType t, ii3));
-
- (* another ugly special case *)
- | (ParenType
- (q1, (Array (eopt,
- (q2, (Pointer
- (q3, (FunctionType t, iifunc)),
- [ipointer]))),
- [iarray1;iarray2])), [i1;i2]) ->
- pp_type_left (q3, (FunctionType t, iifunc));
- pr_elem i1;
- pr_elem ipointer;
- print_ident ident;
- pr_elem iarray1;
- do_option pp_expression eopt;
- pr_elem iarray2;
- pr_elem i2;
- pp_type_right (q3, (FunctionType t, iifunc))
-
-
-
- | (ParenType t, [i1;i2]) ->
- pr2 "PB PARENTYPE ZARB, I forget about the ()";
- pp_type_with_ident_rest ident t attrs;
+ | (ParenType ttop, [i1;i2]) ->
+ (match Ast_c.get_ty_and_ii ttop with
+ | (_q1, (Pointer t2, [ipointer])) ->
+ (match Ast_c.get_ty_and_ii t2 with
+ | (q2, (FunctionType t, ii3)) ->
+
+ pp_type_left (q2, mk_tybis (FunctionType t) ii3);
+ pr_elem i1;
+ pr_elem ipointer;
+ print_ident ident;
+ pr_elem i2;
+ pp_type_right (q2, mk_tybis (FunctionType t) ii3);
+ | _ ->
+ pr2 "PB PARENTYPE ZARB, I forget about the ()";
+ pp_type_with_ident_rest ident ttop attrs;
+ )
+ (* another ugly special case *)
+ | _q1, (Array (eopt,t2 ), [iarray1;iarray2]) ->
+ (match Ast_c.get_ty_and_ii t2 with
+ | (_q2, (Pointer t3, [ipointer])) ->
+ (match Ast_c.get_ty_and_ii t3 with
+ | (q3, (FunctionType t, iifunc)) ->
+
+ pp_type_left (q3, mk_tybis (FunctionType t) iifunc);
+ pr_elem i1;
+ pr_elem ipointer;
+ print_ident ident;
+ pr_elem iarray1;
+ do_option pp_expression eopt;
+ pr_elem iarray2;
+ pr_elem i2;
+ pp_type_right (q3, mk_tybis (FunctionType t) iifunc)
+ | _ ->
+ pr2 "PB PARENTYPE ZARB, I forget about the ()";
+ pp_type_with_ident_rest ident ttop attrs;
+ )
+ | _ ->
+ pr2 "PB PARENTYPE ZARB, I forget about the ()";
+ pp_type_with_ident_rest ident ttop attrs;
+ )
+ | _t ->
+
+ pr2 "PB PARENTYPE ZARB, I forget about the ()";
+ pp_type_with_ident_rest ident ttop attrs;
+ )
| (Array (eopt, t), [i1;i2]) ->
| None ->
pp_type t
| Some name ->
- let (s,i1) = get_s_and_ii_of_name name in
+ let (s,i1) = get_s_and_info_of_name name in
pp_type_with_ident
(Some (s, i1)) None t Ast_c.noattr
(* handling the first var. Special case, we print the whole type *)
(match var with
| Some (name, iniopt) ->
- let (s,iis) = get_s_and_ii_of_name name in
+ let (s,iis) = get_s_and_info_of_name name in
pp_type_with_ident
(Some (s, iis)) (Some (storage, iisto))
returnType attrs;
v_attr = attrs;
}, iivirg) ->
- let (s,iis) = get_s_and_ii_of_name name in
+ let (s,iis) = get_s_and_info_of_name name in
assert (storage2 =*= storage);
iivirg +> List.iter pr_elem;
pp_type_with_ident_rest
pr2 "Decl"
| F.ExprStatement (st, (eopt, ii)) ->
- pp_statement (ExprStatement eopt, ii)
+ pp_statement (Ast_c.mk_st (ExprStatement eopt) ii)
| F.IfHeader (_, (e,ii))
| F.SwitchHeader (_, (e,ii))
Common.format_to_string (fun () ->
pp_expression_simple e
)
+
+let string_of_toplevel top =
+ Common.format_to_string (fun () ->
+ pp_toplevel_simple top
+ )
let (debug_info_of_node:
Ograph_extended.nodei -> Control_flow_c.cflow -> string) =
val debug_info_of_node: Ograph_extended.nodei -> Control_flow_c.cflow -> string
val string_of_expression: Ast_c.expression -> string
+val string_of_toplevel: Ast_c.toplevel -> string
let tmpfile = "/tmp/output.c"
+module Ast_to_flow = Control_flow_c_build
(*****************************************************************************)
(* Subsystem testing *)
else Hashtbl.add newscore file (Common.Pb s)
);
- if not (null !stat_list)
- then begin
- Parsing_stat.print_recurring_problematic_tokens !stat_list;
- Parsing_stat.print_parsing_stat_list !stat_list;
- end;
-
dirname_opt +> Common.do_option (fun dirname ->
pr2_xxxxxxxxxxxxxxxxx();
pr2 "regression testing information";
Common.regression_testing newscore
(Filename.concat score_path
("score_parsing__" ^str ^ def ^ ext ^ ".marshalled"))
- )
+ );
+
+ if not (null !stat_list)
+ then begin
+ Parsing_stat.print_recurring_problematic_tokens !stat_list;
+ Parsing_stat.print_parsing_stat_list !stat_list;
+ end;
+ ()
let test_parse_c xs =
test_parse_gen xs "[ch]"
+(* ---------------------------------------------------------------------- *)
+
+let test_parse xs =
+
+ Flag_parsing_c.filter_msg_define_error := true;
+ Flag_parsing_c.filter_define_error := true;
+ Flag_parsing_c.verbose_lexing := false;
+ Flag_parsing_c.verbose_parsing := false;
+
+ let dirname_opt =
+ match xs with
+ | [x] when is_directory x -> Some x
+ | _ -> None
+ in
+ dirname_opt +> Common.do_option (fun dir ->
+
+ let ext = "h" in
+ let fullxs = Common.files_of_dir_or_files_no_vcs ext [dir] in
+ fullxs +> List.iter (fun file ->
+ let xs = Parse_c.parse_cpp_define_file file in
+ xs +> List.iter (fun (x, def) ->
+ let (s, params, body) = def in
+ Hashtbl.replace !Parse_c._defs s (s, params, body);
+ );
+ );
+ );
+
+ let ext = "[ch]" in
+
+ let fullxs = Common.files_of_dir_or_files_no_vcs ext xs in
+
+ let stat_list = ref [] in
+ Common.check_stack_nbfiles (List.length fullxs);
+
+ fullxs +> List.iter (fun file ->
+ if not (file =~ (".*\\."^ext))
+ then pr2 ("warning: seems not a ."^ext^" file");
+ pr2 "";
+ pr2 ("PARSING: " ^ file);
+
+ let (xs, stat) = Parse_c.parse_print_error_heuristic file in
+ xs +> List.iter (fun (ast, (s, toks)) ->
+ Parse_c.print_commentized toks
+ );
+
+ Common.push2 stat stat_list;
+ );
+
+ if not (null !stat_list)
+ then begin
+ Parsing_stat.print_recurring_problematic_tokens !stat_list;
+ Parsing_stat.print_parsing_stat_list !stat_list;
+ end;
+ ()
+let extract_macros ~selection x =
+ (* CONFIG [ch] ? also do for .c ? maybe less needed now that I
+ * add local_macros.
+ *)
+
+ let ext = "h" in
+ let fullxs = Common.files_of_dir_or_files_no_vcs ext [x] in
+ fullxs +> List.iter (fun file ->
+
+ pr ("/* PARSING: " ^ file ^ " */");
+ let xs = Parse_c.parse_cpp_define_file file in
+ xs +> List.iter (fun (x, def) ->
+ let (s, params, body) = def in
+ assert(s = x);
+ (match params, body with
+ | Cpp_token_c.NoParam, Cpp_token_c.DefineBody [Parser_c.TInt _]
+ | Cpp_token_c.NoParam, Cpp_token_c.DefineBody [] ->
+ ()
+ | _ ->
+
+ let s1 =
+ match params with
+ | Cpp_token_c.NoParam -> spf "#define %s " s
+ | Cpp_token_c.Params xs ->
+ spf "#define %s(%s) "
+ s (Common.join "," xs)
+ in
+ let s2, bodytoks =
+ match body with
+ | Cpp_token_c.DefineHint _ ->
+ failwith "weird, hint in regular header file"
+ | Cpp_token_c.DefineBody xs ->
+ Common.join " " (xs +> List.map Token_helpers.str_of_tok),
+ xs
+ in
+
+ let print =
+ match () with
+ | () when s ==~ Parsing_hacks.regexp_annot -> true
+ | () when List.exists (function
+ | Parser_c.Tattribute _ -> true
+ | _ -> false) bodytoks -> true
+ | () -> false
+ in
+ if print || not selection then pr (s1 ^ s2)
+ );
+ );
+ );
+ ()
+
+
(* ---------------------------------------------------------------------- *)
let test_xxx a =
"-parse_ch", " <file or dir>",
Common.mk_action_n_arg test_parse_ch;
+ "-parse", " <file or dir>",
+ Common.mk_action_n_arg test_parse;
+
"-show_flow", " <file or file:function>",
Common.mk_action_1_arg test_cfg;
"-control_flow", " <file or file:function>",
"-test_cpp", " <file>",
Common.mk_action_1_arg test_cpp;
+ "-extract_macros", " <file or dir>",
+ Common.mk_action_1_arg (extract_macros ~selection:false) ;
+
+ "-extract_macros_select", " <file or dir>",
+ Common.mk_action_1_arg (extract_macros ~selection:true);
"-xxx", " <file1> <>",
* so that ast_c does not need to depend on yacc which depends on
* ast_c, etc.
*
- * Also, OcamlYacc imposes some stupid constraints on the way we can define
- * the token type. OcamlYacc force us to do a token type that
+ * Also, ocamlyacc imposes some stupid constraints on the way we can define
+ * the token type. ocamlyacc forces us to do a token type that
* cant be a pair of a sum type, it must be directly a sum type.
* We don't have this constraint here.
*
(* ---------------------------------------------------------------------- *)
+
+(* end of file *)
let is_eof = function
| EOF x -> true
| _ -> false
+(* end of macro *)
+let is_eom = function
+ | TDefEOL _ -> true
+ | _ -> false
let is_statement = function
| Tfor _ | Tdo _ | Tif _ | Twhile _ | Treturn _
| TMacroStmt _
| TMacroString _
| TMacroDecl _
- | TMacroStructDecl _
| TMacroDeclConst _
| TMacroIterator _
-> true
| TMacroStmt (s, i) -> i
| TMacroString (s, i) -> i
| TMacroDecl (s, i) -> i
- | TMacroStructDecl (s, i) -> i
| TMacroDeclConst (i) -> i
| TMacroIterator (s,i) -> i
(* | TMacroTop (s,i) -> i *)
| TMacroStmt (s, i) -> TMacroStmt (s, f i)
| TMacroString (s, i) -> TMacroString (s, f i)
| TMacroDecl (s, i) -> TMacroDecl (s, f i)
- | TMacroStructDecl (s, i) -> TMacroStructDecl (s, f i)
| TMacroDeclConst (i) -> TMacroDeclConst (f i)
| TMacroIterator (s, i) -> TMacroIterator (s, f i)
(* | TMacroTop (s,i) -> TMacroTop (s,f i) *)
val is_gcc_token : Parser_c.token -> bool
val is_eof : Parser_c.token -> bool
+val is_eom : Parser_c.token -> bool
+
val is_statement : Parser_c.token -> bool
val is_start_of_something : Parser_c.token -> bool
val is_binary_operator : Parser_c.token -> bool
--- /dev/null
+(* Yoann Padioleau
+ *
+ * Copyright (C) 2007, 2008 Ecole des Mines de Nantes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License (GPL)
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * file license.txt for more details.
+ *)
+
+open Common
+
+module TH = Token_helpers
+
+open Parser_c
+
+(*****************************************************************************)
+(* Some debugging functions *)
+(*****************************************************************************)
+
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_parsing
+
+(* ------------------------------------------------------------------------- *)
+(* fuzzy parsing, different "views" over the same program *)
+(* ------------------------------------------------------------------------- *)
+
+
+(* Normally I should not use ref/mutable in the token_extended type
+ * and I should have a set of functions taking a list of tokens and
+ * returning a list of tokens. The problem is that to make easier some
+ * functions, it is better to work on better representation, on "views"
+ * over this list of tokens. But then modifying those views and get
+ * back from those views to the original simple list of tokens is
+ * tedious. One way is to maintain next to the view a list of "actions"
+ * (I was using a hash storing the charpos of the token and associating
+ * the action) but it is tedious too. Simpler to use mutable/ref. We
+ * use the same idea that we use when working on the Ast_c. *)
+
+(* old: when I was using the list of "actions" next to the views, the hash
+ * indexed by the charpos, there could have been some problems:
+ * how my fake_pos interact with the way I tag and adjust token ?
+ * because I base my tagging on the position of the token ! so sometimes
+ * could tag another fakeInfo that should not be tagged ?
+ * fortunately I don't use anymore this technique.
+ *)
+
+(* update: quite close to the Place_c.Inxxx *)
+type context =
+ InFunction | InEnum | InStruct | InInitializer | NoContext
+
+type token_extended = {
+ mutable tok: Parser_c.token;
+ mutable where: context;
+
+ (* less: need also a after ? *)
+ mutable new_tokens_before : Parser_c.token list;
+
+ (* line x col cache, more easily accessible, of the info in the token *)
+ line: int;
+ col : int;
+}
+
+(* todo? is it ok to reset as a comment a TDefEOL ? if do that, then
+ * can confuse the parser.
+ *)
+let set_as_comment cppkind x =
+ if TH.is_eof x.tok
+ then () (* otherwise parse_c will be lost if don't find a EOF token *)
+ else
+ x.tok <- TCommentCpp (cppkind, TH.info_of_tok x.tok)
+
+let mk_token_extended x =
+ let (line, col) = TH.linecol_of_tok x in
+ { tok = x;
+ line = line; col = col;
+ where = NoContext;
+ new_tokens_before = [];
+ }
+
+
+let rebuild_tokens_extented toks_ext =
+ let _tokens = ref [] in
+ toks_ext +> List.iter (fun tok ->
+ tok.new_tokens_before +> List.iter (fun x -> push2 x _tokens);
+ push2 tok.tok _tokens
+ );
+ let tokens = List.rev !_tokens in
+ (tokens +> acc_map mk_token_extended)
+
+
+
+(* x list list, because x list separated by ',' *)
+type paren_grouped =
+ | Parenthised of paren_grouped list list * token_extended list
+ | PToken of token_extended
+
+type brace_grouped =
+ | Braceised of
+ brace_grouped list list * token_extended * token_extended option
+ | BToken of token_extended
+
+(* Far better data structure than doing hacks in the lexer or parser
+ * because in lexer we don't know to which ifdef a endif is related
+ * and so when we want to comment a ifdef, we don't know which endif
+ * we must also comment. Especially true for the #if 0 which sometimes
+ * have a #else part.
+ *
+ * x list list, because x list separated by #else or #elif
+ *)
+type ifdef_grouped =
+ | Ifdef of ifdef_grouped list list * token_extended list
+ | Ifdefbool of bool * ifdef_grouped list list * token_extended list
+ | NotIfdefLine of token_extended list
+
+
+type 'a line_grouped =
+ Line of 'a list
+
+
+type body_function_grouped =
+ | BodyFunction of token_extended list
+ | NotBodyLine of token_extended list
+
+
+(* ------------------------------------------------------------------------- *)
+(* view builders *)
+(* ------------------------------------------------------------------------- *)
+
+(* todo: synchro ! use more indentation
+ * if paren not closed and same indentation level, certainly because
+ * part of a mid-ifdef-expression.
+*)
+let rec mk_parenthised xs =
+ match xs with
+ | [] -> []
+ | x::xs ->
+ (match x.tok with
+ | TOPar _ | TOParDefine _ ->
+ let body, extras, xs = mk_parameters [x] [] xs in
+ Parenthised (body,extras)::mk_parenthised xs
+ | _ ->
+ PToken x::mk_parenthised xs
+ )
+
+(* return the body of the parenthised expression and the rest of the tokens *)
+and mk_parameters extras acc_before_sep xs =
+ match xs with
+ | [] ->
+ (* maybe because of #ifdef which "opens" '(' in 2 branches *)
+ pr2 "PB: not found closing paren in fuzzy parsing";
+ [List.rev acc_before_sep], List.rev extras, []
+ | x::xs ->
+ (match x.tok with
+ (* synchro *)
+ | TOBrace _ when x.col =|= 0 ->
+ pr2 "PB: found synchro point } in paren";
+ [List.rev acc_before_sep], List.rev (extras), (x::xs)
+
+ | TCPar _ | TCParEOL _ ->
+ [List.rev acc_before_sep], List.rev (x::extras), xs
+ | TOPar _ | TOParDefine _ ->
+ let body, extrasnest, xs = mk_parameters [x] [] xs in
+ mk_parameters extras
+ (Parenthised (body,extrasnest)::acc_before_sep)
+ xs
+ | TComma _ ->
+ let body, extras, xs = mk_parameters (x::extras) [] xs in
+ (List.rev acc_before_sep)::body, extras, xs
+ | _ ->
+ mk_parameters extras (PToken x::acc_before_sep) xs
+ )
+
+
+
+
+let rec mk_braceised xs =
+ match xs with
+ | [] -> []
+ | x::xs ->
+ (match x.tok with
+ | TOBrace _ ->
+ let body, endbrace, xs = mk_braceised_aux [] xs in
+ Braceised (body, x, endbrace)::mk_braceised xs
+ | TCBrace _ ->
+ pr2 "PB: found closing brace alone in fuzzy parsing";
+ BToken x::mk_braceised xs
+ | _ ->
+ BToken x::mk_braceised xs
+ )
+
+(* return the body of the parenthised expression and the rest of the tokens *)
+and mk_braceised_aux acc xs =
+ match xs with
+ | [] ->
+ (* maybe because of #ifdef which "opens" '(' in 2 branches *)
+ pr2 "PB: not found closing brace in fuzzy parsing";
+ [List.rev acc], None, []
+ | x::xs ->
+ (match x.tok with
+ | TCBrace _ -> [List.rev acc], Some x, xs
+ | TOBrace _ ->
+ let body, endbrace, xs = mk_braceised_aux [] xs in
+ mk_braceised_aux (Braceised (body,x, endbrace)::acc) xs
+ | _ ->
+ mk_braceised_aux (BToken x::acc) xs
+ )
+
+
+
+
+let rec mk_ifdef xs =
+ match xs with
+ | [] -> []
+ | x::xs ->
+ (match x.tok with
+ | TIfdef _ ->
+ let body, extra, xs = mk_ifdef_parameters [x] [] xs in
+ Ifdef (body, extra)::mk_ifdef xs
+ | TIfdefBool (b,_, _) ->
+ let body, extra, xs = mk_ifdef_parameters [x] [] xs in
+
+ (* if not passing, then consider a #if 0 as an ordinary #ifdef *)
+ if !Flag_parsing_c.if0_passing
+ then Ifdefbool (b, body, extra)::mk_ifdef xs
+ else Ifdef(body, extra)::mk_ifdef xs
+
+ | TIfdefMisc (b,_,_) | TIfdefVersion (b,_,_) ->
+ let body, extra, xs = mk_ifdef_parameters [x] [] xs in
+ Ifdefbool (b, body, extra)::mk_ifdef xs
+
+
+ | _ ->
+ (* todo? can have some Ifdef in the line ? *)
+ let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
+ NotIfdefLine line::mk_ifdef xs
+ )
+
+and mk_ifdef_parameters extras acc_before_sep xs =
+ match xs with
+ | [] ->
+ (* Note that mk_ifdef is assuming that CPP instruction are alone
+ * on their line. Because I do a span (fun x -> is_same_line ...)
+ * I might take with me a #endif if this one is mixed on a line
+ * with some "normal" tokens.
+ *)
+ pr2 "PB: not found closing ifdef in fuzzy parsing";
+ [List.rev acc_before_sep], List.rev extras, []
+ | x::xs ->
+ (match x.tok with
+ | TEndif _ ->
+ [List.rev acc_before_sep], List.rev (x::extras), xs
+ | TIfdef _ ->
+ let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
+ mk_ifdef_parameters
+ extras (Ifdef (body, extrasnest)::acc_before_sep) xs
+
+ | TIfdefBool (b,_,_) ->
+ let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
+
+ if !Flag_parsing_c.if0_passing
+ then
+ mk_ifdef_parameters
+ extras (Ifdefbool (b, body, extrasnest)::acc_before_sep) xs
+ else
+ mk_ifdef_parameters
+ extras (Ifdef (body, extrasnest)::acc_before_sep) xs
+
+
+ | TIfdefMisc (b,_,_) | TIfdefVersion (b,_,_) ->
+ let body, extrasnest, xs = mk_ifdef_parameters [x] [] xs in
+ mk_ifdef_parameters
+ extras (Ifdefbool (b, body, extrasnest)::acc_before_sep) xs
+
+ | TIfdefelse _
+ | TIfdefelif _ ->
+ let body, extras, xs = mk_ifdef_parameters (x::extras) [] xs in
+ (List.rev acc_before_sep)::body, extras, xs
+ | _ ->
+ let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
+ mk_ifdef_parameters extras (NotIfdefLine line::acc_before_sep) xs
+ )
+
+(* --------------------------------------- *)
+
+let line_of_paren = function
+ | PToken x -> x.line
+ | Parenthised (xxs, info_parens) ->
+ (match info_parens with
+ | [] -> raise Impossible
+ | x::xs -> x.line
+ )
+
+
+let rec span_line_paren line = function
+ | [] -> [],[]
+ | x::xs ->
+ (match x with
+ | PToken tok when TH.is_eof tok.tok ->
+ [], x::xs
+ | _ ->
+ if line_of_paren x =|= line
+ then
+ let (l1, l2) = span_line_paren line xs in
+ (x::l1, l2)
+ else ([], x::xs)
+ )
+
+
+let rec mk_line_parenthised xs =
+ match xs with
+ | [] -> []
+ | x::xs ->
+ let line_no = line_of_paren x in
+ let line, xs = span_line_paren line_no xs in
+ Line (x::line)::mk_line_parenthised xs
+
+
+(* --------------------------------------- *)
+let rec mk_body_function_grouped xs =
+ match xs with
+ | [] -> []
+ | x::xs ->
+ (match x with
+ | {tok = TOBrace _; col = 0} ->
+ let is_closing_brace = function
+ | {tok = TCBrace _; col = 0 } -> true
+ | _ -> false
+ in
+ let body, xs = Common.span (fun x -> not (is_closing_brace x)) xs in
+ (match xs with
+ | ({tok = TCBrace _; col = 0 })::xs ->
+ BodyFunction body::mk_body_function_grouped xs
+ | [] ->
+ pr2 "PB:not found closing brace in fuzzy parsing";
+ [NotBodyLine body]
+ | _ -> raise Impossible
+ )
+
+ | _ ->
+ let line, xs = Common.span (fun y -> y.line =|= x.line) (x::xs) in
+ NotBodyLine line::mk_body_function_grouped xs
+ )
+
+
+(* ------------------------------------------------------------------------- *)
+(* view iterators *)
+(* ------------------------------------------------------------------------- *)
+
+let rec iter_token_paren f xs =
+ xs +> List.iter (function
+ | PToken tok -> f tok;
+ | Parenthised (xxs, info_parens) ->
+ info_parens +> List.iter f;
+ xxs +> List.iter (fun xs -> iter_token_paren f xs)
+ )
+
+let rec iter_token_brace f xs =
+ xs +> List.iter (function
+ | BToken tok -> f tok;
+ | Braceised (xxs, tok1, tok2opt) ->
+ f tok1; do_option f tok2opt;
+ xxs +> List.iter (fun xs -> iter_token_brace f xs)
+ )
+
+let rec iter_token_ifdef f xs =
+ xs +> List.iter (function
+ | NotIfdefLine xs -> xs +> List.iter f;
+ | Ifdefbool (_, xxs, info_ifdef)
+ | Ifdef (xxs, info_ifdef) ->
+ info_ifdef +> List.iter f;
+ xxs +> List.iter (iter_token_ifdef f)
+ )
+
+
+
+
+let tokens_of_paren xs =
+ let g = ref [] in
+ xs +> iter_token_paren (fun tok -> push2 tok g);
+ List.rev !g
+
+
+let tokens_of_paren_ordered xs =
+ let g = ref [] in
+
+ let rec aux_tokens_ordered = function
+ | PToken tok -> push2 tok g;
+ | Parenthised (xxs, info_parens) ->
+ let (opar, cpar, commas) =
+ match info_parens with
+ | opar::xs ->
+ (match List.rev xs with
+ | cpar::xs ->
+ opar, cpar, List.rev xs
+ | _ -> raise Impossible
+ )
+ | _ -> raise Impossible
+ in
+ push2 opar g;
+ aux_args (xxs,commas);
+ push2 cpar g;
+
+ and aux_args (xxs, commas) =
+ match xxs, commas with
+ | [], [] -> ()
+ | [xs], [] -> xs +> List.iter aux_tokens_ordered
+ | xs::ys::xxs, comma::commas ->
+ xs +> List.iter aux_tokens_ordered;
+ push2 comma g;
+ aux_args (ys::xxs, commas)
+ | _ -> raise Impossible
+
+ in
+
+ xs +> List.iter aux_tokens_ordered;
+ List.rev !g
+
+
+
+(* ------------------------------------------------------------------------- *)
+(* set the context info in token *)
+(* ------------------------------------------------------------------------- *)
+
+
+let rec set_in_function_tag xs =
+ (* could try: ) { } but it can be the ) of a if or while, so
+ * better to base the heuristic on the position in column zero.
+ * Note that some struct or enum or init put also their { in first column
+ * but set_in_other will overwrite the previous InFunction tag.
+ *)
+ match xs with
+ | [] -> ()
+ (* ) { and the closing } is in column zero, then certainly a function *)
+ | BToken ({tok = TCPar _ })::(Braceised (body, tok1, Some tok2))::xs
+ when tok1.col <> 0 && tok2.col =|= 0 ->
+ body +> List.iter (iter_token_brace (fun tok ->
+ tok.where <- InFunction
+ ));
+ set_in_function_tag xs
+
+ | (BToken x)::xs -> set_in_function_tag xs
+
+ | (Braceised (body, tok1, Some tok2))::xs
+ when tok1.col =|= 0 && tok2.col =|= 0 ->
+ body +> List.iter (iter_token_brace (fun tok ->
+ tok.where <- InFunction
+ ));
+ set_in_function_tag xs
+ | Braceised (body, tok1, tok2)::xs ->
+ set_in_function_tag xs
+
+
+let rec set_in_other xs =
+ match xs with
+ | [] -> ()
+ (* enum x { } *)
+ | BToken ({tok = Tenum _})::BToken ({tok = TIdent _})
+ ::Braceised(body, tok1, tok2)::xs
+ | BToken ({tok = Tenum _})
+ ::Braceised(body, tok1, tok2)::xs
+ ->
+ body +> List.iter (iter_token_brace (fun tok ->
+ tok.where <- InEnum;
+ ));
+ set_in_other xs
+
+ (* struct x { } *)
+ | BToken ({tok = Tstruct _})::BToken ({tok = TIdent _})
+ ::Braceised(body, tok1, tok2)::xs ->
+ body +> List.iter (iter_token_brace (fun tok ->
+ tok.where <- InStruct;
+ ));
+ set_in_other xs
+ (* = { } *)
+ | BToken ({tok = TEq _})
+ ::Braceised(body, tok1, tok2)::xs ->
+ body +> List.iter (iter_token_brace (fun tok ->
+ tok.where <- InInitializer;
+ ));
+ set_in_other xs
+
+ | BToken _::xs -> set_in_other xs
+
+ | Braceised(body, tok1, tok2)::xs ->
+ body +> List.iter set_in_other;
+ set_in_other xs
+
+
+
+
+let set_context_tag xs =
+ begin
+ set_in_function_tag xs;
+ set_in_other xs;
+ end
+
--- /dev/null
+
+type context = InFunction | InEnum | InStruct | InInitializer | NoContext
+
+type token_extended = {
+ mutable tok : Parser_c.token;
+ mutable where : context;
+ mutable new_tokens_before : Parser_c.token list;
+ line : int;
+ col : int;
+}
+val mk_token_extended : Parser_c.token -> token_extended
+
+val rebuild_tokens_extented : token_extended list -> token_extended list
+
+(* ---------------------------------------------------------------------- *)
+type paren_grouped =
+ Parenthised of paren_grouped list list * token_extended list
+ | PToken of token_extended
+
+type brace_grouped =
+ Braceised of brace_grouped list list * token_extended *
+ token_extended option
+ | BToken of token_extended
+
+type ifdef_grouped =
+ Ifdef of ifdef_grouped list list * token_extended list
+ | Ifdefbool of bool * ifdef_grouped list list * token_extended list
+ | NotIfdefLine of token_extended list
+
+type 'a line_grouped = Line of 'a list
+
+type body_function_grouped =
+ BodyFunction of token_extended list
+ | NotBodyLine of token_extended list
+
+(* ---------------------------------------------------------------------- *)
+val mk_parenthised : token_extended list -> paren_grouped list
+val mk_braceised : token_extended list -> brace_grouped list
+val mk_ifdef : token_extended list -> ifdef_grouped list
+val mk_line_parenthised :
+ paren_grouped list -> paren_grouped line_grouped list
+val mk_body_function_grouped :
+ token_extended list -> body_function_grouped list
+
+val line_of_paren : paren_grouped -> int
+val span_line_paren :
+ int -> paren_grouped list -> paren_grouped list * paren_grouped list
+
+(* ---------------------------------------------------------------------- *)
+val iter_token_paren : (token_extended -> unit) -> paren_grouped list -> unit
+val iter_token_brace : (token_extended -> unit) -> brace_grouped list -> unit
+val iter_token_ifdef : (token_extended -> unit) -> ifdef_grouped list -> unit
+
+val tokens_of_paren : paren_grouped list -> token_extended list
+val tokens_of_paren_ordered : paren_grouped list -> token_extended list
+
+(* ---------------------------------------------------------------------- *)
+val set_context_tag: brace_grouped list -> unit
+
+(* ---------------------------------------------------------------------- *)
+val set_as_comment : Token_c.cppcommentkind -> token_extended -> unit
+
(*****************************************************************************)
(* Wrappers *)
(*****************************************************************************)
-let pr2 s =
- if !Flag_parsing_c.verbose_type
- then Common.pr2 s
-
-let pr2_once s =
- if !Flag_parsing_c.verbose_type
- then Common.pr2_once s
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_type
(*****************************************************************************)
(* Environment *)
| VarOrFunc of string * Ast_c.exp_type
| EnumConstant of string * string option
+ (* also used for macro type aliases *)
| TypeDef of string * fullType
(* the structType contains nested "idents" with struct scope *)
| StructUnionNameDef of string * (structUnion * structType) wrap
| StructUnionName (su, s) ->
(try
let (((su,fields),ii), env') = lookup_structunion (su, s) env in
- Ast_c.nQ, (StructUnion (su, Some s, fields), ii)
+ Ast_c.mk_ty (StructUnion (su, Some s, fields)) ii
(* old: +> Ast_c.rewrap_typeC ty
* but must wrap with good ii, otherwise pretty_print_c
* will be lost and raise some Impossible
* I now add a fake parse_info for such default int so no more failwith
* normally.
*)
-let offset (_,(ty,iis)) =
- match ty, iis with
- | TypeName (name, _typ), [] ->
- (match name with
- | RegularName (s, [ii]) -> ii.Ast_c.pinfo
- | _ -> raise Todo
- )
- | _, ii::_ -> ii.Ast_c.pinfo
- | _ -> failwith "type has no text; need to think again"
+let offset ft =
+ let (qu, ty) = ft in
+ (* bugfix: because of string->name, the ii can be deeper *)
+ let ii = Ast_c.get_local_ii_of_tybis_inlining_ii_of_name ty in
+ match ii with
+ | ii::_ -> ii.Ast_c.pinfo
+ | [] -> failwith "type has no text; need to think again"
| Constant (String (s,kind)) -> make_info_def (type_of_s "char *")
| Constant MultiString _ -> make_info_def (type_of_s "char *")
| Constant (Char (s,kind)) -> make_info_def (type_of_s "char")
- | Constant (Int (s)) -> make_info_def (type_of_s "int")
+ | Constant (Int (s,kind)) ->
+ (* this seems really unpleasant, but perhaps the type needs to be set
+ up in some way that allows pretty printing *)
+ make_info_def
+ (match kind with
+ (* matches limited by what is generated in lexer_c.mll *)
+ Si(Signed,CInt) -> type_of_s "int"
+ | Si(UnSigned,CInt) -> type_of_s "unsigned int"
+ | Si(Signed,CLong) -> type_of_s "long"
+ | Si(UnSigned,CLong) -> type_of_s "unsigned long"
+ | Si(Signed,CLongLong) -> type_of_s "long long"
+ | Si(UnSigned,CLongLong) -> type_of_s "unsigned long long"
+ | _ -> failwith "unexpected kind for constant")
| Constant (Float (s,kind)) ->
let fake = Ast_c.fakeInfo (Common.fake_parse_info) in
let fake = Ast_c.rewrap_str "float" fake in
let iinull = [fake] in
- make_info_def
- (Ast_c.nQ, (BaseType (FloatType kind), iinull))
+ make_info_def (Ast_c.mk_ty (BaseType (FloatType kind)) iinull)
(* -------------------------------------------------- *)
* Also as I don't want a warning on the Ident that are a FunCall,
* easier to have a rule separate from the Ident rule.
*)
- | FunCall (((Ident (ident), typ), _ii) as e1, args) ->
+ | FunCall (e1, args) ->
+ (match Ast_c.unwrap_expr e1 with
+ | Ident (ident) ->
(* recurse *)
args +> List.iter (fun (e,ii) ->
)
- | FunCall (e, args) ->
+ | _e ->
k expr;
- (Ast_c.get_type_expr e) +> Type_c.do_with_type (fun typ ->
+ (Ast_c.get_type_expr e1) +> Type_c.do_with_type (fun typ ->
(* copy paste of above *)
(match unwrap_unfold_env typ with
| FunctionType (ret, params) -> make_info_def ret
| _ -> Type_c.noTypeHere
)
)
+ )
(* -------------------------------------------------- *)
let fake = Ast_c.fakeInfo Common.fake_parse_info in
let fake = Ast_c.rewrap_str "*" fake in
- let ft = (Ast_c.nQ, (Pointer t, [fake])) in
+ let ft = Ast_c.mk_ty (Pointer t) [fake] in
make_info_def_fix ft
)
k expr;
Ast_c.get_type_expr e2
+ | Binary (e1, Logical _, e2) ->
+ k expr;
+ make_info_def (type_of_s "int")
+
(* todo: lub *)
- | Binary (e1, op, e2) ->
+ | Binary (e1, Arith op, e2) ->
k expr;
- Type_c.lub (Type_c.get_opt_type e1) (Type_c.get_opt_type e2)
+ Type_c.lub op (Type_c.get_opt_type e1) (Type_c.get_opt_type e2)
| CondExpr (cond, e1opt, e2) ->
k expr;
(* ------------------------------------------------------------ *)
Visitor_c.kstatement = (fun (k, bigf) st ->
- match st with
- | Compound statxs, ii -> do_in_new_scope (fun () -> k st);
+ match Ast_c.unwrap_st st with
+ | Compound statxs -> do_in_new_scope (fun () -> k st);
| _ -> k st
);
(* ------------------------------------------------------------ *)
let local =
match local with
| Ast_c.NotLocalDecl -> Ast_c.NotLocalVar
- | Ast_c.LocalDecl -> Ast_c.LocalVar (offset t)
+ | Ast_c.LocalDecl -> Ast_c.LocalVar (offset t)
in
var +> Common.do_option (fun (name, iniopt) ->
* the ref of abstract-lined types, but the real one, so
* don't al_type here
*)
- let (_q, t) = typ in
- match t with
- | StructUnion (su, Some s, structType),ii ->
+ let (_q, tbis) = typ in
+ match Ast_c.unwrap_typeC typ with
+ | StructUnion (su, Some s, structType) ->
let structType' = Lib.al_fields structType in
+ let ii = Ast_c.get_ii_typeC_take_care tbis in
let ii' = Lib.al_ii ii in
add_binding (StructUnionNameDef (s, ((su, structType'),ii'))) true;
if need_annotate_body
then k typ (* todo: restrict ? new scope so use do_in_scope ? *)
- | Enum (sopt, enums), ii ->
+ | Enum (sopt, enums) ->
enums +> List.iter (fun ((name, eopt), iicomma) ->
(match oldstyle with
| None ->
let typ' =
- Lib.al_type (Ast_c.nQ, (FunctionType ftyp, [i1;i2])) in
+ Lib.al_type (Ast_c.mk_ty (FunctionType ftyp) [i1;i2]) in
add_binding (VarOrFunc (funcs, (typ',islocal i1.Ast_c.pinfo)))
false;
);
);
+ | CppTop x ->
+ (match x with
+ | Define ((s,ii), (DefineVar, DefineType t)) ->
+ add_binding (TypeDef (s,Lib.al_type t)) true;
+ | _ -> k elem
+ )
+
| Declaration _
- | CppTop _
+
+
| IfdefTop _
| MacroTop _
| EmptyDef _
let bigf = { Visitor_c.default_visitor_c with
Visitor_c.kexpr = (fun (k,bigf) expr ->
- (match unwrap expr with
- (CondExpr(e,_,_),_) -> propagate_test e
+ (match unwrap_expr expr with
+ CondExpr(e,_,_) -> propagate_test e
| _ -> ()
);
k expr
);
Visitor_c.kstatement = (fun (k, bigf) st ->
- match unwrap st with
+ match unwrap_st st with
Selection(s) ->
(match s with If(e1,s1,s2) -> propagate_test e1 | _ -> ());
k st;
-(* Yoann Padioleau
+(* Yoann Padioleau, Julia Lawall
*
- * Copyright (C) 2007, 2008, 2009 University of Urbana Champaign
+ * Copyright (C) 2007, 2008, 2009 University of Urbana Champaign and DIKU
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License (GPL)
open Ast_c
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_type
+
(*****************************************************************************)
(* Types *)
(*****************************************************************************)
type completed_typedef = Ast_c.fullType
type removed_typedef = Ast_c.fullType
+(* move in ast_c ?
+ * use Ast_c.nQ, Ast_c.defaultInt, Ast_c.emptyAnnotCocci,
+ * Ast_c.emptyMetavarsBinding, Ast_c.emptyComments
+*)
+let (int_type: Ast_c.fullType) =
+ (* Lib_parsing_c.al_type (Parse_c.type_of_string "int")*)
+ Ast_c.mk_ty
+ (Ast_c.BaseType (Ast_c.IntType (Ast_c.Si (Ast_c.Signed, Ast_c.CInt))))
+ [Ast_c.al_info 0 (* al *)
+ {Ast_c.pinfo =
+ Ast_c.OriginTok
+ {Common.str = "int"; Common.charpos = 0; Common.line = -1;
+ Common.column = -1; Common.file = ""};
+ Ast_c.cocci_tag =
+ {contents = Some (Ast_cocci.CONTEXT (Ast_cocci.NoPos, Ast_cocci.NOTHING), [])};
+ Ast_c.comments_tag = {contents =
+ {Ast_c.mbefore = []; Ast_c.mafter = [];
+ Ast_c.mbefore2 = []; Ast_c.mafter2 = []
+ }}}]
+
+
+
(* normally if the type annotated has done a good job, this should always
* return true. Cf type_annotater_c.typedef_fix.
(None, Ast_c.NotTest)
-
-
-
let do_with_type f (t,_test) =
match t with
| None -> noTypeHere
let structdef_to_struct_name ty =
- match ty with
- | qu, (StructUnion (su, sopt, fields), iis) ->
- (match sopt,iis with
+ let (qu, tybis) = ty in
+ match Ast_c.unwrap_typeC ty with
+ | (StructUnion (su, sopt, fields)) ->
+ let iis = Ast_c.get_ii_typeC_take_care tybis in
+ (match sopt, iis with
(* todo? but what if correspond to a nested struct def ? *)
| Some s , [i1;i2;i3;i4] ->
- qu, (StructUnionName (su, s), [i1;i2])
+ qu, Ast_c.mk_tybis (StructUnionName (su, s)) [i1;i2]
| None, _ ->
ty
| x -> raise Impossible
let fake = Ast_c.fakeInfo (Common.fake_parse_info) in
let fake_cparen = Ast_c.rewrap_str ")" fake in
- Ast_c.nQ, (FunctionType ftyp, [fake_oparen;fake_cparen])
+ Ast_c.mk_ty (FunctionType ftyp) [fake_oparen;fake_cparen]
(* pre: only a single variable *)
rettype +> Common.map_option (fun rettype ->
let (ftyp: functionType) = (rettype, (tyargs, (false,[]))) in
let (t: fullType) =
- (Ast_c.nQ, (FunctionType ftyp, [fake_oparen;fake_cparen]))
+ Ast_c.mk_ty (FunctionType ftyp) [fake_oparen;fake_cparen]
in
t
)
* | (T.Pointer(ty1),ty2) -> T.Pointer(ty1)
*
*)
-let lub t1 t2 =
+let lub op t1 t2 =
let ftopt =
match t1, t2 with
| None, None -> None
| Some t1, Some t2 ->
let t1bis = Ast_c.unwrap_typeC t1 in
let t2bis = Ast_c.unwrap_typeC t2 in
- (match t1bis, t2bis with
+ (* a small attempt to do better, no consideration of typedefs *)
+ (match op, t1bis, t2bis with
+ (* these rules follow ANSI C. See eg:
+ http://flexor.uwaterloo.ca/library/SGI_bookshelves/SGI_Developer/books/CLanguageRef/sgi_html/ch05.html *)
+ _,Ast_c.BaseType(bt1),Ast_c.BaseType(bt2) ->
+ (match bt1,bt2 with
+ Ast_c.Void,_ -> Some t2 (* something has gone wrong *)
+ | _,Ast_c.Void -> Some t1 (* something has gone wrong *)
+ | Ast_c.FloatType(Ast_c.CLongDouble),_ -> Some t1
+ | _,Ast_c.FloatType(Ast_c.CLongDouble) -> Some t2
+ | Ast_c.FloatType(Ast_c.CDouble),_ -> Some t1
+ | _,Ast_c.FloatType(Ast_c.CDouble) -> Some t2
+ | Ast_c.FloatType(Ast_c.CFloat),_ -> Some t1
+ | _,Ast_c.FloatType(Ast_c.CFloat) -> Some t2
+
+ | Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLongLong)),_ ->
+ Some t1
+ | _,Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLongLong)) ->
+ Some t2
+ | Ast_c.IntType(Ast_c.Si(Ast_c.Signed,Ast_c.CLongLong)),_ ->
+ Some t1
+ | _,Ast_c.IntType(Ast_c.Si(Ast_c.Signed,Ast_c.CLongLong)) ->
+ Some t2
+ | Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLong)),_ ->
+ Some t1
+ | _,Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CLong)) ->
+ Some t2
+ | Ast_c.IntType(Ast_c.Si(Ast_c.Signed,Ast_c.CLong)),_ ->
+ Some t1
+ | _,Ast_c.IntType(Ast_c.Si(Ast_c.Signed,Ast_c.CLong)) ->
+ Some t2
+ | Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CInt)),_ ->
+ Some t1
+ | _,Ast_c.IntType(Ast_c.Si(Ast_c.UnSigned,Ast_c.CInt)) ->
+ Some t2
+ | _ -> Some int_type)
+
+ | Ast_c.Plus,Ast_c.Pointer _,Ast_c.BaseType(Ast_c.IntType _) ->
+ Some t1
+ | Ast_c.Plus,Ast_c.BaseType(Ast_c.IntType _),Ast_c.Pointer _ ->
+ Some t2
+ | Ast_c.Minus,Ast_c.Pointer _,Ast_c.BaseType(Ast_c.IntType _) ->
+ Some t1
+ | Ast_c.Minus,Ast_c.BaseType(Ast_c.IntType _),Ast_c.Pointer _ ->
+ Some t2
+ | Ast_c.Minus,Ast_c.Pointer _,Ast_c.Pointer _ ->
+ Some int_type
(* todo, Pointer, Typedef, etc *)
- | _, _ -> Some t1
+ | _, _, _ -> Some t1
)
in
let rec aux_fields fields =
fields +> List.iter (fun x ->
- match Ast_c.unwrap x with
+ match x with
| DeclarationField (FieldDeclList (onefield_multivars, iiptvirg)) ->
onefield_multivars +> List.iter (fun (fieldkind, iicomma) ->
match fieldkind with
| _ -> ()
)
- | EmptyField -> ()
- | MacroStructDeclTodo -> pr2_once "DeclTodo"; ()
+ | EmptyField info -> ()
+ | MacroDeclField _ -> pr2_once "DeclTodo"; ()
| CppDirectiveStruct _
| IfdefStruct _ -> pr2_once "StructCpp";
(* typing rules *)
val lub:
- finalType option -> finalType option -> Ast_c.exp_info
+ Ast_c.arithOp -> finalType option -> finalType option -> Ast_c.exp_info
(* helpers *)
val structdef_to_struct_name:
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_unparsing
+
(*****************************************************************************)
(* Types used during the intermediate phases of the unparsing *)
(*****************************************************************************)
* This type contains the whole information. Have all the tokens with this
* type.
*)
+type min =
+ Min of (int list (* match numbers *) * int (* adjacency information *))
+ | Ctx
+
type token2 =
- | T2 of Parser_c.token * bool (* minus *) *
+ | T2 of Parser_c.token * min *
int option (* orig index, abstracting away comments and space *)
| Fake2
- | Cocci2 of string
+ | Cocci2 of string * int (* line *) * int (* lcol *) * int (* rcol *)
| C2 of string
| Indent_cocci2
| Unindent_cocci2
let str_of_token2 = function
| T2 (t,_,_) -> TH.str_of_tok t
| Fake2 -> ""
- | Cocci2 s -> s
+ | Cocci2 (s,_,_,_) -> s
| C2 s -> s
| Indent_cocci2 -> ""
| Unindent_cocci2 -> ""
let print_token2 = function
- | T2 (t,b,_) -> "T2:"^(if b then "-" else "")^TH.str_of_tok t
+ | T2 (t,b,_) ->
+ let b_str =
+ match b with
+ Min (index,adj) ->
+ Printf.sprintf "-%d[%s]" adj
+ (String.concat " " (List.map string_of_int index))
+ | Ctx -> "" in
+ "T2:"^b_str^TH.str_of_tok t
| Fake2 -> ""
- | Cocci2 s -> "Cocci2:"^s
+ | Cocci2 (s,_,lc,rc) -> Printf.sprintf "Cocci2:%d:%d%s" lc rc s
| C2 s -> "C2:"^s
| Indent_cocci2 -> "Indent"
| Unindent_cocci2 -> "Unindent"
-let print_all_tokens2 l =
+let simple_print_all_tokens2 l =
List.iter (function x -> Printf.printf "%s " (print_token2 x)) l;
Printf.printf "\n"
| Ast_cocci.CONTEXT (_,Ast_cocci.NOTHING) -> false
| Ast_cocci.CONTEXT _ -> true
(* patch: when need full coccinelle transformation *)
- | Ast_cocci.MINUS (_,[]) -> false
- | Ast_cocci.MINUS (_,x::xs) -> true
+ | Ast_cocci.MINUS (_,_,_,[]) -> false
+ | Ast_cocci.MINUS (_,_,_,x::xs) -> true
| Ast_cocci.PLUS -> raise Impossible
let contain_plus info =
match fake_info with
Some(bef,((Fake1 info) as fake),aft) ->
(match !(info.cocci_tag) with
+ | Some x ->
+ (match x with
(Ast_cocci.CONTEXT(_,Ast_cocci.BEFORE _),_) ->
(* move the fake node forwards *)
let (whitespace,rest) = Common.span is_whitespace aft in
failwith "fake node should not be before-after"
| _ -> bef @ fake :: (loop aft) (* old: was removed when have simpler yacfe *)
)
+ | None ->
+ bef @ fake :: (loop aft)
+ )
| None -> toks
| _ -> raise Impossible in
loop toks
in
let expand_info t =
- let (mcode,env) = !((info_of_token1 t).cocci_tag) in
+ let (mcode,env) =
+ Ast_c.mcode_and_env_of_cocciref ((info_of_token1 t).cocci_tag) in
- let pr_cocci s =
- push2 (Cocci2 s) toks_out
- in
+ let pr_cocci s ln col rcol =
+ push2 (Cocci2(s,ln,col,rcol)) toks_out in
let pr_c info =
(match Ast_c.pinfo_of_info info with
Ast_c.AbstractLineTok _ ->
(!(info.Ast_c.comments_tag)).Ast_c.mafter +>
List.iter (fun x -> Common.push2 (comment2t2 x) toks_out) in
+ let pr_barrier ln col = (* marks a position, used around C code *)
+ push2 (Cocci2("",ln,col,col)) toks_out in
+ let pr_nobarrier ln col = () in (* not needed for linux spacing *)
+ let pr_cspace _ = push2 (C2 " ") toks_out in
- let pr_space _ = push2 (C2 " ") toks_out in
+ let pr_space _ = () (* rely on add_space in cocci code *) in
+ let pr_arity _ = () (* not interested *) in
let indent _ = push2 Indent_cocci2 toks_out in
let unindent _ = push2 Unindent_cocci2 toks_out in
- let args_pp = (env, pr_cocci, pr_c, pr_space, indent, unindent) in
+ let args_pp =
+ (env, pr_cocci, pr_c, pr_cspace,
+ (match !Flag_parsing_c.spacing with
+ Flag_parsing_c.SMPL -> pr_space | _ -> pr_cspace),
+ pr_arity,
+ (match !Flag_parsing_c.spacing with
+ Flag_parsing_c.SMPL -> pr_barrier | _ -> pr_nobarrier),
+ indent, unindent) in
(* old: when for yacfe with partial cocci:
* add_elem t false;
(* patch: when need full coccinelle transformation *)
let unparser = Unparse_cocci.pp_list_list_any args_pp false in
match mcode with
- | Ast_cocci.MINUS (_,any_xxs) ->
+ | Ast_cocci.MINUS (_,inst,adj,any_xxs) ->
(* Why adding ? because I want to have all the information, the whole
* set of tokens, so I can then process and remove the
* is_between_two_minus for instance *)
- add_elem t true;
+ add_elem t (Min (inst,adj));
unparser any_xxs Unparse_cocci.InPlace
| Ast_cocci.CONTEXT (_,any_befaft) ->
(match any_befaft with
| Ast_cocci.NOTHING ->
- add_elem t false
+ add_elem t Ctx
| Ast_cocci.BEFORE xxs ->
unparser xxs Unparse_cocci.Before;
- add_elem t false
+ add_elem t Ctx
| Ast_cocci.AFTER xxs ->
- add_elem t false;
+ add_elem t Ctx;
unparser xxs Unparse_cocci.After;
| Ast_cocci.BEFOREAFTER (xxs, yys) ->
unparser xxs Unparse_cocci.Before;
- add_elem t false;
+ add_elem t Ctx;
unparser yys Unparse_cocci.After;
)
| Ast_cocci.PLUS -> raise Impossible
(*previously gave up if the first character was a newline, but not clear why*)
let is_minusable_comment_or_plus x = is_minusable_comment x or all_coccis x
-let set_minus_comment = function
- | T2 (t,false,idx) ->
+let set_minus_comment adj = function
+ | T2 (t,Ctx,idx) ->
let str = TH.str_of_tok t in
(match t with
| Parser_c.TCommentSpace _
(TH.line_of_tok t) str)
| _ -> raise Impossible
);
- T2 (t, true, idx)
+ T2 (t, Min adj, idx)
(* patch: coccinelle *)
- | T2 (Parser_c.TCommentNewline _,true,idx) as x -> x
+ | T2 (Parser_c.TCommentNewline _,Min adj,idx) as x -> x
| _ -> raise Impossible
-let set_minus_comment_or_plus = function
+let set_minus_comment_or_plus adj = function
Cocci2 _ | C2 _ | Indent_cocci2 | Unindent_cocci2 as x -> x
- | x -> set_minus_comment x
+ | x -> set_minus_comment adj x
let remove_minus_and_between_and_expanded_and_fake xs =
(*This drops the space before each completely minused block (no plus code).*)
let minus_or_comment = function
- T2(_,true,_) -> true
+ T2(_,Min adj,_) -> true
| T2(Parser_c.TCommentNewline _,_b,_i) -> false
| x -> is_minusable_comment x in
let rec adjust_before_minus = function
[] -> []
(* patch: coccinelle *)
- | (T2(Parser_c.TCommentNewline c,_b,_i) as x)::((T2(_,true,_)::_) as xs) ->
+ | (T2(Parser_c.TCommentNewline c,_b,_i) as x)::
+ ((T2(_,Min adj,_)::_) as xs) ->
let (between_minus,rest) = Common.span minus_or_comment xs in
(match rest with
- [] -> (set_minus_comment x) :: between_minus
+ [] -> (set_minus_comment adj x) :: between_minus
| T2(Parser_c.TCommentNewline _,_b,_i)::_ ->
- (set_minus_comment x) :: between_minus @
+ (set_minus_comment adj x) :: between_minus @
(adjust_before_minus rest)
| _ -> x :: between_minus @ (adjust_before_minus rest))
| x::xs -> x::adjust_before_minus xs in
(* this drops blank lines after a brace introduced by removing code *)
let rec adjust_after_brace = function
[] -> []
- | ((T2(_,false,_)) as x)::((T2(_,true,_)::_) as xs)
+ | ((T2(_,Ctx,_)) as x)::((T2(_,Min adj,_)::_) as xs)
when str_of_token2 x =$= "{" ->
let (between_minus,rest) = Common.span minus_or_comment xs in
let is_whitespace = function
let (drop_newlines,last_newline) = loop xs in
(drop_newlines,x::last_newline) in
loop (List.rev newlines) in
- x::between_minus@(List.map set_minus_comment drop_newlines)@
+ x::between_minus@(List.map (set_minus_comment adj) drop_newlines)@
last_newline@
adjust_after_brace rest
| x::xs -> x::adjust_after_brace xs in
(* The use of is_minusable_comment_or_plus and set_minus_comment_or_plus
is because the + code can end up anywhere in the middle of the - code;
it is not necessarily to the far left *)
+
+ let common_adj (index1,adj1) (index2,adj2) =
+ adj1 = adj2 (* same adjacency info *) &&
+ (* non-empty intersection of witness trees *)
+ not ((Common.inter_set index1 index2) = []) in
+
let rec adjust_between_minus xs =
match xs with
| [] -> []
- | (T2 (t1,true,idx1))::xs ->
-
+ | ((T2 (_,Min adj1,_)) as t1)::xs ->
let (between_comments, rest) =
Common.span is_minusable_comment_or_plus xs in
(match rest with
- | [] -> [(T2 (t1, true,idx1))]
+ | [] -> [t1]
- | (T2 (t2, true,idx2))::rest ->
- (T2 (t1, true,idx1))::
- (List.map set_minus_comment_or_plus between_comments @
- adjust_between_minus ((T2 (t2, true, idx2))::rest))
+ | ((T2 (_,Min adj2,_)) as t2)::rest when common_adj adj1 adj2 ->
+ t1::
+ (List.map (set_minus_comment_or_plus adj1) between_comments @
+ adjust_between_minus (t2::rest))
| x::xs ->
- (T2 (t1, true, idx1))::
- (between_comments @ adjust_between_minus (x::xs))
+ t1::(between_comments @ adjust_between_minus (x::xs))
)
| x::xs -> x::adjust_between_minus xs in
let xs = adjust_between_minus xs in
let xs = xs +> Common.exclude (function
- | T2 (t,true,_) -> true
+ | T2 (t,Min adj,_) -> true
| _ -> false
) in
xs
let toks = List.rev toks in
let rec loop = function
[] -> []
- | ((T2(_,false,_)) as x)::xs ->
+ | ((T2(_,Ctx,_)) as x)::xs ->
if List.mem (str_of_token2 x) [";";")";","]
then
let (spaces, rest) = Common.span is_minusable_comment xs in
(match rest with
- (T2(_,true,_))::_ | (Cocci2 _)::_ ->
+ (T2(_,Min _,_))::_ | (Cocci2 _)::_ ->
(* only drop spaces if something was actually changed before *)
x :: loop rest
| _ -> x :: loop xs)
match xs with
| [] -> []
| [x] -> [x]
+ | (Cocci2(sx,lnx,_,rcolx) as x)::((Cocci2(sy,lny,lcoly,_)) as y)::xs
+ when !Flag_parsing_c.spacing = Flag_parsing_c.SMPL &&
+ not (lnx = -1) && lnx = lny && not (rcolx = -1) && rcolx < lcoly ->
+ (* this only works within a line. could consider whether
+ something should be done to add newlines too, rather than
+ printing them explicitly in unparse_cocci. *)
+ x::C2 (String.make (lcoly-rcolx) ' ')::add_space (y::xs)
| x::y::xs ->
let sx = str_of_token2 x in
let sy = str_of_token2 y in
| [] -> []
(* patch: coccinelle *)
| ((T2 (tok,_,_)) as x)::(T2 (Parser_c.TCommentNewline s, _, _))::
- (Cocci2 "{")::xs when started && str_of_token2 x =$= ")" ->
+ ((Cocci2 ("{",_,_,_)) as a)::xs
+ when started && str_of_token2 x =$= ")" ->
(* to be done for if, etc, but not for a function header *)
- x::(Cocci2 " {")::(aux started xs)
+ x::(C2 " ")::a::(aux started xs)
| ((T2 (Parser_c.TCommentNewline s, _, _)) as x)::xs ->
let old_tabbing = !_current_tabbing in
str_of_token2 x +> new_tabbing +> (fun s -> _current_tabbing := s);
None -> aux started xs
| Some (tu,_) ->
_current_tabbing := (!_current_tabbing)^tu;
- Cocci2 (tu)::aux started xs)
+ Cocci2 (tu,-1,-1,-1)::aux started xs)
| Unindent_cocci2::xs ->
(match !tabbing_unit with
None -> aux started xs
_current_tabbing := remtab tu (!_current_tabbing);
aux started xs)
(* border between existing code and cocci code *)
- | ((T2 (tok,_,_)) as x)::((Cocci2 "\n") as y)::xs
+ | ((T2 (tok,_,_)) as x)::((Cocci2("\n",_,_,_)) as y)::xs
when str_of_token2 x =$= "{" ->
x::aux true (y::Indent_cocci2::xs)
| ((Cocci2 _) as x)::((T2 (tok,_,_)) as y)::xs
x::aux started (y::Unindent_cocci2::xs)
(* starting the body of the function *)
| ((T2 (tok,_,_)) as x)::xs when str_of_token2 x =$= "{" -> x::aux true xs
- | (Cocci2 "{")::xs -> (Cocci2 "{")::aux true xs
- | ((Cocci2 "\n") as x)::xs ->
+ | ((Cocci2("{",_,_,_)) as a)::xs -> a::aux true xs
+ | ((Cocci2("\n",_,_,_)) as x)::xs ->
(* dont inline in expr because of weird eval order of ocaml *)
let s = !_current_tabbing in
- x::Cocci2 (s)::aux started xs
+ x::Cocci2 (s,-1,-1,-1)::aux started xs
| x::xs -> x::aux started xs in
aux false xs
type pos = Before | After | InPlace
-let rec pp_list_list_any (env, pr, pr_elem, pr_space, indent, unindent)
+let unknown = -1
+
+let rec pp_list_list_any
+ (env, pr, pr_celem, pr_cspace, pr_space, pr_arity, pr_barrier,
+ indent, unindent)
generating xxs before =
(* Just to be able to copy paste the code from pretty_print_cocci.ml. *)
-let print_string = pr in
+let print_string s line lcol =
+ let rcol = if lcol = unknown then unknown else lcol + (String.length s) in
+ pr s line lcol rcol in
+let print_text s = pr s unknown unknown unknown in
let close_box _ = () in
-let print_space() = pr " " in
-let force_newline () = pr "\n" in
+let force_newline () = print_text "\n" in
let start_block () = force_newline(); indent() in
let end_block () = unindent(); force_newline () in
let outdent _ = () (* should go to leftmost col, does nothing now *) in
let pretty_print_c =
- Pretty_print_c.pretty_print_c pr_elem pr_space
+ Pretty_print_c.pretty_print_c pr_celem pr_cspace
force_newline indent outdent unindent in
(* --------------------------------------------------------------------- *)
Ast.Rule_elemTag(_) | Ast.AssignOpTag(_) | Ast.BinaryOpTag(_)
| Ast.ArithOpTag(_) | Ast.LogicalOpTag(_) | Ast.Token("{",_) -> true
| _ -> false) in
- if space then print_string " ";
+ if space then pr_space ();
print_anything_list rest in
let print_around printer term = function
print_anything bef; printer term; print_anything aft in
let print_string_befaft fn fn1 x info =
- List.iter (function (s,_,_) -> fn1(); print_string s; force_newline())
+ List.iter
+ (function (s,ln,col) -> fn1(); print_string s ln col; force_newline())
info.Ast.strbef;
fn x;
- List.iter (function (s,_,_) -> force_newline(); fn1(); print_string s)
+ List.iter
+ (function (s,ln,col) -> force_newline(); fn1(); print_string s ln col)
info.Ast.straft in
-let print_meta (r,x) = print_string x in
+let print_meta (r,x) = print_text x in
let print_pos = function
Ast.MetaPos(name,_,_,_,_) ->
let name = Ast.unwrap_mcode name in
- print_string "@"; print_meta name
+ print_text "@"; print_meta name
| _ -> () in
(* --------------------------------------------------------------------- *)
-let mcode fn arg =
- match (generating,arg) with
- (false,(s,info,_,_)) ->
+let mcode fn (s,info,mc,pos) =
+ let line = info.Ast.line in
+ let lcol = info.Ast.column in
+ match (generating,mc) with
+ (false,_) ->
(* printing for transformation *)
(* Here we don't care about the annotation on s. *)
let print_comments lb comments =
(function line_before ->
function (str,line,col) ->
match line_before with
- None -> print_string str; Some line
- | Some lb when line =|= lb -> print_string str; Some line
- | _ -> print_string "\n"; print_string str; Some line)
+ None -> print_string str line col; Some line
+ | Some lb when line =|= lb ->
+ print_string str line col; Some line
+ | _ -> force_newline(); print_string str line col; Some line)
lb comments in
let line_before = print_comments None info.Ast.strbef in
(match line_before with
None -> ()
| Some lb when lb =|= info.Ast.line -> ()
- | _ -> print_string "\n");
- fn s;
+ | _ -> force_newline());
+ fn s line lcol;
let _ = print_comments (Some info.Ast.line) info.Ast.straft in
()
(* printing for rule generation *)
- | (true, (x, _, Ast.MINUS(_,plus_stream), pos)) ->
- print_string "\n- ";
- fn x; print_pos pos;
+ | (true, Ast.MINUS(_,_,_,plus_stream)) ->
+ force_newline();
+ print_text "- ";
+ fn s line lcol; print_pos pos;
print_anything plus_stream
- | (true, (x, _, Ast.CONTEXT(_,plus_streams), pos)) ->
- let fn x = print_string "\n "; fn x; print_pos pos in
- print_around fn x plus_streams
- | (true,( x, info, Ast.PLUS, pos)) ->
- let fn x = print_string "\n+ "; fn x; print_pos pos in
- print_string_befaft fn (function _ -> print_string "+ ") x info
+ | (true, Ast.CONTEXT(_,plus_streams)) ->
+ let fn s = force_newline(); fn s line lcol; print_pos pos in
+ print_around fn s plus_streams
+ | (true,Ast.PLUS) ->
+ let fn s =
+ force_newline(); print_text "+ "; fn s line lcol; print_pos pos in
+ print_string_befaft fn (function _ -> print_text "+ ") s info
in
(* --------------------------------------------------------------------- *)
let handle_metavar name fn =
- match (Common.optionise (fun () -> List.assoc (term name) env)) with
- | None ->
+ let ((_,b) as s,info,mc,pos) = name in
+ let line = info.Ast.line in
+ let lcol = info.Ast.column in
+ match Common.optionise (fun () -> List.assoc s env) with
+ None ->
let name_string (_,s) = s in
if generating
- then mcode (function _ -> pr (name_string (term name))) name
+ then
+ mcode (function _ -> print_string (name_string s)) name
else
failwith
(Printf.sprintf "SP line %d: Not found a value in env for: %s"
- (Ast_cocci.get_mcode_line name) (name_string (term name)))
+ line (name_string s))
| Some e ->
- if generating
- then mcode (function _ -> fn e) name
- else fn e
+ pr_barrier line lcol;
+ (if generating
+ then
+ (* call mcode to preserve the -+ annotation *)
+ mcode (fun _ _ _ -> fn e) name
+ else fn e);
+ let rcol = if lcol = unknown then unknown else lcol + (String.length b) in
+ pr_barrier line rcol
in
(* --------------------------------------------------------------------- *)
let dots between fn d =
let mc s = if multi then s^"+>" else s^">" in
match Ast.unwrap d with
Ast.DOTS(l) ->
- print_string (mo "..."); f(); start_block();
+ print_text (mo "..."); f(); start_block();
print_between force_newline fn l;
- end_block(); print_string (mc "...")
+ end_block(); print_text (mc "...")
| Ast.CIRCLES(l) ->
- print_string (mo "ooo"); f(); start_block();
+ print_text (mo "ooo"); f(); start_block();
print_between force_newline fn l;
- end_block(); print_string (mc "ooo")
+ end_block(); print_text (mc "ooo")
| Ast.STARS(l) ->
- print_string (mo "***"); f(); start_block();
+ print_text (mo "***"); f(); start_block();
print_between force_newline fn l;
- end_block(); print_string (mc "***")
+ end_block(); print_text (mc "***")
in
(* --------------------------------------------------------------------- *)
Ast.Id(name) -> mcode print_string name
| Ast.MetaId(name,_,_,_) ->
handle_metavar name (function
- | (Ast_c.MetaIdVal id) -> pr id
+ | (Ast_c.MetaIdVal id) -> print_text id
| _ -> raise Impossible
)
| Ast.MetaFunc(name,_,_,_) ->
handle_metavar name (function
- | (Ast_c.MetaFuncVal id) -> pr id
+ | (Ast_c.MetaFuncVal id) -> print_text id
| _ -> raise Impossible
)
| Ast.MetaLocalFunc(name,_,_,_) ->
handle_metavar name (function
- | (Ast_c.MetaLocalFuncVal id) -> pr id
+ | (Ast_c.MetaLocalFuncVal id) -> print_text id
| _ -> raise Impossible
)
(* Expression *)
let print_disj_list fn l =
- force_newline(); print_string "("; force_newline();
- print_between
- (function _ ->
- force_newline(); print_string "|"; force_newline())
- fn l;
- force_newline(); print_string ")"; force_newline() in
+ print_text "\n(\n";
+ print_between (function _ -> print_text "\n|\n") fn l;
+ print_text "\n)\n" in
let rec expression e =
match Ast.unwrap e with
Ast.Ident(id) -> ident id
-
| Ast.Constant(const) -> mcode constant const
| Ast.FunCall(fn,lp,args,rp) ->
expression fn; mcode print_string_box lp;
dots (function _ -> ()) expression args;
close_box(); mcode print_string rp
| Ast.Assignment(left,op,right,_) ->
- expression left; print_string " "; mcode assignOp op;
- print_string " "; expression right
+ expression left; pr_space(); mcode assignOp op;
+ pr_space(); expression right
| Ast.CondExpr(exp1,why,exp2,colon,exp3) ->
- expression exp1; print_string " "; mcode print_string why;
- print_option (function e -> print_string " "; expression e) exp2;
- print_string " "; mcode print_string colon; expression exp3
+ expression exp1; pr_space(); mcode print_string why;
+ print_option (function e -> pr_space(); expression e) exp2;
+ pr_space(); mcode print_string colon; expression exp3
| Ast.Postfix(exp,op) -> expression exp; mcode fixOp op
| Ast.Infix(exp,op) -> mcode fixOp op; expression exp
| Ast.Unary(exp,op) -> mcode unaryOp op; expression exp
| Ast.Binary(left,op,right) ->
- expression left; print_string " "; mcode binaryOp op; print_string " ";
+ expression left; pr_space(); mcode binaryOp op; pr_space();
expression right
| Ast.Nested(left,op,right) -> failwith "nested only in minus code"
| Ast.Paren(lp,exp,rp) ->
| _ -> raise Impossible
)
- | Ast.EComma(cm) -> mcode print_string cm; print_space()
+ | Ast.EComma(cm) -> mcode print_string cm; pr_space()
| Ast.DisjExpr(exp_list) ->
if generating
else raise CantBeInPlus
| Ast.NestExpr(expr_dots,Some whencode,multi) when generating ->
nest_dots multi expression
- (function _ -> print_string " when != "; expression whencode)
+ (function _ -> print_text " when != "; expression whencode)
expr_dots
| Ast.NestExpr(expr_dots,None,multi) when generating ->
nest_dots multi expression (function _ -> ()) expr_dots
if generating
then
(mcode print_string dots;
- print_string " when != ";
+ print_text " when != ";
expression whencode)
else raise CantBeInPlus
| Ast.Edots(dots,None)
and assignOp = function
Ast.SimpleAssign -> print_string "="
- | Ast.OpAssign(aop) -> arithOp aop; print_string "="
+ | Ast.OpAssign(aop) ->
+ (function line -> function lcol ->
+ arithOp aop line lcol; print_string "=" line lcol)
and fixOp = function
Ast.Dec -> print_string "--"
| Ast.OrLog -> print_string "||"
and constant = function
- Ast.String(s) -> print_string "\""; print_string s; print_string "\""
+ Ast.String(s) -> print_string ("\""^s^"\"")
| Ast.Char(s) -> print_string s
| Ast.Int(s) -> print_string s
| Ast.Float(s) -> print_string s
| Ast.Array(ty,lb,size,rb) ->
fullType ty; mcode print_string lb; print_option expression size;
mcode print_string rb
- | Ast.EnumName(kind,name) -> mcode print_string kind; print_string " ";
+ | Ast.EnumName(kind,name) -> mcode print_string kind; pr_space();
ident name
| Ast.StructUnionName(kind,name) ->
mcode structUnion kind;
print_option ident name
| Ast.StructUnionDef(ty,lb,decls,rb) ->
- fullType ty;
+ fullType ty; ft_space ty;
mcode print_string lb;
dots force_newline declaration decls;
mcode print_string rb
(match Ast.unwrap ty1 with
Ast.FunctionPointer(ty,lp1,star,rp1,lp2,params,rp2) ->
print_function_pointer (ty,lp1,star,rp1,lp2,params,rp2)
- (function _ -> print_string " "; ident id)
+ (function _ -> pr_space(); ident id)
| Ast.FunctionType(am,ty,lp1,params,rp1) ->
print_function_type (ty,lp1,params,rp1)
- (function _ -> print_string " "; ident id)
+ (function _ -> pr_space(); ident id)
| Ast.Array(_,_,_,_) ->
let rec loop ty k =
match Ast.unwrap ty with
and ty_space ty =
match Ast.unwrap ty with
Ast.Pointer(_,_) -> ()
- | _ -> print_space()
+ | _ -> pr_space()
and ft_space ty =
match Ast.unwrap ty with
Ast.Type(cv,ty) ->
(match Ast.unwrap ty with
Ast.Pointer(_,_) -> ()
- | _ -> print_space())
- | _ -> print_space()
+ | _ -> pr_space())
+ | _ -> pr_space()
and declaration d =
match Ast.unwrap d with
Ast.Init(stg,ty,id,eq,ini,sem) ->
print_option (mcode storage) stg;
print_named_type ty id;
- print_string " "; mcode print_string eq;
- print_string " "; initialiser true ini; mcode print_string sem
+ pr_space(); mcode print_string eq;
+ pr_space(); initialiser true ini; mcode print_string sem
| Ast.UnInit(stg,ty,id,sem) ->
print_option (mcode storage) stg;
print_named_type ty id;
end_block(); mcode print_string rb
| Ast.InitList(lb,initlist,rb,_) -> failwith "unexpected whencode in plus"
| Ast.InitGccExt(designators,eq,ini) ->
- List.iter designator designators; print_string " ";
- mcode print_string eq; print_string " "; initialiser nlcomma ini
+ List.iter designator designators; pr_space();
+ mcode print_string eq; pr_space(); initialiser nlcomma ini
| Ast.InitGccName(name,eq,ini) ->
ident name; mcode print_string eq; initialiser nlcomma ini
| Ast.IComma(comma) ->
| Ast.MetaParamList(name,_,_,_) ->
failwith "not handling MetaParamList"
- | Ast.PComma(cm) -> mcode print_string cm; print_space()
+ | Ast.PComma(cm) -> mcode print_string cm; pr_space()
| Ast.Pdots(dots) | Ast.Pcircles(dots) when generating ->
mcode print_string dots
| Ast.Pdots(dots) | Ast.Pcircles(dots) -> raise CantBeInPlus
let rec inc_file = function
Ast.Local(elems) ->
- print_string "\"";
- print_between (function _ -> print_string "/") inc_elem elems;
- print_string "\""
+ print_string ("\""^(String.concat "/" (List.map inc_elem elems))^"\"")
| Ast.NonLocal(elems) ->
- print_string "<";
- print_between (function _ -> print_string "/") inc_elem elems;
- print_string ">"
+ print_string ("<"^(String.concat "/" (List.map inc_elem elems))^">")
and inc_elem = function
- Ast.IncPath s -> print_string s
- | Ast.IncDots -> print_string "..."
+ Ast.IncPath s -> s
+ | Ast.IncDots -> "..."
(* --------------------------------------------------------------------- *)
(* Top-level code *)
and rule_elem arity re =
match Ast.unwrap re with
Ast.FunHeader(_,_,fninfo,name,lp,params,rp) ->
- print_string arity; List.iter print_fninfo fninfo;
+ pr_arity arity; List.iter print_fninfo fninfo;
ident name; mcode print_string_box lp;
parameter_list params; close_box(); mcode print_string rp;
- print_string " "
- | Ast.Decl(_,_,decl) -> print_string arity; declaration decl
+ pr_space()
+ | Ast.Decl(_,_,decl) -> pr_arity arity; declaration decl
| Ast.SeqStart(brace) ->
- print_string arity; mcode print_string brace; start_block()
+ pr_arity arity; mcode print_string brace; start_block()
| Ast.SeqEnd(brace) ->
- end_block(); print_string arity; mcode print_string brace
+ end_block(); pr_arity arity; mcode print_string brace
| Ast.ExprStatement(exp,sem) ->
- print_string arity; expression exp; mcode print_string sem
+ pr_arity arity; expression exp; mcode print_string sem
| Ast.IfHeader(iff,lp,exp,rp) ->
- print_string arity;
- mcode print_string iff; print_string " "; mcode print_string_box lp;
+ pr_arity arity;
+ mcode print_string iff; pr_space(); mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp
| Ast.Else(els) ->
- print_string arity; mcode print_string els
+ pr_arity arity; mcode print_string els
| Ast.WhileHeader(whl,lp,exp,rp) ->
- print_string arity;
- mcode print_string whl; print_string " "; mcode print_string_box lp;
+ pr_arity arity;
+ mcode print_string whl; pr_space(); mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp
| Ast.DoHeader(d) ->
- print_string arity; mcode print_string d
+ pr_arity arity; mcode print_string d
| Ast.WhileTail(whl,lp,exp,rp,sem) ->
- print_string arity;
- mcode print_string whl; print_string " "; mcode print_string_box lp;
+ pr_arity arity;
+ mcode print_string whl; pr_space(); mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp;
mcode print_string sem
| Ast.ForHeader(fr,lp,e1,sem1,e2,sem2,e3,rp) ->
- print_string arity;
+ pr_arity arity;
mcode print_string fr; mcode print_string_box lp;
print_option expression e1; mcode print_string sem1;
print_option expression e2; mcode print_string sem2;
print_option expression e3; close_box();
mcode print_string rp
| Ast.IteratorHeader(nm,lp,args,rp) ->
- print_string arity;
- ident nm; print_string " "; mcode print_string_box lp;
+ pr_arity arity;
+ ident nm; pr_space(); mcode print_string_box lp;
dots (function _ -> ()) expression args; close_box();
mcode print_string rp
| Ast.SwitchHeader(switch,lp,exp,rp) ->
- print_string arity;
- mcode print_string switch; print_string " "; mcode print_string_box lp;
+ pr_arity arity;
+ mcode print_string switch; pr_space(); mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp
| Ast.Break(br,sem) ->
- print_string arity; mcode print_string br; mcode print_string sem
+ pr_arity arity; mcode print_string br; mcode print_string sem
| Ast.Continue(cont,sem) ->
- print_string arity; mcode print_string cont; mcode print_string sem
+ pr_arity arity; mcode print_string cont; mcode print_string sem
| Ast.Label(l,dd) -> ident l; mcode print_string dd
| Ast.Goto(goto,l,sem) ->
mcode print_string goto; ident l; mcode print_string sem
| Ast.Return(ret,sem) ->
- print_string arity; mcode print_string ret;
+ pr_arity arity; mcode print_string ret;
mcode print_string sem
| Ast.ReturnExpr(ret,exp,sem) ->
- print_string arity; mcode print_string ret; print_string " ";
+ pr_arity arity; mcode print_string ret; pr_space();
expression exp; mcode print_string sem
- | Ast.Exp(exp) -> print_string arity; expression exp
- | Ast.TopExp(exp) -> print_string arity; expression exp
- | Ast.Ty(ty) -> print_string arity; fullType ty
+ | Ast.Exp(exp) -> pr_arity arity; expression exp
+ | Ast.TopExp(exp) -> pr_arity arity; expression exp
+ | Ast.Ty(ty) -> pr_arity arity; fullType ty
| Ast.TopInit(init) -> initialiser false init
| Ast.Include(inc,s) ->
- mcode print_string inc; print_string " "; mcode inc_file s
+ mcode print_string inc; print_text " "; mcode inc_file s
| Ast.DefineHeader(def,id,params) ->
- mcode print_string def; print_string " "; ident id;
+ mcode print_string def; pr_space(); ident id;
print_define_parameters params
| Ast.Default(def,colon) ->
- mcode print_string def; mcode print_string colon; print_string " "
+ mcode print_string def; mcode print_string colon; pr_space()
| Ast.Case(case,exp,colon) ->
- mcode print_string case; print_string " "; expression exp;
- mcode print_string colon; print_string " "
+ mcode print_string case; pr_space(); expression exp;
+ mcode print_string colon; pr_space()
| Ast.DisjRuleElem(res) ->
if generating
then
- (print_string arity;
- force_newline(); print_string "("; force_newline();
- print_between
- (function _ -> force_newline(); print_string "|"; force_newline())
- (rule_elem arity)
+ (pr_arity arity; print_text "\n(\n";
+ print_between (function _ -> print_text "\n|\n") (rule_elem arity)
res;
- force_newline(); print_string ")")
+ print_text "\n)")
else raise CantBeInPlus
| Ast.MetaRuleElem(name,_,_) ->
| Ast.DPComma(comma) -> mcode print_string comma
| Ast.DPdots(dots) -> mcode print_string dots
| Ast.DPcircles(circles) -> mcode print_string circles
- | Ast.OptDParam(dp) -> print_string "?"; print_define_param dp
- | Ast.UniqueDParam(dp) -> print_string "!"; print_define_param dp
+ | Ast.OptDParam(dp) -> print_text "?"; print_define_param dp
+ | Ast.UniqueDParam(dp) -> print_text "!"; print_define_param dp
and print_fninfo = function
Ast.FStorage(stg) -> mcode storage stg
| Ast.FType(ty) -> fullType ty
- | Ast.FInline(inline) -> mcode print_string inline; print_string " "
- | Ast.FAttr(attr) -> mcode print_string attr; print_string " " in
+ | Ast.FInline(inline) -> mcode print_string inline; pr_space()
+ | Ast.FAttr(attr) -> mcode print_string attr; pr_space() in
let indent_if_needed s f =
match Ast.unwrap s with
- Ast.Seq(lbrace,decls,body,rbrace) -> pr_space(); f()
+ Ast.Seq(lbrace,body,rbrace) -> pr_space(); f()
| _ ->
(*no newline at the end - someone else will do that*)
start_block(); f(); unindent() in
let rec statement arity s =
match Ast.unwrap s with
- Ast.Seq(lbrace,decls,body,rbrace) ->
+ Ast.Seq(lbrace,body,rbrace) ->
rule_elem arity lbrace;
- dots force_newline (statement arity) decls;
dots force_newline (statement arity) body;
rule_elem arity rbrace
| Ast.IfThenElse(header,branch1,els,branch2,_) ->
rule_elem arity header;
indent_if_needed branch1 (function _ -> statement arity branch1);
- print_string " ";
+ force_newline();
rule_elem arity els;
indent_if_needed branch2 (function _ -> statement arity branch2)
-
| Ast.While(header,body,_) ->
rule_elem arity header;
indent_if_needed body (function _ -> statement arity body)
| Ast.Iterator(header,body,(_,_,_,aft)) ->
rule_elem arity header;
indent_if_needed body (function _ -> statement arity body);
- mcode (function _ -> ()) ((),Ast.no_info,aft,Ast.NoMetaPos)
+ mcode (fun _ _ _ -> ()) ((),Ast.no_info,aft,Ast.NoMetaPos)
| Ast.Switch(header,lb,cases,rb) ->
- rule_elem arity header; print_string " "; rule_elem arity lb;
+ rule_elem arity header; pr_space(); rule_elem arity lb;
List.iter (function x -> case_line arity x; force_newline()) cases;
rule_elem arity rb
| Ast.Atomic(re) -> rule_elem arity re
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
rule_elem arity header; rule_elem arity lbrace;
- dots force_newline (statement arity) decls;
dots force_newline (statement arity) body; rule_elem arity rbrace
| Ast.Define(header,body) ->
- rule_elem arity header; print_string " ";
+ rule_elem arity header; pr_space();
dots force_newline (statement arity) body
| Ast.Disj([stmt_dots]) ->
if generating
then
- (print_string arity;
+ (pr_arity arity;
dots force_newline (statement arity) stmt_dots)
else raise CantBeInPlus
| Ast.Disj(stmt_dots_list) -> (* ignores newline directive for readability *)
if generating
then
- (print_string arity;
- force_newline(); print_string "("; force_newline();
- print_between
- (function _ -> force_newline();print_string "|"; force_newline())
+ (pr_arity arity; print_text "\n(\n";
+ print_between (function _ -> print_text "\n|\n")
(dots force_newline (statement arity))
stmt_dots_list;
- force_newline(); print_string ")")
+ print_text "\n)")
else raise CantBeInPlus
| Ast.Nest(stmt_dots,whn,multi,_,_) when generating ->
- print_string arity;
+ pr_arity arity;
nest_dots multi (statement arity)
(function _ ->
print_between force_newline
| Ast.Dots(d,whn,_,_) | Ast.Circles(d,whn,_,_) | Ast.Stars(d,whn,_,_) ->
if generating
then
- (print_string arity; mcode print_string d;
+ (pr_arity arity; mcode print_string d;
print_between force_newline
(whencode (dots force_newline (statement "")) (statement "")) whn;
force_newline())
and whencode notfn alwaysfn = function
Ast.WhenNot a ->
- print_string " WHEN != "; notfn a
+ print_text " WHEN != "; notfn a
| Ast.WhenAlways a ->
- print_string " WHEN = "; alwaysfn a
- | Ast.WhenModifier x -> print_string " WHEN "; print_when_modif x
+ print_text " WHEN = "; alwaysfn a
+ | Ast.WhenModifier x -> print_text " WHEN "; print_when_modif x
| Ast.WhenNotTrue a ->
- print_string " WHEN != TRUE "; rule_elem "" a
+ print_text " WHEN != TRUE "; rule_elem "" a
| Ast.WhenNotFalse a ->
- print_string " WHEN != FALSE "; rule_elem "" a
+ print_text " WHEN != FALSE "; rule_elem "" a
and print_when_modif = function
- | Ast.WhenAny -> print_string "ANY"
- | Ast.WhenStrict -> print_string "STRICT"
- | Ast.WhenForall -> print_string "FORALL"
- | Ast.WhenExists -> print_string "EXISTS"
+ | Ast.WhenAny -> print_text "ANY"
+ | Ast.WhenStrict -> print_text "STRICT"
+ | Ast.WhenForall -> print_text "FORALL"
+ | Ast.WhenExists -> print_text "EXISTS"
and case_line arity c =
match Ast.unwrap c with
Ast.CaseLine(header,code) ->
- rule_elem arity header; print_string " ";
+ rule_elem arity header; pr_space();
dots force_newline (statement arity) code
| Ast.OptCase(case) -> raise CantBeInPlus in
let rec pp_any = function
(* assert: normally there is only CONTEXT NOTHING tokens in any *)
Ast.FullTypeTag(x) -> fullType x; false
- | Ast.BaseTypeTag(x) -> baseType x; false
- | Ast.StructUnionTag(x) -> structUnion x; false
- | Ast.SignTag(x) -> sign x; false
+ | Ast.BaseTypeTag(x) -> baseType x unknown unknown; false
+ | Ast.StructUnionTag(x) -> structUnion x unknown unknown; false
+ | Ast.SignTag(x) -> sign x unknown unknown; false
| Ast.IdentTag(x) -> ident x; false
| Ast.ExpressionTag(x) -> expression x; false
- | Ast.ConstantTag(x) -> constant x; false
- | Ast.UnaryOpTag(x) -> unaryOp x; false
- | Ast.AssignOpTag(x) -> assignOp x; false
- | Ast.FixOpTag(x) -> fixOp x; false
- | Ast.BinaryOpTag(x) -> binaryOp x; false
- | Ast.ArithOpTag(x) -> arithOp x; false
- | Ast.LogicalOpTag(x) -> logicalOp x; false
+ | Ast.ConstantTag(x) -> constant x unknown unknown; false
+ | Ast.UnaryOpTag(x) -> unaryOp x unknown unknown; false
+ | Ast.AssignOpTag(x) -> assignOp x unknown unknown; false
+ | Ast.FixOpTag(x) -> fixOp x unknown unknown; false
+ | Ast.BinaryOpTag(x) -> binaryOp x unknown unknown; false
+ | Ast.ArithOpTag(x) -> arithOp x unknown unknown; false
+ | Ast.LogicalOpTag(x) -> logicalOp x unknown unknown; false
| Ast.InitTag(x) -> initialiser false x; false
| Ast.DeclarationTag(x) -> declaration x; false
- | Ast.StorageTag(x) -> storage x; false
- | Ast.IncFileTag(x) -> inc_file x; false
+ | Ast.StorageTag(x) -> storage x unknown unknown; false
+ | Ast.IncFileTag(x) -> inc_file x unknown unknown; false
| Ast.Rule_elemTag(x) -> rule_elem "" x; false
| Ast.StatementTag(x) -> statement "" x; false
| Ast.CaseLineTag(x) -> case_line "" x; false
- | Ast.ConstVolTag(x) -> const_vol x; false
- | Ast.Pragma(xs) -> print_between force_newline print_string xs; false
- | Ast.Token(x,None) -> print_string x; if_open_brace x
+ | Ast.ConstVolTag(x) -> const_vol x unknown unknown; false
+ | Ast.Pragma(xs) -> print_between force_newline print_text xs; false
+ | Ast.Token(x,None) -> print_text x; if_open_brace x
| Ast.Token(x,Some info) ->
mcode
- (function x ->
+ (fun x line lcol ->
(match x with
- "else" -> pr "\n"
+ "else" -> force_newline()
| _ -> ());
- print_string x;
- (* if x ==~ Common.regexp_alpha then print_string " "; *)
+ print_string x line lcol;
(match x with
- (*"return" |*) "else" -> print_string " "
+ "else" -> pr_space()
| _ -> ()))
(let nomcodekind = Ast.CONTEXT(Ast.DontCarePos,Ast.NOTHING) in
(x,info,nomcodekind,Ast.NoMetaPos));
normally there should be no '...' inside them *)
| Ast.ExprDotsTag(x) -> dots (function _ -> ()) expression x; false
| Ast.ParamDotsTag(x) -> parameter_list x; false
- | Ast.StmtDotsTag(x) -> dots (function _ -> pr "\n") (statement "") x; false
- | Ast.DeclDotsTag(x) -> dots (function _ -> pr "\n") declaration x; false
+ | Ast.StmtDotsTag(x) -> dots force_newline (statement "") x; false
+ | Ast.DeclDotsTag(x) -> dots force_newline declaration x; false
| Ast.TypeCTag(x) -> typeC x; false
| Ast.ParamTag(x) -> parameterTypeDef x; false
| _ -> false in
let prnl x =
(if unindent_before x then unindent());
- pr "\n" in
+ force_newline() in
let newline_before _ =
if before =*= After
then
let hd = List.hd xxs in
match hd with
- (Ast.StatementTag s::_) when isfn s -> pr "\n\n"
+ (Ast.StatementTag s::_) when isfn s ->
+ force_newline(); force_newline()
| (Ast.Pragma _::_)
| (Ast.Rule_elemTag _::_) | (Ast.StatementTag _::_)
| (Ast.InitTag _::_)
then
match List.rev(List.hd(List.rev xxs)) with
(Ast.StatementTag s::_) ->
- if isfn s then pr "\n\n" else pr "\n"
+ (if isfn s then force_newline());
+ force_newline()
| (Ast.Pragma _::_)
| (Ast.Rule_elemTag _::_) | (Ast.InitTag _::_)
- | (Ast.DeclarationTag _::_) | (Ast.Token ("{",_)::_) -> pr "\n"
+ | (Ast.DeclarationTag _::_) | (Ast.Token ("{",_)::_) ->
+ force_newline()
| _ -> () in
(* print a newline at the beginning, if needed *)
newline_before();
(if leading_newline
then
match (indent_needed,unindent_before x) with
- (true,true) -> pr "\n"
- | (true,false) -> pr "\n"; indent()
- | (false,true) -> unindent(); pr "\n"
- | (false,false) -> pr "\n");
+ (true,true) -> force_newline()
+ | (true,false) -> force_newline(); indent()
+ | (false,true) -> unindent(); force_newline()
+ | (false,false) -> force_newline());
let indent_needed =
List.fold_left (function indent_needed -> pp_any) false x in
loop true indent_needed xs in
type pos = Before | After | InPlace
val pp_list_list_any :
- Ast_c.metavars_binding *
- (string -> unit) (* pr cocci *) * Pretty_print_c.pr_elem_func (* pr c *) *
+ Ast_c.metavars_binding *
+ (* pr cocci *)
+ (string -> int (*line*) -> int (*lcol*) -> int (*rcol*) -> unit) *
+ Pretty_print_c.pr_elem_func (* pr c *) *
+ (unit -> unit) (* pr C space *) *
(unit -> unit) (* pr space *) *
+ (string -> unit) (* pr arity *) *
+ (int (*line*) -> int (*lcol*) -> unit) (* pr barrier *) *
(unit -> unit) (* indent *) * (unit -> unit) (* unindent *) ->
bool (*true if generating*) -> Ast_cocci.anything list list -> pos ->
unit
[] any_list_list in
let mcode r mc =
match Ast.get_mcodekind mc with
- Ast.MINUS(_,any_list_list) -> do_any_list_list r any_list_list
+ Ast.MINUS(_,_,_,any_list_list) -> do_any_list_list r any_list_list
| Ast.CONTEXT(_,any_befaft) ->
(match any_befaft with
Ast.BEFORE(any_list_list) | Ast.AFTER(any_list_list) ->
| _ ->
Printf.printf "line: %s\n" (Common.dump info);
error rule "not an abstract line" in
+ let pr_space _ = pr " " in
Unparse_cocci.pp_list_list_any
- (env, pr, pr_c, (function _ -> pr " "),
- (function _ -> ()), (function _ -> ()))
+ (env, (fun s _ _ _ -> pr s), pr_c, pr_space, pr_space, pr,
+ (fun _ _ -> ()), (function _ -> ()), (function _ -> ()))
true printable Unparse_cocci.InPlace;
print_end pr;
pr "\n")
* disable_go_type_annotation ?
*)
+(*****************************************************************************)
+(* Wrappers *)
+(*****************************************************************************)
+let pr2, pr2_once = Common.mk_pr2_wrappers Flag_parsing_c.verbose_visit
+
(*****************************************************************************)
(* Functions to visit the Ast, and now also the CFG nodes *)
(*****************************************************************************)
let (unwrap_st, ii) = st in
iif ii;
match unwrap_st with
- | Labeled (Label (s, st)) -> statf st;
+ | Labeled (Label (name, st)) ->
+ vk_name bigf name;
+ statf st;
| Labeled (Case (e, st)) -> vk_expr bigf e; statf st;
| Labeled (CaseRange (e, e2, st)) ->
vk_expr bigf e; vk_expr bigf e2; statf st;
vk_expr bigf e; statf st;
| Iteration (DoWhile (st, e)) -> statf st; vk_expr bigf e;
| Iteration (For ((e1opt,i1), (e2opt,i2), (e3opt,i3), st)) ->
- statf (ExprStatement (e1opt),i1);
- statf (ExprStatement (e2opt),i2);
- statf (ExprStatement (e3opt),i3);
+ statf (mk_st (ExprStatement (e1opt)) i1);
+ statf (mk_st (ExprStatement (e2opt)) i2);
+ statf (mk_st (ExprStatement (e3opt)) i3);
statf st;
| Iteration (MacroIteration (s, es, st)) ->
let f = bigf.kfield in
let rec k field =
- let (xfield, ii) = field in
- iif ii;
- match xfield with
+ match field with
| DeclarationField
(FieldDeclList (onefield_multivars, iiptvirg)) ->
vk_struct_fieldkinds bigf onefield_multivars;
iif iiptvirg;
- | EmptyField -> ()
- | MacroStructDeclTodo ->
- pr2_once "MacroStructDeclTodo";
- ()
+ | EmptyField info -> iif [info]
+ | MacroDeclField ((s, args),ii) ->
+ iif ii;
+ vk_argument_list bigf args;
| CppDirectiveStruct directive ->
vk_cpp_directive bigf directive
let f = bigf.kdef in
let rec k d =
match d with
- | {f_name = s;
+ | {f_name = name;
f_type = (returnt, (paramst, (b, iib)));
f_storage = sto;
f_body = statxs;
iif iib;
attrs +> List.iter (vk_attribute bigf);
vk_type bigf returnt;
+ vk_name bigf name;
paramst +> List.iter (fun (param,iicomma) ->
vk_param bigf param;
iif iicomma;
let (unwrap_st, ii) = st in
let st' =
match unwrap_st with
- | Labeled (Label (s, st)) ->
- Labeled (Label (s, statf st))
+ | Labeled (Label (name, st)) ->
+ Labeled (Label (vk_name_s bigf name, statf st))
| Labeled (Case (e, st)) ->
Labeled (Case ((vk_expr_s bigf) e , statf st))
| Labeled (CaseRange (e, e2, st)) ->
| Iteration (DoWhile (st, e)) ->
Iteration (DoWhile (statf st, (vk_expr_s bigf) e))
| Iteration (For ((e1opt,i1), (e2opt,i2), (e3opt,i3), st)) ->
- let e1opt' = statf (ExprStatement (e1opt),i1) in
- let e2opt' = statf (ExprStatement (e2opt),i2) in
- let e3opt' = statf (ExprStatement (e3opt),i3) in
- (match (e1opt', e2opt', e3opt') with
- | ((ExprStatement x1,i1), (ExprStatement x2,i2), ((ExprStatement x3,i3))) ->
- Iteration (For ((x1,i1), (x2,i2), (x3,i3), statf st))
+ let e1opt' = statf (mk_st (ExprStatement (e1opt)) i1) in
+ let e2opt' = statf (mk_st (ExprStatement (e2opt)) i2) in
+ let e3opt' = statf (mk_st (ExprStatement (e3opt)) i3) in
+
+ let e1' = Ast_c.unwrap_st e1opt' in
+ let e2' = Ast_c.unwrap_st e2opt' in
+ let e3' = Ast_c.unwrap_st e3opt' in
+ let i1' = Ast_c.get_ii_st_take_care e1opt' in
+ let i2' = Ast_c.get_ii_st_take_care e2opt' in
+ let i3' = Ast_c.get_ii_st_take_care e3opt' in
+
+ (match (e1', e2', e3') with
+ | ((ExprStatement x1), (ExprStatement x2), ((ExprStatement x3))) ->
+ Iteration (For ((x1,i1'), (x2,i2'), (x3,i3'), statf st))
+
| x -> failwith "cant be here if iterator keep ExprStatement as is"
)
let iif ii = vk_ii_s bigf ii in
- fields +> List.map (fun (xfield, iiptvirg) ->
-
- (match xfield with
+ fields +> List.map (fun (field) ->
+ (match field with
| (DeclarationField (FieldDeclList (onefield_multivars, iiptvirg))) ->
DeclarationField
(FieldDeclList
(vk_struct_fieldkinds_s bigf onefield_multivars, iif iiptvirg))
- | EmptyField -> EmptyField
- | MacroStructDeclTodo ->
- pr2_once "MacroStructDeclTodo";
- MacroStructDeclTodo
+ | EmptyField info -> EmptyField (vk_info_s bigf info)
+ | MacroDeclField ((s, args),ii) ->
+ MacroDeclField
+ ((s,
+ args +> List.map (fun (e,ii) -> vk_argument_s bigf e, iif ii)
+ ),
+ iif ii)
| CppDirectiveStruct directive ->
CppDirectiveStruct (vk_cpp_directive_s bigf directive)
| IfdefStruct ifdef ->
IfdefStruct (vk_ifdef_directive_s bigf ifdef)
- ), iif iiptvirg
+ )
)
let iif ii = vk_ii_s bigf ii in
let rec k d =
match d with
- | {f_name = s;
+ | {f_name = name;
f_type = (returnt, (paramst, (b, iib)));
f_storage = sto;
f_body = statxs;
f_old_c_style = oldstyle;
}, ii
->
- {f_name = s;
+ {f_name = vk_name_s bigf name;
f_type =
(vk_type_s bigf returnt,
(paramst +> List.map (fun (param, iicomma) ->
+adjacency.cmi: ast0_cocci.cmi
adjust_pragmas.cmi: ast0_cocci.cmi
arity.cmi: ast0_cocci.cmi
ast0_cocci.cmi: type_cocci.cmi ast_cocci.cmi
unparse_ast0.cmi: ast0_cocci.cmi
visitor_ast.cmi: ast_cocci.cmi
visitor_ast0.cmi: visitor_ast0_types.cmo ast_cocci.cmi ast0_cocci.cmi
+adjacency.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ast0_cocci.cmi \
+ adjacency.cmi
+adjacency.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ast0_cocci.cmx \
+ adjacency.cmi
adjust_pragmas.cmo: visitor_ast0_types.cmo visitor_ast0.cmi ast0_cocci.cmi \
adjust_pragmas.cmi
adjust_pragmas.cmx: visitor_ast0_types.cmx visitor_ast0.cmx ast0_cocci.cmx \
../globals/flag.cmo disjdistr.cmi data.cmi context_neg.cmi \
compute_lines.cmi ../commons/common.cmi comm_assoc.cmi check_meta.cmi \
ast_cocci.cmi ast0toast.cmi ast0_cocci.cmi arity.cmi adjust_pragmas.cmi \
- parse_cocci.cmi
+ adjacency.cmi parse_cocci.cmi
parse_cocci.cmx: visitor_ast0_types.cmx visitor_ast0.cmx unitary_ast0.cmx \
type_infer.cmx test_exps.cmx single_statement.cmx simple_assignments.cmx \
semantic_cocci.cmx pretty_print_cocci.cmx parse_aux.cmx iso_pattern.cmx \
../globals/flag.cmx disjdistr.cmx data.cmx context_neg.cmx \
compute_lines.cmx ../commons/common.cmx comm_assoc.cmx check_meta.cmx \
ast_cocci.cmx ast0toast.cmx ast0_cocci.cmx arity.cmx adjust_pragmas.cmx \
- parse_cocci.cmi
+ adjacency.cmx parse_cocci.cmi
plus.cmo: visitor_ast.cmi ast_cocci.cmi plus.cmi
plus.cmx: visitor_ast.cmx ast_cocci.cmx plus.cmi
pretty_print_cocci.cmo: type_cocci.cmi ../globals/flag.cmo \
unify_ast.ml semantic_cocci.ml data.ml free_vars.ml parse_aux.ml disjdistr.ml \
$(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \
$(SCRIPT_LEXER_SOURCES:.mll=.ml) \
-get_constants.ml get_constants2.ml parse_cocci.ml
+get_constants.ml get_constants2.ml adjacency.ml parse_cocci.ml
LIBS=../commons/commons.cma ../globals/globals.cma
SYSLIBS = str.cma unix.cma
$(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES)
$(OCAMLLEX) $(SCRIPT_LEXER_SOURCES)
-clean::
+distclean::
rm -f $(GENERATED)
# clean rule for others files
--- /dev/null
+module Ast0 = Ast0_cocci
+module V0 = Visitor_ast0
+module VT0 = Visitor_ast0_types
+
+let compute_adjacency p =
+ let counter = ref 0 in
+ let mcode (a,b,c,d,e,_) = (a,b,c,d,e,!counter) in
+ let string_mcode ((str,_,info,mc,_,_) as x) =
+ match str with
+ "..." | "<..." | "...>" | "<+..." | "...+>" ->
+ (match mc with
+ Ast0.MINUS _ -> mcode x
+ | Ast0.CONTEXT _ -> counter := !counter + 1; x
+ | _ -> failwith "unexpected mcode for ...")
+ | _ -> mcode x in
+ let fn =
+ V0.rebuilder
+ {V0.rebuilder_functions with
+ VT0.rebuilder_meta_mcode = mcode;
+ VT0.rebuilder_string_mcode = string_mcode;
+ VT0.rebuilder_const_mcode = mcode;
+ VT0.rebuilder_assign_mcode = mcode;
+ VT0.rebuilder_fix_mcode = mcode;
+ VT0.rebuilder_unary_mcode = mcode;
+ VT0.rebuilder_binary_mcode = mcode;
+ VT0.rebuilder_cv_mcode = mcode;
+ VT0.rebuilder_sign_mcode = mcode;
+ VT0.rebuilder_struct_mcode = mcode;
+ VT0.rebuilder_storage_mcode = mcode;
+ VT0.rebuilder_inc_mcode = mcode;} in
+ List.map fn.VT0.rebuilder_rec_top_level p
+
--- /dev/null
+val compute_adjacency : Ast0_cocci.rule -> Ast0_cocci.rule
None -> None
| Some(pragmas,data) -> Some (pragmas,Ast0.rewrap s (cont data))
-let left_mcode (a,b,info,mcodekind,d) =
+let left_mcode (a,b,info,mcodekind,d,e) =
match (info.Ast0.strings_before,mcodekind) with
([],_) | (_,Ast0.PLUS) -> None
- | (l,_) -> Some(l,(a,b,{info with Ast0.strings_before = []},mcodekind,d))
+ | (l,_) -> Some(l,(a,b,{info with Ast0.strings_before = []},mcodekind,d,e))
-let right_mcode (a,b,info,mcodekind,d) =
+let right_mcode (a,b,info,mcodekind,d,e) =
match (info.Ast0.strings_after,mcodekind) with
([],_) | (_,Ast0.PLUS) -> None
- | (l,_) -> Some(l,(a,b,{info with Ast0.strings_after = []},mcodekind,d))
+ | (l,_) -> Some(l,(a,b,{info with Ast0.strings_after = []},mcodekind,d,e))
let update_before pragmas (info,x) =
({info with Ast0.strings_before = pragmas @ info.Ast0.strings_before},
(* --------------------------------------------------------------------- *)
(* Mcode *)
-let mcode2line (_,_,info,_,_) = info.Ast0.pos_info.Ast0.line_start
-let mcode2arity (_,arity,_,_,_) = arity
+let mcode2line (_,_,info,_,_,_) = info.Ast0.pos_info.Ast0.line_start
+let mcode2arity (_,arity,_,_,_,_) = arity
let mcode x = x (* nothing to do ... *)
strings_before : (string * position_info) list;
strings_after : (string * position_info) list }
-type 'a mcode = 'a * arity * info * mcodekind * meta_pos ref (* pos, - only *)
+(* adjacency index is incremented when we skip over dots or nest delimiters
+it is used in deciding how much to remove, when two adjacent code tokens are
+removed. *)
+type 'a mcode =
+ 'a * arity * info * mcodekind * meta_pos ref (* pos, - only *) *
+ int (* adjacency_index *)
(* int ref is an index *)
and 'a wrap =
{ node : 'a;
true_if_test_exp = false;
iso_info = [] }
let unwrap x = x.node
-let unwrap_mcode (x,_,_,_,_) = x
+let unwrap_mcode (x,_,_,_,_,_) = x
let rewrap model x = { model with node = x }
-let rewrap_mcode (_,arity,info,mcodekind,pos) x = (x,arity,info,mcodekind,pos)
+let rewrap_mcode (_,arity,info,mcodekind,pos,adj) x =
+ (x,arity,info,mcodekind,pos,adj)
let copywrap model x =
{ model with node = x; index = ref !(model.index);
mcodekind = ref !(model.mcodekind); exp_ty = ref !(model.exp_ty)}
-let get_pos (_,_,_,_,x) = !x
-let get_pos_ref (_,_,_,_,x) = x
-let set_pos pos (m,arity,info,mcodekind,_) = (m,arity,info,mcodekind,ref pos)
+let get_pos (_,_,_,_,x,_) = !x
+let get_pos_ref (_,_,_,_,x,_) = x
+let set_pos pos (m,arity,info,mcodekind,_,adj) =
+ (m,arity,info,mcodekind,ref pos,adj)
let get_info x = x.info
let set_info x info = {x with info = info}
let get_line x = x.info.pos_info.line_start
let get_index x = !(x.index)
let set_index x i = x.index := i
let get_mcodekind x = !(x.mcodekind)
-let get_mcode_mcodekind (_,_,_,mcodekind,_) = mcodekind
+let get_mcode_mcodekind (_,_,_,mcodekind,_,_) = mcodekind
let get_mcodekind_ref x = x.mcodekind
let set_mcodekind x mk = x.mcodekind := mk
let set_type x t = x.exp_ty := t
let set_test_exp x = {x with true_if_test_exp = true}
let get_iso x = x.iso_info
let set_iso x i = if !Flag.track_iso_usage then {x with iso_info = i} else x
-let set_mcode_data data (_,ar,info,mc,pos) = (data,ar,info,mc,pos)
+let set_mcode_data data (_,ar,info,mc,pos,adj) = (data,ar,info,mc,pos,adj)
(* --------------------------------------------------------------------- *)
(* this function is a rather minimal attempt. the problem is that information
has been lost. but since it is only used for metavariable types in the isos,
perhaps it doesn't matter *)
-and make_mcode x = (x,NONE,default_info(),context_befaft(),ref NoMetaPos)
-let make_mcode_info x info = (x,NONE,info,context_befaft(),ref NoMetaPos)
+and make_mcode x = (x,NONE,default_info(),context_befaft(),ref NoMetaPos,-1)
+let make_mcode_info x info = (x,NONE,info,context_befaft(),ref NoMetaPos,-1)
exception TyConv
strings_before : (string * position_info) list;
strings_after : (string * position_info) list }
-type 'a mcode = 'a * arity * info * mcodekind * meta_pos ref (* pos, - only *)
+type 'a mcode =
+ 'a * arity * info * mcodekind * meta_pos ref (* pos, - only *) *
+ int (* adjacency_index *)
+
and 'a wrap =
{ node : 'a;
info : info;
let donothing r k e = k e in
let bind x y = x && y in
let option_default = true in
- let mcode (_,_,_,mc,_) =
+ let mcode (_,_,_,mc,_,_) =
match mc with
Ast0.MINUS(r) -> let (plusses,_) = !r in plusses = []
| _ -> false in
{ Ast.line = info.Ast0.pos_info.Ast0.line_start;
Ast.column = info.Ast0.pos_info.Ast0.column;
Ast.strbef = strings_to_s info.Ast0.strings_before;
- Ast.straft = strings_to_s info.Ast0.strings_after; }
+ Ast.straft = strings_to_s info.Ast0.strings_after;}
-let convert_mcodekind = function
+let convert_mcodekind adj = function
Ast0.MINUS(replacements) ->
let (replacements,_) = !replacements in
- Ast.MINUS(Ast.NoPos,replacements)
+ Ast.MINUS(Ast.NoPos,[],adj,replacements)
| Ast0.PLUS -> Ast.PLUS
| Ast0.CONTEXT(befaft) ->
let (befaft,_,_) = !befaft in Ast.CONTEXT(Ast.NoPos,befaft)
| Ast0.MIXED(_) -> failwith "not possible for mcode"
-let pos_mcode(term,_,info,mcodekind,pos) =
+let pos_mcode(term,_,info,mcodekind,pos,adj) =
(* avoids a recursion problem *)
- (term,convert_info info,convert_mcodekind mcodekind,Ast.NoMetaPos)
+ (term,convert_info info,convert_mcodekind adj mcodekind,Ast.NoMetaPos)
-let mcode(term,_,info,mcodekind,pos) =
+let mcode (term,_,info,mcodekind,pos,adj) =
let pos =
match !pos with
Ast0.MetaPos(pos,constraints,per) ->
Ast.MetaPos(pos_mcode pos,constraints,per,unitary,false)
| _ -> Ast.NoMetaPos in
- (term,convert_info info,convert_mcodekind mcodekind,pos)
+ (term,convert_info info,convert_mcodekind adj mcodekind,pos)
(* --------------------------------------------------------------------- *)
(* Dots *)
(match Ast0.unwrap s with
Ast0.Decl((_,bef),decl) ->
Ast.Atomic(rewrap_rule_elem s
- (Ast.Decl(convert_mcodekind bef,
+ (Ast.Decl(convert_mcodekind (-1) bef,
check_allminus.VT0.combiner_rec_statement s,
declaration decl)))
| Ast0.Seq(lbrace,body,rbrace) ->
let lbrace = mcode lbrace in
- let (decls,body) = separate_decls seqible body in
+ let body = dots (statement seqible) body in
let rbrace = mcode rbrace in
Ast.Seq(iso_tokenwrap lbrace s (Ast.SeqStart(lbrace))
(do_isos (Ast0.get_iso s)),
- decls,body,
+ body,
tokenwrap rbrace s (Ast.SeqEnd(rbrace)))
| Ast0.ExprStatement(exp,sem) ->
Ast.Atomic(rewrap_rule_elem s
(rewrap_rule_elem s
(Ast.IfHeader(mcode iff,mcode lp,expression exp,mcode rp)),
statement Ast.NotSequencible branch,
- ([],[],[],convert_mcodekind aft))
+ ([],[],[],convert_mcodekind (-1) aft))
| Ast0.IfThenElse(iff,lp,exp,rp,branch1,els,branch2,(_,aft)) ->
let els = mcode els in
Ast.IfThenElse
statement Ast.NotSequencible branch1,
tokenwrap els s (Ast.Else(els)),
statement Ast.NotSequencible branch2,
- ([],[],[],convert_mcodekind aft))
+ ([],[],[],convert_mcodekind (-1) aft))
| Ast0.While(wh,lp,exp,rp,body,(_,aft)) ->
Ast.While(rewrap_rule_elem s
(Ast.WhileHeader
(mcode wh,mcode lp,expression exp,mcode rp)),
statement Ast.NotSequencible body,
- ([],[],[],convert_mcodekind aft))
+ ([],[],[],convert_mcodekind (-1) aft))
| Ast0.Do(d,body,wh,lp,exp,rp,sem) ->
let wh = mcode wh in
Ast.Do(rewrap_rule_elem s (Ast.DoHeader(mcode d)),
let body = statement Ast.NotSequencible body in
Ast.For(rewrap_rule_elem s
(Ast.ForHeader(fr,lp,exp1,sem1,exp2,sem2,exp3,rp)),
- body,([],[],[],convert_mcodekind aft))
+ body,([],[],[],convert_mcodekind (-1) aft))
| Ast0.Iterator(nm,lp,args,rp,body,(_,aft)) ->
Ast.Iterator(rewrap_rule_elem s
(Ast.IteratorHeader
dots expression args,
mcode rp)),
statement Ast.NotSequencible body,
- ([],[],[],convert_mcodekind aft))
+ ([],[],[],convert_mcodekind (-1) aft))
| Ast0.Switch(switch,lp,exp,rp,lb,cases,rb) ->
let switch = mcode switch in
let lp = mcode lp in
let params = parameter_list params in
let rp = mcode rp in
let lbrace = mcode lbrace in
- let (decls,body) = separate_decls seqible body in
+ let body = dots (statement seqible) body in
let rbrace = mcode rbrace in
let allminus = check_allminus.VT0.combiner_rec_statement s in
Ast.FunDecl(rewrap_rule_elem s
- (Ast.FunHeader(convert_mcodekind bef,
+ (Ast.FunHeader(convert_mcodekind (-1) bef,
allminus,fi,name,lp,params,rp)),
tokenwrap lbrace s (Ast.SeqStart(lbrace)),
- decls,body,
+ body,
tokenwrap rbrace s (Ast.SeqEnd(rbrace)))
| Ast0.Include(inc,str) ->
Ast.Atomic(rewrap_rule_elem s (Ast.Include(mcode inc,mcode str)))
| Ast0.CIRCLES(x) -> Ast.CIRCLES(process_list seqible isos x)
| Ast0.STARS(x) -> Ast.STARS(process_list seqible isos x))
+ (* the following is no longer used.
+ the goal was to let one put a statement at the very beginning of a function
+ pattern and have it skip over the declarations in the C code.
+ that feature was removed a long time ago, however, in favor of
+ ... when != S, which also causes whatever comes after it to match the
+ first real statement.
+ the separation of declarations from the rest of the body means that the
+ quantifier of any variable shared between them comes out too high, posing
+ problems when there is ... decl ... stmt, as the quantifier of any shared
+ variable will be around the whole thing, making variables not free enough
+ in the first ..., and thus not implementing the expected shortest path
+ condition. example: f() { ... int A; ... foo(A); }.
+ the quantifier for A should start just before int A, not at the top of the
+ function.
and separate_decls seqible d =
let rec collect_decls = function
[] -> ([],[])
match Ast0.unwrap d with
Ast0.DOTS(x) -> process x d (function x -> Ast.DOTS x)
| Ast0.CIRCLES(x) -> process x d (function x -> Ast.CIRCLES x)
- | Ast0.STARS(x) -> process x d (function x -> Ast.STARS x) in
+ | Ast0.STARS(x) -> process x d (function x -> Ast.STARS x) *) in
statement Ast.Sequencible s
and 'a mcode = 'a * info * mcodekind * meta_pos (* pos variable *)
(* pos is an offset indicating where in the C code the mcodekind has an
effect *)
+(* int list is the match instances, which are only meaningful in annotated
+C code *)
+(* int is the adjacency index, which is incremented on context dots *)
and mcodekind =
- MINUS of pos * anything list list
+ MINUS of pos * int list * int * anything list list
| CONTEXT of pos * anything befaft
| PLUS
and fixpos =
and rule_elem = base_rule_elem wrap
and base_statement =
- Seq of rule_elem (* { *) * statement dots *
+ Seq of rule_elem (* { *) *
statement dots * rule_elem (* } *)
| IfThen of rule_elem (* header *) * statement * end_info (* endif *)
| IfThenElse of rule_elem (* header *) * statement *
(statement dots,statement) whencode list * multi *
dots_whencode list * dots_whencode list
| FunDecl of rule_elem (* header *) * rule_elem (* { *) *
- statement dots * statement dots * rule_elem (* } *)
+ statement dots * rule_elem (* } *)
| Define of rule_elem (* header *) * statement dots
| Dots of string mcode (* ... *) *
(statement dots,statement) whencode list *
let get_mcodekind (_,_,x,_) = x
let get_line x = x.node_line
let get_mcode_line (_,l,_,_) = l.line
+let get_mcode_col (_,l,_,_) = l.column
let get_fvs x = x.free_vars
let set_fvs fvs x = {x with free_vars = fvs}
let get_mfvs x = x.minus_free_vars
(* --------------------------------------------------------------------- *)
-let no_info = { line = 0; column = 0; strbef = []; straft = [] }
+let no_info = { line = 0; column = -1; strbef = []; straft = [] }
let make_term x =
{node = x;
(* pos is an offset indicating where in the C code the mcodekind has an
effect *)
and mcodekind =
- MINUS of pos * anything list list
+ MINUS of pos * int list * int * anything list list
| CONTEXT of pos * anything befaft
| PLUS
and fixpos =
and rule_elem = base_rule_elem wrap
and base_statement =
- Seq of rule_elem (* { *) * statement dots *
+ Seq of rule_elem (* { *) *
statement dots * rule_elem (* } *)
| IfThen of rule_elem (* header *) * statement * end_info
| IfThenElse of rule_elem (* header *) * statement *
(statement dots,statement) whencode list * multi *
dots_whencode list * dots_whencode list
| FunDecl of rule_elem (* header *) * rule_elem (* { *) *
- statement dots * statement dots * rule_elem (* } *)
+ statement dots * rule_elem (* } *)
| Define of rule_elem (* header *) * statement dots
| Dots of string mcode (* ... *) *
(statement dots,statement) whencode list *
val get_mcodekind : 'a mcode -> mcodekind
val get_line : 'a wrap -> line
val get_mcode_line : 'a mcode -> line
+val get_mcode_col : 'a mcode -> int
val get_fvs : 'a wrap -> meta_name list
val get_wcfvs : ('a wrap,'b wrap) whencode list -> meta_name list
val set_fvs : meta_name list -> 'a wrap -> 'a wrap
let warning s = Printf.fprintf stderr "warning: %s\n" s
-let promote name = (name,(),Ast0.default_info(),(),None)
+let promote name = (name,(),Ast0.default_info(),(),None,-1)
(* --------------------------------------------------------------------- *)
| x::xs -> (try Hashtbl.find x name with Not_found -> loop xs) in
loop table
-let check_table table minus (name,_,info,_,_) =
+let check_table table minus (name,_,info,_,_,_) =
let rl = info.Ast0.pos_info.Ast0.line_start in
if minus
then
let ident context old_metas table minus i =
match Ast0.unwrap i with
- Ast0.Id((name,_,info,_,_) : string Ast0.mcode) ->
+ Ast0.Id((name,_,info,_,_,_) : string Ast0.mcode) ->
let rl = info.Ast0.pos_info.Ast0.line_start in
let err =
if List.exists (function x -> x = name) old_metas
Ast0.logical_start = lstart.Ast0.pos_info.Ast0.logical_start;
Ast0.logical_end = lend.Ast0.pos_info.Ast0.logical_end;
Ast0.column = lstart.Ast0.pos_info.Ast0.column;
- Ast0.offset = lstart.Ast0.pos_info.Ast0.offset; } in
+ Ast0.offset = lstart.Ast0.pos_info.Ast0.offset;} in
let info =
{ Ast0.pos_info = pos_info;
Ast0.attachable_start = lstart.Ast0.attachable_start;
(* --------------------------------------------------------------------- *)
(* Mcode *)
-let promote_mcode (_,_,info,mcodekind,_) =
+let promote_mcode (_,_,info,mcodekind,_,_) =
let new_info =
{info with
Ast0.mcode_start = [mcodekind]; Ast0.mcode_end = [mcodekind]} in
{(Ast0.wrap ()) with Ast0.info = new_info; Ast0.mcodekind = ref mcodekind}
-let promote_mcode_plus_one (_,_,info,mcodekind,_) =
+let promote_mcode_plus_one (_,_,info,mcodekind,_,_) =
let new_pos_info =
{info.Ast0.pos_info with
Ast0.line_start = info.Ast0.pos_info.Ast0.line_start + 1;
{(Ast0.wrap ()) with Ast0.info = new_info; Ast0.mcodekind = ref mcodekind}
(* mcode is good by default *)
-let bad_mcode (t,a,info,mcodekind,pos) =
+let bad_mcode (t,a,info,mcodekind,pos,adj) =
let new_info =
{info with Ast0.attachable_start = false; Ast0.attachable_end = false} in
- (t,a,new_info,mcodekind,pos)
+ (t,a,new_info,mcodekind,pos,adj)
let get_all_start_info l =
(List.for_all (function x -> (Ast0.get_info x).Ast0.attachable_start) l,
let bind x y = () in
let option_default = () in
let donothing r k e = k e in
- let mcode (_,_,info,mcodekind,_) =
+ let mcode (_,_,info,mcodekind,_,_) =
match mcodekind with
Ast0.PLUS -> insert info.Ast0.pos_info.Ast0.line_start
| _ -> () in
let option_default = (*Bind(Neutral,[],[],[],[],[])*)
Recursor(Neutral,[],[],[])
-let mcode (_,_,info,mcodekind,pos) =
+let mcode (_,_,info,mcodekind,pos,_) =
let offset = info.Ast0.pos_info.Ast0.offset in
match mcodekind with
Ast0.MINUS(_) -> Token(AllMarked,offset,mcodekind,[])
| Ast0.CONTEXT(_) -> Token(NotAllMarked,offset,mcodekind,[offset])
| _ -> failwith "not possible"
-let neutral_mcode (_,_,info,mcodekind,pos) =
+let neutral_mcode (_,_,info,mcodekind,pos,_) =
let offset = info.Ast0.pos_info.Ast0.offset in
match mcodekind with
Ast0.MINUS(_) -> Token(Neutral,offset,mcodekind,[])
(* neutral for context; used for mcode in bef aft nodes that don't represent
anything if they don't contain some information *)
-let nc_mcode (_,_,info,mcodekind,pos) =
+let nc_mcode (_,_,info,mcodekind,pos,_) =
let offset = info.Ast0.pos_info.Ast0.offset in
match mcodekind with
Ast0.MINUS(_) -> Token(AllMarked,offset,mcodekind,[])
(* cases for everything with extra mcode *)
| Ast0.FunDecl((info,bef),_,_,_,_,_,_,_,_)
| Ast0.Decl((info,bef),_) ->
- bind (nc_mcode ((),(),info,bef,())) (k s)
+ bind (nc_mcode ((),(),info,bef,(),-1)) (k s)
| Ast0.IfThen(_,_,_,_,_,(info,aft))
| Ast0.IfThenElse(_,_,_,_,_,_,_,(info,aft))
| Ast0.Iterator(_,_,_,_,_,(info,aft))
| Ast0.While(_,_,_,_,_,(info,aft))
| Ast0.For(_,_,_,_,_,_,_,_,_,(info,aft)) ->
- bind (k s) (nc_mcode ((),(),info,aft,()))
+ bind (k s) (nc_mcode ((),(),info,aft,(),-1))
| _ -> k s
) in
(* this is just a sanity check - really only need to look at the top-level
structure *)
-let equal_mcode (_,_,info1,_,_) (_,_,info2,_,_) =
+let equal_mcode (_,_,info1,_,_,_) (_,_,info2,_,_,_) =
info1.Ast0.pos_info.Ast0.offset = info2.Ast0.pos_info.Ast0.offset
let equal_option e1 e2 =
(List.map (function l -> List.fold_left (@) [] (List.map astfvs l))
anythings) in
match mck with
- Ast.MINUS(_,anythings) -> process_anything_list_list anythings
+ Ast.MINUS(_,_,_,anythings) -> process_anything_list_list anythings
| Ast.CONTEXT(_,befaft) ->
(match befaft with
Ast.BEFORE(ll) -> process_anything_list_list ll
(* --------------------------------------------------------------------- *)
(* collect all of the functions *)
-let brace_to_semi (_,arity,info,mcodekind,pos) =
- (";",Ast0.NONE,info,mcodekind,pos)
+let brace_to_semi (_,arity,info,mcodekind,pos,adj) =
+ let info =
+ (* drop column information, so that with -smpl_spacing the semicolon
+ will come out right after the close parenthesis *)
+ {info with Ast0.pos_info = {info.Ast0.pos_info with Ast0.column = -1}} in
+ (";",Ast0.NONE,info,mcodekind,pos,adj)
let collect_function (stm : Ast0.statement) =
match Ast0.unwrap stm with
and strip =
let donothing r k e =
{(Ast0.wrap (Ast0.unwrap (k e))) with Ast0.mcodekind = ref Ast0.PLUS} in
- let mcode (mc,_,_,_,_) =
- (mc,Ast0.NONE,Ast0.default_info(),Ast0.PLUS,ref Ast0.NoMetaPos) in
+ let mcode (mc,_,_,_,_,_) =
+ (mc,Ast0.NONE,Ast0.default_info(),Ast0.PLUS,ref Ast0.NoMetaPos,-1) in
(* need a case for everything that has an unvisited component and can be in
a function prototype *)
match Ast0.unwrap param with
Ast0.Param(ty,Some id) when all ->
(match Ast0.unwrap id with
- Ast0.MetaId(((_,name),arity,info,mcodekind,pos),constraints,pure) ->
+ Ast0.MetaId
+ (((_,name),arity,info,mcodekind,pos,adj),constraints,pure) ->
let nm = ("__no_name__",new_name name) in
let new_id =
Ast0.rewrap id
(Ast0.MetaId
- ((nm,arity,info,mcodekind,pos),constraints,Ast0.Pure)) in
+ ((nm,arity,info,mcodekind,pos,adj),constraints,Ast0.Pure)) in
([Ast.MetaIdDecl(Ast.NONE,nm)],
Ast0.rewrap param (Ast0.Param(ty,Some new_id)))
| _ -> ([],param))
Ast0.get_mcode_mcodekind lp in
let pdots =
("...",Ast0.NONE,info,mcodekind,
- ref Ast0.NoMetaPos) in
+ ref Ast0.NoMetaPos,-1) in
Ast0.DOTS
([Ast0.rewrap params
(Ast0.Pdots(pdots))])),
if !Flag.sgrep_mode2
then
match ty with
- (_,_,Ast.MINUS(_,_),_) -> [Ast.unwrap_mcode ty]
+ (_,_,Ast.MINUS(_,_,_,_),_) -> [Ast.unwrap_mcode ty]
| _ -> []
else [Ast.unwrap_mcode ty]
| _ -> k e in
let option_default = [] in
let mcode r (x,_,mcodekind,_) =
match mcodekind with
- Ast.MINUS(_,_) -> [x]
+ Ast.MINUS(_,_,_,_) -> [x]
| _ -> [] in
let other r (x,_,mcodekind,_) = [] in
bind (fn.V.combiner_anything cur) prev))
[] l in
match mcodekind with
- Ast.MINUS(_,anythings) -> recurse anythings
+ Ast.MINUS(_,_,_,anythings) -> recurse anythings
| Ast.CONTEXT(_,Ast.BEFORE(a)) -> recurse a
| Ast.CONTEXT(_,Ast.AFTER(a)) -> recurse a
| Ast.CONTEXT(_,Ast.BEFOREAFTER(a1,a2)) ->
let option_default = [] in
let mcode r (x,_,mcodekind,_) =
match mcodekind with
- Ast.MINUS(_,_) -> [x]
+ Ast.MINUS(_,_,_,_) -> [x]
| _ when minus_only -> []
| _ -> [x] in
let other r _ = [] in
bind ((get_all_constants false).V.combiner_anything cur) prev))
[] l in
match mcodekind with
- Ast.MINUS(_,anythings) -> recurse anythings
+ Ast.MINUS(_,_,_,anythings) -> recurse anythings
| Ast.CONTEXT(_,Ast.BEFORE(a)) -> recurse a
| Ast.CONTEXT(_,Ast.AFTER(a)) -> recurse a
| Ast.CONTEXT(_,Ast.BEFOREAFTER(a1,a2)) ->
let bind x y = x @ y in
let option_default = [] in
- let mcode (_,_,info,mcodekind,_) =
+ let mcode (_,_,info,mcodekind,_,_) =
if List.mem (info.Ast0.pos_info.Ast0.offset) unfavored_tokens
then [(Unfavored,info,mcodekind)]
else [(Favored,info,mcodekind)] in
let aft = extract info.Ast0.strings_after in
(bef,aft) in
- let mcode fn (term,_,info,mcodekind,_) =
+ let mcode fn (term,_,info,mcodekind,_,_) =
match mcodekind with
Ast0.PLUS -> [(info,fn term)]
| Ast0.CONTEXT _ -> let (bef,aft) = extract_strings info in bef@aft
| _ -> [] in
- let imcode fn (term,_,info,mcodekind,_) =
+ let imcode fn (term,_,info,mcodekind,_,_) =
match mcodekind with
Ast0.PLUS -> [(info,fn term (Ast0toast.convert_info info))]
| Ast0.CONTEXT _ -> let (bef,aft) = extract_strings info in bef@aft
let bind = (@) in
let option_default = [] in
- let mcode (_,_,_,mc,_) =
+ let mcode (_,_,_,mc,_,_) =
match mc with
Ast0.CONTEXT(mc) -> let (ba,_,_) = !mc in [ba]
| _ -> [] in
Ast_cocci.metavar list * Ast0_cocci.anything list list * string (* name *)
let strip_info =
- let mcode (term,_,_,_,_) =
- (term,Ast0.NONE,Ast0.default_info(),Ast0.PLUS,ref Ast0.NoMetaPos) in
+ let mcode (term,_,_,_,_,_) =
+ (term,Ast0.NONE,Ast0.default_info(),Ast0.PLUS,ref Ast0.NoMetaPos,-1) in
let donothing r k e =
let x = k e in
{(Ast0.wrap (Ast0.unwrap x)) with
failwith "only for isos within iso phase"
| _ -> false
-let term (var1,_,_,_,_) = var1
-let dot_term (var1,_,info,_,_) =
+let term (var1,_,_,_,_,_) = var1
+let dot_term (var1,_,info,_,_,_) =
("", var1 ^ (string_of_int info.Ast0.pos_info.Ast0.offset))
| [x] -> x
| x::xs -> conjunct_bindings x (conjunct_many_bindings xs)
-let mcode_equal (x,_,_,_,_) (y,_,_,_,_) = x = y
+let mcode_equal (x,_,_,_,_,_) (y,_,_,_,_,_) = x = y
let return b binding = if b then OK binding else Fail NonMatch
let return_false reason binding = Fail reason
(* make an entire tree MINUS *)
let make_minus =
- let mcode (term,arity,info,mcodekind,pos) =
+ let mcode (term,arity,info,mcodekind,pos,adj) =
let new_mcodekind =
match mcodekind with
Ast0.CONTEXT(mc) ->
| _ -> failwith "make_minus: unexpected befaft")
| Ast0.MINUS(mc) -> mcodekind (* in the part copied from the src term *)
| _ -> failwith "make_minus mcode: unexpected mcodekind" in
- (term,arity,info,new_mcodekind,pos) in
+ (term,arity,info,new_mcodekind,pos,adj) in
let update_mc mcodekind e =
match !mcodekind with
indices, and so we allow PLUS code as well *)
Ast0.PLUS in
- let mcode (term,arity,info,mcodekind,pos) =
+ let mcode (term,arity,info,mcodekind,pos,adj) =
let info =
match start_line with
Some x ->
Ast0.line_end = x; } in
{info with Ast0.pos_info = new_pos_info}
| None -> info in
- (term,arity,info,copy_mcodekind mcodekind,pos) in
+ (term,arity,info,copy_mcodekind mcodekind,pos,adj) in
let copy_one x =
let old_info = Ast0.get_info x in
let rec renamer = function
Type_cocci.MetaType(name,keep,inherited) ->
(match
- lookup (name,(),(),(),None) bindings mv_bindings
+ lookup (name,(),(),(),None,-1) bindings mv_bindings
with
Common.Left(Ast0.TypeCTag(t)) ->
Ast0.ast0_type_to_type t
(* should be done by functorizing the parser to use wrap or context_wrap *)
let rewrap =
- let mcode (x,a,i,mc,pos) = (x,a,i,Ast0.context_befaft(),pos) in
+ let mcode (x,a,i,mc,pos,adj) = (x,a,i,Ast0.context_befaft(),pos,adj) in
let donothing r k e = Ast0.context_wrap(Ast0.unwrap(k e)) in
V0.flat_rebuilder
mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode mcode
let lex_start = Lexing.lexeme_start lexbuf in
let preceeding_spaces =
if !line_start < 0 then 0 else lex_start - !line_start in
- line_start := -1;
+ (*line_start := -1;*)
prev_plus := (c = D.PLUS);
(c,l,ll,lex_start,preceeding_spaces,[],[],Ast0.NoMetaPos)
let current_line_started = ref false
Hashtbl.clear metavariables;
Hashtbl.clear type_names;
Hashtbl.clear rule_names;
+ Hashtbl.clear iterator_names;
+ Hashtbl.clear declarer_names;
let get_name (_,x) = x in
Data.add_id_meta :=
(fun name constraints pure ->
| "&" { start_line true; TAnd (get_current_line_type lexbuf) }
| "^" { start_line true; TXor(get_current_line_type lexbuf) }
- | ( ("#" [' ' '\t']* "define" [' ' '\t']+))
+ | (( ("#" [' ' '\t']* "define" [' ' '\t']+)) as def)
( (letter (letter |digit)*) as ident)
{ start_line true;
let (arity,line,lline,offset,col,strbef,straft,pos) as lt =
get_current_line_type lexbuf in
- let off = String.length "#define " in
+ let off = String.length def in
(* -1 in the code below because the ident is not at the line start *)
TDefine
(lt,
check_var ident
- (arity,line,lline,offset+off,(-1),[],[],Ast0.NoMetaPos)) }
- | ( ("#" [' ' '\t']* "define" [' ' '\t']+))
+ (arity,line,lline,offset+off,col+off,[],[],Ast0.NoMetaPos)) }
+ | (( ("#" [' ' '\t']* "define" [' ' '\t']+)) as def)
( (letter (letter | digit)*) as ident)
'('
{ start_line true;
let (arity,line,lline,offset,col,strbef,straft,pos) as lt =
get_current_line_type lexbuf in
- let off = String.length "#define " in
+ let off = String.length def in
TDefineParam
(lt,
check_var ident
(* why pos here but not above? *)
- (arity,line,lline,offset+off,(-1),strbef,straft,pos),
- offset + off + (String.length ident)) }
+ (arity,line,lline,offset+off,col+off,strbef,straft,pos),
+ offset + off + (String.length ident),
+ col + off + (String.length ident)) }
| "#" [' ' '\t']* "include" [' ' '\t']* '"' [^ '"']+ '"'
{ TIncludeL
(let str = tok lexbuf in
let new_pos_info =
{Ast0.line_start = line; Ast0.line_end = line;
Ast0.logical_start = logical_line; Ast0.logical_end = logical_line;
- Ast0.column = col; Ast0.offset = offset;} in
+ Ast0.column = col; Ast0.offset = offset; } in
{ Ast0.pos_info = new_pos_info;
Ast0.attachable_start = true; Ast0.attachable_end = true;
Ast0.mcode_start = []; Ast0.mcode_end = [];
let clt2mcode str = function
(Data.MINUS,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.NONE,make_info line lline offset col strbef straft,
- Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos)
+ Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos,-1)
| (Data.OPTMINUS,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.OPT,make_info line lline offset col strbef straft,
- Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos)
+ Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos,-1)
| (Data.UNIQUEMINUS,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.UNIQUE,make_info line lline offset col strbef straft,
- Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos)
+ Ast0.MINUS(ref([],Ast0.default_token_info)),ref pos,-1)
| (Data.PLUS,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.NONE,make_info line lline offset col strbef straft,Ast0.PLUS,
- ref pos)
+ ref pos,-1)
| (Data.CONTEXT,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.NONE,make_info line lline offset col strbef straft,
Ast0.CONTEXT(ref(Ast.NOTHING,
Ast0.default_token_info,Ast0.default_token_info)),
- ref pos)
+ ref pos,-1)
| (Data.OPT,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.OPT,make_info line lline offset col strbef straft,
Ast0.CONTEXT(ref(Ast.NOTHING,
Ast0.default_token_info,Ast0.default_token_info)),
- ref pos)
+ ref pos,-1)
| (Data.UNIQUE,line,lline,offset,col,strbef,straft,pos) ->
(str,Ast0.UNIQUE,make_info line lline offset col strbef straft,
Ast0.CONTEXT(ref(Ast.NOTHING,
Ast0.default_token_info,Ast0.default_token_info)),
- ref pos)
+ ref pos,-1)
let id2name (name, clt) = name
let id2clt (name, clt) = clt
let make_script_rule_name_result lang deps =
let l = id2name lang in
- Ast.ScriptRulename (l,deps)
+ Ast.ScriptRulename (l,deps)
let make_initial_script_rule_name_result lang =
let l = id2name lang in
| PC.TIncludeL(s,clt) -> (pr "#include \"%s\"" s)^(line_type2c clt)
| PC.TIncludeNL(s,clt) -> (pr "#include <%s>" s)^(line_type2c clt)
| PC.TDefine(clt,_) -> "#define"^(line_type2c clt)
- | PC.TDefineParam(clt,_,_) -> "#define_param"^(line_type2c clt)
+ | PC.TDefineParam(clt,_,_,_) -> "#define_param"^(line_type2c clt)
| PC.TMinusFile(s,clt) -> (pr "--- %s" s)^(line_type2c clt)
| PC.TPlusFile(s,clt) -> (pr "+++ %s" s)^(line_type2c clt)
| PC.Textern(clt) | PC.Tconst(clt) | PC.Tvolatile(clt)
| PC.TIncludeL(_,clt) | PC.TIncludeNL(_,clt) | PC.TDefine(clt,_)
- | PC.TDefineParam(clt,_,_) | PC.TMinusFile(_,clt) | PC.TPlusFile(_,clt)
+ | PC.TDefineParam(clt,_,_,_) | PC.TMinusFile(_,clt) | PC.TPlusFile(_,clt)
| PC.TInc(clt) | PC.TDec(clt)
| PC.Textern(clt) | PC.Tconst(clt) | PC.Tvolatile(clt)
| PC.TIncludeL(_,clt) | PC.TIncludeNL(_,clt) | PC.TDefine(clt,_)
- | PC.TDefineParam(clt,_,_) | PC.TMinusFile(_,clt) | PC.TPlusFile(_,clt)
+ | PC.TDefineParam(clt,_,_,_) | PC.TMinusFile(_,clt) | PC.TPlusFile(_,clt)
| PC.TInc(clt) | PC.TDec(clt)
| PC.TIncludeL(s,_) -> (PC.TIncludeL(s,clt),x)
| PC.TIncludeNL(s,_) -> (PC.TIncludeNL(s,clt),x)
| PC.TDefine(_,a) -> (PC.TDefine(clt,a),x)
- | PC.TDefineParam(_,a,b) -> (PC.TDefineParam(clt,a,b),x)
+ | PC.TDefineParam(_,a,b,c) -> (PC.TDefineParam(clt,a,b,c),x)
| PC.TMinusFile(s,_) -> (PC.TMinusFile(s,clt),x)
| PC.TPlusFile(s,_) -> (PC.TPlusFile(s,clt),x)
| PC.TPlusFile(s,clt) | PC.TMinusFile(s,clt)
| PC.TIncludeL(s,clt) | PC.TIncludeNL(s,clt) ->
split t clt
- | PC.TDefine(clt,_) | PC.TDefineParam(clt,_,_) -> split t clt
+ | PC.TDefine(clt,_) | PC.TDefineParam(clt,_,_,_) -> split t clt
| PC.TIf(clt) | PC.TElse(clt) | PC.TWhile(clt) | PC.TFor(clt) | PC.TDo(clt)
| PC.TSwitch(clt) | PC.TCase(clt) | PC.TDefault(clt)
| PC.TPtrOp(clt)
- | PC.TDefine(clt,_) | PC.TDefineParam(clt,_,_)
+ | PC.TDefine(clt,_) | PC.TDefineParam(clt,_,_,_)
| PC.TIncludeL(_,clt) | PC.TIncludeNL(_,clt)
| PC.TEq(clt) | PC.TAssign(_,clt) | PC.TDot(clt) | PC.TComma(clt)
| (((PC.TWhen(clt),q) as x)::xs) ->
x::(find_line_end true (token2line x) clt q xs)
| (((PC.TDefine(clt,_),q) as x)::xs)
- | (((PC.TDefineParam(clt,_,_),q) as x)::xs) ->
+ | (((PC.TDefineParam(clt,_,_,_),q) as x)::xs) ->
x::(find_line_end false (token2line x) clt q xs)
| x::xs -> x::(insert_line_end xs)
some restrictions on the -+ code *)
([],_) | (_,Ast.Generated) -> ([],minus)
| _ -> Iso_pattern.apply_isos chosen_isos minus rule_name in
+ (* after iso, because iso can intro ... *)
+ let minus = Adjacency.compute_adjacency minus in
let minus = Comm_assoc.comm_assoc minus rule_name dropiso in
let minus =
if !Flag.sgrep_mode2 then minus
| TDepends
| TDefineParam of (
# 82 "parser_cocci_menhir.mly"
- (Data.clt * token * int)
+ (Data.clt * token * int * int)
# 558 "parser_cocci_menhir.ml"
)
| TDefine of (
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_aexpr =
-# 1766 "parser_cocci_menhir.mly"
+# 1767 "parser_cocci_menhir.mly"
( Ast0.set_arg_exp _1 )
# 1535 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_aexpr =
-# 1768 "parser_cocci_menhir.mly"
+# 1769 "parser_cocci_menhir.mly"
( let (nm,lenname,pure,clt) = _1 in
let nm = P.clt2mcode nm clt in
let lenname =
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_aexpr =
-# 1776 "parser_cocci_menhir.mly"
+# 1777 "parser_cocci_menhir.mly"
( Ast0.set_arg_exp(Ast0.wrap(Ast0.TypeExp(_1))) )
# 1593 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_any_strict =
-# 1820 "parser_cocci_menhir.mly"
+# 1821 "parser_cocci_menhir.mly"
( Ast.WhenAny )
# 1615 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_any_strict =
-# 1821 "parser_cocci_menhir.mly"
+# 1822 "parser_cocci_menhir.mly"
( Ast.WhenStrict )
# 1637 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_any_strict =
-# 1822 "parser_cocci_menhir.mly"
+# 1823 "parser_cocci_menhir.mly"
( Ast.WhenForall )
# 1659 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_any_strict =
-# 1823 "parser_cocci_menhir.mly"
+# 1824 "parser_cocci_menhir.mly"
( Ast.WhenExists )
# 1681 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1263 "parser_cocci_menhir.mly"
+# 1264 "parser_cocci_menhir.mly"
( _1 )
# 1705 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1265 "parser_cocci_menhir.mly"
+# 1266 "parser_cocci_menhir.mly"
( P.arith_op Ast.Mul _1 _2 _3 )
# 1745 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1267 "parser_cocci_menhir.mly"
+# 1268 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 1785 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1269 "parser_cocci_menhir.mly"
+# 1270 "parser_cocci_menhir.mly"
( P.arith_op Ast.Plus _1 _2 _3 )
# 1825 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1271 "parser_cocci_menhir.mly"
+# 1272 "parser_cocci_menhir.mly"
( P.arith_op Ast.Minus _1 _2 _3 )
# 1865 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1273 "parser_cocci_menhir.mly"
+# 1274 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 1905 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1275 "parser_cocci_menhir.mly"
+# 1276 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.logic_op op _1 clt _3 )
# 1945 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1277 "parser_cocci_menhir.mly"
+# 1278 "parser_cocci_menhir.mly"
( P.logic_op Ast.Eq _1 _2 _3 )
# 1985 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1279 "parser_cocci_menhir.mly"
+# 1280 "parser_cocci_menhir.mly"
( P.logic_op Ast.NotEq _1 _2 _3 )
# 2025 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1281 "parser_cocci_menhir.mly"
+# 1282 "parser_cocci_menhir.mly"
( P.arith_op Ast.And _1 _2 _3 )
# 2065 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1283 "parser_cocci_menhir.mly"
+# 1284 "parser_cocci_menhir.mly"
( P.arith_op Ast.Or _1 _2 _3 )
# 2105 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1285 "parser_cocci_menhir.mly"
+# 1286 "parser_cocci_menhir.mly"
( P.arith_op Ast.Xor _1 _2 _3 )
# 2145 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1287 "parser_cocci_menhir.mly"
+# 1288 "parser_cocci_menhir.mly"
( P.logic_op Ast.AndLog _1 _2 _3 )
# 2185 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_dot_expressions_ =
-# 1289 "parser_cocci_menhir.mly"
+# 1290 "parser_cocci_menhir.mly"
( P.logic_op Ast.OrLog _1 _2 _3 )
# 2225 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1263 "parser_cocci_menhir.mly"
+# 1264 "parser_cocci_menhir.mly"
( _1 )
# 2249 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1265 "parser_cocci_menhir.mly"
+# 1266 "parser_cocci_menhir.mly"
( P.arith_op Ast.Mul _1 _2 _3 )
# 2289 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1267 "parser_cocci_menhir.mly"
+# 1268 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 2329 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1269 "parser_cocci_menhir.mly"
+# 1270 "parser_cocci_menhir.mly"
( P.arith_op Ast.Plus _1 _2 _3 )
# 2369 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1271 "parser_cocci_menhir.mly"
+# 1272 "parser_cocci_menhir.mly"
( P.arith_op Ast.Minus _1 _2 _3 )
# 2409 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1273 "parser_cocci_menhir.mly"
+# 1274 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 2449 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1275 "parser_cocci_menhir.mly"
+# 1276 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.logic_op op _1 clt _3 )
# 2489 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1277 "parser_cocci_menhir.mly"
+# 1278 "parser_cocci_menhir.mly"
( P.logic_op Ast.Eq _1 _2 _3 )
# 2529 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1279 "parser_cocci_menhir.mly"
+# 1280 "parser_cocci_menhir.mly"
( P.logic_op Ast.NotEq _1 _2 _3 )
# 2569 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1281 "parser_cocci_menhir.mly"
+# 1282 "parser_cocci_menhir.mly"
( P.arith_op Ast.And _1 _2 _3 )
# 2609 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1283 "parser_cocci_menhir.mly"
+# 1284 "parser_cocci_menhir.mly"
( P.arith_op Ast.Or _1 _2 _3 )
# 2649 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1285 "parser_cocci_menhir.mly"
+# 1286 "parser_cocci_menhir.mly"
( P.arith_op Ast.Xor _1 _2 _3 )
# 2689 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1287 "parser_cocci_menhir.mly"
+# 1288 "parser_cocci_menhir.mly"
( P.logic_op Ast.AndLog _1 _2 _3 )
# 2729 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_invalid_ =
-# 1289 "parser_cocci_menhir.mly"
+# 1290 "parser_cocci_menhir.mly"
( P.logic_op Ast.OrLog _1 _2 _3 )
# 2769 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1263 "parser_cocci_menhir.mly"
+# 1264 "parser_cocci_menhir.mly"
( _1 )
# 2793 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1265 "parser_cocci_menhir.mly"
+# 1266 "parser_cocci_menhir.mly"
( P.arith_op Ast.Mul _1 _2 _3 )
# 2833 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1267 "parser_cocci_menhir.mly"
+# 1268 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 2873 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1269 "parser_cocci_menhir.mly"
+# 1270 "parser_cocci_menhir.mly"
( P.arith_op Ast.Plus _1 _2 _3 )
# 2913 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1271 "parser_cocci_menhir.mly"
+# 1272 "parser_cocci_menhir.mly"
( P.arith_op Ast.Minus _1 _2 _3 )
# 2953 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1273 "parser_cocci_menhir.mly"
+# 1274 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 2993 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1275 "parser_cocci_menhir.mly"
+# 1276 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.logic_op op _1 clt _3 )
# 3033 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1277 "parser_cocci_menhir.mly"
+# 1278 "parser_cocci_menhir.mly"
( P.logic_op Ast.Eq _1 _2 _3 )
# 3073 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1279 "parser_cocci_menhir.mly"
+# 1280 "parser_cocci_menhir.mly"
( P.logic_op Ast.NotEq _1 _2 _3 )
# 3113 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1281 "parser_cocci_menhir.mly"
+# 1282 "parser_cocci_menhir.mly"
( P.arith_op Ast.And _1 _2 _3 )
# 3153 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1283 "parser_cocci_menhir.mly"
+# 1284 "parser_cocci_menhir.mly"
( P.arith_op Ast.Or _1 _2 _3 )
# 3193 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1285 "parser_cocci_menhir.mly"
+# 1286 "parser_cocci_menhir.mly"
( P.arith_op Ast.Xor _1 _2 _3 )
# 3233 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1287 "parser_cocci_menhir.mly"
+# 1288 "parser_cocci_menhir.mly"
( P.logic_op Ast.AndLog _1 _2 _3 )
# 3273 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_eexpr_nest_expressions_ =
-# 1289 "parser_cocci_menhir.mly"
+# 1290 "parser_cocci_menhir.mly"
( P.logic_op Ast.OrLog _1 _2 _3 )
# 3313 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1263 "parser_cocci_menhir.mly"
+# 1264 "parser_cocci_menhir.mly"
( _1 )
# 3337 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1265 "parser_cocci_menhir.mly"
+# 1266 "parser_cocci_menhir.mly"
( P.arith_op Ast.Mul _1 _2 _3 )
# 3377 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1267 "parser_cocci_menhir.mly"
+# 1268 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 3417 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1269 "parser_cocci_menhir.mly"
+# 1270 "parser_cocci_menhir.mly"
( P.arith_op Ast.Plus _1 _2 _3 )
# 3457 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1271 "parser_cocci_menhir.mly"
+# 1272 "parser_cocci_menhir.mly"
( P.arith_op Ast.Minus _1 _2 _3 )
# 3497 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1273 "parser_cocci_menhir.mly"
+# 1274 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.arith_op op _1 clt _3 )
# 3537 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1275 "parser_cocci_menhir.mly"
+# 1276 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in P.logic_op op _1 clt _3 )
# 3577 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1277 "parser_cocci_menhir.mly"
+# 1278 "parser_cocci_menhir.mly"
( P.logic_op Ast.Eq _1 _2 _3 )
# 3617 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1279 "parser_cocci_menhir.mly"
+# 1280 "parser_cocci_menhir.mly"
( P.logic_op Ast.NotEq _1 _2 _3 )
# 3657 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1281 "parser_cocci_menhir.mly"
+# 1282 "parser_cocci_menhir.mly"
( P.arith_op Ast.And _1 _2 _3 )
# 3697 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1283 "parser_cocci_menhir.mly"
+# 1284 "parser_cocci_menhir.mly"
( P.arith_op Ast.Or _1 _2 _3 )
# 3737 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1285 "parser_cocci_menhir.mly"
+# 1286 "parser_cocci_menhir.mly"
( P.arith_op Ast.Xor _1 _2 _3 )
# 3777 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1287 "parser_cocci_menhir.mly"
+# 1288 "parser_cocci_menhir.mly"
( P.logic_op Ast.AndLog _1 _2 _3 )
# 3817 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_arith_expr_expr_invalid_ =
-# 1289 "parser_cocci_menhir.mly"
+# 1290 "parser_cocci_menhir.mly"
( P.logic_op Ast.OrLog _1 _2 _3 )
# 3857 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_l_ in
let _endpos = _endpos_r_ in
let _v : 'tv_array_dec =
-# 1070 "parser_cocci_menhir.mly"
+# 1071 "parser_cocci_menhir.mly"
( (l,i,r) )
# 3984 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_assign_expr_eexpr_dot_expressions_ =
-# 1235 "parser_cocci_menhir.mly"
+# 1236 "parser_cocci_menhir.mly"
( _1 )
# 4008 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_eexpr_dot_expressions_ =
-# 1237 "parser_cocci_menhir.mly"
+# 1238 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in
Ast0.wrap(Ast0.Assignment(_1,P.clt2mcode op clt,
Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_eexpr_dot_expressions_ =
-# 1241 "parser_cocci_menhir.mly"
+# 1242 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.Assignment
(_1,P.clt2mcode Ast.SimpleAssign _2,Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_assign_expr_eexpr_nest_expressions_ =
-# 1235 "parser_cocci_menhir.mly"
+# 1236 "parser_cocci_menhir.mly"
( _1 )
# 4116 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_eexpr_nest_expressions_ =
-# 1237 "parser_cocci_menhir.mly"
+# 1238 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in
Ast0.wrap(Ast0.Assignment(_1,P.clt2mcode op clt,
Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_eexpr_nest_expressions_ =
-# 1241 "parser_cocci_menhir.mly"
+# 1242 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.Assignment
(_1,P.clt2mcode Ast.SimpleAssign _2,Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_assign_expr_expr_invalid_ =
-# 1235 "parser_cocci_menhir.mly"
+# 1236 "parser_cocci_menhir.mly"
( _1 )
# 4224 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_expr_invalid_ =
-# 1237 "parser_cocci_menhir.mly"
+# 1238 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in
Ast0.wrap(Ast0.Assignment(_1,P.clt2mcode op clt,
Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_expr_invalid_ =
-# 1241 "parser_cocci_menhir.mly"
+# 1242 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.Assignment
(_1,P.clt2mcode Ast.SimpleAssign _2,Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_assign_expr_bis =
-# 1246 "parser_cocci_menhir.mly"
+# 1247 "parser_cocci_menhir.mly"
( _1 )
# 4332 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_bis =
-# 1248 "parser_cocci_menhir.mly"
+# 1249 "parser_cocci_menhir.mly"
( let (op,clt) = _2 in
Ast0.wrap(Ast0.Assignment(_1,P.clt2mcode op clt,
Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_assign_expr_bis =
-# 1252 "parser_cocci_menhir.mly"
+# 1253 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.Assignment
(_1,P.clt2mcode Ast.SimpleAssign _2,Ast0.set_arg_exp _3,false)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_basic_expr_eexpr_dot_expressions_ =
-# 1232 "parser_cocci_menhir.mly"
+# 1233 "parser_cocci_menhir.mly"
( _1 )
# 4440 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_basic_expr_eexpr_nest_expressions_ =
-# 1232 "parser_cocci_menhir.mly"
+# 1233 "parser_cocci_menhir.mly"
( _1 )
# 4464 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_basic_expr_expr_invalid_ =
-# 1232 "parser_cocci_menhir.mly"
+# 1233 "parser_cocci_menhir.mly"
( _1 )
# 4488 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_case_line =
-# 942 "parser_cocci_menhir.mly"
+# 943 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Default(P.clt2mcode "default" _1,P.clt2mcode ":" _2,_3)) )
# 4532 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_case_line =
-# 944 "parser_cocci_menhir.mly"
+# 945 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Case(P.clt2mcode "case" _1,_2,P.clt2mcode ":" _3,_4)) )
# 4582 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cast_expr_eexpr_dot_expressions_ =
-# 1292 "parser_cocci_menhir.mly"
+# 1293 "parser_cocci_menhir.mly"
( _1 )
# 4606 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_lp_ in
let _endpos = _endpos_e_ in
let _v : 'tv_cast_expr_eexpr_dot_expressions_ =
-# 1294 "parser_cocci_menhir.mly"
+# 1295 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Cast (P.clt2mcode "(" lp, t,
P.clt2mcode ")" rp, e)) )
# 4657 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cast_expr_eexpr_invalid_ =
-# 1292 "parser_cocci_menhir.mly"
+# 1293 "parser_cocci_menhir.mly"
( _1 )
# 4681 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_lp_ in
let _endpos = _endpos_e_ in
let _v : 'tv_cast_expr_eexpr_invalid_ =
-# 1294 "parser_cocci_menhir.mly"
+# 1295 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Cast (P.clt2mcode "(" lp, t,
P.clt2mcode ")" rp, e)) )
# 4732 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cast_expr_eexpr_nest_expressions_ =
-# 1292 "parser_cocci_menhir.mly"
+# 1293 "parser_cocci_menhir.mly"
( _1 )
# 4756 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_lp_ in
let _endpos = _endpos_e_ in
let _v : 'tv_cast_expr_eexpr_nest_expressions_ =
-# 1294 "parser_cocci_menhir.mly"
+# 1295 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Cast (P.clt2mcode "(" lp, t,
P.clt2mcode ")" rp, e)) )
# 4807 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cast_expr_expr_invalid_ =
-# 1292 "parser_cocci_menhir.mly"
+# 1293 "parser_cocci_menhir.mly"
( _1 )
# 4831 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_lp_ in
let _endpos = _endpos_e_ in
let _v : 'tv_cast_expr_expr_invalid_ =
-# 1294 "parser_cocci_menhir.mly"
+# 1295 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Cast (P.clt2mcode "(" lp, t,
P.clt2mcode ")" rp, e)) )
# 4882 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_comma_decls_TEllipsis_decl_ =
-# 1567 "parser_cocci_menhir.mly"
+# 1568 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.PComma(P.clt2mcode "," _1));
dot_builder _2] )
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_comma_decls_TEllipsis_decl_ =
-# 1571 "parser_cocci_menhir.mly"
+# 1572 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.PComma(P.clt2mcode "," _1)); _2] )
# 4985 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_comma_decls_TEllipsis_name_opt_decl_ =
-# 1567 "parser_cocci_menhir.mly"
+# 1568 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.PComma(P.clt2mcode "," _1));
dot_builder _2] )
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_comma_decls_TEllipsis_name_opt_decl_ =
-# 1571 "parser_cocci_menhir.mly"
+# 1572 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.PComma(P.clt2mcode "," _1)); _2] )
# 5060 "parser_cocci_menhir.ml"
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_comma_initializers_edots_when_TEllipsis_initialize__ =
-# 1123 "parser_cocci_menhir.mly"
+# 1124 "parser_cocci_menhir.mly"
( [] )
# 5077 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_d_ in
let _endpos = _endpos_r_ in
let _v : 'tv_comma_initializers_edots_when_TEllipsis_initialize__ =
-# 1125 "parser_cocci_menhir.mly"
+# 1126 "parser_cocci_menhir.mly"
( (function dot_builder -> [dot_builder d])::r )
# 5107 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_i_ in
let _endpos = _endpos_r_ in
let _v : 'tv_comma_initializers_edots_when_TEllipsis_initialize__ =
-# 1127 "parser_cocci_menhir.mly"
+# 1128 "parser_cocci_menhir.mly"
( (function dot_builder -> [i; Ast0.wrap(Ast0.IComma(P.clt2mcode "," c))])::
r )
# 5148 "parser_cocci_menhir.ml"
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_comma_initializers2_edots_when_TEllipsis_initialize__ =
-# 1131 "parser_cocci_menhir.mly"
+# 1132 "parser_cocci_menhir.mly"
( [] )
# 5165 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_i_ in
let _endpos = _endpos_r_ in
let _v : 'tv_comma_initializers2_edots_when_TEllipsis_initialize__ =
-# 1133 "parser_cocci_menhir.mly"
+# 1134 "parser_cocci_menhir.mly"
( (function dot_builder -> [i; Ast0.wrap(Ast0.IComma(P.clt2mcode "," c))])::
r )
# 5206 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_any_strict_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5230 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_ctype_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5254 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_d_ident_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5278 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_dexpr_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5302 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_ident_or_const_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5326 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_meta_ident_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5350 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5374 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5398 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_with_not_eq_not_ceq__ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5422 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_with_not_eq_not_eq__ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5446 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_with_not_eq_not_eqe__ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5470 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_with_not_eq_not_pos__ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5494 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_comma_list_pure_ident_or_meta_ident_with_seed_ =
-# 1798 "parser_cocci_menhir.mly"
+# 1799 "parser_cocci_menhir.mly"
( _1 )
# 5518 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cond_expr_eexpr_dot_expressions_ =
-# 1257 "parser_cocci_menhir.mly"
+# 1258 "parser_cocci_menhir.mly"
( _1 )
# 5542 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_l_ in
let _endpos = _endpos_r_ in
let _v : 'tv_cond_expr_eexpr_dot_expressions_ =
-# 1259 "parser_cocci_menhir.mly"
+# 1260 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.CondExpr (l, P.clt2mcode "?" w, t,
P.clt2mcode ":" dd, r)) )
# 5599 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cond_expr_eexpr_nest_expressions_ =
-# 1257 "parser_cocci_menhir.mly"
+# 1258 "parser_cocci_menhir.mly"
( _1 )
# 5623 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_l_ in
let _endpos = _endpos_r_ in
let _v : 'tv_cond_expr_eexpr_nest_expressions_ =
-# 1259 "parser_cocci_menhir.mly"
+# 1260 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.CondExpr (l, P.clt2mcode "?" w, t,
P.clt2mcode ":" dd, r)) )
# 5680 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_cond_expr_expr_invalid_ =
-# 1257 "parser_cocci_menhir.mly"
+# 1258 "parser_cocci_menhir.mly"
( _1 )
# 5704 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_l_ in
let _endpos = _endpos_r_ in
let _v : 'tv_cond_expr_expr_invalid_ =
-# 1259 "parser_cocci_menhir.mly"
+# 1260 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.CondExpr (l, P.clt2mcode "?" w, t,
P.clt2mcode ":" dd, r)) )
# 5761 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_const_vol =
-# 851 "parser_cocci_menhir.mly"
+# 852 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Const _1 )
# 5789 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_const_vol =
-# 852 "parser_cocci_menhir.mly"
+# 853 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Volatile _1 )
# 5817 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_d_ident =
-# 1061 "parser_cocci_menhir.mly"
+# 1062 "parser_cocci_menhir.mly"
( (_1,
function t ->
List.fold_right
let _startpos = _startpos_t_ in
let _endpos = _endpos_i_ in
let _v : 'tv_decl =
-# 821 "parser_cocci_menhir.mly"
+# 822 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Param(t, Some i)) )
# 6395 "parser_cocci_menhir.ml"
in
let _startpos = _startpos_t_ in
let _endpos = _endpos_rp1_ in
let _v : 'tv_decl =
-# 824 "parser_cocci_menhir.mly"
+# 825 "parser_cocci_menhir.mly"
( let fnptr =
Ast0.wrap
(Ast0.FunctionPointer
let _startpos = _startpos_t_ in
let _endpos = _endpos_t_ in
let _v : 'tv_decl =
-# 831 "parser_cocci_menhir.mly"
+# 832 "parser_cocci_menhir.mly"
( let ty =
Ast0.wrap(Ast0.BaseType(Ast.VoidType,[P.clt2mcode "void" t])) in
Ast0.wrap(Ast0.VoidParam(ty)) )
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl =
-# 835 "parser_cocci_menhir.mly"
+# 836 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaParam(P.clt2mcode nm clt,pure)) )
# 6545 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_ident =
-# 1516 "parser_cocci_menhir.mly"
+# 1517 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Id(P.id2mcode _1)) )
# 6573 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_ident =
-# 1518 "parser_cocci_menhir.mly"
+# 1519 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaId(P.clt2mcode nm clt,constraints,pure)) )
# 6602 "parser_cocci_menhir.ml"
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_decl_list_decl_ =
-# 1538 "parser_cocci_menhir.mly"
+# 1539 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS([])) )
# 6619 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_list_decl_ =
-# 1540 "parser_cocci_menhir.mly"
+# 1541 "parser_cocci_menhir.mly"
(let circle x =
match Ast0.unwrap x with Ast0.Pcircles(_) -> true | _ -> false in
if List.exists circle _1
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_decl_list_name_opt_decl_ =
-# 1538 "parser_cocci_menhir.mly"
+# 1539 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS([])) )
# 6664 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_list_name_opt_decl_ =
-# 1540 "parser_cocci_menhir.mly"
+# 1541 "parser_cocci_menhir.mly"
(let circle x =
match Ast0.unwrap x with Ast0.Pcircles(_) -> true | _ -> false in
if List.exists circle _1
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_list_start_decl_ =
-# 1547 "parser_cocci_menhir.mly"
+# 1548 "parser_cocci_menhir.mly"
( [_1] )
# 6716 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_decl_list_start_decl_ =
-# 1549 "parser_cocci_menhir.mly"
+# 1550 "parser_cocci_menhir.mly"
( _1::Ast0.wrap(Ast0.PComma(P.clt2mcode "," _2))::_3 )
# 6756 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_decl_list_start_decl_ =
-# 1551 "parser_cocci_menhir.mly"
+# 1552 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Pdots(P.clt2mcode "..." _1))::
(List.concat(List.map (function x -> x (P.mkpdots "...")) _2)) )
# 6791 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_list_start_name_opt_decl_ =
-# 1547 "parser_cocci_menhir.mly"
+# 1548 "parser_cocci_menhir.mly"
( [_1] )
# 6815 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_decl_list_start_name_opt_decl_ =
-# 1549 "parser_cocci_menhir.mly"
+# 1550 "parser_cocci_menhir.mly"
( _1::Ast0.wrap(Ast0.PComma(P.clt2mcode "," _2))::_3 )
# 6855 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_decl_list_start_name_opt_decl_ =
-# 1551 "parser_cocci_menhir.mly"
+# 1552 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Pdots(P.clt2mcode "..." _1))::
(List.concat(List.map (function x -> x (P.mkpdots "...")) _2)) )
# 6890 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement =
-# 1139 "parser_cocci_menhir.mly"
+# 1140 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = _1 in
[Ast0.wrap(Ast0.MetaStmt(P.clt2mcode nm clt,pure))] )
# 6919 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement =
-# 1142 "parser_cocci_menhir.mly"
+# 1143 "parser_cocci_menhir.mly"
( List.map
(function x ->
Ast0.wrap
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement =
-# 1147 "parser_cocci_menhir.mly"
+# 1148 "parser_cocci_menhir.mly"
( [_1] )
# 6971 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_decl_statement =
-# 1156 "parser_cocci_menhir.mly"
+# 1157 "parser_cocci_menhir.mly"
( let (mids,code) = t in
if List.for_all
(function x ->
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement_expr =
-# 1169 "parser_cocci_menhir.mly"
+# 1170 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = _1 in
[Ast0.wrap(Ast0.MetaStmt(P.clt2mcode nm clt,pure))] )
# 7052 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement_expr =
-# 1172 "parser_cocci_menhir.mly"
+# 1173 "parser_cocci_menhir.mly"
( List.map
(function x ->
Ast0.wrap
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_decl_statement_expr =
-# 1177 "parser_cocci_menhir.mly"
+# 1178 "parser_cocci_menhir.mly"
( [_1] )
# 7104 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_decl_statement_expr =
-# 1186 "parser_cocci_menhir.mly"
+# 1187 "parser_cocci_menhir.mly"
( let (mids,code) = t in
if List.for_all (function [] -> true | _ -> false) code
then []
let _startpos = _startpos_t_ in
let _endpos = _endpos_pv_ in
let _v : 'tv_decl_var =
-# 952 "parser_cocci_menhir.mly"
+# 953 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.TyDecl(t,P.clt2mcode ";" pv))] )
# 7189 "parser_cocci_menhir.ml"
in
in
-# 954 "parser_cocci_menhir.mly"
+# 955 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)))
in
-# 954 "parser_cocci_menhir.mly"
+# 955 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)))
let _startpos = _startpos_f_ in
let _endpos = _endpos_f_ in
let _v : 'tv_decl_var =
-# 958 "parser_cocci_menhir.mly"
+# 959 "parser_cocci_menhir.mly"
( [f] )
# 7320 "parser_cocci_menhir.ml"
in
in
-# 960 "parser_cocci_menhir.mly"
+# 961 "parser_cocci_menhir.mly"
(let (id,fn) = d in
[Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv))])
# 7384 "parser_cocci_menhir.ml"
in
-# 960 "parser_cocci_menhir.mly"
+# 961 "parser_cocci_menhir.mly"
(let (id,fn) = d in
[Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv))])
# 7455 "parser_cocci_menhir.ml"
in
-# 965 "parser_cocci_menhir.mly"
+# 966 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
let idtype =
in
-# 965 "parser_cocci_menhir.mly"
+# 966 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
let idtype =
in
-# 965 "parser_cocci_menhir.mly"
+# 966 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
let idtype =
in
-# 965 "parser_cocci_menhir.mly"
+# 966 "parser_cocci_menhir.mly"
( List.map
(function (id,fn) ->
let idtype =
in
-# 973 "parser_cocci_menhir.mly"
+# 974 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
in
-# 973 "parser_cocci_menhir.mly"
+# 974 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
in
-# 973 "parser_cocci_menhir.mly"
+# 974 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
in
-# 973 "parser_cocci_menhir.mly"
+# 974 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
in
-# 983 "parser_cocci_menhir.mly"
+# 984 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
in
-# 983 "parser_cocci_menhir.mly"
+# 984 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_decl_var =
-# 991 "parser_cocci_menhir.mly"
+# 992 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.MacroDecl(_1,P.clt2mcode "(" _2,_3,
P.clt2mcode ")" _4,P.clt2mcode ";" _5))] )
# 8329 "parser_cocci_menhir.ml"
in
-# 997 "parser_cocci_menhir.mly"
+# 998 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
in
-# 997 "parser_cocci_menhir.mly"
+# 998 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
let _startpos = _startpos_s_ in
let _endpos = _endpos_pv_ in
let _v : 'tv_decl_var =
-# 1005 "parser_cocci_menhir.mly"
+# 1006 "parser_cocci_menhir.mly"
( let s = P.clt2mcode "typedef" s in
[Ast0.wrap(Ast0.Typedef(s,t,id,P.clt2mcode ";" pv))] )
# 8637 "parser_cocci_menhir.ml"
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_define_param_list =
-# 713 "parser_cocci_menhir.mly"
+# 714 "parser_cocci_menhir.mly"
(let circle x =
match Ast0.unwrap x with Ast0.DPcircles(_) -> true | _ -> false in
if List.exists circle _1
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_define_param_list_option =
-# 737 "parser_cocci_menhir.mly"
+# 738 "parser_cocci_menhir.mly"
( _1 )
# 8689 "parser_cocci_menhir.ml"
in
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_define_param_list_option =
-# 738 "parser_cocci_menhir.mly"
+# 739 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS([])) )
# 8706 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_define_param_list_start =
-# 720 "parser_cocci_menhir.mly"
+# 721 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.DParam _1)] )
# 8730 "parser_cocci_menhir.ml"
in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_define_param_list_start =
-# 722 "parser_cocci_menhir.mly"
+# 723 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DParam _1)::
Ast0.wrap(Ast0.DPComma(P.clt2mcode "," _2))::_3 )
# 8771 "parser_cocci_menhir.ml"
let _startpos = _startpos_d_ in
let _endpos = _endpos_r_ in
let _v : 'tv_define_param_list_start =
-# 725 "parser_cocci_menhir.mly"
+# 726 "parser_cocci_menhir.mly"
( (P.mkdpdots "..." d)::
(List.concat (List.map (function x -> x (P.mkdpdots "...")) r)) )
# 8806 "parser_cocci_menhir.ml"
let _2 : 'tv_define_param_list_option = Obj.magic _2 in
let _1 : (
# 82 "parser_cocci_menhir.mly"
- (Data.clt * token * int)
+ (Data.clt * token * int * int)
# 8886 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_defineop =
# 690 "parser_cocci_menhir.mly"
- ( let (clt,ident,parenoff) = _1 in
+ ( let (clt,ident,parenoff,parencol) = _1 in
+ (* clt is the start of the #define itself *)
let (arity,line,lline,offset,col,strbef,straft,pos) = clt in
let lp =
P.clt2mcode "("
- (arity,line,lline,parenoff,0,[],[],Ast0.NoMetaPos) in
+ (arity,line,lline,parenoff,parencol,[],[],Ast0.NoMetaPos) in
function body ->
Ast0.wrap
(Ast0.Define
(Semantic_cocci.Semantic
"unexpected name for a #define")),
Ast0.wrap (Ast0.DParams (lp,_2,P.clt2mcode ")" _3)),body)) )
-# 8911 "parser_cocci_menhir.ml"
+# 8912 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_dep =
# 225 "parser_cocci_menhir.mly"
( _1 )
-# 8935 "parser_cocci_menhir.ml"
+# 8936 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_dep =
# 226 "parser_cocci_menhir.mly"
( Ast.AndDep(_1, _3) )
-# 8969 "parser_cocci_menhir.ml"
+# 8970 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_dep =
# 227 "parser_cocci_menhir.mly"
( Ast.OrDep (_1, _3) )
-# 9003 "parser_cocci_menhir.ml"
+# 9004 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_depends =
# 221 "parser_cocci_menhir.mly"
( Ast.NoDep )
-# 9020 "parser_cocci_menhir.ml"
+# 9021 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_depends =
# 222 "parser_cocci_menhir.mly"
( parents )
-# 9052 "parser_cocci_menhir.ml"
+# 9053 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 9079 "parser_cocci_menhir.ml"
+# 9080 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_designator =
-# 1103 "parser_cocci_menhir.mly"
+# 1104 "parser_cocci_menhir.mly"
( Ast0.DesignatorField (P.clt2mcode "." _1,_2) )
-# 9086 "parser_cocci_menhir.ml"
+# 9087 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 9117 "parser_cocci_menhir.ml"
+# 9118 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 9123 "parser_cocci_menhir.ml"
+# 9124 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_designator =
-# 1105 "parser_cocci_menhir.mly"
+# 1106 "parser_cocci_menhir.mly"
( Ast0.DesignatorIndex (P.clt2mcode "[" _1,_2,P.clt2mcode "]" _3) )
-# 9130 "parser_cocci_menhir.ml"
+# 9131 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _5 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 9171 "parser_cocci_menhir.ml"
+# 9172 "parser_cocci_menhir.ml"
) = Obj.magic _5 in
let _4 : 'tv_eexpr = Obj.magic _4 in
let _3 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9177 "parser_cocci_menhir.ml"
+# 9178 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 9183 "parser_cocci_menhir.ml"
+# 9184 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_designator =
-# 1107 "parser_cocci_menhir.mly"
+# 1108 "parser_cocci_menhir.mly"
( Ast0.DesignatorRange (P.clt2mcode "[" _1,_2,P.clt2mcode "..." _3,
_4,P.clt2mcode "]" _5) )
-# 9191 "parser_cocci_menhir.ml"
+# 9192 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_dexpr =
-# 1206 "parser_cocci_menhir.mly"
+# 1207 "parser_cocci_menhir.mly"
( _1 )
-# 9215 "parser_cocci_menhir.ml"
+# 9216 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_disable =
# 240 "parser_cocci_menhir.mly"
( List.map P.id2name _2 )
-# 9243 "parser_cocci_menhir.ml"
+# 9244 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9264 "parser_cocci_menhir.ml"
+# 9265 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_dot_expressions =
-# 1215 "parser_cocci_menhir.mly"
+# 1216 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Edots(P.clt2mcode "..." _1,None)) )
-# 9271 "parser_cocci_menhir.ml"
+# 9272 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_dot_expressions =
-# 1216 "parser_cocci_menhir.mly"
+# 1217 "parser_cocci_menhir.mly"
( _1 )
-# 9295 "parser_cocci_menhir.ml"
+# 9296 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9321 "parser_cocci_menhir.ml"
+# 9322 "parser_cocci_menhir.ml"
) = Obj.magic d in
let c : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 9326 "parser_cocci_menhir.ml"
+# 9327 "parser_cocci_menhir.ml"
) = Obj.magic c in
let _startpos = _startpos_c_ in
let _endpos = _endpos_d_ in
let _v : 'tv_dp_comma_args_TEllipsis_ =
-# 730 "parser_cocci_menhir.mly"
+# 731 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.DPComma(P.clt2mcode "," c)); dot_builder d] )
-# 9334 "parser_cocci_menhir.ml"
+# 9335 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 9361 "parser_cocci_menhir.ml"
+# 9362 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_dp_comma_args_TEllipsis_ =
-# 733 "parser_cocci_menhir.mly"
+# 734 "parser_cocci_menhir.mly"
( function dot_builder ->
[Ast0.wrap(Ast0.DPComma(P.clt2mcode "," _1));
Ast0.wrap(Ast0.DParam _2)] )
-# 9370 "parser_cocci_menhir.ml"
+# 9371 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9391 "parser_cocci_menhir.ml"
+# 9392 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos_d_ in
let _v : 'tv_edots_when_TEllipsis_eexpr_ =
-# 1808 "parser_cocci_menhir.mly"
+# 1809 "parser_cocci_menhir.mly"
( (d,None) )
-# 9398 "parser_cocci_menhir.ml"
+# 9399 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9437 "parser_cocci_menhir.ml"
+# 9438 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos__5_ in
let _v : 'tv_edots_when_TEllipsis_eexpr_ =
-# 1809 "parser_cocci_menhir.mly"
+# 1810 "parser_cocci_menhir.mly"
( (d,Some w) )
-# 9444 "parser_cocci_menhir.ml"
+# 9445 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9465 "parser_cocci_menhir.ml"
+# 9466 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos_d_ in
let _v : 'tv_edots_when_TEllipsis_initialize_ =
-# 1808 "parser_cocci_menhir.mly"
+# 1809 "parser_cocci_menhir.mly"
( (d,None) )
-# 9472 "parser_cocci_menhir.ml"
+# 9473 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9511 "parser_cocci_menhir.ml"
+# 9512 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos__5_ in
let _v : 'tv_edots_when_TEllipsis_initialize_ =
-# 1809 "parser_cocci_menhir.mly"
+# 1810 "parser_cocci_menhir.mly"
( (d,Some w) )
-# 9518 "parser_cocci_menhir.ml"
+# 9519 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9539 "parser_cocci_menhir.ml"
+# 9540 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos_d_ in
let _v : 'tv_edots_when_TEllipsis_struct_decl_ =
-# 1808 "parser_cocci_menhir.mly"
+# 1809 "parser_cocci_menhir.mly"
( (d,None) )
-# 9546 "parser_cocci_menhir.ml"
+# 9547 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let d : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 9585 "parser_cocci_menhir.ml"
+# 9586 "parser_cocci_menhir.ml"
) = Obj.magic d in
let _startpos = _startpos_d_ in
let _endpos = _endpos__5_ in
let _v : 'tv_edots_when_TEllipsis_struct_decl_ =
-# 1809 "parser_cocci_menhir.mly"
+# 1810 "parser_cocci_menhir.mly"
( (d,Some w) )
-# 9592 "parser_cocci_menhir.ml"
+# 9593 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_eexpr =
-# 1204 "parser_cocci_menhir.mly"
+# 1205 "parser_cocci_menhir.mly"
( _1 )
-# 9616 "parser_cocci_menhir.ml"
+# 9617 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_eexpr_list =
-# 1752 "parser_cocci_menhir.mly"
+# 1753 "parser_cocci_menhir.mly"
(let circle x =
match Ast0.unwrap x with Ast0.Ecircles(_) -> true | _ -> false in
let star x =
if List.exists star _1
then Ast0.wrap(Ast0.STARS(_1))
else Ast0.wrap(Ast0.DOTS(_1)) )
-# 9649 "parser_cocci_menhir.ml"
+# 9650 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_eexpr_list_option =
-# 1791 "parser_cocci_menhir.mly"
+# 1792 "parser_cocci_menhir.mly"
( _1 )
-# 9673 "parser_cocci_menhir.ml"
+# 9674 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_eexpr_list_option =
-# 1792 "parser_cocci_menhir.mly"
+# 1793 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS([])) )
-# 9690 "parser_cocci_menhir.ml"
+# 9691 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_eexpr_list_start =
-# 1779 "parser_cocci_menhir.mly"
+# 1780 "parser_cocci_menhir.mly"
( [_1] )
-# 9714 "parser_cocci_menhir.ml"
+# 9715 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 9746 "parser_cocci_menhir.ml"
+# 9747 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_aexpr = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_eexpr_list_start =
-# 1781 "parser_cocci_menhir.mly"
+# 1782 "parser_cocci_menhir.mly"
( _1::Ast0.wrap(Ast0.EComma(P.clt2mcode "," _2))::_3 )
-# 9754 "parser_cocci_menhir.ml"
+# 9755 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__6_ in
let _v : 'tv_error_words =
-# 1578 "parser_cocci_menhir.mly"
+# 1579 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.ERRORWORDS(cl))] )
-# 9798 "parser_cocci_menhir.ml"
+# 9799 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_exists =
# 243 "parser_cocci_menhir.mly"
( Ast.Exists )
-# 9820 "parser_cocci_menhir.ml"
+# 9821 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_exists =
# 244 "parser_cocci_menhir.mly"
( Ast.Forall )
-# 9842 "parser_cocci_menhir.ml"
+# 9843 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_exists =
# 245 "parser_cocci_menhir.mly"
( Ast.ReverseForall )
-# 9868 "parser_cocci_menhir.ml"
+# 9869 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_exists =
# 246 "parser_cocci_menhir.mly"
( Ast.Undetermined )
-# 9885 "parser_cocci_menhir.ml"
+# 9886 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_expr =
-# 1202 "parser_cocci_menhir.mly"
+# 1203 "parser_cocci_menhir.mly"
( _1 )
-# 9909 "parser_cocci_menhir.ml"
+# 9910 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_r_ in
let _endpos = _endpos_r_ in
let _v : 'tv_expr_dots_TEllipsis_ =
-# 1384 "parser_cocci_menhir.mly"
+# 1385 "parser_cocci_menhir.mly"
( r )
-# 9933 "parser_cocci_menhir.ml"
+# 9934 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_extends =
# 216 "parser_cocci_menhir.mly"
( () )
-# 9950 "parser_cocci_menhir.ml"
+# 9951 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let parent : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 9975 "parser_cocci_menhir.ml"
+# 9976 "parser_cocci_menhir.ml"
) = Obj.magic parent in
let _startpos = _startpos__1_ in
let _endpos = _endpos_parent_ in
let _v : 'tv_extends =
# 218 "parser_cocci_menhir.mly"
( !Data.install_bindings (parent) )
-# 9982 "parser_cocci_menhir.ml"
+# 9983 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 83 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 10008 "parser_cocci_menhir.ml"
+# 10009 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 83 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 10013 "parser_cocci_menhir.ml"
+# 10014 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
( [Ast0.wrap
(Ast0.FILEINFO(P.id2mcode _1,
P.id2mcode _2))] )
-# 10022 "parser_cocci_menhir.ml"
+# 10023 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_fn_ctype =
# 581 "parser_cocci_menhir.mly"
( P.pointerify ty m )
-# 10052 "parser_cocci_menhir.ml"
+# 10053 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let t : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 10079 "parser_cocci_menhir.ml"
+# 10080 "parser_cocci_menhir.ml"
) = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_m_ in
( P.pointerify
(Ast0.wrap(Ast0.BaseType(Ast.VoidType,[P.clt2mcode "void" t])))
m )
-# 10088 "parser_cocci_menhir.ml"
+# 10089 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fninfo =
-# 776 "parser_cocci_menhir.mly"
+# 777 "parser_cocci_menhir.mly"
( [] )
-# 10105 "parser_cocci_menhir.ml"
+# 10106 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo =
-# 778 "parser_cocci_menhir.mly"
+# 779 "parser_cocci_menhir.mly"
( try
let _ =
List.find (function Ast0.FStorage(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "duplicate storage")
with Not_found -> (Ast0.FStorage(_1))::_2 )
-# 10139 "parser_cocci_menhir.ml"
+# 10140 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_t_ in
let _endpos = _endpos_r_ in
let _v : 'tv_fninfo =
-# 783 "parser_cocci_menhir.mly"
+# 784 "parser_cocci_menhir.mly"
( (Ast0.FType(t))::r )
-# 10169 "parser_cocci_menhir.ml"
+# 10170 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 10196 "parser_cocci_menhir.ml"
+# 10197 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo =
-# 785 "parser_cocci_menhir.mly"
+# 786 "parser_cocci_menhir.mly"
( try
let _ = List.find (function Ast0.FInline(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "duplicate inline")
with Not_found -> (Ast0.FInline(P.clt2mcode "inline" _1))::_2 )
-# 10206 "parser_cocci_menhir.ml"
+# 10207 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 55 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 10233 "parser_cocci_menhir.ml"
+# 10234 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo =
-# 790 "parser_cocci_menhir.mly"
+# 791 "parser_cocci_menhir.mly"
( try
let _ = List.find (function Ast0.FAttr(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "multiple attributes")
with Not_found -> (Ast0.FAttr(P.id2mcode _1))::_2 )
-# 10243 "parser_cocci_menhir.ml"
+# 10244 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fninfo_nt =
-# 796 "parser_cocci_menhir.mly"
+# 797 "parser_cocci_menhir.mly"
( [] )
-# 10260 "parser_cocci_menhir.ml"
+# 10261 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo_nt =
-# 798 "parser_cocci_menhir.mly"
+# 799 "parser_cocci_menhir.mly"
( try
let _ =
List.find (function Ast0.FStorage(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "duplicate storage")
with Not_found -> (Ast0.FStorage(_1))::_2 )
-# 10294 "parser_cocci_menhir.ml"
+# 10295 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 10321 "parser_cocci_menhir.ml"
+# 10322 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo_nt =
-# 804 "parser_cocci_menhir.mly"
+# 805 "parser_cocci_menhir.mly"
( try
let _ = List.find (function Ast0.FInline(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "duplicate inline")
with Not_found -> (Ast0.FInline(P.clt2mcode "inline" _1))::_2 )
-# 10331 "parser_cocci_menhir.ml"
+# 10332 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 55 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 10358 "parser_cocci_menhir.ml"
+# 10359 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fninfo_nt =
-# 809 "parser_cocci_menhir.mly"
+# 810 "parser_cocci_menhir.mly"
( try
let _ = List.find (function Ast0.FAttr(_) -> true | _ -> false) _2 in
raise (Semantic_cocci.Semantic "duplicate init")
with Not_found -> (Ast0.FAttr(P.id2mcode _1))::_2 )
-# 10368 "parser_cocci_menhir.ml"
+# 10369 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fun_after_dots =
-# 1700 "parser_cocci_menhir.mly"
+# 1701 "parser_cocci_menhir.mly"
([])
-# 10385 "parser_cocci_menhir.ml"
+# 10386 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots =
-# 1701 "parser_cocci_menhir.mly"
+# 1702 "parser_cocci_menhir.mly"
(_2)
-# 10413 "parser_cocci_menhir.ml"
+# 10414 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots =
-# 1702 "parser_cocci_menhir.mly"
+# 1703 "parser_cocci_menhir.mly"
(Ast0.wrap(Ast0.Exp(_1))::_2)
-# 10443 "parser_cocci_menhir.ml"
+# 10444 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots =
-# 1703 "parser_cocci_menhir.mly"
+# 1704 "parser_cocci_menhir.mly"
(_1@_2)
-# 10473 "parser_cocci_menhir.ml"
+# 10474 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fun_after_dots_or =
-# 1710 "parser_cocci_menhir.mly"
+# 1711 "parser_cocci_menhir.mly"
([])
-# 10490 "parser_cocci_menhir.ml"
+# 10491 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots_or =
-# 1711 "parser_cocci_menhir.mly"
+# 1712 "parser_cocci_menhir.mly"
(_2)
-# 10518 "parser_cocci_menhir.ml"
+# 10519 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots_or =
-# 1712 "parser_cocci_menhir.mly"
+# 1713 "parser_cocci_menhir.mly"
(Ast0.wrap(Ast0.Exp(_1))::_2)
-# 10548 "parser_cocci_menhir.ml"
+# 10549 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_dots_or =
-# 1713 "parser_cocci_menhir.mly"
+# 1714 "parser_cocci_menhir.mly"
(_1@_2)
-# 10578 "parser_cocci_menhir.ml"
+# 10579 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_exp =
-# 1706 "parser_cocci_menhir.mly"
+# 1707 "parser_cocci_menhir.mly"
(_1::_2)
-# 10608 "parser_cocci_menhir.ml"
+# 10609 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fun_after_exp_or =
-# 1716 "parser_cocci_menhir.mly"
+# 1717 "parser_cocci_menhir.mly"
([])
-# 10625 "parser_cocci_menhir.ml"
+# 10626 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_exp_or =
-# 1717 "parser_cocci_menhir.mly"
+# 1718 "parser_cocci_menhir.mly"
(_1::_2)
-# 10655 "parser_cocci_menhir.ml"
+# 10656 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_fun_after_stm =
-# 1695 "parser_cocci_menhir.mly"
+# 1696 "parser_cocci_menhir.mly"
([])
-# 10672 "parser_cocci_menhir.ml"
+# 10673 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_stm =
-# 1696 "parser_cocci_menhir.mly"
+# 1697 "parser_cocci_menhir.mly"
(_1::_2)
-# 10702 "parser_cocci_menhir.ml"
+# 10703 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_fun_after_stm =
-# 1697 "parser_cocci_menhir.mly"
+# 1698 "parser_cocci_menhir.mly"
(_1@_2)
-# 10732 "parser_cocci_menhir.ml"
+# 10733 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_fun_start =
-# 1692 "parser_cocci_menhir.mly"
+# 1693 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS(_1)) )
-# 10756 "parser_cocci_menhir.ml"
+# 10757 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_func_ident =
-# 1496 "parser_cocci_menhir.mly"
+# 1497 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Id(P.id2mcode _1)) )
-# 10780 "parser_cocci_menhir.ml"
+# 10781 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 61 "parser_cocci_menhir.mly"
(Parse_aux.idinfo)
-# 10801 "parser_cocci_menhir.ml"
+# 10802 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_func_ident =
-# 1498 "parser_cocci_menhir.mly"
+# 1499 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaId(P.clt2mcode nm clt,constraints,pure)) )
-# 10809 "parser_cocci_menhir.ml"
+# 10810 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 61 "parser_cocci_menhir.mly"
(Parse_aux.idinfo)
-# 10830 "parser_cocci_menhir.ml"
+# 10831 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_func_ident =
-# 1501 "parser_cocci_menhir.mly"
+# 1502 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaFunc(P.clt2mcode nm clt,constraints,pure)) )
-# 10838 "parser_cocci_menhir.ml"
+# 10839 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 61 "parser_cocci_menhir.mly"
(Parse_aux.idinfo)
-# 10859 "parser_cocci_menhir.ml"
+# 10860 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_func_ident =
-# 1504 "parser_cocci_menhir.mly"
+# 1505 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap
(Ast0.MetaLocalFunc(P.clt2mcode nm clt,constraints,pure)) )
-# 10868 "parser_cocci_menhir.ml"
+# 10869 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rb : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 10928 "parser_cocci_menhir.ml"
+# 10929 "parser_cocci_menhir.ml"
) = Obj.magic rb in
let b : 'tv_fun_start = Obj.magic b in
let lb : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 10934 "parser_cocci_menhir.ml"
+# 10935 "parser_cocci_menhir.ml"
) = Obj.magic lb in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 10939 "parser_cocci_menhir.ml"
+# 10940 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let d : 'tv_decl_list_decl_ = Obj.magic d in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 10945 "parser_cocci_menhir.ml"
+# 10946 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let i : 'tv_func_ident = Obj.magic i in
let f : 'tv_fninfo = Obj.magic f in
let _startpos = _startpos_f_ in
let _endpos = _endpos_rb_ in
let _v : 'tv_fundecl =
-# 768 "parser_cocci_menhir.mly"
+# 769 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.FunDecl((Ast0.default_info(),Ast0.context_befaft()),
f, i,
P.clt2mcode "(" lp, d,
P.clt2mcode ")" rp,
P.clt2mcode "{" lb, b,
P.clt2mcode "}" rb)) )
-# 10959 "parser_cocci_menhir.ml"
+# 10960 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pt : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 11005 "parser_cocci_menhir.ml"
+# 11006 "parser_cocci_menhir.ml"
) = Obj.magic pt in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 11010 "parser_cocci_menhir.ml"
+# 11011 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let d : 'tv_decl_list_name_opt_decl_ = Obj.magic d in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 11016 "parser_cocci_menhir.ml"
+# 11017 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let id : 'tv_func_ident = Obj.magic id in
let t : 'tv_ctype = Obj.magic t in
# 39 "standard.mly"
( None )
-# 11026 "parser_cocci_menhir.ml"
+# 11027 "parser_cocci_menhir.ml"
in
-# 745 "parser_cocci_menhir.mly"
+# 746 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.UnInit
(s,
(Ast0.FunctionType(Some t,
P.clt2mcode "(" lp, d, P.clt2mcode ")" rp)),
id, P.clt2mcode ";" pt)) )
-# 11038 "parser_cocci_menhir.ml"
+# 11039 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pt : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 11089 "parser_cocci_menhir.ml"
+# 11090 "parser_cocci_menhir.ml"
) = Obj.magic pt in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 11094 "parser_cocci_menhir.ml"
+# 11095 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let d : 'tv_decl_list_name_opt_decl_ = Obj.magic d in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 11100 "parser_cocci_menhir.ml"
+# 11101 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let id : 'tv_func_ident = Obj.magic id in
let t : 'tv_ctype = Obj.magic t in
# 41 "standard.mly"
( Some x )
-# 11112 "parser_cocci_menhir.ml"
+# 11113 "parser_cocci_menhir.ml"
in
-# 745 "parser_cocci_menhir.mly"
+# 746 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.UnInit
(s,
(Ast0.FunctionType(Some t,
P.clt2mcode "(" lp, d, P.clt2mcode ")" rp)),
id, P.clt2mcode ";" pt)) )
-# 11124 "parser_cocci_menhir.ml"
+# 11125 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pt : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 11170 "parser_cocci_menhir.ml"
+# 11171 "parser_cocci_menhir.ml"
) = Obj.magic pt in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 11175 "parser_cocci_menhir.ml"
+# 11176 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let d : 'tv_decl_list_name_opt_decl_ = Obj.magic d in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 11181 "parser_cocci_menhir.ml"
+# 11182 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let id : 'tv_func_ident = Obj.magic id in
let t : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 11187 "parser_cocci_menhir.ml"
+# 11188 "parser_cocci_menhir.ml"
) = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_pt_ in
# 39 "standard.mly"
( None )
-# 11195 "parser_cocci_menhir.ml"
+# 11196 "parser_cocci_menhir.ml"
in
-# 754 "parser_cocci_menhir.mly"
+# 755 "parser_cocci_menhir.mly"
( let t = Ast0.wrap(Ast0.BaseType(Ast.VoidType,[P.clt2mcode "void" t])) in
Ast0.wrap
(Ast0.UnInit
(Ast0.FunctionType(Some t,
P.clt2mcode "(" lp, d, P.clt2mcode ")" rp)),
id, P.clt2mcode ";" pt)) )
-# 11208 "parser_cocci_menhir.ml"
+# 11209 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pt : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 11259 "parser_cocci_menhir.ml"
+# 11260 "parser_cocci_menhir.ml"
) = Obj.magic pt in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 11264 "parser_cocci_menhir.ml"
+# 11265 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let d : 'tv_decl_list_name_opt_decl_ = Obj.magic d in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 11270 "parser_cocci_menhir.ml"
+# 11271 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let id : 'tv_func_ident = Obj.magic id in
let t : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 11276 "parser_cocci_menhir.ml"
+# 11277 "parser_cocci_menhir.ml"
) = Obj.magic t in
let x0 : 'tv_storage = Obj.magic x0 in
let _startpos = _startpos_x0_ in
# 41 "standard.mly"
( Some x )
-# 11286 "parser_cocci_menhir.ml"
+# 11287 "parser_cocci_menhir.ml"
in
-# 754 "parser_cocci_menhir.mly"
+# 755 "parser_cocci_menhir.mly"
( let t = Ast0.wrap(Ast0.BaseType(Ast.VoidType,[P.clt2mcode "void" t])) in
Ast0.wrap
(Ast0.UnInit
(Ast0.FunctionType(Some t,
P.clt2mcode "(" lp, d, P.clt2mcode ")" rp)),
id, P.clt2mcode ";" pt)) )
-# 11299 "parser_cocci_menhir.ml"
+# 11300 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let r0 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11320 "parser_cocci_menhir.ml"
+# 11321 "parser_cocci_menhir.ml"
) = Obj.magic r0 in
let _startpos = _startpos_r0_ in
let _endpos = _endpos_r0_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 11329 "parser_cocci_menhir.ml"
+# 11330 "parser_cocci_menhir.ml"
in
# 513 "parser_cocci_menhir.mly"
( q None )
-# 11335 "parser_cocci_menhir.ml"
+# 11336 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let r0 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11356 "parser_cocci_menhir.ml"
+# 11357 "parser_cocci_menhir.ml"
) = Obj.magic r0 in
let _startpos = _startpos_r0_ in
let _endpos = _endpos_r0_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 11365 "parser_cocci_menhir.ml"
+# 11366 "parser_cocci_menhir.ml"
in
# 513 "parser_cocci_menhir.mly"
( q None )
-# 11371 "parser_cocci_menhir.ml"
+# 11372 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_generic_ctype =
# 514 "parser_cocci_menhir.mly"
( _1 )
-# 11395 "parser_cocci_menhir.ml"
+# 11396 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11421 "parser_cocci_menhir.ml"
+# 11422 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11426 "parser_cocci_menhir.ml"
+# 11427 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 11437 "parser_cocci_menhir.ml"
+# 11438 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11443 "parser_cocci_menhir.ml"
+# 11444 "parser_cocci_menhir.ml"
in
# 466 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.CharType,[P.clt2mcode "char" ty]))) )
-# 11449 "parser_cocci_menhir.ml"
+# 11450 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11475 "parser_cocci_menhir.ml"
+# 11476 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11480 "parser_cocci_menhir.ml"
+# 11481 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 11491 "parser_cocci_menhir.ml"
+# 11492 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11497 "parser_cocci_menhir.ml"
+# 11498 "parser_cocci_menhir.ml"
in
# 466 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.CharType,[P.clt2mcode "char" ty]))) )
-# 11503 "parser_cocci_menhir.ml"
+# 11504 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11524 "parser_cocci_menhir.ml"
+# 11525 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let _startpos = _startpos_ty_ in
let _endpos = _endpos_ty_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 11532 "parser_cocci_menhir.ml"
+# 11533 "parser_cocci_menhir.ml"
in
# 466 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.CharType,[P.clt2mcode "char" ty]))) )
-# 11538 "parser_cocci_menhir.ml"
+# 11539 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11564 "parser_cocci_menhir.ml"
+# 11565 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11569 "parser_cocci_menhir.ml"
+# 11570 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 11580 "parser_cocci_menhir.ml"
+# 11581 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11586 "parser_cocci_menhir.ml"
+# 11587 "parser_cocci_menhir.ml"
in
# 468 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.ShortType,[P.clt2mcode "short" ty]))))
-# 11592 "parser_cocci_menhir.ml"
+# 11593 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11618 "parser_cocci_menhir.ml"
+# 11619 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11623 "parser_cocci_menhir.ml"
+# 11624 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 11634 "parser_cocci_menhir.ml"
+# 11635 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11640 "parser_cocci_menhir.ml"
+# 11641 "parser_cocci_menhir.ml"
in
# 468 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.ShortType,[P.clt2mcode "short" ty]))))
-# 11646 "parser_cocci_menhir.ml"
+# 11647 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11667 "parser_cocci_menhir.ml"
+# 11668 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let _startpos = _startpos_ty_ in
let _endpos = _endpos_ty_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 11675 "parser_cocci_menhir.ml"
+# 11676 "parser_cocci_menhir.ml"
in
# 468 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.ShortType,[P.clt2mcode "short" ty]))))
-# 11681 "parser_cocci_menhir.ml"
+# 11682 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11707 "parser_cocci_menhir.ml"
+# 11708 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11712 "parser_cocci_menhir.ml"
+# 11713 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 11723 "parser_cocci_menhir.ml"
+# 11724 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11729 "parser_cocci_menhir.ml"
+# 11730 "parser_cocci_menhir.ml"
in
# 470 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.IntType,[P.clt2mcode "int" ty]))) )
-# 11735 "parser_cocci_menhir.ml"
+# 11736 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11761 "parser_cocci_menhir.ml"
+# 11762 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11766 "parser_cocci_menhir.ml"
+# 11767 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 11777 "parser_cocci_menhir.ml"
+# 11778 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11783 "parser_cocci_menhir.ml"
+# 11784 "parser_cocci_menhir.ml"
in
# 470 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.IntType,[P.clt2mcode "int" ty]))) )
-# 11789 "parser_cocci_menhir.ml"
+# 11790 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11810 "parser_cocci_menhir.ml"
+# 11811 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let _startpos = _startpos_ty_ in
let _endpos = _endpos_ty_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 11818 "parser_cocci_menhir.ml"
+# 11819 "parser_cocci_menhir.ml"
in
# 470 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.IntType,[P.clt2mcode "int" ty]))) )
-# 11824 "parser_cocci_menhir.ml"
+# 11825 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let t : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11845 "parser_cocci_menhir.ml"
+# 11846 "parser_cocci_menhir.ml"
) = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_t_ in
let _v : 'tv_generic_ctype_full =
# 472 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.BaseType(Ast.DoubleType,[P.clt2mcode "double" t])) )
-# 11852 "parser_cocci_menhir.ml"
+# 11853 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let t : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11873 "parser_cocci_menhir.ml"
+# 11874 "parser_cocci_menhir.ml"
) = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_t_ in
let _v : 'tv_generic_ctype_full =
# 474 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.BaseType(Ast.FloatType,[P.clt2mcode "float" t])) )
-# 11880 "parser_cocci_menhir.ml"
+# 11881 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11906 "parser_cocci_menhir.ml"
+# 11907 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11911 "parser_cocci_menhir.ml"
+# 11912 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 11922 "parser_cocci_menhir.ml"
+# 11923 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11928 "parser_cocci_menhir.ml"
+# 11929 "parser_cocci_menhir.ml"
in
# 476 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.LongType,[P.clt2mcode "long" ty]))) )
-# 11934 "parser_cocci_menhir.ml"
+# 11935 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 11960 "parser_cocci_menhir.ml"
+# 11961 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 11965 "parser_cocci_menhir.ml"
+# 11966 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 11976 "parser_cocci_menhir.ml"
+# 11977 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 11982 "parser_cocci_menhir.ml"
+# 11983 "parser_cocci_menhir.ml"
in
# 476 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.LongType,[P.clt2mcode "long" ty]))) )
-# 11988 "parser_cocci_menhir.ml"
+# 11989 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12009 "parser_cocci_menhir.ml"
+# 12010 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let _startpos = _startpos_ty_ in
let _endpos = _endpos_ty_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 12017 "parser_cocci_menhir.ml"
+# 12018 "parser_cocci_menhir.ml"
in
# 476 "parser_cocci_menhir.mly"
( q (Ast0.wrap(Ast0.BaseType(Ast.LongType,[P.clt2mcode "long" ty]))) )
-# 12023 "parser_cocci_menhir.ml"
+# 12024 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty1 : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12054 "parser_cocci_menhir.ml"
+# 12055 "parser_cocci_menhir.ml"
) = Obj.magic ty1 in
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12059 "parser_cocci_menhir.ml"
+# 12060 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 12064 "parser_cocci_menhir.ml"
+# 12065 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty1_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 12075 "parser_cocci_menhir.ml"
+# 12076 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 12081 "parser_cocci_menhir.ml"
+# 12082 "parser_cocci_menhir.ml"
in
(Ast0.BaseType
(Ast.LongLongType,
[P.clt2mcode "long" ty;P.clt2mcode "long" ty1]))) )
-# 12090 "parser_cocci_menhir.ml"
+# 12091 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty1 : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12121 "parser_cocci_menhir.ml"
+# 12122 "parser_cocci_menhir.ml"
) = Obj.magic ty1 in
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12126 "parser_cocci_menhir.ml"
+# 12127 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 12131 "parser_cocci_menhir.ml"
+# 12132 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_ty1_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 12142 "parser_cocci_menhir.ml"
+# 12143 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 12148 "parser_cocci_menhir.ml"
+# 12149 "parser_cocci_menhir.ml"
in
(Ast0.BaseType
(Ast.LongLongType,
[P.clt2mcode "long" ty;P.clt2mcode "long" ty1]))) )
-# 12157 "parser_cocci_menhir.ml"
+# 12158 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty1 : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12183 "parser_cocci_menhir.ml"
+# 12184 "parser_cocci_menhir.ml"
) = Obj.magic ty1 in
let ty : (
# 49 "parser_cocci_menhir.mly"
(Data.clt)
-# 12188 "parser_cocci_menhir.ml"
+# 12189 "parser_cocci_menhir.ml"
) = Obj.magic ty in
let _startpos = _startpos_ty_ in
let _endpos = _endpos_ty1_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 12196 "parser_cocci_menhir.ml"
+# 12197 "parser_cocci_menhir.ml"
in
(Ast0.BaseType
(Ast.LongLongType,
[P.clt2mcode "long" ty;P.clt2mcode "long" ty1]))) )
-# 12205 "parser_cocci_menhir.ml"
+# 12206 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 12232 "parser_cocci_menhir.ml"
+# 12233 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_i_ in
let _v : 'tv_generic_ctype_full =
# 483 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.EnumName(P.clt2mcode "enum" s, i)) )
-# 12239 "parser_cocci_menhir.ml"
+# 12240 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_generic_ctype_full =
# 485 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.StructUnionName(s, Some i)) )
-# 12269 "parser_cocci_menhir.ml"
+# 12270 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let r : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12305 "parser_cocci_menhir.ml"
+# 12306 "parser_cocci_menhir.ml"
) = Obj.magic r in
let d : 'tv_struct_decl_list = Obj.magic d in
let l : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12311 "parser_cocci_menhir.ml"
+# 12312 "parser_cocci_menhir.ml"
) = Obj.magic l in
let s : 'tv_struct_or_union = Obj.magic s in
let _startpos = _startpos_s_ in
# 39 "standard.mly"
( None )
-# 12320 "parser_cocci_menhir.ml"
+# 12321 "parser_cocci_menhir.ml"
in
Ast0.wrap(Ast0.StructUnionDef(Ast0.wrap(Ast0.StructUnionName(s, i)),
P.clt2mcode "{" l,
d, P.clt2mcode "}" r)) )
-# 12330 "parser_cocci_menhir.ml"
+# 12331 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let r : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12371 "parser_cocci_menhir.ml"
+# 12372 "parser_cocci_menhir.ml"
) = Obj.magic r in
let d : 'tv_struct_decl_list = Obj.magic d in
let l : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12377 "parser_cocci_menhir.ml"
+# 12378 "parser_cocci_menhir.ml"
) = Obj.magic l in
let x0 : 'tv_ident = Obj.magic x0 in
let s : 'tv_struct_or_union = Obj.magic s in
# 41 "standard.mly"
( Some x )
-# 12388 "parser_cocci_menhir.ml"
+# 12389 "parser_cocci_menhir.ml"
in
Ast0.wrap(Ast0.StructUnionDef(Ast0.wrap(Ast0.StructUnionName(s, i)),
P.clt2mcode "{" l,
d, P.clt2mcode "}" r)) )
-# 12398 "parser_cocci_menhir.ml"
+# 12399 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let r : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12434 "parser_cocci_menhir.ml"
+# 12435 "parser_cocci_menhir.ml"
) = Obj.magic r in
let d : 'tv_struct_decl_list = Obj.magic d in
let l : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 12440 "parser_cocci_menhir.ml"
+# 12441 "parser_cocci_menhir.ml"
) = Obj.magic l in
let s : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 12445 "parser_cocci_menhir.ml"
+# 12446 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_r_ in
Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure)) in
Ast0.wrap
(Ast0.StructUnionDef(ty,P.clt2mcode "{" l,d,P.clt2mcode "}" r)) )
-# 12456 "parser_cocci_menhir.ml"
+# 12457 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let p : (
# 59 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12486 "parser_cocci_menhir.ml"
+# 12487 "parser_cocci_menhir.ml"
) = Obj.magic p in
let r : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 12491 "parser_cocci_menhir.ml"
+# 12492 "parser_cocci_menhir.ml"
) = Obj.magic r in
let _startpos = _startpos_r_ in
let _endpos = _endpos_p_ in
let _ = P.check_meta(Ast.MetaTypeDecl(Ast.NONE,nm)) in
Ast0.wrap(Ast0.MetaType(P.clt2mcode nm (P.id2clt p),
Ast0.Impure (*will be ignored*))) )
-# 12503 "parser_cocci_menhir.ml"
+# 12504 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let p : (
# 59 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12524 "parser_cocci_menhir.ml"
+# 12525 "parser_cocci_menhir.ml"
) = Obj.magic p in
let _startpos = _startpos_p_ in
let _endpos = _endpos_p_ in
let _v : 'tv_generic_ctype_full =
# 507 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.TypeName(P.id2mcode p)) )
-# 12531 "parser_cocci_menhir.ml"
+# 12532 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let p : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 12557 "parser_cocci_menhir.ml"
+# 12558 "parser_cocci_menhir.ml"
) = Obj.magic p in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 12562 "parser_cocci_menhir.ml"
+# 12563 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_p_ in
# 589 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Unsigned r,x)) )
-# 12573 "parser_cocci_menhir.ml"
+# 12574 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 12579 "parser_cocci_menhir.ml"
+# 12580 "parser_cocci_menhir.ml"
in
# 509 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = p in
q (Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure))) )
-# 12586 "parser_cocci_menhir.ml"
+# 12587 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let p : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 12612 "parser_cocci_menhir.ml"
+# 12613 "parser_cocci_menhir.ml"
) = Obj.magic p in
let r00 : (
# 51 "parser_cocci_menhir.mly"
(Data.clt)
-# 12617 "parser_cocci_menhir.ml"
+# 12618 "parser_cocci_menhir.ml"
) = Obj.magic r00 in
let _startpos = _startpos_r00_ in
let _endpos = _endpos_p_ in
# 591 "parser_cocci_menhir.mly"
( function x -> Ast0.wrap(Ast0.Signed(P.clt2mcode Ast.Signed r,x)) )
-# 12628 "parser_cocci_menhir.ml"
+# 12629 "parser_cocci_menhir.ml"
in
# 594 "parser_cocci_menhir.mly"
( function x -> s (Some x) )
-# 12634 "parser_cocci_menhir.ml"
+# 12635 "parser_cocci_menhir.ml"
in
# 509 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = p in
q (Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure))) )
-# 12641 "parser_cocci_menhir.ml"
+# 12642 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let p : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 12662 "parser_cocci_menhir.ml"
+# 12663 "parser_cocci_menhir.ml"
) = Obj.magic p in
let _startpos = _startpos_p_ in
let _endpos = _endpos_p_ in
# 595 "parser_cocci_menhir.mly"
( function x -> x )
-# 12670 "parser_cocci_menhir.ml"
+# 12671 "parser_cocci_menhir.ml"
in
# 509 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = p in
q (Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure))) )
-# 12677 "parser_cocci_menhir.ml"
+# 12678 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_ident =
-# 1509 "parser_cocci_menhir.mly"
+# 1510 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Id(P.id2mcode _1)) )
-# 12701 "parser_cocci_menhir.ml"
+# 12702 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 61 "parser_cocci_menhir.mly"
(Parse_aux.idinfo)
-# 12722 "parser_cocci_menhir.ml"
+# 12723 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_ident =
-# 1511 "parser_cocci_menhir.mly"
+# 1512 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaId(P.clt2mcode nm clt,constraints,pure)) )
-# 12730 "parser_cocci_menhir.ml"
+# 12731 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_i_ in
let _endpos = _endpos_i_ in
let _v : 'tv_ident_or_const =
-# 1463 "parser_cocci_menhir.mly"
+# 1464 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Ident(Ast0.wrap(Ast0.Id(P.id2mcode i)))) )
-# 12754 "parser_cocci_menhir.ml"
+# 12755 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12775 "parser_cocci_menhir.ml"
+# 12776 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_ident_or_const =
-# 1465 "parser_cocci_menhir.mly"
+# 1466 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Int x) clt)) )
-# 12783 "parser_cocci_menhir.ml"
+# 12784 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12808 "parser_cocci_menhir.ml"
+# 12809 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_incl =
# 257 "parser_cocci_menhir.mly"
( Common.Left(P.id2name _2) )
-# 12815 "parser_cocci_menhir.ml"
+# 12816 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 79 "parser_cocci_menhir.mly"
(string)
-# 12840 "parser_cocci_menhir.ml"
+# 12841 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_incl =
# 258 "parser_cocci_menhir.mly"
( Common.Right _2 )
-# 12847 "parser_cocci_menhir.ml"
+# 12848 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 146 "parser_cocci_menhir.mly"
((string,string) Common.either list)
-# 12875 "parser_cocci_menhir.ml"
+# 12876 "parser_cocci_menhir.ml"
) =
# 253 "parser_cocci_menhir.mly"
( _1 )
-# 12879 "parser_cocci_menhir.ml"
+# 12880 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 146 "parser_cocci_menhir.mly"
((string,string) Common.either list)
-# 12907 "parser_cocci_menhir.ml"
+# 12908 "parser_cocci_menhir.ml"
) =
# 254 "parser_cocci_menhir.mly"
( _1 )
-# 12911 "parser_cocci_menhir.ml"
+# 12912 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 80 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12932 "parser_cocci_menhir.ml"
+# 12933 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
P.clt2mcode
(Ast.Local (Parse_aux.str2inc (P.id2name _1)))
(P.drop_bef clt))) )
-# 12947 "parser_cocci_menhir.ml"
+# 12948 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 80 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 12968 "parser_cocci_menhir.ml"
+# 12969 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
P.clt2mcode
(Ast.NonLocal (Parse_aux.str2inc (P.id2name _1)))
(P.drop_bef clt))) )
-# 12983 "parser_cocci_menhir.ml"
+# 12984 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 658 "parser_cocci_menhir.mly"
( let ty = Ast0.wrap(Ast0.TopExp(Ast0.wrap(Ast0.TypeExp(t)))) in
d (Ast0.wrap(Ast0.DOTS([ty]))) )
-# 13018 "parser_cocci_menhir.ml"
+# 13019 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
| _ -> b)
| _ -> b in
_1 (Ast0.wrap(Ast0.DOTS(body))) )
-# 13060 "parser_cocci_menhir.ml"
+# 13061 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_initialize =
-# 1074 "parser_cocci_menhir.mly"
+# 1075 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitExpr(_1)) )
-# 13084 "parser_cocci_menhir.ml"
+# 13085 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13115 "parser_cocci_menhir.ml"
+# 13116 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_initialize_list = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13121 "parser_cocci_menhir.ml"
+# 13122 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_initialize =
-# 1076 "parser_cocci_menhir.mly"
+# 1077 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitList(P.clt2mcode "{" _1,_2,P.clt2mcode "}" _3)) )
-# 13128 "parser_cocci_menhir.ml"
+# 13129 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13154 "parser_cocci_menhir.ml"
+# 13155 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13159 "parser_cocci_menhir.ml"
+# 13160 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_initialize =
-# 1078 "parser_cocci_menhir.mly"
+# 1079 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.InitList(P.clt2mcode "{" _1,Ast0.wrap(Ast0.DOTS []),
P.clt2mcode "}" _2)) )
-# 13168 "parser_cocci_menhir.ml"
+# 13169 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 65 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 13189 "parser_cocci_menhir.ml"
+# 13190 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_initialize =
-# 1082 "parser_cocci_menhir.mly"
+# 1083 "parser_cocci_menhir.mly"
(let (nm,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaInit(P.clt2mcode nm clt,pure)) )
-# 13197 "parser_cocci_menhir.ml"
+# 13198 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_initialize2 =
-# 1088 "parser_cocci_menhir.mly"
+# 1089 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitExpr(_1)) )
-# 13221 "parser_cocci_menhir.ml"
+# 13222 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13252 "parser_cocci_menhir.ml"
+# 13253 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_initialize_list = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13258 "parser_cocci_menhir.ml"
+# 13259 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_initialize2 =
-# 1090 "parser_cocci_menhir.mly"
+# 1091 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitList(P.clt2mcode "{" _1,_2,P.clt2mcode "}" _3)) )
-# 13265 "parser_cocci_menhir.ml"
+# 13266 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13291 "parser_cocci_menhir.ml"
+# 13292 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 13296 "parser_cocci_menhir.ml"
+# 13297 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_initialize2 =
-# 1092 "parser_cocci_menhir.mly"
+# 1093 "parser_cocci_menhir.mly"
( Ast0.wrap
(Ast0.InitList(P.clt2mcode "{" _1,Ast0.wrap(Ast0.DOTS []),
P.clt2mcode "}" _2)) )
-# 13305 "parser_cocci_menhir.ml"
+# 13306 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 13337 "parser_cocci_menhir.ml"
+# 13338 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_list_designator_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_initialize2 =
-# 1097 "parser_cocci_menhir.mly"
+# 1098 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitGccExt(_1,P.clt2mcode "=" _2,_3)) )
-# 13345 "parser_cocci_menhir.ml"
+# 13346 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 13377 "parser_cocci_menhir.ml"
+# 13378 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_ident = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_initialize2 =
-# 1099 "parser_cocci_menhir.mly"
+# 1100 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitGccName(_1,P.clt2mcode ":" _2,_3)) )
-# 13385 "parser_cocci_menhir.ml"
+# 13386 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_initialize_list =
-# 1111 "parser_cocci_menhir.mly"
+# 1112 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS(_1)) )
-# 13409 "parser_cocci_menhir.ml"
+# 13410 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 13435 "parser_cocci_menhir.ml"
+# 13436 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_initialize2 = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_initialize_list_start =
-# 1114 "parser_cocci_menhir.mly"
+# 1115 "parser_cocci_menhir.mly"
( [_1;Ast0.wrap(Ast0.IComma(P.clt2mcode "," _2))] )
-# 13443 "parser_cocci_menhir.ml"
+# 13444 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 13475 "parser_cocci_menhir.ml"
+# 13476 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_initialize2 = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_initialize_list_start =
-# 1116 "parser_cocci_menhir.mly"
+# 1117 "parser_cocci_menhir.mly"
( _1::Ast0.wrap(Ast0.IComma(P.clt2mcode "," _2))::_3 )
-# 13483 "parser_cocci_menhir.ml"
+# 13484 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_d_ in
let _endpos = _endpos_r_ in
let _v : 'tv_initialize_list_start =
-# 1119 "parser_cocci_menhir.mly"
+# 1120 "parser_cocci_menhir.mly"
( (P.mkidots "..." d)::
(List.concat(List.map (function x -> x (P.mkidots "...")) r)) )
-# 13514 "parser_cocci_menhir.ml"
+# 13515 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_invalid =
-# 1212 "parser_cocci_menhir.mly"
+# 1213 "parser_cocci_menhir.mly"
( raise (Semantic_cocci.Semantic "not matchable") )
-# 13536 "parser_cocci_menhir.ml"
+# 13537 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_is_expression =
# 249 "parser_cocci_menhir.mly"
( false )
-# 13553 "parser_cocci_menhir.ml"
+# 13554 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_is_expression =
# 250 "parser_cocci_menhir.mly"
( true )
-# 13575 "parser_cocci_menhir.ml"
+# 13576 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_ctype_ =
-# 1860 "parser_cocci_menhir.mly"
+# 1866 "parser_cocci_menhir.mly"
( Common.Left t )
-# 13603 "parser_cocci_menhir.ml"
+# 13604 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_ctype_ =
-# 1861 "parser_cocci_menhir.mly"
+# 1867 "parser_cocci_menhir.mly"
( Common.Right t )
-# 13631 "parser_cocci_menhir.ml"
+# 13632 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_decl_var_ =
-# 1860 "parser_cocci_menhir.mly"
+# 1866 "parser_cocci_menhir.mly"
( Common.Left t )
-# 13659 "parser_cocci_menhir.ml"
+# 13660 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_decl_var_ =
-# 1861 "parser_cocci_menhir.mly"
+# 1867 "parser_cocci_menhir.mly"
( Common.Right t )
-# 13687 "parser_cocci_menhir.ml"
+# 13688 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_dexpr_ =
-# 1860 "parser_cocci_menhir.mly"
+# 1866 "parser_cocci_menhir.mly"
( Common.Left t )
-# 13715 "parser_cocci_menhir.ml"
+# 13716 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_dexpr_ =
-# 1861 "parser_cocci_menhir.mly"
+# 1867 "parser_cocci_menhir.mly"
( Common.Right t )
-# 13743 "parser_cocci_menhir.ml"
+# 13744 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_nest_start_ =
-# 1860 "parser_cocci_menhir.mly"
+# 1866 "parser_cocci_menhir.mly"
( Common.Left t )
-# 13771 "parser_cocci_menhir.ml"
+# 13772 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_nest_start_ =
-# 1861 "parser_cocci_menhir.mly"
+# 1867 "parser_cocci_menhir.mly"
( Common.Right t )
-# 13799 "parser_cocci_menhir.ml"
+# 13800 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_single_statement_ =
-# 1860 "parser_cocci_menhir.mly"
+# 1866 "parser_cocci_menhir.mly"
( Common.Left t )
-# 13827 "parser_cocci_menhir.ml"
+# 13828 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_t_ in
let _v : 'tv_iso_single_statement_ =
-# 1861 "parser_cocci_menhir.mly"
+# 1867 "parser_cocci_menhir.mly"
( Common.Right t )
-# 13855 "parser_cocci_menhir.ml"
+# 13856 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 13893 "parser_cocci_menhir.ml"
+# 13894 "parser_cocci_menhir.ml"
) =
-# 1832 "parser_cocci_menhir.mly"
+# 1838 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.ExprTag x) e1 el )
-# 13897 "parser_cocci_menhir.ml"
+# 13898 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 13935 "parser_cocci_menhir.ml"
+# 13936 "parser_cocci_menhir.ml"
) =
-# 1834 "parser_cocci_menhir.mly"
+# 1840 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.ArgExprTag x) e1 el )
-# 13939 "parser_cocci_menhir.ml"
+# 13940 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 13977 "parser_cocci_menhir.ml"
+# 13978 "parser_cocci_menhir.ml"
) =
-# 1836 "parser_cocci_menhir.mly"
+# 1842 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.TestExprTag x) e1 el )
-# 13981 "parser_cocci_menhir.ml"
+# 13982 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 14019 "parser_cocci_menhir.ml"
+# 14020 "parser_cocci_menhir.ml"
) =
-# 1838 "parser_cocci_menhir.mly"
+# 1844 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.StmtTag x) s1 sl )
-# 14023 "parser_cocci_menhir.ml"
+# 14024 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 14061 "parser_cocci_menhir.ml"
+# 14062 "parser_cocci_menhir.ml"
) =
-# 1840 "parser_cocci_menhir.mly"
+# 1846 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.TypeCTag x) t1 tl )
-# 14065 "parser_cocci_menhir.ml"
+# 14066 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 14103 "parser_cocci_menhir.ml"
+# 14104 "parser_cocci_menhir.ml"
) =
-# 1842 "parser_cocci_menhir.mly"
+# 1848 "parser_cocci_menhir.mly"
( P.iso_adjust (function x -> Ast0.DotsStmtTag x) e1 el )
-# 14107 "parser_cocci_menhir.ml"
+# 14108 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 14145 "parser_cocci_menhir.ml"
+# 14146 "parser_cocci_menhir.ml"
) =
-# 1844 "parser_cocci_menhir.mly"
+# 1850 "parser_cocci_menhir.mly"
( let check_one = function
[x] -> x
| _ ->
| Common.Right x -> Common.Right(check_one x))
dl in
P.iso_adjust (function x -> Ast0.DeclTag x) d1 dl )
-# 14162 "parser_cocci_menhir.ml"
+# 14163 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 165 "parser_cocci_menhir.mly"
((Ast_cocci.metavar,Ast_cocci.metavar) Common.either list)
-# 14186 "parser_cocci_menhir.ml"
+# 14187 "parser_cocci_menhir.ml"
) =
# 182 "parser_cocci_menhir.mly"
( m "" )
-# 14190 "parser_cocci_menhir.ml"
+# 14191 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 149 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 14218 "parser_cocci_menhir.ml"
+# 14219 "parser_cocci_menhir.ml"
) =
# 197 "parser_cocci_menhir.mly"
( P.make_iso_rule_name_result (P.id2name nm) )
-# 14222 "parser_cocci_menhir.ml"
+# 14223 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 59 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 14243 "parser_cocci_menhir.ml"
+# 14244 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_iter_ident =
-# 1523 "parser_cocci_menhir.mly"
+# 1524 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Id(P.id2mcode _1)) )
-# 14250 "parser_cocci_menhir.ml"
+# 14251 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 62 "parser_cocci_menhir.mly"
(Parse_aux.idinfo)
-# 14271 "parser_cocci_menhir.ml"
+# 14272 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_iter_ident =
-# 1525 "parser_cocci_menhir.mly"
+# 1526 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaId(P.clt2mcode nm clt,constraints,pure)) )
-# 14279 "parser_cocci_menhir.ml"
+# 14280 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_TMul_ =
# 114 "standard.mly"
( [] )
-# 14296 "parser_cocci_menhir.ml"
+# 14297 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let x : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 14323 "parser_cocci_menhir.ml"
+# 14324 "parser_cocci_menhir.ml"
) = Obj.magic x in
let _startpos = _startpos_x_ in
let _endpos = _endpos_xs_ in
let _v : 'tv_list_TMul_ =
# 116 "standard.mly"
( x :: xs )
-# 14330 "parser_cocci_menhir.ml"
+# 14331 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_array_dec_ =
# 114 "standard.mly"
( [] )
-# 14347 "parser_cocci_menhir.ml"
+# 14348 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_array_dec_ =
# 116 "standard.mly"
( x :: xs )
-# 14377 "parser_cocci_menhir.ml"
+# 14378 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_case_line_ =
# 114 "standard.mly"
( [] )
-# 14394 "parser_cocci_menhir.ml"
+# 14395 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_case_line_ =
# 116 "standard.mly"
( x :: xs )
-# 14424 "parser_cocci_menhir.ml"
+# 14425 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_comma_decls_TEllipsis_decl__ =
# 114 "standard.mly"
( [] )
-# 14441 "parser_cocci_menhir.ml"
+# 14442 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_comma_decls_TEllipsis_decl__ =
# 116 "standard.mly"
( x :: xs )
-# 14471 "parser_cocci_menhir.ml"
+# 14472 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_comma_decls_TEllipsis_name_opt_decl__ =
# 114 "standard.mly"
( [] )
-# 14488 "parser_cocci_menhir.ml"
+# 14489 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_comma_decls_TEllipsis_name_opt_decl__ =
# 116 "standard.mly"
( x :: xs )
-# 14518 "parser_cocci_menhir.ml"
+# 14519 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_designator_ =
# 114 "standard.mly"
( [] )
-# 14535 "parser_cocci_menhir.ml"
+# 14536 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_designator_ =
# 116 "standard.mly"
( x :: xs )
-# 14565 "parser_cocci_menhir.ml"
+# 14566 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_dp_comma_args_TEllipsis__ =
# 114 "standard.mly"
( [] )
-# 14582 "parser_cocci_menhir.ml"
+# 14583 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_dp_comma_args_TEllipsis__ =
# 116 "standard.mly"
( x :: xs )
-# 14612 "parser_cocci_menhir.ml"
+# 14613 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_incl_ =
# 114 "standard.mly"
( [] )
-# 14629 "parser_cocci_menhir.ml"
+# 14630 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_incl_ =
# 116 "standard.mly"
( x :: xs )
-# 14659 "parser_cocci_menhir.ml"
+# 14660 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_ctype__ =
# 114 "standard.mly"
( [] )
-# 14676 "parser_cocci_menhir.ml"
+# 14677 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_ctype__ =
# 116 "standard.mly"
( x :: xs )
-# 14706 "parser_cocci_menhir.ml"
+# 14707 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_decl_var__ =
# 114 "standard.mly"
( [] )
-# 14723 "parser_cocci_menhir.ml"
+# 14724 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_decl_var__ =
# 116 "standard.mly"
( x :: xs )
-# 14753 "parser_cocci_menhir.ml"
+# 14754 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_dexpr__ =
# 114 "standard.mly"
( [] )
-# 14770 "parser_cocci_menhir.ml"
+# 14771 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_dexpr__ =
# 116 "standard.mly"
( x :: xs )
-# 14800 "parser_cocci_menhir.ml"
+# 14801 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_nest_start__ =
# 114 "standard.mly"
( [] )
-# 14817 "parser_cocci_menhir.ml"
+# 14818 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_nest_start__ =
# 116 "standard.mly"
( x :: xs )
-# 14847 "parser_cocci_menhir.ml"
+# 14848 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_single_statement__ =
# 114 "standard.mly"
( [] )
-# 14864 "parser_cocci_menhir.ml"
+# 14865 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_iso_single_statement__ =
# 116 "standard.mly"
( x :: xs )
-# 14894 "parser_cocci_menhir.ml"
+# 14895 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_ctype__ =
# 114 "standard.mly"
( [] )
-# 14911 "parser_cocci_menhir.ml"
+# 14912 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_ctype__ =
# 116 "standard.mly"
( x :: xs )
-# 14941 "parser_cocci_menhir.ml"
+# 14942 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_eexpr__ =
# 114 "standard.mly"
( [] )
-# 14958 "parser_cocci_menhir.ml"
+# 14959 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_eexpr__ =
# 116 "standard.mly"
( x :: xs )
-# 14988 "parser_cocci_menhir.ml"
+# 14989 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_fun_after_dots_or__ =
# 114 "standard.mly"
( [] )
-# 15005 "parser_cocci_menhir.ml"
+# 15006 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_fun_after_dots_or__ =
# 116 "standard.mly"
( x :: xs )
-# 15035 "parser_cocci_menhir.ml"
+# 15036 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_fun_start__ =
# 114 "standard.mly"
( [] )
-# 15052 "parser_cocci_menhir.ml"
+# 15053 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_fun_start__ =
# 116 "standard.mly"
( x :: xs )
-# 15082 "parser_cocci_menhir.ml"
+# 15083 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_rule_elem_statement__ =
# 114 "standard.mly"
( [] )
-# 15099 "parser_cocci_menhir.ml"
+# 15100 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_rule_elem_statement__ =
# 116 "standard.mly"
( x :: xs )
-# 15129 "parser_cocci_menhir.ml"
+# 15130 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_statement__ =
# 114 "standard.mly"
( [] )
-# 15146 "parser_cocci_menhir.ml"
+# 15147 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_mzl_statement__ =
# 116 "standard.mly"
( x :: xs )
-# 15176 "parser_cocci_menhir.ml"
+# 15177 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_pair_edots_when_TEllipsis_eexpr__dexpr__ =
# 114 "standard.mly"
( [] )
-# 15193 "parser_cocci_menhir.ml"
+# 15194 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 70 "standard.mly"
( (x, y) )
-# 15232 "parser_cocci_menhir.ml"
+# 15233 "parser_cocci_menhir.ml"
in
# 116 "standard.mly"
( x :: xs )
-# 15238 "parser_cocci_menhir.ml"
+# 15239 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_whenppdecs_ =
# 114 "standard.mly"
( [] )
-# 15255 "parser_cocci_menhir.ml"
+# 15256 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_list_whenppdecs_ =
# 116 "standard.mly"
( x :: xs )
-# 15285 "parser_cocci_menhir.ml"
+# 15286 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_choose_iso_ =
# 57 "standard.mly"
( [] )
-# 15302 "parser_cocci_menhir.ml"
+# 15303 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_choose_iso_ =
# 59 "standard.mly"
( x )
-# 15326 "parser_cocci_menhir.ml"
+# 15327 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_disable_ =
# 57 "standard.mly"
( [] )
-# 15343 "parser_cocci_menhir.ml"
+# 15344 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_disable_ =
# 59 "standard.mly"
( x )
-# 15367 "parser_cocci_menhir.ml"
+# 15368 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_error_words_ =
# 57 "standard.mly"
( [] )
-# 15384 "parser_cocci_menhir.ml"
+# 15385 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_error_words_ =
# 59 "standard.mly"
( x )
-# 15408 "parser_cocci_menhir.ml"
+# 15409 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_filespec_ =
# 57 "standard.mly"
( [] )
-# 15425 "parser_cocci_menhir.ml"
+# 15426 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_filespec_ =
# 59 "standard.mly"
( x )
-# 15449 "parser_cocci_menhir.ml"
+# 15450 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_minus_start_ =
# 57 "standard.mly"
( [] )
-# 15466 "parser_cocci_menhir.ml"
+# 15467 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_minus_start_ =
# 59 "standard.mly"
( x )
-# 15490 "parser_cocci_menhir.ml"
+# 15491 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_ceq_ =
# 57 "standard.mly"
( [] )
-# 15507 "parser_cocci_menhir.ml"
+# 15508 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_ceq_ =
# 59 "standard.mly"
( x )
-# 15531 "parser_cocci_menhir.ml"
+# 15532 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_eq_ =
# 57 "standard.mly"
( [] )
-# 15548 "parser_cocci_menhir.ml"
+# 15549 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_eq_ =
# 59 "standard.mly"
( x )
-# 15572 "parser_cocci_menhir.ml"
+# 15573 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_eqe_ =
# 57 "standard.mly"
( [] )
-# 15589 "parser_cocci_menhir.ml"
+# 15590 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_eqe_ =
# 59 "standard.mly"
( x )
-# 15613 "parser_cocci_menhir.ml"
+# 15614 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_pos_ =
# 57 "standard.mly"
( [] )
-# 15630 "parser_cocci_menhir.ml"
+# 15631 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_not_pos_ =
# 59 "standard.mly"
( x )
-# 15654 "parser_cocci_menhir.ml"
+# 15655 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_plus_start_ =
# 57 "standard.mly"
( [] )
-# 15671 "parser_cocci_menhir.ml"
+# 15672 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_loption_plus_start_ =
# 59 "standard.mly"
( x )
-# 15695 "parser_cocci_menhir.ml"
+# 15696 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_meta_exp_type =
# 453 "parser_cocci_menhir.mly"
( [Ast0_cocci.ast0_type_to_type t] )
-# 15719 "parser_cocci_menhir.ml"
+# 15720 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( List.map
(function x -> P.ty_pointerify (Ast0_cocci.ast0_type_to_type x) m)
t )
-# 15759 "parser_cocci_menhir.ml"
+# 15760 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 15790 "parser_cocci_menhir.ml"
+# 15791 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_meta_ident =
-# 1398 "parser_cocci_menhir.mly"
+# 1399 "parser_cocci_menhir.mly"
( (Some _1,P.id2name _3) )
-# 15797 "parser_cocci_menhir.ml"
+# 15798 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 157 "parser_cocci_menhir.mly"
((Ast_cocci.metavar,Ast_cocci.metavar) Common.either list)
-# 15821 "parser_cocci_menhir.ml"
+# 15822 "parser_cocci_menhir.ml"
) =
# 181 "parser_cocci_menhir.mly"
( m (!Ast0.rule_name) )
-# 15825 "parser_cocci_menhir.ml"
+# 15826 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaParamDecl(arity,name)) in
!Data.add_param_meta name pure; tok) )
-# 15872 "parser_cocci_menhir.ml"
+# 15873 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 15878 "parser_cocci_menhir.ml"
+# 15879 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaParamListDecl(arity,name,None)) in
!Data.add_paramlist_meta name None pure; tok) )
-# 15929 "parser_cocci_menhir.ml"
+# 15930 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 15935 "parser_cocci_menhir.ml"
+# 15936 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaExpListDecl(arity,name,None)) in
!Data.add_explist_meta name None pure; tok) )
-# 15986 "parser_cocci_menhir.ml"
+# 15987 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 15992 "parser_cocci_menhir.ml"
+# 15993 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaTypeDecl(arity,name)) in
!Data.add_type_meta name pure; tok) )
-# 16039 "parser_cocci_menhir.ml"
+# 16040 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16045 "parser_cocci_menhir.ml"
+# 16046 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaInitDecl(arity,name)) in
!Data.add_init_meta name pure; tok) )
-# 16092 "parser_cocci_menhir.ml"
+# 16093 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16098 "parser_cocci_menhir.ml"
+# 16099 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaStmDecl(arity,name)) in
!Data.add_stm_meta name pure; tok) )
-# 16145 "parser_cocci_menhir.ml"
+# 16146 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16151 "parser_cocci_menhir.ml"
+# 16152 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta ->
let tok = check_meta(Ast.MetaStmListDecl(arity,name)) in
!Data.add_stmlist_meta name pure; tok) )
-# 16202 "parser_cocci_menhir.ml"
+# 16203 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16208 "parser_cocci_menhir.ml"
+# 16209 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
if arity = Ast.NONE && pure = Ast0.Impure
then (!Data.add_type_name name; [])
else raise (Semantic_cocci.Semantic "bad typedef")) )
-# 16256 "parser_cocci_menhir.ml"
+# 16257 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16262 "parser_cocci_menhir.ml"
+# 16263 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
if arity = Ast.NONE && pure = Ast0.Impure
then (!Data.add_declarer_name name; [])
else raise (Semantic_cocci.Semantic "bad declarer")) )
-# 16314 "parser_cocci_menhir.ml"
+# 16315 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16320 "parser_cocci_menhir.ml"
+# 16321 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
if arity = Ast.NONE && pure = Ast0.Impure
then (!Data.add_iterator_name name; [])
else raise (Semantic_cocci.Semantic "bad iterator")) )
-# 16372 "parser_cocci_menhir.ml"
+# 16373 "parser_cocci_menhir.ml"
in
# 263 "parser_cocci_menhir.mly"
( P.create_metadec ar ispure kindfn ids )
-# 16378 "parser_cocci_menhir.ml"
+# 16379 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun name check_meta seed ->
let tok = check_meta(Ast.MetaFreshIdDecl(name,seed)) in
!Data.add_fresh_id_meta name; tok) )
-# 16417 "parser_cocci_menhir.ml"
+# 16418 "parser_cocci_menhir.ml"
in
# 266 "parser_cocci_menhir.mly"
( P.create_fresh_metadec kindfn ids )
-# 16423 "parser_cocci_menhir.ml"
+# 16424 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaIdDecl(arity,name)) in
!Data.add_id_meta name constraints pure; tok) )
-# 16470 "parser_cocci_menhir.ml"
+# 16471 "parser_cocci_menhir.ml"
in
# 270 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16476 "parser_cocci_menhir.ml"
+# 16477 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaFuncDecl(arity,name)) in
!Data.add_func_meta name constraints pure; tok) )
-# 16523 "parser_cocci_menhir.ml"
+# 16524 "parser_cocci_menhir.ml"
in
# 270 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16529 "parser_cocci_menhir.ml"
+# 16530 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let tok = check_meta(Ast.MetaLocalFuncDecl(arity,name)) in
!Data.add_local_func_meta name constraints pure;
tok) )
-# 16581 "parser_cocci_menhir.ml"
+# 16582 "parser_cocci_menhir.ml"
in
# 270 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16587 "parser_cocci_menhir.ml"
+# 16588 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaDeclarerDecl(arity,name)) in
!Data.add_declarer_meta name constraints pure; tok) )
-# 16634 "parser_cocci_menhir.ml"
+# 16635 "parser_cocci_menhir.ml"
in
# 270 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16640 "parser_cocci_menhir.ml"
+# 16641 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaIteratorDecl(arity,name)) in
!Data.add_iterator_meta name constraints pure; tok) )
-# 16687 "parser_cocci_menhir.ml"
+# 16688 "parser_cocci_menhir.ml"
in
# 270 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16693 "parser_cocci_menhir.ml"
+# 16694 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaErrDecl(arity,name)) in
!Data.add_err_meta name constraints pure; tok) )
-# 16740 "parser_cocci_menhir.ml"
+# 16741 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16746 "parser_cocci_menhir.ml"
+# 16747 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 39 "standard.mly"
( None )
-# 16799 "parser_cocci_menhir.ml"
+# 16800 "parser_cocci_menhir.ml"
in
| Some _ ->
!Data.add_local_idexp_meta ty name constraints pure;
check_meta(Ast.MetaLocalIdExpDecl(arity,name,ty))) )
-# 16812 "parser_cocci_menhir.ml"
+# 16813 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16818 "parser_cocci_menhir.ml"
+# 16819 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 41 "standard.mly"
( Some x )
-# 16879 "parser_cocci_menhir.ml"
+# 16880 "parser_cocci_menhir.ml"
in
| Some _ ->
!Data.add_local_idexp_meta ty name constraints pure;
check_meta(Ast.MetaLocalIdExpDecl(arity,name,ty))) )
-# 16892 "parser_cocci_menhir.ml"
+# 16893 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16898 "parser_cocci_menhir.ml"
+# 16899 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
| Some _ ->
!Data.add_local_idexp_meta ty name constraints pure;
check_meta(Ast.MetaLocalIdExpDecl(arity,name,ty))) )
-# 16965 "parser_cocci_menhir.ml"
+# 16966 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 16971 "parser_cocci_menhir.ml"
+# 16972 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty = Some [P.ty_pointerify Type_cocci.Unknown m] in
let tok = check_meta(Ast.MetaExpDecl(arity,name,ty)) in
!Data.add_exp_meta ty name constraints pure; tok) )
-# 17026 "parser_cocci_menhir.ml"
+# 17027 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17032 "parser_cocci_menhir.ml"
+# 17033 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let ty = Some (List.map (function x -> Type_cocci.Array x) vl) in
let tok = check_meta(Ast.MetaExpDecl(arity,name,ty)) in
!Data.add_exp_meta ty name constraints pure; tok) )
-# 17091 "parser_cocci_menhir.ml"
+# 17092 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17097 "parser_cocci_menhir.ml"
+# 17098 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 39 "standard.mly"
( None )
-# 17143 "parser_cocci_menhir.ml"
+# 17144 "parser_cocci_menhir.ml"
in
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaConstDecl(arity,name,ty)) in
!Data.add_const_meta ty name constraints pure; tok) )
-# 17151 "parser_cocci_menhir.ml"
+# 17152 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17157 "parser_cocci_menhir.ml"
+# 17158 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
# 41 "standard.mly"
( Some x )
-# 17211 "parser_cocci_menhir.ml"
+# 17212 "parser_cocci_menhir.ml"
in
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaConstDecl(arity,name,ty)) in
!Data.add_const_meta ty name constraints pure; tok) )
-# 17219 "parser_cocci_menhir.ml"
+# 17220 "parser_cocci_menhir.ml"
in
# 274 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17225 "parser_cocci_menhir.ml"
+# 17226 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( (fun arity name pure check_meta constraints ->
let tok = check_meta(Ast.MetaExpDecl(arity,name,None)) in
!Data.add_exp_meta None name constraints pure; tok) )
-# 17272 "parser_cocci_menhir.ml"
+# 17273 "parser_cocci_menhir.ml"
in
# 278 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17278 "parser_cocci_menhir.ml"
+# 17279 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
constraints;
let tok = check_meta(Ast.MetaExpDecl(arity,name,ty)) in
!Data.add_exp_meta ty name constraints pure; tok) )
-# 17344 "parser_cocci_menhir.ml"
+# 17345 "parser_cocci_menhir.ml"
in
# 278 "parser_cocci_menhir.mly"
( P.create_metadec_ne ar ispure kindfn ids )
-# 17350 "parser_cocci_menhir.ml"
+# 17351 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let any = match a with None -> Ast.PER | Some _ -> Ast.ALL in
!Data.add_pos_meta name constraints any; tok in
P.create_metadec_ne ar false kindfn ids )
-# 17400 "parser_cocci_menhir.ml"
+# 17401 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
check_meta(Ast.MetaParamListDecl(arity,name,Some lenname)) in
!Data.add_paramlist_meta name (Some lenname) pure; tok)
id ids )
-# 17467 "parser_cocci_menhir.ml"
+# 17468 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
check_meta(Ast.MetaExpListDecl(arity,name,Some lenname)) in
!Data.add_explist_meta name (Some lenname) pure; tok)
id ids )
-# 17534 "parser_cocci_menhir.ml"
+# 17535 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_ctype_ctype_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17564 "parser_cocci_menhir.ml"
+# 17565 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_eexpr_eexpr_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17594 "parser_cocci_menhir.ml"
+# 17595 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_expr_eexpr_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17624 "parser_cocci_menhir.ml"
+# 17625 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_fun_after_stm_fun_after_dots_or_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17654 "parser_cocci_menhir.ml"
+# 17655 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_fun_start_fun_start_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17684 "parser_cocci_menhir.ml"
+# 17685 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_rule_elem_statement_rule_elem_statement_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17714 "parser_cocci_menhir.ml"
+# 17715 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_midzero_list_statement_statement_ =
-# 1802 "parser_cocci_menhir.mly"
+# 1803 "parser_cocci_menhir.mly"
( let (mids,code) = List.split b in (mids,(a::code)) )
-# 17744 "parser_cocci_menhir.ml"
+# 17745 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( match f@b@ew with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
| code -> Top_level.top_level code )
-# 17782 "parser_cocci_menhir.ml"
+# 17783 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
( match f@[b]@ew with
[] -> raise (Semantic_cocci.Semantic "minus slice can't be empty")
| code -> Top_level.top_level code )
-# 17820 "parser_cocci_menhir.ml"
+# 17821 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 137 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 17848 "parser_cocci_menhir.ml"
+# 17849 "parser_cocci_menhir.ml"
) =
# 177 "parser_cocci_menhir.mly"
( _1 )
-# 17852 "parser_cocci_menhir.ml"
+# 17853 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 137 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 17880 "parser_cocci_menhir.ml"
+# 17881 "parser_cocci_menhir.ml"
) =
# 177 "parser_cocci_menhir.mly"
( m )
-# 17884 "parser_cocci_menhir.ml"
+# 17885 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 137 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 17912 "parser_cocci_menhir.ml"
+# 17913 "parser_cocci_menhir.ml"
) =
# 178 "parser_cocci_menhir.mly"
( m )
-# 17916 "parser_cocci_menhir.ml"
+# 17917 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 134 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 17944 "parser_cocci_menhir.ml"
+# 17945 "parser_cocci_menhir.ml"
) =
# 173 "parser_cocci_menhir.mly"
( _1 )
-# 17948 "parser_cocci_menhir.ml"
+# 17949 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 134 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 17976 "parser_cocci_menhir.ml"
+# 17977 "parser_cocci_menhir.ml"
) =
# 173 "parser_cocci_menhir.mly"
( m )
-# 17980 "parser_cocci_menhir.ml"
+# 17981 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 134 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 18008 "parser_cocci_menhir.ml"
+# 18009 "parser_cocci_menhir.ml"
) =
# 174 "parser_cocci_menhir.mly"
( m )
-# 18012 "parser_cocci_menhir.ml"
+# 18013 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_minus_start =
-# 1611 "parser_cocci_menhir.mly"
+# 1612 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.DECL(_1))] )
-# 18036 "parser_cocci_menhir.ml"
+# 18037 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_minus_start =
-# 1612 "parser_cocci_menhir.mly"
+# 1613 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Ty(_1))))] )
-# 18060 "parser_cocci_menhir.ml"
+# 18061 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_minus_start =
-# 1613 "parser_cocci_menhir.mly"
+# 1614 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.TopInit(_1))))] )
-# 18084 "parser_cocci_menhir.ml"
+# 18085 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_minus_start =
-# 1615 "parser_cocci_menhir.mly"
+# 1616 "parser_cocci_menhir.mly"
( List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) _1 )
-# 18108 "parser_cocci_menhir.ml"
+# 18109 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18135 "parser_cocci_menhir.ml"
+# 18136 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_ctype_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18142 "parser_cocci_menhir.ml"
+# 18143 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18169 "parser_cocci_menhir.ml"
+# 18170 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_eexpr_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18176 "parser_cocci_menhir.ml"
+# 18177 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18203 "parser_cocci_menhir.ml"
+# 18204 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_fun_after_dots_or_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18210 "parser_cocci_menhir.ml"
+# 18211 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18237 "parser_cocci_menhir.ml"
+# 18238 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_fun_start_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18244 "parser_cocci_menhir.ml"
+# 18245 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18271 "parser_cocci_menhir.ml"
+# 18272 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_rule_elem_statement_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18278 "parser_cocci_menhir.ml"
+# 18279 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18305 "parser_cocci_menhir.ml"
+# 18306 "parser_cocci_menhir.ml"
) = Obj.magic a in
let _startpos = _startpos_a_ in
let _endpos = _endpos_b_ in
let _v : 'tv_mzl_statement_ =
-# 1805 "parser_cocci_menhir.mly"
+# 1806 "parser_cocci_menhir.mly"
( (P.clt2mcode "|" a, b) )
-# 18312 "parser_cocci_menhir.ml"
+# 18313 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_name_opt_decl =
-# 839 "parser_cocci_menhir.mly"
+# 840 "parser_cocci_menhir.mly"
( _1 )
-# 18336 "parser_cocci_menhir.ml"
+# 18337 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_t_ in
let _endpos = _endpos_t_ in
let _v : 'tv_name_opt_decl =
-# 840 "parser_cocci_menhir.mly"
+# 841 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Param(t, None)) )
-# 18360 "parser_cocci_menhir.ml"
+# 18361 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18411 "parser_cocci_menhir.ml"
+# 18412 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_decl_list_name_opt_decl_ = Obj.magic d in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 18417 "parser_cocci_menhir.ml"
+# 18418 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 18422 "parser_cocci_menhir.ml"
+# 18423 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let s : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 18427 "parser_cocci_menhir.ml"
+# 18428 "parser_cocci_menhir.ml"
) = Obj.magic s in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 18432 "parser_cocci_menhir.ml"
+# 18433 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let t : 'tv_fn_ctype = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_rp1_ in
let _v : 'tv_name_opt_decl =
-# 843 "parser_cocci_menhir.mly"
+# 844 "parser_cocci_menhir.mly"
( let fnptr =
Ast0.wrap
(Ast0.FunctionPointer
(t,P.clt2mcode "(" lp,P.clt2mcode "*" s,P.clt2mcode ")" rp,
P.clt2mcode "(" lp1,d,P.clt2mcode ")" rp1)) in
Ast0.wrap(Ast0.Param(fnptr, None)) )
-# 18445 "parser_cocci_menhir.ml"
+# 18446 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_dots =
-# 1726 "parser_cocci_menhir.mly"
+# 1727 "parser_cocci_menhir.mly"
(_1@_2)
-# 18475 "parser_cocci_menhir.ml"
+# 18476 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_dots =
-# 1727 "parser_cocci_menhir.mly"
+# 1728 "parser_cocci_menhir.mly"
(_2)
-# 18503 "parser_cocci_menhir.ml"
+# 18504 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_dots =
-# 1728 "parser_cocci_menhir.mly"
+# 1729 "parser_cocci_menhir.mly"
((Ast0.wrap(Ast0.Exp(_1)))::_2)
-# 18533 "parser_cocci_menhir.ml"
+# 18534 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_nest_after_exp =
-# 1736 "parser_cocci_menhir.mly"
+# 1737 "parser_cocci_menhir.mly"
([])
-# 18550 "parser_cocci_menhir.ml"
+# 18551 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_exp =
-# 1737 "parser_cocci_menhir.mly"
+# 1738 "parser_cocci_menhir.mly"
(_1::_2)
-# 18580 "parser_cocci_menhir.ml"
+# 18581 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_nest_after_stm =
-# 1731 "parser_cocci_menhir.mly"
+# 1732 "parser_cocci_menhir.mly"
([])
-# 18597 "parser_cocci_menhir.ml"
+# 18598 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_stm =
-# 1732 "parser_cocci_menhir.mly"
+# 1733 "parser_cocci_menhir.mly"
(_1::_2)
-# 18627 "parser_cocci_menhir.ml"
+# 18628 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_nest_after_stm =
-# 1733 "parser_cocci_menhir.mly"
+# 1734 "parser_cocci_menhir.mly"
(_1@_2)
-# 18657 "parser_cocci_menhir.ml"
+# 18658 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 18688 "parser_cocci_menhir.ml"
+# 18689 "parser_cocci_menhir.ml"
) = Obj.magic c in
let e : 'tv_expr_dots_TEllipsis_ = Obj.magic e in
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 18694 "parser_cocci_menhir.ml"
+# 18695 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_c_ in
let _v : 'tv_nest_expressions =
-# 1221 "parser_cocci_menhir.mly"
+# 1222 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.NestExpr(P.clt2mcode "<..." _1,
Ast0.wrap(Ast0.DOTS(e (P.mkedots "..."))),
P.clt2mcode "...>" c, None, false)) )
-# 18703 "parser_cocci_menhir.ml"
+# 18704 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 18734 "parser_cocci_menhir.ml"
+# 18735 "parser_cocci_menhir.ml"
) = Obj.magic c in
let e : 'tv_expr_dots_TEllipsis_ = Obj.magic e in
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 18740 "parser_cocci_menhir.ml"
+# 18741 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_c_ in
let _v : 'tv_nest_expressions =
-# 1225 "parser_cocci_menhir.mly"
+# 1226 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.NestExpr(P.clt2mcode "<+..." _1,
Ast0.wrap(Ast0.DOTS(e (P.mkedots "..."))),
P.clt2mcode "...+>" c, None, true)) )
-# 18749 "parser_cocci_menhir.ml"
+# 18750 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_nest_start =
-# 1723 "parser_cocci_menhir.mly"
+# 1724 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS(_1)) )
-# 18773 "parser_cocci_menhir.ml"
+# 18774 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 168 "parser_cocci_menhir.mly"
(unit)
-# 18795 "parser_cocci_menhir.ml"
+# 18796 "parser_cocci_menhir.ml"
) =
-# 1868 "parser_cocci_menhir.mly"
+# 1874 "parser_cocci_menhir.mly"
( () )
-# 18799 "parser_cocci_menhir.ml"
+# 18800 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 168 "parser_cocci_menhir.mly"
(unit)
-# 18825 "parser_cocci_menhir.ml"
+# 18826 "parser_cocci_menhir.ml"
) =
-# 1869 "parser_cocci_menhir.mly"
+# 1875 "parser_cocci_menhir.mly"
( () )
-# 18829 "parser_cocci_menhir.ml"
+# 18830 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 168 "parser_cocci_menhir.mly"
(unit)
-# 18851 "parser_cocci_menhir.ml"
+# 18852 "parser_cocci_menhir.ml"
) =
-# 1870 "parser_cocci_menhir.mly"
+# 1876 "parser_cocci_menhir.mly"
( () )
-# 18855 "parser_cocci_menhir.ml"
+# 18856 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_g_ in
let _endpos = _endpos_dg_ in
let _v : 'tv_no_dot_start_end_dexpr_edots_when_TEllipsis_eexpr__ =
-# 1389 "parser_cocci_menhir.mly"
+# 1390 "parser_cocci_menhir.mly"
( function dot_builder ->
g :: (List.concat(List.map (function (d,g) -> [dot_builder d;g]) dg)) )
-# 18886 "parser_cocci_menhir.ml"
+# 18887 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let x : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 18907 "parser_cocci_menhir.ml"
+# 18908 "parser_cocci_menhir.ml"
) = Obj.magic x in
let _startpos = _startpos_x_ in
let _endpos = _endpos_x_ in
let _v : 'tv_nonempty_list_TMul_ =
# 124 "standard.mly"
( [ x ] )
-# 18914 "parser_cocci_menhir.ml"
+# 18915 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let x : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 18941 "parser_cocci_menhir.ml"
+# 18942 "parser_cocci_menhir.ml"
) = Obj.magic x in
let _startpos = _startpos_x_ in
let _endpos = _endpos_xs_ in
let _v : 'tv_nonempty_list_TMul_ =
# 126 "standard.mly"
( x :: xs )
-# 18948 "parser_cocci_menhir.ml"
+# 18949 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_i_ in
let _v : 'tv_not_ceq =
-# 1450 "parser_cocci_menhir.mly"
+# 1451 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
then failwith "constraints not allowed in a generated rule file");
[i] )
-# 18980 "parser_cocci_menhir.ml"
+# 18981 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_not_ceq =
-# 1456 "parser_cocci_menhir.mly"
+# 1457 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
then failwith "constraints not allowed in a generated rule file");
l )
-# 19020 "parser_cocci_menhir.ml"
+# 19021 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_i_ in
let _v : 'tv_not_eq =
-# 1417 "parser_cocci_menhir.mly"
+# 1418 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
them in the pattern *)
then failwith "constraints not allowed in a generated rule file");
[Ast0.wrap(Ast0.Id(P.id2mcode i))] )
-# 19054 "parser_cocci_menhir.ml"
+# 19055 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_not_eq =
-# 1425 "parser_cocci_menhir.mly"
+# 1426 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
then failwith "constraints not allowed in a generated rule file");
List.map (function i -> Ast0.wrap(Ast0.Id(P.id2mcode i))) l )
-# 19094 "parser_cocci_menhir.ml"
+# 19095 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_i_ in
let _v : 'tv_not_eqe =
-# 1433 "parser_cocci_menhir.mly"
+# 1434 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
then failwith "constraints not allowed in a generated rule file");
[Ast0.wrap(Ast0.Ident(Ast0.wrap(Ast0.Id(P.id2mcode i))))] )
-# 19126 "parser_cocci_menhir.ml"
+# 19127 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_not_eqe =
-# 1439 "parser_cocci_menhir.mly"
+# 1440 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
(function i ->
Ast0.wrap(Ast0.Ident(Ast0.wrap(Ast0.Id(P.id2mcode i)))))
l )
-# 19169 "parser_cocci_menhir.ml"
+# 19170 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos_i_ in
let _v : 'tv_not_pos =
-# 1470 "parser_cocci_menhir.mly"
+# 1471 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
let i = (rule,name) in
P.check_meta(Ast.MetaPosDecl(Ast.NONE,i));
[i] )
-# 19206 "parser_cocci_menhir.ml"
+# 19207 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_not_pos =
-# 1481 "parser_cocci_menhir.mly"
+# 1482 "parser_cocci_menhir.mly"
( (if !Data.in_iso
then failwith "constraints not allowed in iso file");
(if !Data.in_generating
P.check_meta(Ast.MetaPosDecl(Ast.NONE,i));
i)
l )
-# 19254 "parser_cocci_menhir.ml"
+# 19255 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_one_dec_decl_ =
-# 1555 "parser_cocci_menhir.mly"
+# 1556 "parser_cocci_menhir.mly"
( _1 )
-# 19278 "parser_cocci_menhir.ml"
+# 19279 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 66 "parser_cocci_menhir.mly"
(Parse_aux.list_info)
-# 19299 "parser_cocci_menhir.ml"
+# 19300 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_one_dec_decl_ =
-# 1557 "parser_cocci_menhir.mly"
+# 1558 "parser_cocci_menhir.mly"
( let (nm,lenname,pure,clt) = _1 in
let nm = P.clt2mcode nm clt in
let lenname =
Some nm -> Some(P.clt2mcode nm clt)
| None -> None in
Ast0.wrap(Ast0.MetaParamList(nm,lenname,pure)) )
-# 19312 "parser_cocci_menhir.ml"
+# 19313 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_one_dec_name_opt_decl_ =
-# 1555 "parser_cocci_menhir.mly"
+# 1556 "parser_cocci_menhir.mly"
( _1 )
-# 19336 "parser_cocci_menhir.ml"
+# 19337 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 66 "parser_cocci_menhir.mly"
(Parse_aux.list_info)
-# 19357 "parser_cocci_menhir.ml"
+# 19358 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_one_dec_name_opt_decl_ =
-# 1557 "parser_cocci_menhir.mly"
+# 1558 "parser_cocci_menhir.mly"
( let (nm,lenname,pure,clt) = _1 in
let nm = P.clt2mcode nm clt in
let lenname =
Some nm -> Some(P.clt2mcode nm clt)
| None -> None in
Ast0.wrap(Ast0.MetaParamList(nm,lenname,pure)) )
-# 19370 "parser_cocci_menhir.ml"
+# 19371 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19396 "parser_cocci_menhir.ml"
+# 19397 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let t : 'tv_ctype = Obj.magic t in
let _startpos = _startpos_t_ in
let _endpos = _endpos_pv_ in
let _v : 'tv_one_decl_var =
-# 1010 "parser_cocci_menhir.mly"
+# 1011 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.TyDecl(t,P.clt2mcode ";" pv)) )
-# 19404 "parser_cocci_menhir.ml"
+# 19405 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19435 "parser_cocci_menhir.ml"
+# 19436 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let t : 'tv_ctype = Obj.magic t in
# 39 "standard.mly"
( None )
-# 19445 "parser_cocci_menhir.ml"
+# 19446 "parser_cocci_menhir.ml"
in
-# 1012 "parser_cocci_menhir.mly"
+# 1013 "parser_cocci_menhir.mly"
( let (id,fn) = d in
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)) )
-# 19452 "parser_cocci_menhir.ml"
+# 19453 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19488 "parser_cocci_menhir.ml"
+# 19489 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let t : 'tv_ctype = Obj.magic t in
# 41 "standard.mly"
( Some x )
-# 19500 "parser_cocci_menhir.ml"
+# 19501 "parser_cocci_menhir.ml"
in
-# 1012 "parser_cocci_menhir.mly"
+# 1013 "parser_cocci_menhir.mly"
( let (id,fn) = d in
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)) )
-# 19507 "parser_cocci_menhir.ml"
+# 19508 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_f_ in
let _endpos = _endpos_f_ in
let _v : 'tv_one_decl_var =
-# 1014 "parser_cocci_menhir.mly"
+# 1015 "parser_cocci_menhir.mly"
( f )
-# 19531 "parser_cocci_menhir.ml"
+# 19532 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19572 "parser_cocci_menhir.ml"
+# 19573 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19578 "parser_cocci_menhir.ml"
+# 19579 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let t : 'tv_ctype = Obj.magic t in
# 39 "standard.mly"
( None )
-# 19588 "parser_cocci_menhir.ml"
+# 19589 "parser_cocci_menhir.ml"
in
-# 1016 "parser_cocci_menhir.mly"
+# 1017 "parser_cocci_menhir.mly"
( let (id,fn) = d in
Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv)) )
-# 19595 "parser_cocci_menhir.ml"
+# 19596 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19641 "parser_cocci_menhir.ml"
+# 19642 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19647 "parser_cocci_menhir.ml"
+# 19648 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let t : 'tv_ctype = Obj.magic t in
# 41 "standard.mly"
( Some x )
-# 19659 "parser_cocci_menhir.ml"
+# 19660 "parser_cocci_menhir.ml"
in
-# 1016 "parser_cocci_menhir.mly"
+# 1017 "parser_cocci_menhir.mly"
( let (id,fn) = d in
Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv)) )
-# 19666 "parser_cocci_menhir.ml"
+# 19667 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19697 "parser_cocci_menhir.ml"
+# 19698 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 39 "standard.mly"
( None )
-# 19707 "parser_cocci_menhir.ml"
+# 19708 "parser_cocci_menhir.ml"
in
let s =
# 39 "standard.mly"
( None )
-# 19714 "parser_cocci_menhir.ml"
+# 19715 "parser_cocci_menhir.ml"
in
-# 1021 "parser_cocci_menhir.mly"
+# 1022 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.UnInit(s,fn idtype,id,P.clt2mcode ";" pv)) )
-# 19722 "parser_cocci_menhir.ml"
+# 19723 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19758 "parser_cocci_menhir.ml"
+# 19759 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 41 "standard.mly"
( Some x )
-# 19770 "parser_cocci_menhir.ml"
+# 19771 "parser_cocci_menhir.ml"
in
let s =
# 39 "standard.mly"
( None )
-# 19777 "parser_cocci_menhir.ml"
+# 19778 "parser_cocci_menhir.ml"
in
-# 1021 "parser_cocci_menhir.mly"
+# 1022 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.UnInit(s,fn idtype,id,P.clt2mcode ";" pv)) )
-# 19785 "parser_cocci_menhir.ml"
+# 19786 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19821 "parser_cocci_menhir.ml"
+# 19822 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 39 "standard.mly"
( None )
-# 19832 "parser_cocci_menhir.ml"
+# 19833 "parser_cocci_menhir.ml"
in
let s =
# 41 "standard.mly"
( Some x )
-# 19840 "parser_cocci_menhir.ml"
+# 19841 "parser_cocci_menhir.ml"
in
-# 1021 "parser_cocci_menhir.mly"
+# 1022 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.UnInit(s,fn idtype,id,P.clt2mcode ";" pv)) )
-# 19848 "parser_cocci_menhir.ml"
+# 19849 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19889 "parser_cocci_menhir.ml"
+# 19890 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 41 "standard.mly"
( Some x )
-# 19902 "parser_cocci_menhir.ml"
+# 19903 "parser_cocci_menhir.ml"
in
let s =
# 41 "standard.mly"
( Some x )
-# 19910 "parser_cocci_menhir.ml"
+# 19911 "parser_cocci_menhir.ml"
in
-# 1021 "parser_cocci_menhir.mly"
+# 1022 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.UnInit(s,fn idtype,id,P.clt2mcode ";" pv)) )
-# 19918 "parser_cocci_menhir.ml"
+# 19919 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19959 "parser_cocci_menhir.ml"
+# 19960 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 19965 "parser_cocci_menhir.ml"
+# 19966 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 39 "standard.mly"
( None )
-# 19975 "parser_cocci_menhir.ml"
+# 19976 "parser_cocci_menhir.ml"
in
let s =
# 39 "standard.mly"
( None )
-# 19982 "parser_cocci_menhir.ml"
+# 19983 "parser_cocci_menhir.ml"
in
-# 1026 "parser_cocci_menhir.mly"
+# 1027 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.Init(s,fn idtype,id,P.clt2mcode "=" q,e,
P.clt2mcode ";" pv)) )
-# 19992 "parser_cocci_menhir.ml"
+# 19993 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20038 "parser_cocci_menhir.ml"
+# 20039 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20044 "parser_cocci_menhir.ml"
+# 20045 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 41 "standard.mly"
( Some x )
-# 20056 "parser_cocci_menhir.ml"
+# 20057 "parser_cocci_menhir.ml"
in
let s =
# 39 "standard.mly"
( None )
-# 20063 "parser_cocci_menhir.ml"
+# 20064 "parser_cocci_menhir.ml"
in
-# 1026 "parser_cocci_menhir.mly"
+# 1027 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.Init(s,fn idtype,id,P.clt2mcode "=" q,e,
P.clt2mcode ";" pv)) )
-# 20073 "parser_cocci_menhir.ml"
+# 20074 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20119 "parser_cocci_menhir.ml"
+# 20120 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20125 "parser_cocci_menhir.ml"
+# 20126 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 39 "standard.mly"
( None )
-# 20136 "parser_cocci_menhir.ml"
+# 20137 "parser_cocci_menhir.ml"
in
let s =
# 41 "standard.mly"
( Some x )
-# 20144 "parser_cocci_menhir.ml"
+# 20145 "parser_cocci_menhir.ml"
in
-# 1026 "parser_cocci_menhir.mly"
+# 1027 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.Init(s,fn idtype,id,P.clt2mcode "=" q,e,
P.clt2mcode ";" pv)) )
-# 20154 "parser_cocci_menhir.ml"
+# 20155 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20205 "parser_cocci_menhir.ml"
+# 20206 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20211 "parser_cocci_menhir.ml"
+# 20212 "parser_cocci_menhir.ml"
) = Obj.magic q in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 41 "standard.mly"
( Some x )
-# 20224 "parser_cocci_menhir.ml"
+# 20225 "parser_cocci_menhir.ml"
in
let s =
# 41 "standard.mly"
( Some x )
-# 20232 "parser_cocci_menhir.ml"
+# 20233 "parser_cocci_menhir.ml"
in
-# 1026 "parser_cocci_menhir.mly"
+# 1027 "parser_cocci_menhir.mly"
( let (id,fn) = d in
!Data.add_type_name (P.id2name i);
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
Ast0.wrap(Ast0.Init(s,fn idtype,id,P.clt2mcode "=" q,e,
P.clt2mcode ";" pv)) )
-# 20242 "parser_cocci_menhir.ml"
+# 20243 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20303 "parser_cocci_menhir.ml"
+# 20304 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let rp2 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20308 "parser_cocci_menhir.ml"
+# 20309 "parser_cocci_menhir.ml"
) = Obj.magic rp2 in
let p : 'tv_decl_list_name_opt_decl_ = Obj.magic p in
let lp2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20314 "parser_cocci_menhir.ml"
+# 20315 "parser_cocci_menhir.ml"
) = Obj.magic lp2 in
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20319 "parser_cocci_menhir.ml"
+# 20320 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_d_ident = Obj.magic d in
let st : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 20325 "parser_cocci_menhir.ml"
+# 20326 "parser_cocci_menhir.ml"
) = Obj.magic st in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20330 "parser_cocci_menhir.ml"
+# 20331 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let t : 'tv_fn_ctype = Obj.magic t in
let _startpos = _startpos_t_ in
# 39 "standard.mly"
( None )
-# 20339 "parser_cocci_menhir.ml"
+# 20340 "parser_cocci_menhir.ml"
in
-# 1036 "parser_cocci_menhir.mly"
+# 1037 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
(t,P.clt2mcode "(" lp1,P.clt2mcode "*" st,P.clt2mcode ")" rp1,
P.clt2mcode "(" lp2,p,P.clt2mcode ")" rp2)) in
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)) )
-# 20351 "parser_cocci_menhir.ml"
+# 20352 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20417 "parser_cocci_menhir.ml"
+# 20418 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let rp2 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20422 "parser_cocci_menhir.ml"
+# 20423 "parser_cocci_menhir.ml"
) = Obj.magic rp2 in
let p : 'tv_decl_list_name_opt_decl_ = Obj.magic p in
let lp2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20428 "parser_cocci_menhir.ml"
+# 20429 "parser_cocci_menhir.ml"
) = Obj.magic lp2 in
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20433 "parser_cocci_menhir.ml"
+# 20434 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_d_ident = Obj.magic d in
let st : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 20439 "parser_cocci_menhir.ml"
+# 20440 "parser_cocci_menhir.ml"
) = Obj.magic st in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20444 "parser_cocci_menhir.ml"
+# 20445 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let t : 'tv_fn_ctype = Obj.magic t in
let x0 : 'tv_storage = Obj.magic x0 in
# 41 "standard.mly"
( Some x )
-# 20455 "parser_cocci_menhir.ml"
+# 20456 "parser_cocci_menhir.ml"
in
-# 1036 "parser_cocci_menhir.mly"
+# 1037 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
(t,P.clt2mcode "(" lp1,P.clt2mcode "*" st,P.clt2mcode ")" rp1,
P.clt2mcode "(" lp2,p,P.clt2mcode ")" rp2)) in
Ast0.wrap(Ast0.UnInit(s,fn t,id,P.clt2mcode ";" pv)) )
-# 20467 "parser_cocci_menhir.ml"
+# 20468 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _5 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20508 "parser_cocci_menhir.ml"
+# 20509 "parser_cocci_menhir.ml"
) = Obj.magic _5 in
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20513 "parser_cocci_menhir.ml"
+# 20514 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20519 "parser_cocci_menhir.ml"
+# 20520 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_decl_ident = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_one_decl_var =
-# 1044 "parser_cocci_menhir.mly"
+# 1045 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.MacroDecl(_1,P.clt2mcode "(" _2,_3,
P.clt2mcode ")" _4,P.clt2mcode ";" _5)) )
-# 20528 "parser_cocci_menhir.ml"
+# 20529 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20599 "parser_cocci_menhir.ml"
+# 20600 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20605 "parser_cocci_menhir.ml"
+# 20606 "parser_cocci_menhir.ml"
) = Obj.magic q in
let rp2 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20610 "parser_cocci_menhir.ml"
+# 20611 "parser_cocci_menhir.ml"
) = Obj.magic rp2 in
let p : 'tv_decl_list_name_opt_decl_ = Obj.magic p in
let lp2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20616 "parser_cocci_menhir.ml"
+# 20617 "parser_cocci_menhir.ml"
) = Obj.magic lp2 in
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20621 "parser_cocci_menhir.ml"
+# 20622 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_d_ident = Obj.magic d in
let st : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 20627 "parser_cocci_menhir.ml"
+# 20628 "parser_cocci_menhir.ml"
) = Obj.magic st in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20632 "parser_cocci_menhir.ml"
+# 20633 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let t : 'tv_fn_ctype = Obj.magic t in
let _startpos = _startpos_t_ in
# 39 "standard.mly"
( None )
-# 20641 "parser_cocci_menhir.ml"
+# 20642 "parser_cocci_menhir.ml"
in
-# 1050 "parser_cocci_menhir.mly"
+# 1051 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
(t,P.clt2mcode "(" lp1,P.clt2mcode "*" st,P.clt2mcode ")" rp1,
P.clt2mcode "(" lp2,p,P.clt2mcode ")" rp2)) in
Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv)))
-# 20653 "parser_cocci_menhir.ml"
+# 20654 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20729 "parser_cocci_menhir.ml"
+# 20730 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let e : 'tv_initialize = Obj.magic e in
let q : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 20735 "parser_cocci_menhir.ml"
+# 20736 "parser_cocci_menhir.ml"
) = Obj.magic q in
let rp2 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20740 "parser_cocci_menhir.ml"
+# 20741 "parser_cocci_menhir.ml"
) = Obj.magic rp2 in
let p : 'tv_decl_list_name_opt_decl_ = Obj.magic p in
let lp2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20746 "parser_cocci_menhir.ml"
+# 20747 "parser_cocci_menhir.ml"
) = Obj.magic lp2 in
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 20751 "parser_cocci_menhir.ml"
+# 20752 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_d_ident = Obj.magic d in
let st : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 20757 "parser_cocci_menhir.ml"
+# 20758 "parser_cocci_menhir.ml"
) = Obj.magic st in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 20762 "parser_cocci_menhir.ml"
+# 20763 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let t : 'tv_fn_ctype = Obj.magic t in
let x0 : 'tv_storage = Obj.magic x0 in
# 41 "standard.mly"
( Some x )
-# 20773 "parser_cocci_menhir.ml"
+# 20774 "parser_cocci_menhir.ml"
in
-# 1050 "parser_cocci_menhir.mly"
+# 1051 "parser_cocci_menhir.mly"
( let (id,fn) = d in
let t =
Ast0.wrap
(t,P.clt2mcode "(" lp1,P.clt2mcode "*" st,P.clt2mcode ")" rp1,
P.clt2mcode "(" lp2,p,P.clt2mcode ")" rp2)) in
Ast0.wrap(Ast0.Init(s,fn t,id,P.clt2mcode "=" q,e,P.clt2mcode ";" pv)))
-# 20785 "parser_cocci_menhir.ml"
+# 20786 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_TLocal_ =
# 29 "standard.mly"
( None )
-# 20802 "parser_cocci_menhir.ml"
+# 20803 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_TLocal_ =
# 31 "standard.mly"
( Some x )
-# 20826 "parser_cocci_menhir.ml"
+# 20827 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_TPosAny_ =
# 29 "standard.mly"
( None )
-# 20843 "parser_cocci_menhir.ml"
+# 20844 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_TPosAny_ =
# 31 "standard.mly"
( Some x )
-# 20867 "parser_cocci_menhir.ml"
+# 20868 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_eexpr_ =
# 29 "standard.mly"
( None )
-# 20884 "parser_cocci_menhir.ml"
+# 20885 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_option_eexpr_ =
# 31 "standard.mly"
( Some x )
-# 20908 "parser_cocci_menhir.ml"
+# 20909 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_plus_after_dots =
-# 1673 "parser_cocci_menhir.mly"
+# 1674 "parser_cocci_menhir.mly"
([])
-# 20925 "parser_cocci_menhir.ml"
+# 20926 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_dots =
-# 1674 "parser_cocci_menhir.mly"
+# 1675 "parser_cocci_menhir.mly"
(_2)
-# 20953 "parser_cocci_menhir.ml"
+# 20954 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_dots =
-# 1676 "parser_cocci_menhir.mly"
+# 1677 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Exp(_1)))))::_2 )
-# 20983 "parser_cocci_menhir.ml"
+# 20984 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_dots =
-# 1677 "parser_cocci_menhir.mly"
+# 1678 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DECL(_1))::_2 )
-# 21013 "parser_cocci_menhir.ml"
+# 21014 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_dots =
-# 1679 "parser_cocci_menhir.mly"
+# 1680 "parser_cocci_menhir.mly"
( (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) _1)@_2 )
-# 21043 "parser_cocci_menhir.ml"
+# 21044 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_plus_after_exp =
-# 1669 "parser_cocci_menhir.mly"
+# 1670 "parser_cocci_menhir.mly"
([])
-# 21060 "parser_cocci_menhir.ml"
+# 21061 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_exp =
-# 1670 "parser_cocci_menhir.mly"
+# 1671 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.OTHER(_1)))::_2 )
-# 21090 "parser_cocci_menhir.ml"
+# 21091 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_plus_after_stm =
-# 1682 "parser_cocci_menhir.mly"
+# 1683 "parser_cocci_menhir.mly"
([])
-# 21107 "parser_cocci_menhir.ml"
+# 21108 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_stm =
-# 1683 "parser_cocci_menhir.mly"
+# 1684 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.OTHER(_1)))::_2 )
-# 21137 "parser_cocci_menhir.ml"
+# 21138 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_stm =
-# 1684 "parser_cocci_menhir.mly"
+# 1685 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DECL(_1))::_2 )
-# 21167 "parser_cocci_menhir.ml"
+# 21168 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_after_stm =
-# 1686 "parser_cocci_menhir.mly"
+# 1687 "parser_cocci_menhir.mly"
( (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) _1)@_2 )
-# 21197 "parser_cocci_menhir.ml"
+# 21198 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_plus_body =
# 614 "parser_cocci_menhir.mly"
( Top_level.top_level (f@b@ew) )
-# 21233 "parser_cocci_menhir.ml"
+# 21234 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_plus_exp_body =
# 628 "parser_cocci_menhir.mly"
( Top_level.top_level (f@[b]@ew) )
-# 21269 "parser_cocci_menhir.ml"
+# 21270 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 143 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21297 "parser_cocci_menhir.ml"
+# 21298 "parser_cocci_menhir.ml"
) =
# 179 "parser_cocci_menhir.mly"
( _1 )
-# 21301 "parser_cocci_menhir.ml"
+# 21302 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 143 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21329 "parser_cocci_menhir.ml"
+# 21330 "parser_cocci_menhir.ml"
) =
# 179 "parser_cocci_menhir.mly"
( p )
-# 21333 "parser_cocci_menhir.ml"
+# 21334 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 143 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21361 "parser_cocci_menhir.ml"
+# 21362 "parser_cocci_menhir.ml"
) =
# 180 "parser_cocci_menhir.mly"
( p )
-# 21365 "parser_cocci_menhir.ml"
+# 21366 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 140 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21393 "parser_cocci_menhir.ml"
+# 21394 "parser_cocci_menhir.ml"
) =
# 175 "parser_cocci_menhir.mly"
( _1 )
-# 21397 "parser_cocci_menhir.ml"
+# 21398 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 140 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21425 "parser_cocci_menhir.ml"
+# 21426 "parser_cocci_menhir.ml"
) =
# 175 "parser_cocci_menhir.mly"
( p )
-# 21429 "parser_cocci_menhir.ml"
+# 21430 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 140 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 21457 "parser_cocci_menhir.ml"
+# 21458 "parser_cocci_menhir.ml"
) =
# 176 "parser_cocci_menhir.mly"
( p )
-# 21461 "parser_cocci_menhir.ml"
+# 21462 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_plus_start =
-# 1658 "parser_cocci_menhir.mly"
+# 1659 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Ty(_1))))] )
-# 21485 "parser_cocci_menhir.ml"
+# 21486 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_plus_start =
-# 1659 "parser_cocci_menhir.mly"
+# 1660 "parser_cocci_menhir.mly"
( [Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.TopInit(_1))))] )
-# 21509 "parser_cocci_menhir.ml"
+# 21510 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_start =
-# 1661 "parser_cocci_menhir.mly"
+# 1662 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.OTHER(_1)))::_2 )
-# 21539 "parser_cocci_menhir.ml"
+# 21540 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_start =
-# 1663 "parser_cocci_menhir.mly"
+# 1664 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Exp(_1)))))::_2 )
-# 21569 "parser_cocci_menhir.ml"
+# 21570 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_start =
-# 1664 "parser_cocci_menhir.mly"
+# 1665 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DECL(_1))::_2 )
-# 21599 "parser_cocci_menhir.ml"
+# 21600 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_plus_start =
-# 1666 "parser_cocci_menhir.mly"
+# 1667 "parser_cocci_menhir.mly"
( (List.map (function x -> Ast0.wrap(Ast0.OTHER(x))) _1)@_2 )
-# 21629 "parser_cocci_menhir.ml"
+# 21630 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 21650 "parser_cocci_menhir.ml"
+# 21651 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pnrule =
# 230 "parser_cocci_menhir.mly"
( Ast.Dep _1 )
-# 21657 "parser_cocci_menhir.ml"
+# 21658 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 21682 "parser_cocci_menhir.ml"
+# 21683 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_pnrule =
# 231 "parser_cocci_menhir.mly"
( Ast.AntiDep _2 )
-# 21689 "parser_cocci_menhir.ml"
+# 21690 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 21714 "parser_cocci_menhir.ml"
+# 21715 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_pnrule =
# 232 "parser_cocci_menhir.mly"
( Ast.EverDep _2 )
-# 21721 "parser_cocci_menhir.ml"
+# 21722 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 21746 "parser_cocci_menhir.ml"
+# 21747 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_pnrule =
# 233 "parser_cocci_menhir.mly"
( Ast.NeverDep _2 )
-# 21753 "parser_cocci_menhir.ml"
+# 21754 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pnrule =
# 234 "parser_cocci_menhir.mly"
( _2 )
-# 21785 "parser_cocci_menhir.ml"
+# 21786 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1322 "parser_cocci_menhir.mly"
+# 1323 "parser_cocci_menhir.mly"
( _1 )
-# 21809 "parser_cocci_menhir.ml"
+# 21810 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 21845 "parser_cocci_menhir.ml"
+# 21846 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 21851 "parser_cocci_menhir.ml"
+# 21852 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1324 "parser_cocci_menhir.mly"
+# 1325 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.ArrayAccess (_1,P.clt2mcode "[" _2,_3,
P.clt2mcode "]" _4)) )
-# 21860 "parser_cocci_menhir.ml"
+# 21861 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 21892 "parser_cocci_menhir.ml"
+# 21893 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1327 "parser_cocci_menhir.mly"
+# 1328 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordAccess(_1, P.clt2mcode "." _2, _3)) )
-# 21900 "parser_cocci_menhir.ml"
+# 21901 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 104 "parser_cocci_menhir.mly"
(Data.clt)
-# 21932 "parser_cocci_menhir.ml"
+# 21933 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1329 "parser_cocci_menhir.mly"
+# 1330 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordPtAccess(_1, P.clt2mcode "->" _2,
_3)) )
-# 21941 "parser_cocci_menhir.ml"
+# 21942 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 21967 "parser_cocci_menhir.ml"
+# 21968 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1332 "parser_cocci_menhir.mly"
+# 1333 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Inc _2)) )
-# 21975 "parser_cocci_menhir.ml"
+# 21976 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22001 "parser_cocci_menhir.ml"
+# 22002 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1334 "parser_cocci_menhir.mly"
+# 1335 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Dec _2)) )
-# 22009 "parser_cocci_menhir.ml"
+# 22010 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 22045 "parser_cocci_menhir.ml"
+# 22046 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 22051 "parser_cocci_menhir.ml"
+# 22052 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_dot_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_dot_expressions_ =
-# 1336 "parser_cocci_menhir.mly"
+# 1337 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.FunCall(_1,P.clt2mcode "(" _2,
_3,
P.clt2mcode ")" _4)) )
-# 22061 "parser_cocci_menhir.ml"
+# 22062 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1322 "parser_cocci_menhir.mly"
+# 1323 "parser_cocci_menhir.mly"
( _1 )
-# 22085 "parser_cocci_menhir.ml"
+# 22086 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22121 "parser_cocci_menhir.ml"
+# 22122 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22127 "parser_cocci_menhir.ml"
+# 22128 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1324 "parser_cocci_menhir.mly"
+# 1325 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.ArrayAccess (_1,P.clt2mcode "[" _2,_3,
P.clt2mcode "]" _4)) )
-# 22136 "parser_cocci_menhir.ml"
+# 22137 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 22168 "parser_cocci_menhir.ml"
+# 22169 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1327 "parser_cocci_menhir.mly"
+# 1328 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordAccess(_1, P.clt2mcode "." _2, _3)) )
-# 22176 "parser_cocci_menhir.ml"
+# 22177 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 104 "parser_cocci_menhir.mly"
(Data.clt)
-# 22208 "parser_cocci_menhir.ml"
+# 22209 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1329 "parser_cocci_menhir.mly"
+# 1330 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordPtAccess(_1, P.clt2mcode "->" _2,
_3)) )
-# 22217 "parser_cocci_menhir.ml"
+# 22218 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22243 "parser_cocci_menhir.ml"
+# 22244 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1332 "parser_cocci_menhir.mly"
+# 1333 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Inc _2)) )
-# 22251 "parser_cocci_menhir.ml"
+# 22252 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22277 "parser_cocci_menhir.ml"
+# 22278 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1334 "parser_cocci_menhir.mly"
+# 1335 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Dec _2)) )
-# 22285 "parser_cocci_menhir.ml"
+# 22286 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 22321 "parser_cocci_menhir.ml"
+# 22322 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 22327 "parser_cocci_menhir.ml"
+# 22328 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_invalid_ =
-# 1336 "parser_cocci_menhir.mly"
+# 1337 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.FunCall(_1,P.clt2mcode "(" _2,
_3,
P.clt2mcode ")" _4)) )
-# 22337 "parser_cocci_menhir.ml"
+# 22338 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1322 "parser_cocci_menhir.mly"
+# 1323 "parser_cocci_menhir.mly"
( _1 )
-# 22361 "parser_cocci_menhir.ml"
+# 22362 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22397 "parser_cocci_menhir.ml"
+# 22398 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22403 "parser_cocci_menhir.ml"
+# 22404 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1324 "parser_cocci_menhir.mly"
+# 1325 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.ArrayAccess (_1,P.clt2mcode "[" _2,_3,
P.clt2mcode "]" _4)) )
-# 22412 "parser_cocci_menhir.ml"
+# 22413 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 22444 "parser_cocci_menhir.ml"
+# 22445 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1327 "parser_cocci_menhir.mly"
+# 1328 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordAccess(_1, P.clt2mcode "." _2, _3)) )
-# 22452 "parser_cocci_menhir.ml"
+# 22453 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 104 "parser_cocci_menhir.mly"
(Data.clt)
-# 22484 "parser_cocci_menhir.ml"
+# 22485 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1329 "parser_cocci_menhir.mly"
+# 1330 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordPtAccess(_1, P.clt2mcode "->" _2,
_3)) )
-# 22493 "parser_cocci_menhir.ml"
+# 22494 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22519 "parser_cocci_menhir.ml"
+# 22520 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1332 "parser_cocci_menhir.mly"
+# 1333 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Inc _2)) )
-# 22527 "parser_cocci_menhir.ml"
+# 22528 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22553 "parser_cocci_menhir.ml"
+# 22554 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1334 "parser_cocci_menhir.mly"
+# 1335 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Dec _2)) )
-# 22561 "parser_cocci_menhir.ml"
+# 22562 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 22597 "parser_cocci_menhir.ml"
+# 22598 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 22603 "parser_cocci_menhir.ml"
+# 22604 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_eexpr_nest_expressions_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_eexpr_nest_expressions_ =
-# 1336 "parser_cocci_menhir.mly"
+# 1337 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.FunCall(_1,P.clt2mcode "(" _2,
_3,
P.clt2mcode ")" _4)) )
-# 22613 "parser_cocci_menhir.ml"
+# 22614 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1322 "parser_cocci_menhir.mly"
+# 1323 "parser_cocci_menhir.mly"
( _1 )
-# 22637 "parser_cocci_menhir.ml"
+# 22638 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22673 "parser_cocci_menhir.ml"
+# 22674 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 102 "parser_cocci_menhir.mly"
(Data.clt)
-# 22679 "parser_cocci_menhir.ml"
+# 22680 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1324 "parser_cocci_menhir.mly"
+# 1325 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.ArrayAccess (_1,P.clt2mcode "[" _2,_3,
P.clt2mcode "]" _4)) )
-# 22688 "parser_cocci_menhir.ml"
+# 22689 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 22720 "parser_cocci_menhir.ml"
+# 22721 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1327 "parser_cocci_menhir.mly"
+# 1328 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordAccess(_1, P.clt2mcode "." _2, _3)) )
-# 22728 "parser_cocci_menhir.ml"
+# 22729 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 104 "parser_cocci_menhir.mly"
(Data.clt)
-# 22760 "parser_cocci_menhir.ml"
+# 22761 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1329 "parser_cocci_menhir.mly"
+# 1330 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.RecordPtAccess(_1, P.clt2mcode "->" _2,
_3)) )
-# 22769 "parser_cocci_menhir.ml"
+# 22770 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22795 "parser_cocci_menhir.ml"
+# 22796 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1332 "parser_cocci_menhir.mly"
+# 1333 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Inc _2)) )
-# 22803 "parser_cocci_menhir.ml"
+# 22804 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 22829 "parser_cocci_menhir.ml"
+# 22830 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1334 "parser_cocci_menhir.mly"
+# 1335 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Postfix (_1, P.clt2mcode Ast.Dec _2)) )
-# 22837 "parser_cocci_menhir.ml"
+# 22838 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 22873 "parser_cocci_menhir.ml"
+# 22874 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 22879 "parser_cocci_menhir.ml"
+# 22880 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_postfix_expr_expr_invalid_ = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
let _v : 'tv_postfix_expr_expr_invalid_ =
-# 1336 "parser_cocci_menhir.mly"
+# 1337 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.FunCall(_1,P.clt2mcode "(" _2,
_3,
P.clt2mcode ")" _4)) )
-# 22889 "parser_cocci_menhir.ml"
+# 22890 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1341 "parser_cocci_menhir.mly"
+# 1342 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Ident(_1)) )
-# 22913 "parser_cocci_menhir.ml"
+# 22914 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 22934 "parser_cocci_menhir.ml"
+# 22935 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1343 "parser_cocci_menhir.mly"
+# 1344 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Int x) clt)) )
-# 22942 "parser_cocci_menhir.ml"
+# 22943 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 22963 "parser_cocci_menhir.ml"
+# 22964 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1346 "parser_cocci_menhir.mly"
+# 1347 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Float x) clt)) )
-# 22971 "parser_cocci_menhir.ml"
+# 22972 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 22992 "parser_cocci_menhir.ml"
+# 22993 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1349 "parser_cocci_menhir.mly"
+# 1350 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.String x) clt)) )
-# 23000 "parser_cocci_menhir.ml"
+# 23001 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23021 "parser_cocci_menhir.ml"
+# 23022 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1352 "parser_cocci_menhir.mly"
+# 1353 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Char x) clt)) )
-# 23029 "parser_cocci_menhir.ml"
+# 23030 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23050 "parser_cocci_menhir.ml"
+# 23051 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1355 "parser_cocci_menhir.mly"
+# 1356 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.CONST,pure)) )
-# 23059 "parser_cocci_menhir.ml"
+# 23060 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 63 "parser_cocci_menhir.mly"
(Parse_aux.expinfo)
-# 23080 "parser_cocci_menhir.ml"
+# 23081 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1359 "parser_cocci_menhir.mly"
+# 1360 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaErr(P.clt2mcode nm clt,constraints,pure)) )
-# 23088 "parser_cocci_menhir.ml"
+# 23089 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23109 "parser_cocci_menhir.ml"
+# 23110 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1362 "parser_cocci_menhir.mly"
+# 1363 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ANY,pure)) )
-# 23118 "parser_cocci_menhir.ml"
+# 23119 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23139 "parser_cocci_menhir.ml"
+# 23140 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1366 "parser_cocci_menhir.mly"
+# 1367 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ID,pure)) )
-# 23148 "parser_cocci_menhir.ml"
+# 23149 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23169 "parser_cocci_menhir.ml"
+# 23170 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1370 "parser_cocci_menhir.mly"
+# 1371 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.LocalID,pure)) )
-# 23178 "parser_cocci_menhir.ml"
+# 23179 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 23209 "parser_cocci_menhir.ml"
+# 23210 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 23215 "parser_cocci_menhir.ml"
+# 23216 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1374 "parser_cocci_menhir.mly"
+# 1375 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Paren(P.clt2mcode "(" _1,_2,
P.clt2mcode ")" _3)) )
-# 23223 "parser_cocci_menhir.ml"
+# 23224 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 23254 "parser_cocci_menhir.ml"
+# 23255 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_eexpr_eexpr_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 23260 "parser_cocci_menhir.ml"
+# 23261 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1377 "parser_cocci_menhir.mly"
+# 1378 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap(Ast0.DisjExpr(P.clt2mcode "(" _1,
code, mids,
P.clt2mcode ")" _3)) )
-# 23270 "parser_cocci_menhir.ml"
+# 23271 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_dot_expressions_ =
-# 1381 "parser_cocci_menhir.mly"
+# 1382 "parser_cocci_menhir.mly"
( _1 )
-# 23294 "parser_cocci_menhir.ml"
+# 23295 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1341 "parser_cocci_menhir.mly"
+# 1342 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Ident(_1)) )
-# 23318 "parser_cocci_menhir.ml"
+# 23319 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23339 "parser_cocci_menhir.ml"
+# 23340 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1343 "parser_cocci_menhir.mly"
+# 1344 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Int x) clt)) )
-# 23347 "parser_cocci_menhir.ml"
+# 23348 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23368 "parser_cocci_menhir.ml"
+# 23369 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1346 "parser_cocci_menhir.mly"
+# 1347 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Float x) clt)) )
-# 23376 "parser_cocci_menhir.ml"
+# 23377 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23397 "parser_cocci_menhir.ml"
+# 23398 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1349 "parser_cocci_menhir.mly"
+# 1350 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.String x) clt)) )
-# 23405 "parser_cocci_menhir.ml"
+# 23406 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23426 "parser_cocci_menhir.ml"
+# 23427 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1352 "parser_cocci_menhir.mly"
+# 1353 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Char x) clt)) )
-# 23434 "parser_cocci_menhir.ml"
+# 23435 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23455 "parser_cocci_menhir.ml"
+# 23456 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1355 "parser_cocci_menhir.mly"
+# 1356 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.CONST,pure)) )
-# 23464 "parser_cocci_menhir.ml"
+# 23465 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 63 "parser_cocci_menhir.mly"
(Parse_aux.expinfo)
-# 23485 "parser_cocci_menhir.ml"
+# 23486 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1359 "parser_cocci_menhir.mly"
+# 1360 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaErr(P.clt2mcode nm clt,constraints,pure)) )
-# 23493 "parser_cocci_menhir.ml"
+# 23494 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23514 "parser_cocci_menhir.ml"
+# 23515 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1362 "parser_cocci_menhir.mly"
+# 1363 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ANY,pure)) )
-# 23523 "parser_cocci_menhir.ml"
+# 23524 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23544 "parser_cocci_menhir.ml"
+# 23545 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1366 "parser_cocci_menhir.mly"
+# 1367 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ID,pure)) )
-# 23553 "parser_cocci_menhir.ml"
+# 23554 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23574 "parser_cocci_menhir.ml"
+# 23575 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1370 "parser_cocci_menhir.mly"
+# 1371 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.LocalID,pure)) )
-# 23583 "parser_cocci_menhir.ml"
+# 23584 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 23614 "parser_cocci_menhir.ml"
+# 23615 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 23620 "parser_cocci_menhir.ml"
+# 23621 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1374 "parser_cocci_menhir.mly"
+# 1375 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Paren(P.clt2mcode "(" _1,_2,
P.clt2mcode ")" _3)) )
-# 23628 "parser_cocci_menhir.ml"
+# 23629 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 23659 "parser_cocci_menhir.ml"
+# 23660 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_eexpr_eexpr_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 23665 "parser_cocci_menhir.ml"
+# 23666 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1377 "parser_cocci_menhir.mly"
+# 1378 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap(Ast0.DisjExpr(P.clt2mcode "(" _1,
code, mids,
P.clt2mcode ")" _3)) )
-# 23675 "parser_cocci_menhir.ml"
+# 23676 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_invalid_ =
-# 1381 "parser_cocci_menhir.mly"
+# 1382 "parser_cocci_menhir.mly"
( _1 )
-# 23699 "parser_cocci_menhir.ml"
+# 23700 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1341 "parser_cocci_menhir.mly"
+# 1342 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Ident(_1)) )
-# 23723 "parser_cocci_menhir.ml"
+# 23724 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23744 "parser_cocci_menhir.ml"
+# 23745 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1343 "parser_cocci_menhir.mly"
+# 1344 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Int x) clt)) )
-# 23752 "parser_cocci_menhir.ml"
+# 23753 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23773 "parser_cocci_menhir.ml"
+# 23774 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1346 "parser_cocci_menhir.mly"
+# 1347 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Float x) clt)) )
-# 23781 "parser_cocci_menhir.ml"
+# 23782 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23802 "parser_cocci_menhir.ml"
+# 23803 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1349 "parser_cocci_menhir.mly"
+# 1350 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.String x) clt)) )
-# 23810 "parser_cocci_menhir.ml"
+# 23811 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 23831 "parser_cocci_menhir.ml"
+# 23832 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1352 "parser_cocci_menhir.mly"
+# 1353 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Char x) clt)) )
-# 23839 "parser_cocci_menhir.ml"
+# 23840 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23860 "parser_cocci_menhir.ml"
+# 23861 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1355 "parser_cocci_menhir.mly"
+# 1356 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.CONST,pure)) )
-# 23869 "parser_cocci_menhir.ml"
+# 23870 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 63 "parser_cocci_menhir.mly"
(Parse_aux.expinfo)
-# 23890 "parser_cocci_menhir.ml"
+# 23891 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1359 "parser_cocci_menhir.mly"
+# 1360 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaErr(P.clt2mcode nm clt,constraints,pure)) )
-# 23898 "parser_cocci_menhir.ml"
+# 23899 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23919 "parser_cocci_menhir.ml"
+# 23920 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1362 "parser_cocci_menhir.mly"
+# 1363 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ANY,pure)) )
-# 23928 "parser_cocci_menhir.ml"
+# 23929 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23949 "parser_cocci_menhir.ml"
+# 23950 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1366 "parser_cocci_menhir.mly"
+# 1367 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ID,pure)) )
-# 23958 "parser_cocci_menhir.ml"
+# 23959 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 23979 "parser_cocci_menhir.ml"
+# 23980 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1370 "parser_cocci_menhir.mly"
+# 1371 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.LocalID,pure)) )
-# 23988 "parser_cocci_menhir.ml"
+# 23989 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 24019 "parser_cocci_menhir.ml"
+# 24020 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 24025 "parser_cocci_menhir.ml"
+# 24026 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1374 "parser_cocci_menhir.mly"
+# 1375 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Paren(P.clt2mcode "(" _1,_2,
P.clt2mcode ")" _3)) )
-# 24033 "parser_cocci_menhir.ml"
+# 24034 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 24064 "parser_cocci_menhir.ml"
+# 24065 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_eexpr_eexpr_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 24070 "parser_cocci_menhir.ml"
+# 24071 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1377 "parser_cocci_menhir.mly"
+# 1378 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap(Ast0.DisjExpr(P.clt2mcode "(" _1,
code, mids,
P.clt2mcode ")" _3)) )
-# 24080 "parser_cocci_menhir.ml"
+# 24081 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_eexpr_nest_expressions_ =
-# 1381 "parser_cocci_menhir.mly"
+# 1382 "parser_cocci_menhir.mly"
( _1 )
-# 24104 "parser_cocci_menhir.ml"
+# 24105 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1341 "parser_cocci_menhir.mly"
+# 1342 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Ident(_1)) )
-# 24128 "parser_cocci_menhir.ml"
+# 24129 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24149 "parser_cocci_menhir.ml"
+# 24150 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1343 "parser_cocci_menhir.mly"
+# 1344 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Int x) clt)) )
-# 24157 "parser_cocci_menhir.ml"
+# 24158 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24178 "parser_cocci_menhir.ml"
+# 24179 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1346 "parser_cocci_menhir.mly"
+# 1347 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Float x) clt)) )
-# 24186 "parser_cocci_menhir.ml"
+# 24187 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24207 "parser_cocci_menhir.ml"
+# 24208 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1349 "parser_cocci_menhir.mly"
+# 1350 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.String x) clt)) )
-# 24215 "parser_cocci_menhir.ml"
+# 24216 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24236 "parser_cocci_menhir.ml"
+# 24237 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1352 "parser_cocci_menhir.mly"
+# 1353 "parser_cocci_menhir.mly"
( let (x,clt) = _1 in
Ast0.wrap(Ast0.Constant (P.clt2mcode (Ast.Char x) clt)) )
-# 24244 "parser_cocci_menhir.ml"
+# 24245 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 24265 "parser_cocci_menhir.ml"
+# 24266 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1355 "parser_cocci_menhir.mly"
+# 1356 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.CONST,pure)) )
-# 24274 "parser_cocci_menhir.ml"
+# 24275 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 63 "parser_cocci_menhir.mly"
(Parse_aux.expinfo)
-# 24295 "parser_cocci_menhir.ml"
+# 24296 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1359 "parser_cocci_menhir.mly"
+# 1360 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaErr(P.clt2mcode nm clt,constraints,pure)) )
-# 24303 "parser_cocci_menhir.ml"
+# 24304 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 24324 "parser_cocci_menhir.ml"
+# 24325 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1362 "parser_cocci_menhir.mly"
+# 1363 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ANY,pure)) )
-# 24333 "parser_cocci_menhir.ml"
+# 24334 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 24354 "parser_cocci_menhir.ml"
+# 24355 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1366 "parser_cocci_menhir.mly"
+# 1367 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.ID,pure)) )
-# 24363 "parser_cocci_menhir.ml"
+# 24364 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 67 "parser_cocci_menhir.mly"
(Parse_aux.typed_info)
-# 24384 "parser_cocci_menhir.ml"
+# 24385 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1370 "parser_cocci_menhir.mly"
+# 1371 "parser_cocci_menhir.mly"
( let (nm,constraints,pure,ty,clt) = _1 in
Ast0.wrap
(Ast0.MetaExpr(P.clt2mcode nm clt,constraints,ty,Ast.LocalID,pure)) )
-# 24393 "parser_cocci_menhir.ml"
+# 24394 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 24424 "parser_cocci_menhir.ml"
+# 24425 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 24430 "parser_cocci_menhir.ml"
+# 24431 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1374 "parser_cocci_menhir.mly"
+# 1375 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Paren(P.clt2mcode "(" _1,_2,
P.clt2mcode ")" _3)) )
-# 24438 "parser_cocci_menhir.ml"
+# 24439 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 24469 "parser_cocci_menhir.ml"
+# 24470 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_expr_eexpr_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 24475 "parser_cocci_menhir.ml"
+# 24476 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1377 "parser_cocci_menhir.mly"
+# 1378 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap(Ast0.DisjExpr(P.clt2mcode "(" _1,
code, mids,
P.clt2mcode ")" _3)) )
-# 24485 "parser_cocci_menhir.ml"
+# 24486 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_primary_expr_expr_invalid_ =
-# 1381 "parser_cocci_menhir.mly"
+# 1382 "parser_cocci_menhir.mly"
( _1 )
-# 24509 "parser_cocci_menhir.ml"
+# 24510 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pure =
# 190 "parser_cocci_menhir.mly"
( Ast0.Pure )
-# 24531 "parser_cocci_menhir.ml"
+# 24532 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pure =
# 191 "parser_cocci_menhir.mly"
( Ast0.Context )
-# 24553 "parser_cocci_menhir.ml"
+# 24554 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pure =
# 192 "parser_cocci_menhir.mly"
( Ast0.PureContext )
-# 24579 "parser_cocci_menhir.ml"
+# 24580 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pure =
# 193 "parser_cocci_menhir.mly"
( Ast0.PureContext )
-# 24605 "parser_cocci_menhir.ml"
+# 24606 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_pure =
# 194 "parser_cocci_menhir.mly"
( Ast0.Impure )
-# 24622 "parser_cocci_menhir.ml"
+# 24623 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 59 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24643 "parser_cocci_menhir.ml"
+# 24644 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident =
-# 1395 "parser_cocci_menhir.mly"
+# 1396 "parser_cocci_menhir.mly"
( _1 )
-# 24650 "parser_cocci_menhir.ml"
+# 24651 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1401 "parser_cocci_menhir.mly"
+# 1402 "parser_cocci_menhir.mly"
( (None,P.id2name _1) )
-# 24674 "parser_cocci_menhir.ml"
+# 24675 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1402 "parser_cocci_menhir.mly"
+# 1403 "parser_cocci_menhir.mly"
( _1 )
-# 24698 "parser_cocci_menhir.ml"
+# 24699 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1403 "parser_cocci_menhir.mly"
+# 1404 "parser_cocci_menhir.mly"
( (None,"list") )
-# 24720 "parser_cocci_menhir.ml"
+# 24721 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1404 "parser_cocci_menhir.mly"
+# 1405 "parser_cocci_menhir.mly"
( (None,"error") )
-# 24742 "parser_cocci_menhir.ml"
+# 24743 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1405 "parser_cocci_menhir.mly"
+# 1406 "parser_cocci_menhir.mly"
( (None,"type") )
-# 24764 "parser_cocci_menhir.ml"
+# 24765 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident =
-# 1406 "parser_cocci_menhir.mly"
+# 1407 "parser_cocci_menhir.mly"
( (None,"name") )
-# 24786 "parser_cocci_menhir.ml"
+# 24787 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_i_ in
let _endpos = _endpos_l_ in
let _v : 'tv_pure_ident_or_meta_ident_with_not_eq_not_ceq_ =
-# 1413 "parser_cocci_menhir.mly"
+# 1414 "parser_cocci_menhir.mly"
( (i,l) )
-# 24816 "parser_cocci_menhir.ml"
+# 24817 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_i_ in
let _endpos = _endpos_l_ in
let _v : 'tv_pure_ident_or_meta_ident_with_not_eq_not_eq_ =
-# 1413 "parser_cocci_menhir.mly"
+# 1414 "parser_cocci_menhir.mly"
( (i,l) )
-# 24846 "parser_cocci_menhir.ml"
+# 24847 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_i_ in
let _endpos = _endpos_l_ in
let _v : 'tv_pure_ident_or_meta_ident_with_not_eq_not_eqe_ =
-# 1413 "parser_cocci_menhir.mly"
+# 1414 "parser_cocci_menhir.mly"
( (i,l) )
-# 24876 "parser_cocci_menhir.ml"
+# 24877 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos_i_ in
let _endpos = _endpos_l_ in
let _v : 'tv_pure_ident_or_meta_ident_with_not_eq_not_pos_ =
-# 1413 "parser_cocci_menhir.mly"
+# 1414 "parser_cocci_menhir.mly"
( (i,l) )
-# 24906 "parser_cocci_menhir.ml"
+# 24907 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_pure_ident_or_meta_ident_with_seed =
-# 1409 "parser_cocci_menhir.mly"
+# 1410 "parser_cocci_menhir.mly"
( (_1,None) )
-# 24930 "parser_cocci_menhir.ml"
+# 24931 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 24960 "parser_cocci_menhir.ml"
+# 24961 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _1 : 'tv_pure_ident_or_meta_ident = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_s_ in
let _v : 'tv_pure_ident_or_meta_ident_with_seed =
-# 1410 "parser_cocci_menhir.mly"
+# 1411 "parser_cocci_menhir.mly"
( (_1,Some (P.id2name s)) )
-# 24968 "parser_cocci_menhir.ml"
+# 24969 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 131 "parser_cocci_menhir.mly"
(unit)
-# 24985 "parser_cocci_menhir.ml"
+# 24986 "parser_cocci_menhir.ml"
) =
# 172 "parser_cocci_menhir.mly"
( )
-# 24989 "parser_cocci_menhir.ml"
+# 24990 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_rule_elem_statement =
-# 915 "parser_cocci_menhir.mly"
+# 916 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Decl((Ast0.default_info(),Ast0.context_befaft()),_1)) )
-# 25013 "parser_cocci_menhir.ml"
+# 25014 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 25039 "parser_cocci_menhir.ml"
+# 25040 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_expr = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_rule_elem_statement =
-# 916 "parser_cocci_menhir.mly"
+# 917 "parser_cocci_menhir.mly"
( P.exp_stm _1 _2 )
-# 25047 "parser_cocci_menhir.ml"
+# 25048 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 25078 "parser_cocci_menhir.ml"
+# 25079 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 25084 "parser_cocci_menhir.ml"
+# 25085 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_rule_elem_statement =
-# 917 "parser_cocci_menhir.mly"
+# 918 "parser_cocci_menhir.mly"
( P.ret_exp _1 _2 _3 )
-# 25091 "parser_cocci_menhir.ml"
+# 25092 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 25117 "parser_cocci_menhir.ml"
+# 25118 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 25122 "parser_cocci_menhir.ml"
+# 25123 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_rule_elem_statement =
-# 918 "parser_cocci_menhir.mly"
+# 919 "parser_cocci_menhir.mly"
( P.ret _1 _2 )
-# 25129 "parser_cocci_menhir.ml"
+# 25130 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 25155 "parser_cocci_menhir.ml"
+# 25156 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 25160 "parser_cocci_menhir.ml"
+# 25161 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_rule_elem_statement =
-# 919 "parser_cocci_menhir.mly"
+# 920 "parser_cocci_menhir.mly"
( P.break _1 _2 )
-# 25167 "parser_cocci_menhir.ml"
+# 25168 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 25193 "parser_cocci_menhir.ml"
+# 25194 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 25198 "parser_cocci_menhir.ml"
+# 25199 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_rule_elem_statement =
-# 920 "parser_cocci_menhir.mly"
+# 921 "parser_cocci_menhir.mly"
( P.cont _1 _2 )
-# 25205 "parser_cocci_menhir.ml"
+# 25206 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 25236 "parser_cocci_menhir.ml"
+# 25237 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_rule_elem_statement_rule_elem_statement_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 25242 "parser_cocci_menhir.ml"
+# 25243 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_rule_elem_statement =
-# 922 "parser_cocci_menhir.mly"
+# 923 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap
(Ast0.Disj(P.clt2mcode "(" _1,
List.map (function x -> Ast0.wrap(Ast0.DOTS([x]))) code,
mids, P.clt2mcode ")" _3)) )
-# 25253 "parser_cocci_menhir.ml"
+# 25254 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25309 "parser_cocci_menhir.ml"
+# 25310 "parser_cocci_menhir.ml"
) = let nm =
# 39 "standard.mly"
( None )
-# 25314 "parser_cocci_menhir.ml"
+# 25315 "parser_cocci_menhir.ml"
in
# 202 "parser_cocci_menhir.mly"
( P.make_cocci_rule_name_result nm d i a e ee )
-# 25320 "parser_cocci_menhir.ml"
+# 25321 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25382 "parser_cocci_menhir.ml"
+# 25383 "parser_cocci_menhir.ml"
) = let nm =
let x = x0 in
# 41 "standard.mly"
( Some x )
-# 25388 "parser_cocci_menhir.ml"
+# 25389 "parser_cocci_menhir.ml"
in
# 202 "parser_cocci_menhir.mly"
( P.make_cocci_rule_name_result nm d i a e ee )
-# 25394 "parser_cocci_menhir.ml"
+# 25395 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25454 "parser_cocci_menhir.ml"
+# 25455 "parser_cocci_menhir.ml"
) =
# 207 "parser_cocci_menhir.mly"
( P.make_generated_rule_name_result None d i a e ee )
-# 25458 "parser_cocci_menhir.ml"
+# 25459 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25500 "parser_cocci_menhir.ml"
+# 25501 "parser_cocci_menhir.ml"
) =
# 209 "parser_cocci_menhir.mly"
( P.make_script_rule_name_result lang d )
-# 25504 "parser_cocci_menhir.ml"
+# 25505 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25540 "parser_cocci_menhir.ml"
+# 25541 "parser_cocci_menhir.ml"
) =
# 211 "parser_cocci_menhir.mly"
( P.make_initial_script_rule_name_result lang )
-# 25544 "parser_cocci_menhir.ml"
+# 25545 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 25580 "parser_cocci_menhir.ml"
+# 25581 "parser_cocci_menhir.ml"
) =
# 213 "parser_cocci_menhir.mly"
( P.make_final_script_rule_name_result lang )
-# 25584 "parser_cocci_menhir.ml"
+# 25585 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 47 "parser_cocci_menhir.mly"
(string)
-# 25628 "parser_cocci_menhir.ml"
+# 25629 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let py : 'tv_pure_ident = Obj.magic py in
let _startpos = _startpos_py_ in
let _v : (
# 159 "parser_cocci_menhir.mly"
(string * (string * string))
-# 25636 "parser_cocci_menhir.ml"
+# 25637 "parser_cocci_menhir.ml"
) =
-# 1873 "parser_cocci_menhir.mly"
+# 1879 "parser_cocci_menhir.mly"
( (P.id2name py, (_3, P.id2name cocci)) )
-# 25640 "parser_cocci_menhir.ml"
+# 25641 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let x : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 25661 "parser_cocci_menhir.ml"
+# 25662 "parser_cocci_menhir.ml"
) = Obj.magic x in
let _startpos = _startpos_x_ in
let _endpos = _endpos_x_ in
let _v : 'tv_separated_nonempty_list_TComma_TString_ =
# 144 "standard.mly"
( [ x ] )
-# 25668 "parser_cocci_menhir.ml"
+# 25669 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let x : (
# 87 "parser_cocci_menhir.mly"
(string * Data.clt)
-# 25699 "parser_cocci_menhir.ml"
+# 25700 "parser_cocci_menhir.ml"
) = Obj.magic x in
let _startpos = _startpos_x_ in
let _endpos = _endpos_xs_ in
let _v : 'tv_separated_nonempty_list_TComma_TString_ =
# 146 "standard.mly"
( x :: xs )
-# 25706 "parser_cocci_menhir.ml"
+# 25707 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_any_strict_ =
# 144 "standard.mly"
( [ x ] )
-# 25730 "parser_cocci_menhir.ml"
+# 25731 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_any_strict_ =
# 146 "standard.mly"
( x :: xs )
-# 25764 "parser_cocci_menhir.ml"
+# 25765 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_ctype_ =
# 144 "standard.mly"
( [ x ] )
-# 25788 "parser_cocci_menhir.ml"
+# 25789 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_ctype_ =
# 146 "standard.mly"
( x :: xs )
-# 25822 "parser_cocci_menhir.ml"
+# 25823 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_d_ident_ =
# 144 "standard.mly"
( [ x ] )
-# 25846 "parser_cocci_menhir.ml"
+# 25847 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_d_ident_ =
# 146 "standard.mly"
( x :: xs )
-# 25880 "parser_cocci_menhir.ml"
+# 25881 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_dexpr_ =
# 144 "standard.mly"
( [ x ] )
-# 25904 "parser_cocci_menhir.ml"
+# 25905 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_dexpr_ =
# 146 "standard.mly"
( x :: xs )
-# 25938 "parser_cocci_menhir.ml"
+# 25939 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_ident_or_const_ =
# 144 "standard.mly"
( [ x ] )
-# 25962 "parser_cocci_menhir.ml"
+# 25963 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_ident_or_const_ =
# 146 "standard.mly"
( x :: xs )
-# 25996 "parser_cocci_menhir.ml"
+# 25997 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_meta_ident_ =
# 144 "standard.mly"
( [ x ] )
-# 26020 "parser_cocci_menhir.ml"
+# 26021 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_meta_ident_ =
# 146 "standard.mly"
( x :: xs )
-# 26054 "parser_cocci_menhir.ml"
+# 26055 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_ =
# 144 "standard.mly"
( [ x ] )
-# 26078 "parser_cocci_menhir.ml"
+# 26079 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_ =
# 146 "standard.mly"
( x :: xs )
-# 26112 "parser_cocci_menhir.ml"
+# 26113 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_ =
# 144 "standard.mly"
( [ x ] )
-# 26136 "parser_cocci_menhir.ml"
+# 26137 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_ =
# 146 "standard.mly"
( x :: xs )
-# 26170 "parser_cocci_menhir.ml"
+# 26171 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_ceq__ =
# 144 "standard.mly"
( [ x ] )
-# 26194 "parser_cocci_menhir.ml"
+# 26195 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_ceq__ =
# 146 "standard.mly"
( x :: xs )
-# 26228 "parser_cocci_menhir.ml"
+# 26229 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_eq__ =
# 144 "standard.mly"
( [ x ] )
-# 26252 "parser_cocci_menhir.ml"
+# 26253 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_eq__ =
# 146 "standard.mly"
( x :: xs )
-# 26286 "parser_cocci_menhir.ml"
+# 26287 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_eqe__ =
# 144 "standard.mly"
( [ x ] )
-# 26310 "parser_cocci_menhir.ml"
+# 26311 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_eqe__ =
# 146 "standard.mly"
( x :: xs )
-# 26344 "parser_cocci_menhir.ml"
+# 26345 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_pos__ =
# 144 "standard.mly"
( [ x ] )
-# 26368 "parser_cocci_menhir.ml"
+# 26369 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_not_eq_not_pos__ =
# 146 "standard.mly"
( x :: xs )
-# 26402 "parser_cocci_menhir.ml"
+# 26403 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_seed_ =
# 144 "standard.mly"
( [ x ] )
-# 26426 "parser_cocci_menhir.ml"
+# 26427 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_separated_nonempty_list_TComma_pure_ident_or_meta_ident_with_seed_ =
# 146 "standard.mly"
( x :: xs )
-# 26460 "parser_cocci_menhir.ml"
+# 26461 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_single_statement =
-# 930 "parser_cocci_menhir.mly"
+# 931 "parser_cocci_menhir.mly"
( _1 )
-# 26484 "parser_cocci_menhir.ml"
+# 26485 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26515 "parser_cocci_menhir.ml"
+# 26516 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_midzero_list_statement_statement_ = Obj.magic _2 in
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26521 "parser_cocci_menhir.ml"
+# 26522 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_single_statement =
-# 934 "parser_cocci_menhir.mly"
+# 935 "parser_cocci_menhir.mly"
( let (mids,code) = _2 in
Ast0.wrap
(Ast0.Disj(P.clt2mcode "(" _1,
List.map (function x -> Ast0.wrap(Ast0.DOTS([x]))) code,
mids, P.clt2mcode ")" _3)) )
-# 26532 "parser_cocci_menhir.ml"
+# 26533 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_statement =
-# 857 "parser_cocci_menhir.mly"
+# 858 "parser_cocci_menhir.mly"
( _1 )
-# 26556 "parser_cocci_menhir.ml"
+# 26557 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 26577 "parser_cocci_menhir.ml"
+# 26578 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_statement =
-# 859 "parser_cocci_menhir.mly"
+# 860 "parser_cocci_menhir.mly"
( P.meta_stm _1 )
-# 26584 "parser_cocci_menhir.ml"
+# 26585 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 26610 "parser_cocci_menhir.ml"
+# 26611 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_expr = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_statement =
-# 861 "parser_cocci_menhir.mly"
+# 862 "parser_cocci_menhir.mly"
( P.exp_stm _1 _2 )
-# 26618 "parser_cocci_menhir.ml"
+# 26619 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26660 "parser_cocci_menhir.ml"
+# 26661 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26666 "parser_cocci_menhir.ml"
+# 26667 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26671 "parser_cocci_menhir.ml"
+# 26672 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_statement =
-# 863 "parser_cocci_menhir.mly"
+# 864 "parser_cocci_menhir.mly"
( P.ifthen _1 _2 _3 _4 _5 )
-# 26678 "parser_cocci_menhir.ml"
+# 26679 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _6 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26730 "parser_cocci_menhir.ml"
+# 26731 "parser_cocci_menhir.ml"
) = Obj.magic _6 in
let _5 : 'tv_single_statement = Obj.magic _5 in
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26736 "parser_cocci_menhir.ml"
+# 26737 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26742 "parser_cocci_menhir.ml"
+# 26743 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26747 "parser_cocci_menhir.ml"
+# 26748 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__7_ in
let _v : 'tv_statement =
-# 865 "parser_cocci_menhir.mly"
+# 866 "parser_cocci_menhir.mly"
( P.ifthenelse _1 _2 _3 _4 _5 _6 _7 )
-# 26754 "parser_cocci_menhir.ml"
+# 26755 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _8 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26816 "parser_cocci_menhir.ml"
+# 26817 "parser_cocci_menhir.ml"
) = Obj.magic _8 in
let _7 : 'tv_option_eexpr_ = Obj.magic _7 in
let _6 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 26822 "parser_cocci_menhir.ml"
+# 26823 "parser_cocci_menhir.ml"
) = Obj.magic _6 in
let _5 : 'tv_option_eexpr_ = Obj.magic _5 in
let _4 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 26828 "parser_cocci_menhir.ml"
+# 26829 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_option_eexpr_ = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26834 "parser_cocci_menhir.ml"
+# 26835 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26839 "parser_cocci_menhir.ml"
+# 26840 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__9_ in
let _v : 'tv_statement =
-# 868 "parser_cocci_menhir.mly"
+# 869 "parser_cocci_menhir.mly"
( P.forloop _1 _2 _3 _4 _5 _6 _7 _8 _9 )
-# 26846 "parser_cocci_menhir.ml"
+# 26847 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26888 "parser_cocci_menhir.ml"
+# 26889 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26894 "parser_cocci_menhir.ml"
+# 26895 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26899 "parser_cocci_menhir.ml"
+# 26900 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_statement =
-# 870 "parser_cocci_menhir.mly"
+# 871 "parser_cocci_menhir.mly"
( P.whileloop _1 _2 _3 _4 _5 )
-# 26906 "parser_cocci_menhir.ml"
+# 26907 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _7 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 26957 "parser_cocci_menhir.ml"
+# 26958 "parser_cocci_menhir.ml"
) = Obj.magic _7 in
let _6 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 26962 "parser_cocci_menhir.ml"
+# 26963 "parser_cocci_menhir.ml"
) = Obj.magic _6 in
let _5 : 'tv_eexpr = Obj.magic _5 in
let _4 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 26968 "parser_cocci_menhir.ml"
+# 26969 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26973 "parser_cocci_menhir.ml"
+# 26974 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_single_statement = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 26979 "parser_cocci_menhir.ml"
+# 26980 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__7_ in
let _v : 'tv_statement =
-# 872 "parser_cocci_menhir.mly"
+# 873 "parser_cocci_menhir.mly"
( P.doloop _1 _2 _3 _4 _5 _6 _7 )
-# 26986 "parser_cocci_menhir.ml"
+# 26987 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 27028 "parser_cocci_menhir.ml"
+# 27029 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr_list_option = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 27034 "parser_cocci_menhir.ml"
+# 27035 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_iter_ident = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__5_ in
let _v : 'tv_statement =
-# 874 "parser_cocci_menhir.mly"
+# 875 "parser_cocci_menhir.mly"
( P.iterator _1 _2 _3 _4 _5 )
-# 27042 "parser_cocci_menhir.ml"
+# 27043 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _7 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 27093 "parser_cocci_menhir.ml"
+# 27094 "parser_cocci_menhir.ml"
) = Obj.magic _7 in
let _6 : 'tv_list_case_line_ = Obj.magic _6 in
let _5 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 27099 "parser_cocci_menhir.ml"
+# 27100 "parser_cocci_menhir.ml"
) = Obj.magic _5 in
let _4 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 27104 "parser_cocci_menhir.ml"
+# 27105 "parser_cocci_menhir.ml"
) = Obj.magic _4 in
let _3 : 'tv_eexpr = Obj.magic _3 in
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 27110 "parser_cocci_menhir.ml"
+# 27111 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 27115 "parser_cocci_menhir.ml"
+# 27116 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__7_ in
let _v : 'tv_statement =
-# 876 "parser_cocci_menhir.mly"
+# 877 "parser_cocci_menhir.mly"
( P.switch _1 _2 _3 _4 _5 _6 _7 )
-# 27122 "parser_cocci_menhir.ml"
+# 27123 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27153 "parser_cocci_menhir.ml"
+# 27154 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_eexpr = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 27159 "parser_cocci_menhir.ml"
+# 27160 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_statement =
-# 877 "parser_cocci_menhir.mly"
+# 878 "parser_cocci_menhir.mly"
( P.ret_exp _1 _2 _3 )
-# 27166 "parser_cocci_menhir.ml"
+# 27167 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27192 "parser_cocci_menhir.ml"
+# 27193 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 57 "parser_cocci_menhir.mly"
(Data.clt)
-# 27197 "parser_cocci_menhir.ml"
+# 27198 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_statement =
-# 878 "parser_cocci_menhir.mly"
+# 879 "parser_cocci_menhir.mly"
( P.ret _1 _2 )
-# 27204 "parser_cocci_menhir.ml"
+# 27205 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27230 "parser_cocci_menhir.ml"
+# 27231 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 27235 "parser_cocci_menhir.ml"
+# 27236 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_statement =
-# 879 "parser_cocci_menhir.mly"
+# 880 "parser_cocci_menhir.mly"
( P.break _1 _2 )
-# 27242 "parser_cocci_menhir.ml"
+# 27243 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27268 "parser_cocci_menhir.ml"
+# 27269 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 27273 "parser_cocci_menhir.ml"
+# 27274 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_statement =
-# 880 "parser_cocci_menhir.mly"
+# 881 "parser_cocci_menhir.mly"
( P.cont _1 _2 )
-# 27280 "parser_cocci_menhir.ml"
+# 27281 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 27306 "parser_cocci_menhir.ml"
+# 27307 "parser_cocci_menhir.ml"
) = Obj.magic _2 in
let _1 : 'tv_ident = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_statement =
-# 881 "parser_cocci_menhir.mly"
+# 882 "parser_cocci_menhir.mly"
( P.label _1 _2 )
-# 27314 "parser_cocci_menhir.ml"
+# 27315 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27345 "parser_cocci_menhir.ml"
+# 27346 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_ident = Obj.magic _2 in
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 27351 "parser_cocci_menhir.ml"
+# 27352 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_statement =
-# 882 "parser_cocci_menhir.mly"
+# 883 "parser_cocci_menhir.mly"
( P.goto _1 _2 _3 )
-# 27358 "parser_cocci_menhir.ml"
+# 27359 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 27389 "parser_cocci_menhir.ml"
+# 27390 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_fun_start = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 27395 "parser_cocci_menhir.ml"
+# 27396 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_statement =
-# 884 "parser_cocci_menhir.mly"
+# 885 "parser_cocci_menhir.mly"
( P.seq _1 _2 _3 )
-# 27402 "parser_cocci_menhir.ml"
+# 27403 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 27429 "parser_cocci_menhir.ml"
+# 27430 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_w_ in
let _v : 'tv_stm_dots =
-# 888 "parser_cocci_menhir.mly"
+# 889 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Dots(P.clt2mcode "..." _1, List.concat w)) )
-# 27436 "parser_cocci_menhir.ml"
+# 27437 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 27472 "parser_cocci_menhir.ml"
+# 27473 "parser_cocci_menhir.ml"
) = Obj.magic c in
let b : 'tv_nest_start = Obj.magic b in
let w : 'tv_list_whenppdecs_ = Obj.magic w in
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 27479 "parser_cocci_menhir.ml"
+# 27480 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_c_ in
let _v : 'tv_stm_dots =
-# 890 "parser_cocci_menhir.mly"
+# 891 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<..." _1, b,
P.clt2mcode "...>" c, List.concat w, false)) )
-# 27487 "parser_cocci_menhir.ml"
+# 27488 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 27523 "parser_cocci_menhir.ml"
+# 27524 "parser_cocci_menhir.ml"
) = Obj.magic c in
let b : 'tv_nest_start = Obj.magic b in
let w : 'tv_list_whenppdecs_ = Obj.magic w in
let _1 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 27530 "parser_cocci_menhir.ml"
+# 27531 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos_c_ in
let _v : 'tv_stm_dots =
-# 893 "parser_cocci_menhir.mly"
+# 894 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<+..." _1, b,
P.clt2mcode "...+>" c, List.concat w, true)) )
-# 27538 "parser_cocci_menhir.ml"
+# 27539 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 27559 "parser_cocci_menhir.ml"
+# 27560 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_s_ in
let _v : 'tv_storage =
-# 815 "parser_cocci_menhir.mly"
+# 816 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Static s )
-# 27566 "parser_cocci_menhir.ml"
+# 27567 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 27587 "parser_cocci_menhir.ml"
+# 27588 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_s_ in
let _v : 'tv_storage =
-# 816 "parser_cocci_menhir.mly"
+# 817 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Auto s )
-# 27594 "parser_cocci_menhir.ml"
+# 27595 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 27615 "parser_cocci_menhir.ml"
+# 27616 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_s_ in
let _v : 'tv_storage =
-# 817 "parser_cocci_menhir.mly"
+# 818 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Register s )
-# 27622 "parser_cocci_menhir.ml"
+# 27623 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 53 "parser_cocci_menhir.mly"
(Data.clt)
-# 27643 "parser_cocci_menhir.ml"
+# 27644 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_s_ in
let _v : 'tv_storage =
-# 818 "parser_cocci_menhir.mly"
+# 819 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Extern s )
-# 27650 "parser_cocci_menhir.ml"
+# 27651 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_struct_decl =
# 521 "parser_cocci_menhir.mly"
( [] )
-# 27672 "parser_cocci_menhir.ml"
+# 27673 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27703 "parser_cocci_menhir.ml"
+# 27704 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let t : 'tv_ctype = Obj.magic t in
# 523 "parser_cocci_menhir.mly"
( let (id,fn) = d in
[Ast0.wrap(Ast0.UnInit(None,fn t,id,P.clt2mcode ";" pv))] )
-# 27713 "parser_cocci_menhir.ml"
+# 27714 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27774 "parser_cocci_menhir.ml"
+# 27775 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let rp2 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 27779 "parser_cocci_menhir.ml"
+# 27780 "parser_cocci_menhir.ml"
) = Obj.magic rp2 in
let p : 'tv_decl_list_name_opt_decl_ = Obj.magic p in
let lp2 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 27785 "parser_cocci_menhir.ml"
+# 27786 "parser_cocci_menhir.ml"
) = Obj.magic lp2 in
let rp1 : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 27790 "parser_cocci_menhir.ml"
+# 27791 "parser_cocci_menhir.ml"
) = Obj.magic rp1 in
let d : 'tv_d_ident = Obj.magic d in
let st : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 27796 "parser_cocci_menhir.ml"
+# 27797 "parser_cocci_menhir.ml"
) = Obj.magic st in
let lp1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 27801 "parser_cocci_menhir.ml"
+# 27802 "parser_cocci_menhir.ml"
) = Obj.magic lp1 in
let t : 'tv_fn_ctype = Obj.magic t in
let _startpos = _startpos_t_ in
(t,P.clt2mcode "(" lp1,P.clt2mcode "*" st,P.clt2mcode ")" rp1,
P.clt2mcode "(" lp2,p,P.clt2mcode ")" rp2)) in
[Ast0.wrap(Ast0.UnInit(None,fn t,id,P.clt2mcode ";" pv))] )
-# 27815 "parser_cocci_menhir.ml"
+# 27816 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27846 "parser_cocci_menhir.ml"
+# 27847 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 39 "standard.mly"
( None )
-# 27856 "parser_cocci_menhir.ml"
+# 27857 "parser_cocci_menhir.ml"
in
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
[Ast0.wrap(Ast0.UnInit(None,fn idtype,id,P.clt2mcode ";" pv))] )
-# 27864 "parser_cocci_menhir.ml"
+# 27865 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let pv : (
# 107 "parser_cocci_menhir.mly"
(Data.clt)
-# 27900 "parser_cocci_menhir.ml"
+# 27901 "parser_cocci_menhir.ml"
) = Obj.magic pv in
let d : 'tv_d_ident = Obj.magic d in
let i : 'tv_pure_ident = Obj.magic i in
# 41 "standard.mly"
( Some x )
-# 27912 "parser_cocci_menhir.ml"
+# 27913 "parser_cocci_menhir.ml"
in
( let (id,fn) = d in
let idtype = P.make_cv cv (Ast0.wrap (Ast0.TypeName(P.id2mcode i))) in
[Ast0.wrap(Ast0.UnInit(None,fn idtype,id,P.clt2mcode ";" pv))] )
-# 27920 "parser_cocci_menhir.ml"
+# 27921 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_struct_decl_list =
# 540 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS(_1)) )
-# 27944 "parser_cocci_menhir.ml"
+# 27945 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_struct_decl_list_start =
# 543 "parser_cocci_menhir.mly"
( _1 )
-# 27968 "parser_cocci_menhir.ml"
+# 27969 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_struct_decl_list_start =
# 544 "parser_cocci_menhir.mly"
( _1@_2 )
-# 27998 "parser_cocci_menhir.ml"
+# 27999 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _v : 'tv_struct_decl_list_start =
# 546 "parser_cocci_menhir.mly"
( (P.mkddots "..." d)::r )
-# 28028 "parser_cocci_menhir.ml"
+# 28029 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let s : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 28049 "parser_cocci_menhir.ml"
+# 28050 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_s_ in
let _v : 'tv_struct_or_union =
# 517 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Struct s )
-# 28056 "parser_cocci_menhir.ml"
+# 28057 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let u : (
# 50 "parser_cocci_menhir.mly"
(Data.clt)
-# 28077 "parser_cocci_menhir.ml"
+# 28078 "parser_cocci_menhir.ml"
) = Obj.magic u in
let _startpos = _startpos_u_ in
let _endpos = _endpos_u_ in
let _v : 'tv_struct_or_union =
# 518 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Union u )
-# 28084 "parser_cocci_menhir.ml"
+# 28085 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_top_eexpr =
-# 1209 "parser_cocci_menhir.mly"
+# 1210 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.OTHER(Ast0.wrap(Ast0.Exp(_1)))) )
-# 28108 "parser_cocci_menhir.ml"
+# 28109 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _3 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 28139 "parser_cocci_menhir.ml"
+# 28140 "parser_cocci_menhir.ml"
) = Obj.magic _3 in
let _2 : 'tv_initialize_list = Obj.magic _2 in
let _1 : (
# 101 "parser_cocci_menhir.mly"
(Data.clt)
-# 28145 "parser_cocci_menhir.ml"
+# 28146 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
let _v : 'tv_top_init =
-# 1651 "parser_cocci_menhir.mly"
+# 1652 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.InitList(P.clt2mcode "{" _1,_2,P.clt2mcode "}" _3)) )
-# 28152 "parser_cocci_menhir.ml"
+# 28153 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_toplevel_after_dots =
-# 1639 "parser_cocci_menhir.mly"
+# 1640 "parser_cocci_menhir.mly"
([])
-# 28169 "parser_cocci_menhir.ml"
+# 28170 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots =
-# 1640 "parser_cocci_menhir.mly"
+# 1641 "parser_cocci_menhir.mly"
(_2)
-# 28197 "parser_cocci_menhir.ml"
+# 28198 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots =
-# 1641 "parser_cocci_menhir.mly"
+# 1642 "parser_cocci_menhir.mly"
((Ast0.wrap(Ast0.Exp(_1)))::_2)
-# 28227 "parser_cocci_menhir.ml"
+# 28228 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots =
-# 1642 "parser_cocci_menhir.mly"
+# 1643 "parser_cocci_menhir.mly"
(_1@_2)
-# 28257 "parser_cocci_menhir.ml"
+# 28258 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots_init =
-# 1630 "parser_cocci_menhir.mly"
+# 1631 "parser_cocci_menhir.mly"
(_2)
-# 28285 "parser_cocci_menhir.ml"
+# 28286 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots_init =
-# 1631 "parser_cocci_menhir.mly"
+# 1632 "parser_cocci_menhir.mly"
((Ast0.wrap(Ast0.Exp(_1)))::_2)
-# 28315 "parser_cocci_menhir.ml"
+# 28316 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_dots_init =
-# 1632 "parser_cocci_menhir.mly"
+# 1633 "parser_cocci_menhir.mly"
(_1@_2)
-# 28345 "parser_cocci_menhir.ml"
+# 28346 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_toplevel_after_exp =
-# 1635 "parser_cocci_menhir.mly"
+# 1636 "parser_cocci_menhir.mly"
([])
-# 28362 "parser_cocci_menhir.ml"
+# 28363 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_exp =
-# 1636 "parser_cocci_menhir.mly"
+# 1637 "parser_cocci_menhir.mly"
(_1::_2)
-# 28392 "parser_cocci_menhir.ml"
+# 28393 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _menhir_env.MenhirLib.EngineTypes.lexbuf.Lexing.lex_start_p in
let _endpos = _startpos in
let _v : 'tv_toplevel_after_stm =
-# 1645 "parser_cocci_menhir.mly"
+# 1646 "parser_cocci_menhir.mly"
([])
-# 28409 "parser_cocci_menhir.ml"
+# 28410 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_stm =
-# 1646 "parser_cocci_menhir.mly"
+# 1647 "parser_cocci_menhir.mly"
(_1::_2)
-# 28439 "parser_cocci_menhir.ml"
+# 28440 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_after_stm =
-# 1647 "parser_cocci_menhir.mly"
+# 1648 "parser_cocci_menhir.mly"
(_1@_2)
-# 28469 "parser_cocci_menhir.ml"
+# 28470 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_seq_start_toplevel_after_dots_ =
-# 1625 "parser_cocci_menhir.mly"
+# 1626 "parser_cocci_menhir.mly"
( _1::_2 )
-# 28499 "parser_cocci_menhir.ml"
+# 28500 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_seq_start_toplevel_after_dots_ =
-# 1626 "parser_cocci_menhir.mly"
+# 1627 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.Exp(_1)))::_2 )
-# 28529 "parser_cocci_menhir.ml"
+# 28530 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_seq_start_toplevel_after_dots_ =
-# 1627 "parser_cocci_menhir.mly"
+# 1628 "parser_cocci_menhir.mly"
( _1@_2 )
-# 28559 "parser_cocci_menhir.ml"
+# 28560 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let a0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28592 "parser_cocci_menhir.ml"
+# 28593 "parser_cocci_menhir.ml"
) = Obj.magic a0 in
let _startpos = _startpos_a0_ in
let _endpos = _endpos_b_ in
let w = w0 in
let a = a0 in
-# 898 "parser_cocci_menhir.mly"
+# 899 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Dots(P.clt2mcode "..." a, List.concat w)) )
-# 28602 "parser_cocci_menhir.ml"
+# 28603 "parser_cocci_menhir.ml"
in
-# 1618 "parser_cocci_menhir.mly"
+# 1619 "parser_cocci_menhir.mly"
( a::b )
-# 28608 "parser_cocci_menhir.ml"
+# 28609 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28650 "parser_cocci_menhir.ml"
+# 28651 "parser_cocci_menhir.ml"
) = Obj.magic c0 in
let b0 : 'tv_nest_start = Obj.magic b0 in
let w0 : 'tv_list_whenppdecs_ = Obj.magic w0 in
let a0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28657 "parser_cocci_menhir.ml"
+# 28658 "parser_cocci_menhir.ml"
) = Obj.magic a0 in
let _startpos = _startpos_a0_ in
let _endpos = _endpos_b_ in
let w = w0 in
let a = a0 in
-# 902 "parser_cocci_menhir.mly"
+# 903 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<..." a, b,
P.clt2mcode "...>" c, List.concat w, false)) )
-# 28670 "parser_cocci_menhir.ml"
+# 28671 "parser_cocci_menhir.ml"
in
-# 1619 "parser_cocci_menhir.mly"
+# 1620 "parser_cocci_menhir.mly"
( a::b )
-# 28676 "parser_cocci_menhir.ml"
+# 28677 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28718 "parser_cocci_menhir.ml"
+# 28719 "parser_cocci_menhir.ml"
) = Obj.magic c0 in
let b0 : 'tv_nest_start = Obj.magic b0 in
let w0 : 'tv_list_whenppdecs_ = Obj.magic w0 in
let a0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28725 "parser_cocci_menhir.ml"
+# 28726 "parser_cocci_menhir.ml"
) = Obj.magic a0 in
let _startpos = _startpos_a0_ in
let _endpos = _endpos_b_ in
let w = w0 in
let a = a0 in
-# 905 "parser_cocci_menhir.mly"
+# 906 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<+..." a, b,
P.clt2mcode "...+>" c, List.concat w, true)) )
-# 28738 "parser_cocci_menhir.ml"
+# 28739 "parser_cocci_menhir.ml"
in
-# 1619 "parser_cocci_menhir.mly"
+# 1620 "parser_cocci_menhir.mly"
( a::b )
-# 28744 "parser_cocci_menhir.ml"
+# 28745 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28780 "parser_cocci_menhir.ml"
+# 28781 "parser_cocci_menhir.ml"
) = Obj.magic c0 in
let b0 : 'tv_nest_start = Obj.magic b0 in
let w0 : 'tv_list_whenppdecs_ = Obj.magic w0 in
let a0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28787 "parser_cocci_menhir.ml"
+# 28788 "parser_cocci_menhir.ml"
) = Obj.magic a0 in
let _startpos = _startpos_a0_ in
let _endpos = _endpos_c0_ in
let w = w0 in
let a = a0 in
-# 902 "parser_cocci_menhir.mly"
+# 903 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<..." a, b,
P.clt2mcode "...>" c, List.concat w, false)) )
-# 28800 "parser_cocci_menhir.ml"
+# 28801 "parser_cocci_menhir.ml"
in
-# 1620 "parser_cocci_menhir.mly"
+# 1621 "parser_cocci_menhir.mly"
( [a] )
-# 28806 "parser_cocci_menhir.ml"
+# 28807 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let c0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28842 "parser_cocci_menhir.ml"
+# 28843 "parser_cocci_menhir.ml"
) = Obj.magic c0 in
let b0 : 'tv_nest_start = Obj.magic b0 in
let w0 : 'tv_list_whenppdecs_ = Obj.magic w0 in
let a0 : (
# 73 "parser_cocci_menhir.mly"
(Data.clt)
-# 28849 "parser_cocci_menhir.ml"
+# 28850 "parser_cocci_menhir.ml"
) = Obj.magic a0 in
let _startpos = _startpos_a0_ in
let _endpos = _endpos_c0_ in
let w = w0 in
let a = a0 in
-# 905 "parser_cocci_menhir.mly"
+# 906 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Nest(P.clt2mcode "<+..." a, b,
P.clt2mcode "...+>" c, List.concat w, true)) )
-# 28862 "parser_cocci_menhir.ml"
+# 28863 "parser_cocci_menhir.ml"
in
-# 1620 "parser_cocci_menhir.mly"
+# 1621 "parser_cocci_menhir.mly"
( [a] )
-# 28868 "parser_cocci_menhir.ml"
+# 28869 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_seq_startne_toplevel_after_dots_init_ =
-# 1621 "parser_cocci_menhir.mly"
+# 1622 "parser_cocci_menhir.mly"
( (Ast0.wrap(Ast0.Exp(_1)))::_2 )
-# 28898 "parser_cocci_menhir.ml"
+# 28899 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_toplevel_seq_startne_toplevel_after_dots_init_ =
-# 1622 "parser_cocci_menhir.mly"
+# 1623 "parser_cocci_menhir.mly"
( _1@_2 )
-# 28928 "parser_cocci_menhir.ml"
+# 28929 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_typedef_ident =
-# 1530 "parser_cocci_menhir.mly"
+# 1531 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.TypeName(P.id2mcode _1)) )
-# 28952 "parser_cocci_menhir.ml"
+# 28953 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 64 "parser_cocci_menhir.mly"
(Parse_aux.info)
-# 28973 "parser_cocci_menhir.ml"
+# 28974 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_typedef_ident =
-# 1532 "parser_cocci_menhir.mly"
+# 1533 "parser_cocci_menhir.mly"
( let (nm,pure,clt) = _1 in
Ast0.wrap(Ast0.MetaType(P.clt2mcode nm clt,pure)) )
-# 28981 "parser_cocci_menhir.ml"
+# 28982 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1298 "parser_cocci_menhir.mly"
+# 1299 "parser_cocci_menhir.mly"
( _1 )
-# 29005 "parser_cocci_menhir.ml"
+# 29006 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29032 "parser_cocci_menhir.ml"
+# 29033 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1300 "parser_cocci_menhir.mly"
+# 1301 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Inc _1)) )
-# 29039 "parser_cocci_menhir.ml"
+# 29040 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29066 "parser_cocci_menhir.ml"
+# 29067 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1302 "parser_cocci_menhir.mly"
+# 1303 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Dec _1)) )
-# 29073 "parser_cocci_menhir.ml"
+# 29074 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1304 "parser_cocci_menhir.mly"
+# 1305 "parser_cocci_menhir.mly"
( let mcode = _1 in Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29103 "parser_cocci_menhir.ml"
+# 29104 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29130 "parser_cocci_menhir.ml"
+# 29131 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1306 "parser_cocci_menhir.mly"
+# 1307 "parser_cocci_menhir.mly"
( let mcode = P.clt2mcode Ast.Not _1 in
Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29138 "parser_cocci_menhir.ml"
+# 29139 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29165 "parser_cocci_menhir.ml"
+# 29166 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1309 "parser_cocci_menhir.mly"
+# 1310 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfExpr (P.clt2mcode "sizeof" _1, _2)) )
-# 29172 "parser_cocci_menhir.ml"
+# 29173 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 29208 "parser_cocci_menhir.ml"
+# 29209 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let t : 'tv_ctype = Obj.magic t in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29214 "parser_cocci_menhir.ml"
+# 29215 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let s : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29219 "parser_cocci_menhir.ml"
+# 29220 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_rp_ in
let _v : 'tv_unary_expr_eexpr_dot_expressions_ =
-# 1311 "parser_cocci_menhir.mly"
+# 1312 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfType (P.clt2mcode "sizeof" s,
P.clt2mcode "(" lp,t,
P.clt2mcode ")" rp)) )
-# 29228 "parser_cocci_menhir.ml"
+# 29229 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1298 "parser_cocci_menhir.mly"
+# 1299 "parser_cocci_menhir.mly"
( _1 )
-# 29252 "parser_cocci_menhir.ml"
+# 29253 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29279 "parser_cocci_menhir.ml"
+# 29280 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1300 "parser_cocci_menhir.mly"
+# 1301 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Inc _1)) )
-# 29286 "parser_cocci_menhir.ml"
+# 29287 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29313 "parser_cocci_menhir.ml"
+# 29314 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1302 "parser_cocci_menhir.mly"
+# 1303 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Dec _1)) )
-# 29320 "parser_cocci_menhir.ml"
+# 29321 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1304 "parser_cocci_menhir.mly"
+# 1305 "parser_cocci_menhir.mly"
( let mcode = _1 in Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29350 "parser_cocci_menhir.ml"
+# 29351 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29377 "parser_cocci_menhir.ml"
+# 29378 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1306 "parser_cocci_menhir.mly"
+# 1307 "parser_cocci_menhir.mly"
( let mcode = P.clt2mcode Ast.Not _1 in
Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29385 "parser_cocci_menhir.ml"
+# 29386 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29412 "parser_cocci_menhir.ml"
+# 29413 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1309 "parser_cocci_menhir.mly"
+# 1310 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfExpr (P.clt2mcode "sizeof" _1, _2)) )
-# 29419 "parser_cocci_menhir.ml"
+# 29420 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 29455 "parser_cocci_menhir.ml"
+# 29456 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let t : 'tv_ctype = Obj.magic t in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29461 "parser_cocci_menhir.ml"
+# 29462 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let s : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29466 "parser_cocci_menhir.ml"
+# 29467 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_rp_ in
let _v : 'tv_unary_expr_eexpr_invalid_ =
-# 1311 "parser_cocci_menhir.mly"
+# 1312 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfType (P.clt2mcode "sizeof" s,
P.clt2mcode "(" lp,t,
P.clt2mcode ")" rp)) )
-# 29475 "parser_cocci_menhir.ml"
+# 29476 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1298 "parser_cocci_menhir.mly"
+# 1299 "parser_cocci_menhir.mly"
( _1 )
-# 29499 "parser_cocci_menhir.ml"
+# 29500 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29526 "parser_cocci_menhir.ml"
+# 29527 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1300 "parser_cocci_menhir.mly"
+# 1301 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Inc _1)) )
-# 29533 "parser_cocci_menhir.ml"
+# 29534 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29560 "parser_cocci_menhir.ml"
+# 29561 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1302 "parser_cocci_menhir.mly"
+# 1303 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Dec _1)) )
-# 29567 "parser_cocci_menhir.ml"
+# 29568 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1304 "parser_cocci_menhir.mly"
+# 1305 "parser_cocci_menhir.mly"
( let mcode = _1 in Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29597 "parser_cocci_menhir.ml"
+# 29598 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29624 "parser_cocci_menhir.ml"
+# 29625 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1306 "parser_cocci_menhir.mly"
+# 1307 "parser_cocci_menhir.mly"
( let mcode = P.clt2mcode Ast.Not _1 in
Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29632 "parser_cocci_menhir.ml"
+# 29633 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29659 "parser_cocci_menhir.ml"
+# 29660 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1309 "parser_cocci_menhir.mly"
+# 1310 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfExpr (P.clt2mcode "sizeof" _1, _2)) )
-# 29666 "parser_cocci_menhir.ml"
+# 29667 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 29702 "parser_cocci_menhir.ml"
+# 29703 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let t : 'tv_ctype = Obj.magic t in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29708 "parser_cocci_menhir.ml"
+# 29709 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let s : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29713 "parser_cocci_menhir.ml"
+# 29714 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_rp_ in
let _v : 'tv_unary_expr_eexpr_nest_expressions_ =
-# 1311 "parser_cocci_menhir.mly"
+# 1312 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfType (P.clt2mcode "sizeof" s,
P.clt2mcode "(" lp,t,
P.clt2mcode ")" rp)) )
-# 29722 "parser_cocci_menhir.ml"
+# 29723 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1298 "parser_cocci_menhir.mly"
+# 1299 "parser_cocci_menhir.mly"
( _1 )
-# 29746 "parser_cocci_menhir.ml"
+# 29747 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29773 "parser_cocci_menhir.ml"
+# 29774 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1300 "parser_cocci_menhir.mly"
+# 1301 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Inc _1)) )
-# 29780 "parser_cocci_menhir.ml"
+# 29781 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 85 "parser_cocci_menhir.mly"
(Data.clt)
-# 29807 "parser_cocci_menhir.ml"
+# 29808 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1302 "parser_cocci_menhir.mly"
+# 1303 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.Infix (_2, P.clt2mcode Ast.Dec _1)) )
-# 29814 "parser_cocci_menhir.ml"
+# 29815 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1304 "parser_cocci_menhir.mly"
+# 1305 "parser_cocci_menhir.mly"
( let mcode = _1 in Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29844 "parser_cocci_menhir.ml"
+# 29845 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29871 "parser_cocci_menhir.ml"
+# 29872 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1306 "parser_cocci_menhir.mly"
+# 1307 "parser_cocci_menhir.mly"
( let mcode = P.clt2mcode Ast.Not _1 in
Ast0.wrap(Ast0.Unary(_2, mcode)) )
-# 29879 "parser_cocci_menhir.ml"
+# 29880 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29906 "parser_cocci_menhir.ml"
+# 29907 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1309 "parser_cocci_menhir.mly"
+# 1310 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfExpr (P.clt2mcode "sizeof" _1, _2)) )
-# 29913 "parser_cocci_menhir.ml"
+# 29914 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let rp : (
# 77 "parser_cocci_menhir.mly"
(Data.clt)
-# 29949 "parser_cocci_menhir.ml"
+# 29950 "parser_cocci_menhir.ml"
) = Obj.magic rp in
let t : 'tv_ctype = Obj.magic t in
let lp : (
# 76 "parser_cocci_menhir.mly"
(Data.clt)
-# 29955 "parser_cocci_menhir.ml"
+# 29956 "parser_cocci_menhir.ml"
) = Obj.magic lp in
let s : (
# 58 "parser_cocci_menhir.mly"
(Data.clt)
-# 29960 "parser_cocci_menhir.ml"
+# 29961 "parser_cocci_menhir.ml"
) = Obj.magic s in
let _startpos = _startpos_s_ in
let _endpos = _endpos_rp_ in
let _v : 'tv_unary_expr_expr_invalid_ =
-# 1311 "parser_cocci_menhir.mly"
+# 1312 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.SizeOfType (P.clt2mcode "sizeof" s,
P.clt2mcode "(" lp,t,
P.clt2mcode ")" rp)) )
-# 29969 "parser_cocci_menhir.ml"
+# 29970 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 93 "parser_cocci_menhir.mly"
(Data.clt)
-# 29990 "parser_cocci_menhir.ml"
+# 29991 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_op =
-# 1315 "parser_cocci_menhir.mly"
+# 1316 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.GetRef _1 )
-# 29997 "parser_cocci_menhir.ml"
+# 29998 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 30018 "parser_cocci_menhir.ml"
+# 30019 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_op =
-# 1316 "parser_cocci_menhir.mly"
+# 1317 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.DeRef _1 )
-# 30025 "parser_cocci_menhir.ml"
+# 30026 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 98 "parser_cocci_menhir.mly"
(Data.clt)
-# 30046 "parser_cocci_menhir.ml"
+# 30047 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_op =
-# 1317 "parser_cocci_menhir.mly"
+# 1318 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.UnPlus _1 )
-# 30053 "parser_cocci_menhir.ml"
+# 30054 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 98 "parser_cocci_menhir.mly"
(Data.clt)
-# 30074 "parser_cocci_menhir.ml"
+# 30075 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_op =
-# 1318 "parser_cocci_menhir.mly"
+# 1319 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.UnMinus _1 )
-# 30081 "parser_cocci_menhir.ml"
+# 30082 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _1 : (
# 99 "parser_cocci_menhir.mly"
(Data.clt)
-# 30102 "parser_cocci_menhir.ml"
+# 30103 "parser_cocci_menhir.ml"
) = Obj.magic _1 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__1_ in
let _v : 'tv_unary_op =
-# 1319 "parser_cocci_menhir.mly"
+# 1320 "parser_cocci_menhir.mly"
( P.clt2mcode Ast.Tilde _1 )
-# 30109 "parser_cocci_menhir.ml"
+# 30110 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_when_start =
-# 1744 "parser_cocci_menhir.mly"
+# 1745 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS((Ast0.wrap(Ast0.Exp(_1)))::_2)) )
-# 30139 "parser_cocci_menhir.ml"
+# 30140 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _startpos = _startpos__1_ in
let _endpos = _endpos__2_ in
let _v : 'tv_when_start =
-# 1746 "parser_cocci_menhir.mly"
+# 1747 "parser_cocci_menhir.mly"
( Ast0.wrap(Ast0.DOTS(_1@_2)) )
-# 30169 "parser_cocci_menhir.ml"
+# 30170 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
MenhirLib.EngineTypes.endp = _endpos_w_;
MenhirLib.EngineTypes.next = _menhir_stack;
} = _menhir_stack in
- let w : 'tv_whens_when_start_rule_elem_statement_ = Obj.magic w in
+ let w : 'tv_whens_when_start_rule_elem_statement_any_strict_ = Obj.magic w in
let _startpos = _startpos_w_ in
let _endpos = _endpos_w_ in
let _v : 'tv_whenppdecs =
-# 909 "parser_cocci_menhir.mly"
+# 910 "parser_cocci_menhir.mly"
( w )
-# 30193 "parser_cocci_menhir.ml"
+# 30194 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let w : 'tv_when_start = Obj.magic w in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
- let _v : 'tv_whens_when_start_rule_elem_statement_ =
-# 1812 "parser_cocci_menhir.mly"
+ let _v : 'tv_whens_when_start_rule_elem_statement_any_strict_ =
+# 1813 "parser_cocci_menhir.mly"
( [Ast0.WhenNot w] )
-# 30229 "parser_cocci_menhir.ml"
+# 30230 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let w : 'tv_rule_elem_statement = Obj.magic w in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
- let _v : 'tv_whens_when_start_rule_elem_statement_ =
-# 1813 "parser_cocci_menhir.mly"
+ let _v : 'tv_whens_when_start_rule_elem_statement_any_strict_ =
+# 1814 "parser_cocci_menhir.mly"
( [Ast0.WhenAlways w] )
-# 30265 "parser_cocci_menhir.ml"
+# 30266 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let _2 : 'tv_comma_list_any_strict_ = Obj.magic _2 in
let _startpos = _startpos__1_ in
let _endpos = _endpos__3_ in
- let _v : 'tv_whens_when_start_rule_elem_statement_ =
-# 1815 "parser_cocci_menhir.mly"
+ let _v : 'tv_whens_when_start_rule_elem_statement_any_strict_ =
+# 1816 "parser_cocci_menhir.mly"
( List.map (function x -> Ast0.WhenModifier(x)) _2 )
-# 30297 "parser_cocci_menhir.ml"
+# 30298 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let e : 'tv_eexpr = Obj.magic e in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
- let _v : 'tv_whens_when_start_rule_elem_statement_ =
-# 1816 "parser_cocci_menhir.mly"
+ let _v : 'tv_whens_when_start_rule_elem_statement_any_strict_ =
+# 1817 "parser_cocci_menhir.mly"
( [Ast0.WhenNotTrue e] )
-# 30333 "parser_cocci_menhir.ml"
+# 30334 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
let e : 'tv_eexpr = Obj.magic e in
let _startpos = _startpos__1_ in
let _endpos = _endpos__4_ in
- let _v : 'tv_whens_when_start_rule_elem_statement_ =
-# 1817 "parser_cocci_menhir.mly"
+ let _v : 'tv_whens_when_start_rule_elem_statement_any_strict_ =
+# 1818 "parser_cocci_menhir.mly"
( [Ast0.WhenNotFalse e] )
-# 30369 "parser_cocci_menhir.ml"
+# 30370 "parser_cocci_menhir.ml"
in
_menhir_env.MenhirLib.EngineTypes.stack <- {
MenhirLib.EngineTypes.state = _menhir_s;
(Obj.magic (MenhirInterpreter.entry 1549 lexer lexbuf) : (
# 159 "parser_cocci_menhir.mly"
(string * (string * string))
-# 30393 "parser_cocci_menhir.ml"
+# 30394 "parser_cocci_menhir.ml"
))
and rule_name =
(Obj.magic (MenhirInterpreter.entry 1477 lexer lexbuf) : (
# 153 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 30401 "parser_cocci_menhir.ml"
+# 30402 "parser_cocci_menhir.ml"
))
and reinit =
(Obj.magic (MenhirInterpreter.entry 1475 lexer lexbuf) : (
# 131 "parser_cocci_menhir.mly"
(unit)
-# 30409 "parser_cocci_menhir.ml"
+# 30410 "parser_cocci_menhir.ml"
))
and plus_main =
(Obj.magic (MenhirInterpreter.entry 1439 lexer lexbuf) : (
# 140 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 30417 "parser_cocci_menhir.ml"
+# 30418 "parser_cocci_menhir.ml"
))
and plus_exp_main =
(Obj.magic (MenhirInterpreter.entry 1430 lexer lexbuf) : (
# 143 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 30425 "parser_cocci_menhir.ml"
+# 30426 "parser_cocci_menhir.ml"
))
and never_used =
(Obj.magic (MenhirInterpreter.entry 1424 lexer lexbuf) : (
# 168 "parser_cocci_menhir.mly"
(unit)
-# 30433 "parser_cocci_menhir.ml"
+# 30434 "parser_cocci_menhir.ml"
))
and minus_main =
(Obj.magic (MenhirInterpreter.entry 1338 lexer lexbuf) : (
# 134 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 30441 "parser_cocci_menhir.ml"
+# 30442 "parser_cocci_menhir.ml"
))
and minus_exp_main =
(Obj.magic (MenhirInterpreter.entry 1314 lexer lexbuf) : (
# 137 "parser_cocci_menhir.mly"
(Ast0_cocci.rule)
-# 30449 "parser_cocci_menhir.ml"
+# 30450 "parser_cocci_menhir.ml"
))
and meta_main =
(Obj.magic (MenhirInterpreter.entry 1311 lexer lexbuf) : (
# 157 "parser_cocci_menhir.mly"
((Ast_cocci.metavar,Ast_cocci.metavar) Common.either list)
-# 30457 "parser_cocci_menhir.ml"
+# 30458 "parser_cocci_menhir.ml"
))
and iso_rule_name =
(Obj.magic (MenhirInterpreter.entry 1307 lexer lexbuf) : (
# 149 "parser_cocci_menhir.mly"
(Ast_cocci.rulename)
-# 30465 "parser_cocci_menhir.ml"
+# 30466 "parser_cocci_menhir.ml"
))
and iso_meta_main =
(Obj.magic (MenhirInterpreter.entry 1104 lexer lexbuf) : (
# 165 "parser_cocci_menhir.mly"
((Ast_cocci.metavar,Ast_cocci.metavar) Common.either list)
-# 30473 "parser_cocci_menhir.ml"
+# 30474 "parser_cocci_menhir.ml"
))
and iso_main =
(Obj.magic (MenhirInterpreter.entry 10 lexer lexbuf) : (
# 162 "parser_cocci_menhir.mly"
(Ast0_cocci.anything list list)
-# 30481 "parser_cocci_menhir.ml"
+# 30482 "parser_cocci_menhir.ml"
))
and include_main =
(Obj.magic (MenhirInterpreter.entry 0 lexer lexbuf) : (
# 146 "parser_cocci_menhir.mly"
((string,string) Common.either list)
-# 30489 "parser_cocci_menhir.ml"
+# 30490 "parser_cocci_menhir.ml"
))
| TDmOp of (Ast_cocci.arithOp * Data.clt)
| TDisable
| TDepends
- | TDefineParam of (Data.clt * token * int)
+ | TDefineParam of (Data.clt * token * int * int)
| TDefine of (Data.clt * token)
| TDefault of (Data.clt)
| TDeclarerId of (string * Data.clt)
%token <string> TPathIsoFile
%token <string * Data.clt> TIncludeL TIncludeNL
%token <Data.clt * token> TDefine
-%token <Data.clt * token * int> TDefineParam
+%token <Data.clt * token * int * int> TDefineParam
%token <string * Data.clt> TMinusFile TPlusFile
%token <Data.clt> TInc TDec
Ast0.wrap Ast0.NoParams,
body)) }
| TDefineParam define_param_list_option TCPar
- { let (clt,ident,parenoff) = $1 in
+ { let (clt,ident,parenoff,parencol) = $1 in
+ (* clt is the start of the #define itself *)
let (arity,line,lline,offset,col,strbef,straft,pos) = clt in
let lp =
P.clt2mcode "("
- (arity,line,lline,parenoff,0,[],[],Ast0.NoMetaPos) in
+ (arity,line,lline,parenoff,parencol,[],[],Ast0.NoMetaPos) in
function body ->
Ast0.wrap
(Ast0.Define
{ Ast0.wrap(Ast0.Nest(P.clt2mcode "<+..." a, b,
P.clt2mcode "...+>" c, List.concat w, true)) }
-whenppdecs: w=whens(when_start,rule_elem_statement)
+whenppdecs: w=whens(when_start,rule_elem_statement,any_strict)
{ w }
/* a statement that fits into a single rule_elem. should nests be included?
d=dotter { (d,None) }
| d=dotter TWhen TNotEq w=when_grammar TLineEnd { (d,Some w) }
-whens(when_grammar,simple_when_grammar):
+whens(when_grammar,simple_when_grammar,any_strict):
TWhen TNotEq w=when_grammar TLineEnd { [Ast0.WhenNot w] }
| TWhen TEq w=simple_when_grammar TLineEnd { [Ast0.WhenAlways w] }
| TWhen comma_list(any_strict) TLineEnd
| TForall { Ast.WhenForall }
| TExists { Ast.WhenExists }
+any_only:
+ TAny { Ast.WhenAny }
+ | TForall { Ast.WhenForall }
+ | TExists { Ast.WhenExists }
+
/*****************************************************************************
*
*
| _ -> ()
let mcode fn = function
- (x, _, Ast.MINUS(_,plus_stream), pos) ->
+ (x, _, Ast.MINUS(_,_,adj,plus_stream), pos) ->
if !print_minus_flag
then print_string (if !Flag.sgrep_mode2 then "*" else "-");
fn x; print_pos pos;
print_string_befaft fn x info
let print_mcodekind = function
- Ast.MINUS(_,plus_stream) ->
+ Ast.MINUS(_,_,_,plus_stream) ->
print_string "MINUS";
print_anything ">>> " plus_stream
| Ast.CONTEXT(_,plus_streams) ->
and statement arity s =
match Ast.unwrap s with
- Ast.Seq(lbrace,decls,body,rbrace) ->
+ Ast.Seq(lbrace,body,rbrace) ->
rule_elem arity lbrace;
- dots force_newline (statement arity) decls;
dots force_newline (statement arity) body;
rule_elem arity rbrace
| Ast.IfThen(header,branch,(_,_,_,aft)) ->
List.iter (function x -> case_line arity x; force_newline()) cases;
rule_elem arity rb
| Ast.Atomic(re) -> rule_elem arity re
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
rule_elem arity header; rule_elem arity lbrace;
- dots force_newline (statement arity) decls;
dots force_newline (statement arity) body;
rule_elem arity rbrace
| Ast.Disj([stmt_dots]) ->
| _ -> false)
| Ast0.CONTEXT(mc) -> false
| _ -> false in
- let mcode (_,_,_,mc,_) = mcodekind mc in
+ let mcode (_,_,_,mc,_,_) = mcodekind mc in
let donothing r k e = mcodekind (Ast0.get_mcodekind e) && k e in
let rec unify_statement s1 s2 =
match (Ast.unwrap s1,Ast.unwrap s2) with
- (Ast.Seq(lb1,d1,s1,rb1),Ast.Seq(lb2,d2,s2,rb2)) ->
+ (Ast.Seq(lb1,s1,rb1),Ast.Seq(lb2,s2,rb2)) ->
conjunct_bindings (unify_rule_elem lb1 lb2)
(conjunct_bindings
(unify_dots unify_statement sdots s1 s2)
- (conjunct_bindings
- (unify_dots unify_statement sdots d1 d2)
- (unify_rule_elem rb1 rb2)))
+ (unify_rule_elem rb1 rb2))
| (Ast.IfThen(h1,thn1,_),Ast.IfThen(h2,thn2,_)) ->
conjunct_bindings (unify_rule_elem h1 h2) (unify_statement thn1 thn2)
| (Ast.IfThenElse(h1,thn1,e1,els1,_),Ast.IfThenElse(h2,thn2,e2,els2,_)) ->
s2)
| (Ast.Nest(s1,_,_,_,_),Ast.Nest(s2,_,_,_,_)) ->
unify_dots unify_statement sdots s1 s2
- | (Ast.FunDecl(h1,lb1,d1,s1,rb1),Ast.FunDecl(h2,lb2,d2,s2,rb2)) ->
+ | (Ast.FunDecl(h1,lb1,s1,rb1),Ast.FunDecl(h2,lb2,s2,rb2)) ->
conjunct_bindings (unify_rule_elem h1 h2)
(conjunct_bindings (unify_rule_elem lb1 lb2)
- (conjunct_bindings (unify_dots unify_statement sdots d1 d2)
- (conjunct_bindings (unify_dots unify_statement sdots s1 s2)
- (unify_rule_elem rb1 rb2))))
+ (conjunct_bindings (unify_dots unify_statement sdots s1 s2)
+ (unify_rule_elem rb1 rb2)))
| (Ast.Define(h1,s1),Ast.Define(h2,s2)) ->
conjunct_bindings (unify_rule_elem h1 h2)
(unify_dots unify_statement sdots s1 s2)
let minus_checker name = let id = Ast0.unwrap_mcode name in [id]
(* take only what is in the plus code *)
-let plus_checker (nm,_,_,mc,_) =
+let plus_checker (nm,_,_,mc,_,_) =
match mc with Ast0.PLUS -> [nm] | _ -> []
let get_free checker t =
let quiet = ref true (* true = no decoration on - context, etc *)
+let full_ids = ref false (* true = print rule name as well *)
+
let start_block str =
force_newline(); print_string " "; open_box 0
(function x ->
print_string lb; fn x; print_string rb)
x plus_streams
- | Ast0.PLUS -> fn x
+ | Ast0.PLUS -> print_int (info.Ast0.pos_info.Ast0.column); fn x
| Ast0.MIXED(plus_streams) ->
let (lb,rb) =
if !quiet
x plus_streams);
List.iter (function (s,_) -> print_string s) info.Ast0.strings_after
-let mcode fn (x,_,info,mc,pos) =
+let mcode fn (x,_,info,mc,pos,adj) =
let fn x = fn x; meta_pos !pos in
mcodekind (Some info.Ast0.pos_info.Ast0.line_start)(*None*) fn x info mc
mcodekind (Some (Ast0.get_line x)) fn () (Ast0.get_info x)
(Ast0.get_mcodekind x)
-let print_meta (_,name) = print_string name
+let print_meta (ctx,name) =
+ if !full_ids then (print_string ctx; print_string ":");
+ print_string name
(* --------------------------------------------------------------------- *)
(* --------------------------------------------------------------------- *)
mcode print_string iff; print_string " "; mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp; print_string " ";
statement arity branch1;
- mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos)
+ mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos,-1)
| Ast0.IfThenElse(iff,lp,exp,rp,branch1,els,branch2,(info,aft)) ->
print_string arity;
mcode print_string iff; print_string " "; mcode print_string_box lp;
statement arity branch1;
print_string arity; mcode print_string els; print_string " ";
statement arity branch2;
- mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos)
+ mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos,-1)
| Ast0.While(whl,lp,exp,rp,body,(info,aft)) ->
print_string arity;
mcode print_string whl; print_string " "; mcode print_string_box lp;
expression exp; close_box(); mcode print_string rp; print_string " ";
statement arity body;
- mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos)
+ mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos,-1)
| Ast0.Do(d,body,whl,lp,exp,rp,sem) ->
print_string arity; mcode print_string d; print_string " ";
statement arity body;
print_option expression e2; mcode print_string sem2;
print_option expression e3; close_box();
mcode print_string rp; print_string " "; statement arity body;
- mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos)
+ mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos,-1)
| Ast0.Iterator(nm,lp,args,rp,body,(info,aft)) ->
print_string arity;
ident nm; print_string " "; mcode print_string_box lp;
let _ = dots (function _ -> ()) expression args in
close_box(); mcode print_string rp; print_string " ";
statement arity body;
- mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos)
+ mcode (function _ -> ()) ((),(),info,aft,ref Ast0.NoMetaPos,-1)
| Ast0.Switch(switch,lp,exp,rp,lb,cases,rb) ->
print_string arity;
mcode print_string switch; print_string " ";
process_bef_aft s;
let k s =
match Ast.unwrap s with
- Ast.Seq(lbrace,decls,body,rbrace) ->
- multibind [rule_elem lbrace; statement_dots decls;
+ Ast.Seq(lbrace,body,rbrace) ->
+ multibind [rule_elem lbrace;
statement_dots body; rule_elem rbrace]
| Ast.IfThen(header,branch,_) ->
multibind [rule_elem header; statement branch]
| Ast.Nest(stmt_dots,whn,_,_,_) ->
bind (statement_dots stmt_dots)
(multibind (List.map (whencode statement_dots statement) whn))
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
multibind [rule_elem header; rule_elem lbrace;
- statement_dots decls; statement_dots body;
- rule_elem rbrace]
+ statement_dots body; rule_elem rbrace]
| Ast.Define(header,body) ->
bind (rule_elem header) (statement_dots body)
| Ast.Dots(d,whn,_,_) | Ast.Circles(d,whn,_,_) | Ast.Stars(d,whn,_,_) ->
let k s =
Ast.rewrap s
(match Ast.unwrap s with
- Ast.Seq(lbrace,decls,body,rbrace) ->
- Ast.Seq(rule_elem lbrace, statement_dots decls,
+ Ast.Seq(lbrace,body,rbrace) ->
+ Ast.Seq(rule_elem lbrace,
statement_dots body, rule_elem rbrace)
| Ast.IfThen(header,branch,aft) ->
Ast.IfThen(rule_elem header, statement branch,aft)
Ast.Nest(statement_dots stmt_dots,
List.map (whencode statement_dots statement) whn,
multi,bef,aft)
- | Ast.FunDecl(header,lbrace,decls,body,rbrace) ->
+ | Ast.FunDecl(header,lbrace,body,rbrace) ->
Ast.FunDecl(rule_elem header,rule_elem lbrace,
- statement_dots decls,
statement_dots body, rule_elem rbrace)
| Ast.Define(header,body) ->
Ast.Define(rule_elem header,statement_dots body)
(match Ast0.unwrap p with
Ast0.VoidParam(ty) ->
let (n,ty) = typeC ty in (n,Ast0.VoidParam(ty))
- | Ast0.Param(ty,id) ->
+ | Ast0.Param(ty,Some id) ->
+ let ((ty_id_n,ty),id) = named_type ty id in
+ (ty_id_n, Ast0.Param(ty,Some id))
+ | Ast0.Param(ty,None) ->
let (ty_n,ty) = typeC ty in
- let (id_n,id) = get_option ident id in
- (bind ty_n id_n, Ast0.Param(ty,id))
+ (ty_n, Ast0.Param(ty,None))
| Ast0.MetaParam(name,pure) ->
let (n,name) = meta_mcode name in
(n,Ast0.MetaParam(name,pure))
Ast_c.String (s,isWchar) -> s
| Ast_c.MultiString _ -> "TODO: MultiString"
| Ast_c.Char (s,isWchar) -> s
-| Ast_c.Int s -> s
-| Ast_c.Float (s,t) -> s
+| Ast_c.Int (s, _t) -> s
+| Ast_c.Float (s, _t) -> s
let call_pretty f a =
let str = ref ([] : string list) in
+ Coccinelle
+
+
Coccinelle allows programmers to easily write some complex
style-preserving source-to-source transformations on C source code,
like for instance to perform some refactorings.
To install Coccinelle from its source, see the instructions in install.txt.
-For more information on Coccinelle, type 'make docs' and see look at the
-files in the docs/ directory. You may need to install the texlive-fonts-extra
-packages from your distribution to compile some of the LaTeX documentation
-files.
-
Once you have installed Coccinelle (either from the source or from one
of the binary form available on the Coccinelle website), You may have
to setup a few environment variables so that the Coccinelle program
-know where to find its configuration files.
+knows where to find its configuration files.
For bash do:
- source env.sh
+ $ source env.sh
For tcsh do:
- source env.csh
+ $ source env.csh
You can then test coccinelle with:
- spatch -sp_file demos/simple.cocci demos/simple.c
+ $ spatch -sp_file demos/simple.cocci demos/simple.c
If you downloaded the bytecode version of spatch you may first
have to install OCaml (which contains the 'ocamlrun' bytecode interpreter,
the equivalent of 'java', the Java virtual machine, but for OCaml) and then do:
- ocamlrun spatch -sp_file demos/simple.cocci demos/simple.c
+ $ ocamlrun spatch -sp_file demos/simple.cocci demos/simple.c
+
+
+
+For more information on Coccinelle, type 'make docs' and have a look at the
+files in the docs/ directory. You may need to install the texlive-fonts-extra
+packages from your distribution to compile some of the LaTeX documentation
+files.
+
-// clone: yacfe(master), coccinelle, acomment,
-
// ****************************************************************************
-// Prelude, this file is to be used with the -macro_file option of the C parser
+// Prelude, this file is used with -macro_file_builtins option of the C parser
// ****************************************************************************
/* This file contains:
* - macros found in <.h>
+ * - macros found in ".h"
+ * but where we cant detect that it will be a "bad macro"
+ * - hints, cf below.
+ *
+ * A "bad macro" is a macro using free variables or when expanded
+ * that influence the control-flow of the code. In those cases it
+ * is preferable to expand the macro so that the coccinelle engine
+ * has a more accurate representation of what is going on.
+ *
+ *
+ *
+ *
+ * old: this file was also containing what is below but now we
+ * try to expand on demand the macro found in the c file, so those cases
+ * are not needed any more:
* - macros found in .c; macros that cannot be parsed.
* In the future should be autodetected
* (not so easy to do same for macros in .h cos require to access .h file)
- * - macros found in ".h"
- * but where we cant detect that it will be a "bad macro"
* - macros found in .c; macros correctly parsed
* but where we cant detect that it will be a "bad macro"
- * - hints, cf below.
*
* Some of those macros could be deleted and the C code rewritten because
* they are "bad" macros.
// #define FOO(a,b) fn(a,b)
#define FOO_METH_TEST(a) YACFE_IDENT_BUILDER
-// ****************************************************************************
-// Generic macros
-// ****************************************************************************
+//#define FOO YACFE_DECLARATOR
// ****************************************************************************
-// Yacc macros
-// ****************************************************************************
-
-#define YY_PROTO(x) x
-#define yyconst const
-
-
-// ****************************************************************************
-// GNU Hello macros
+// Generic macros
// ****************************************************************************
-#define __getopt_argv_const const
+// this is defined by windows compiler, and so can not be found via a macro
+// after a -extract_macros
+#define __stdcall /*could: YACFE_ATTRIBUTE*/
+#define __declspec(a)
-
-// ****************************************************************************
-// Gcc (as in the source of gcc code) macros
-// ****************************************************************************
+#define WINAPI
+#define CALLBACK
// ****************************************************************************
#define __uses_jump_to_uncached
+
+// last last
+#define __net_init
+#define __net_exit
+#define __net_initdata
+
+#define __paginginit // in mm
+
// ----------------------------------------------------------------------------
// String macros
// ----------------------------------------------------------------------------
#define TRACE_EXIT return
+#define notrace
+
+#define noinline_for_stack // in fs
+#define debug_noinline // in net
// ----------------------------------------------------------------------------
// linkage
//#define ACPI_MODULE_NAME(x)
-
-
-// ****************************************************************************
-// Httpd (apache) macros
-// ****************************************************************************
-
-#define AP_DECLARE(x) x
-#define PROXY_DECLARE(x) x
-#define CACHE_DECLARE(x) x
-#define DBD_DECLARE_NONSTD(x) x
-#define DAV_DECLARE(x) x
-#define APU_DECLARE(x) x
-#define APU_DECLARE_NONSTD(x) x
-#define APR_DECLARE(x) x
-#define AP_CORE_DECLARE(x) x
-#define AP_DECLARE_NONSTD(x) x
-#define AP_CORE_DECLARE_NONSTD(x) x
-#define APR_OPTIONAL_FN_TYPE(x) x
-#define DAV_DECLARE_NONSTD(x) x
-#define APR_DECLARE_NONSTD(x) x
-
-#define APU_DECLARE_DATA
-#define APR_THREAD_FUNC
-#define AP_DECLARE_DATA
-#define PROXY_DECLARE_DATA
-#define AP_MODULE_DECLARE_DATA
-#define APR_DECLARE_DATA
-
-
-
-#define APR_INLINE inline
-#define EXPORT static
-#define REGISTER register
-
-#define MODSSL_D2I_SSL_SESSION_CONST const
-#define MODSSL_D2I_X509_CONST const
-#define MODSSL_D2I_PrivateKey_CONST const
-#define MODSSL_D2I_SSL_SESSION_CONST const
-
-#define STACK_OF(X509_NAME) X509_NAME
-
-#define MODSSL_PCHAR_CAST (pchar)
-
-#define WINAPI
-//#define CALLBACK
-// generate false positive in Linux
-#define APIENTRY
-#define __declspec(x)
-#define __stdcall
-
-
-//#define module struct xxx
-
-#define APR_POOL_IMPLEMENT_ACCESSOR(shm)
-
-#define ADD_SUITE(suite) suite;
-
-// ****************************************************************************
-// CISCO vpn client macros
-// ****************************************************************************
-
-// #define NOREGPARM
-// #define IN
-// #define OUT
-// #define OPTIONAL
-
-#define likely(x) x
-#define unlikely(x) x
@@
X < Y <=> Y > X
+Expression
+@ gtr_lss_eq @
+expression X, Y;
+@@
+X <= Y <=> Y >= X
+
// ---------------------------------------------------------------------------
// Increment isomorphisms
// ---------------------------------------------------------------------------
(* ------------------------------------------------------------------------ *)
-let testall () =
-
+(* note: if you get some weird results in -testall, and not in -test,
+ * it is possible that a test file work in -test but may not
+ * work while used inside a -testall. If we have some bugs in our
+ * parser that modify some global state and that those states
+ * are not reseted between each test file, then having run previous
+ * test files may have an influence on another test file which mean
+ * than a test may work in isolation (via -test) but not otherwise
+ * (via -testall). Fortunately such bugs are rare.
+ *
+ *)
+let testall ?(expected_score_file="tests/SCORE_expected.sexp") () =
+
let score = empty_score () in
let expected_result_files =
try (
Common.timeout_function timeout_testall (fun () ->
+ pr2 res;
+
let cocci_infos = Cocci.pre_engine (cocci_file, !Config.std_iso) in
let xs = Cocci.full_engine cocci_infos [cfile] in
Cocci.post_engine cocci_infos;
let (correct, diffxs) = Compare_c.compare_default generated expected
in
- pr2 res;
(* I don't use Compare_c.compare_result_to_string because
* I want to indent a little more the messages.
*)
pr2 "--------------------------------";
pr2 "regression testing information";
pr2 "--------------------------------";
-
+
+ (* now default argument of testall:
let expected_score_file = "tests/SCORE_expected.sexp" in
+ *)
+ let expected_score_file_orig = "tests/SCORE_expected_orig.sexp" in
let best_of_both_file = "tests/SCORE_best_of_both.sexp" in
let actual_score_file = "tests/SCORE_actual.sexp" in
-
+
pr2 ("regression file: "^ expected_score_file);
let (expected_score : score) =
if Sys.file_exists expected_score_file
then
let sexp = Sexp.load_sexp expected_score_file in
Sexp_common.score_of_sexp sexp
- else empty_score()
+ else
+ if Sys.file_exists expected_score_file_orig
+ then begin
+ pr2 (spf "use expected orig file (%s)" expected_score_file_orig);
+ Common.command2 (spf "cp %s %s" expected_score_file_orig
+ expected_score_file);
+ let sexp = Sexp.load_sexp expected_score_file in
+ Sexp_common.score_of_sexp sexp
+ end
+ else
+ empty_score()
in
let new_bestscore = Common.regression_testing_vs score expected_score in
else
if good < expected_good
then begin
- pr2 "Current score is lower than expected, :(";
+ pr2 "Current score is lower than expected :(";
+ pr2 (spf "(was expecting %d but got %d)" expected_good good);
pr2 "";
pr2 "If you think it's normal, then maybe you need to update the";
pr2 (spf "score file %s, copying info from %s."
raise (UnixExit 1);
end
else begin
- pr2 "Current score is greater than expected, :)";
+ pr2 "Current score is greater than expected :)";
+ pr2 (spf "(was expecting %d but got %d)" expected_good good);
pr2 "Generating new expected score file and saving old one";
Common.command2_y_or_no_exit_if_no
(spf "mv %s %s" expected_score_file (expected_score_file ^ ".save"));
(* work with tests/ *)
(*****************************************************************************)
val testone : string (*test*) -> bool (*compare_expected*) -> unit
-val testall : unit -> unit
+val testall : ?expected_score_file:string -> unit -> unit
(*****************************************************************************)
(* works with tests-big/. The .res, .ok, .spatch_ok, .failed, .var *)
(bad_ptr_print.res Ok) (bad_typedef.res Ok) (badexp.res Ok)
(badpos.res
(Pb
- "PROBLEM\n exn = Failure(\"rule starting on line 1: already tagged token:\\nFile \\\"tests/badpos.c\\\", line 5, column 30, charpos = 139\\n around = 'reg_ptr', whole content = \\t (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));\")\n"))
- (badtypedef.res Ok) (ben.res Ok) (bitfield.res Ok) (braces.res Ok)
- (break.res Ok) (bug1.res Ok)
+ "PROBLEM\n exn = Failure(\"rule starting on line 1: already tagged token:\\nC code context\\nFile \\\"tests/badpos.c\\\", line 5, column 30, charpos = 139\\n around = 'reg_ptr', whole content = \\t (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));\")\n"))
+ (badtypedef.res Ok) (badzero.res Ok) (ben.res Ok) (bitfield.res Ok)
+ (braces.res Ok) (break.res Ok) (bug1.res Ok)
(bugloop.res
(Pb
- "PROBLEM\n exn = Failure(\"try to delete an expanded token: flags\")\n"))
+ "INCORRECT:diff token: PF_FREEZE VS )\nFile <COCCIOUTPUTFILE>, line 12, column 16, charpos = 390\n around = 'PF_FREEZE', whole content = \t\t\trefrigerator(PF_FREEZE);\nFile \"tests/bugloop.res\", line 8, column 16, charpos = 160\n around = ')', whole content = \t\t\trefrigerator();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,7 +1,3 @@\n -/* this doesn't work, because on the paths where we don't find refrigerator,\n -we expect to reach Exit without first going through current->flags & PF_FREEZE,\n -but of course any path that goes around the loop does precisely that */\n -\n static int stir_transmit_thread(void *arg)\n {\n \n @@ -9,7 +5,7 @@\n \t{\n \t\t/* if suspending, then power off and wait */\n \t\tif (unlikely(freezing(current))) {\n -\t\t\trefrigerator(PF_FREEZE);\n +\t\t\trefrigerator();\n \n \t\t}\n \t}\n"))
(bugon.res Ok) (cards.res Ok) (cast.res Ok) (cast_iso.res Ok)
(compare.res Ok) (const.res Ok) (const1bis.res Ok) (const_adding.res Ok)
(const_array.res Ok) (const_implicit_iso.res Ok) (constty.res Ok)
(define_exp.res Ok) (define_param.res Ok) (deftodo.res Ok) (deref.res Ok)
(devlink.res Ok) (disjexpr.res Ok) (disjexpr_ver1.res Ok)
(disjexpr_ver2.res Ok) (distribute.res Ok) (double.res Ok)
- (double_assign.res Ok)
- (double_switch.res (Pb "PROBLEM\n exn = Common.Impossible\n"))
- (doublepos.res Ok)
- (doubleswitch.res (Pb "PROBLEM\n exn = Common.Impossible\n"))
- (dowhile.res Ok) (dropf.res Ok) (dropparam.res Ok) (edots.res Ok)
- (edots_ver1.res Ok) (empty.res Ok) (end_commas.res Ok) (endif.res Ok)
- (exp.res Ok) (expnest.res Ok) (expopt.res Ok) (expopt2.res Ok)
- (expopt3.res Ok) (expopt3_ver1.res Ok) (expopt3_ver2.res Ok) (fields.res Ok)
- (fieldsmin.res Ok) (fix_flow_need.res Ok) (fn_todo.res Ok) (fnptr.res Ok)
- (fnret.res Ok) (four.res Ok) (foura.res Ok) (fp.res Ok) (fun.res Ok)
+ (double_assign.res Ok) (double_switch.res Ok) (doublepos.res Ok)
+ (doubleswitch.res Ok) (dowhile.res Ok) (dropf.res Ok) (dropparam.res Ok)
+ (edots.res Ok) (edots_ver1.res Ok) (empty.res Ok) (end_commas.res Ok)
+ (endif.res Ok) (exp.res Ok) (expnest.res Ok) (expopt.res Ok)
+ (expopt2.res Ok) (expopt3.res Ok) (expopt3_ver1.res Ok)
+ (expopt3_ver2.res Ok) (fields.res Ok) (fieldsmin.res Ok) (find_long.res Ok)
+ (fix_flow_need.res Ok) (fn_todo.res Ok) (fnptr.res Ok) (fnret.res Ok)
+ (four.res Ok) (foura.res Ok) (fp.res Ok) (fun.res Ok)
(gilles-question.res Ok) (gotobreak.res Ok) (hd.res Ok) (headers.res Ok)
- (hex.res Ok)
- (hil1.res Ok) (if.res Ok) (ifbr.res Ok) (ifdef1.res Ok) (ifdef2.res Ok)
+ (hex.res Ok) (hil1.res Ok) (if.res Ok) (ifbr.res Ok) (ifdef1.res Ok)
+ (ifdef2.res Ok)
(ifdef3.res
(Pb
"PROBLEM\n exn = Lexer_cocci.Lexical(\"unrecognised symbol, in token rule: #\")\n"))
(ifdef4.res Ok) (ifdef5.res Ok) (ifdef6.res Ok) (ifdef6a.res Ok)
+ (ifdefmeta.res Ok) (ifdefmeta1.res Ok) (ifdefmeta2.res Ok)
+ (ifdefmeta3.res Ok)
+ (ifdefmeta4.res
+ (Pb
+ "PROBLEM\n exn = Unix.Unix_error(20, \"stat\", \"tests/ifdefmeta4.cocci\")\n"))
(ifend.res Ok) (ifzer.res Ok) (inc.res Ok)
(incdir.res
(Pb
(jloop1.res
(Pb
"PROBLEM\n exn = Failure(\"minus: parse error: \\n = File \\\"tests/jloop1.cocci\\\", line 10, column 3, charpos = 129\\n around = '...>', whole content = ...>\\n\")\n"))
- (julia10.res Ok) (julia7.res Ok) (keep_comma.res Ok)
- (km.res
- (Pb
- "INCORRECT:diff token: } VS memset\nFile <COCCIOUTPUTFILE>, line 4, column 0, charpos = 85\n around = '}', whole content = }\nFile \"tests/km.res\", line 4, column 2, charpos = 87\n around = 'memset', whole content = memset(data, 0, element->string.length + 1);\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,5 @@\n int main() {\n int *data = kzalloc(element->string.length + 1, GFP_KERNEL);\n foo();\n + memset(data, 0, element->string.length + 1);\n }\n"))
+ (julia10.res Ok) (julia7.res Ok) (keep_comma.res Ok) (km.res Ok)
(kmalloc.res Ok) (kmc.res Ok) (ktype.res Ok)
(labels_metastatement.res
(Pb
"INCORRECT:diff token: { VS x\nFile <COCCIOUTPUTFILE>, line 4, column 2, charpos = 30\n around = '{', whole content = {\nFile \"tests/labels_metastatement.res\", line 4, column 4, charpos = 32\n around = 'x', whole content = x = 3; foo();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,15 +1,10 @@\n int foo(int i) {\n \n if(1) {\n - {\n - x = 3;\n - foo();\n - z = 4;\n - foo();\n - }\n - foo();\n - }\n - foo(); // we dont want that it add both foo on the } and on the endif\n + x = 3; foo();\n + z = 4; foo();\n + } // we dont want that it add both foo on the } and on the endif\n // (note: but need correct endif accrochage)\n + foo();\n \n }\n"))
(labels_metastatement_ver1.res Ok) (local.res Ok) (localid.res Ok)
- (longlong.res Ok) (longlongint.res Ok) (loop.res Ok) (lvalue.res Ok)
- (macro.res Ok) (match_no_meta.res Ok) (max.res Ok)
+ (longconst.res Ok) (longlong.res Ok) (longlongint.res Ok) (loop.res Ok)
+ (lvalue.res Ok) (macro.res Ok) (macro_int16.res Ok) (match_no_meta.res Ok)
+ (max.res Ok)
(metahex.res
(Pb
"INCORRECT:diff token: f VS }\nFile \"tests/metahex.c\", line 2, column 2, charpos = 15\n around = 'f', whole content = f(3);\nFile \"tests/metahex.res\", line 2, column 0, charpos = 13\n around = '}', whole content = }\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,2 @@\n int main() {\n - f(3);\n - g(0x03);\n }\n"))
(multiplus.res Ok) (multitype.res Ok) (multitypedef.res Ok)
(multivars.res Ok) (nest.res Ok) (nestone.res Ok) (nestseq.res Ok)
(neststruct.res Ok) (nl.res Ok) (nocast.res Ok) (not.res Ok) (noty.res Ok)
- (null_type.res Ok) (of.res Ok) (oneline.res Ok) (opt.res Ok)
- (optional_qualifier.res Ok) (optional_storage.res Ok) (orexp.res Ok)
- (param.res Ok) (param_end.res Ok) (param_ver1.res Ok)
- (parameters_dots.res Ok) (partial.res Ok)
+ (null_type.res Ok)
+ (oddifdef.res
+ (Pb
+ "INCORRECT:diff token: #else\n VS x\nFile <COCCIOUTPUTFILE>, line 10, column 0, charpos = 114\n around = '#else\n', whole content = #else\nFile \"tests/oddifdef.res\", line 10, column 2, charpos = 116\n around = 'x', whole content = x = 0;\n\n diff (result(<) vs expected_result(>)) = \n @@ -7,8 +7,9 @@\n a = 5;\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n \n @@ -21,8 +22,9 @@\n a = 3;\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n \n @@ -35,7 +37,8 @@\n #endif\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n"))
+ (of.res Ok) (oneline.res Ok) (opt.res Ok) (optional_qualifier.res Ok)
+ (optional_storage.res Ok) (orexp.res Ok) (param.res Ok) (param_end.res Ok)
+ (param_ver1.res Ok) (parameters_dots.res Ok) (partial.res Ok)
(pb_distribute_type.res
(Pb
"INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -5,11 +5,11 @@\n \n \n int foo() {\n - int * *x;\n + int **x;\n return 0;\n }\n \n int foo() {\n - int[45] *x;\n + int (*x)[45];\n return 0;\n }\n"))
(wierdinit.res
(Pb
"seems incorrect, but only because of code that was not parsablediff token: dev_link_t VS struct\nFile \"tests/wierdinit.c\", line 4, column 1, charpos = 27\n around = 'dev_link_t', whole content = \tdev_link_t *link;\nFile \"tests/wierdinit.res\", line 4, column 1, charpos = 27\n around = 'struct', whole content = \tstruct pcmcia_device *link;\n"))
- (ws2.res Ok) (y2.res Ok) (zero.res Ok))
\ No newline at end of file
+ (ws2.res Ok) (xfield.res Ok) (y2.res Ok) (zero.res Ok))
\ No newline at end of file
--- /dev/null
+((a3d.res Ok) (a_and_e.res Ok) (a_and_e_ver1.res Ok) (addelse.res Ok)
+ (addif.res Ok) (addif1.res Ok) (addif2.res Ok) (after_if.res Ok)
+ (anon.res Ok) (ar.res Ok) (arg.res Ok) (argument.res Ok) (array_init.res Ok)
+ (array_size.res Ok) (arraysz.res Ok) (b1.res Ok) (b2.res Ok)
+ (bad_iso_example.res
+ (Pb
+ "INCORRECT:diff token: ( VS x\nFile \"tests/bad_iso_example.c\", line 2, column 6, charpos = 19\n around = '(', whole content = if ((x = 3)) return;\nFile \"tests/bad_iso_example.res\", line 2, column 6, charpos = 19\n around = 'x', whole content = if (x) return;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n - if ((x = 3)) return;\n + if (x) return;\n }\n \n"))
+ (bad_ptr_print.res Ok) (bad_typedef.res Ok) (badexp.res Ok)
+ (badpos.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"rule starting on line 1: already tagged token:\\nFile \\\"tests/badpos.c\\\", line 5, column 30, charpos = 139\\n around = 'reg_ptr', whole content = \\t (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));\")\n"))
+ (badtypedef.res Ok) (badzero.res Ok) (ben.res Ok) (bitfield.res Ok)
+ (braces.res Ok) (break.res Ok) (bug1.res Ok)
+ (bugloop.res
+ (Pb
+ "INCORRECT:diff token: PF_FREEZE VS )\nFile <COCCIOUTPUTFILE>, line 12, column 16, charpos = 390\n around = 'PF_FREEZE', whole content = \t\t\trefrigerator(PF_FREEZE);\nFile \"tests/bugloop.res\", line 8, column 16, charpos = 160\n around = ')', whole content = \t\t\trefrigerator();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,7 +1,3 @@\n -/* this doesn't work, because on the paths where we don't find refrigerator,\n -we expect to reach Exit without first going through current->flags & PF_FREEZE,\n -but of course any path that goes around the loop does precisely that */\n -\n static int stir_transmit_thread(void *arg)\n {\n \n @@ -9,7 +5,7 @@\n \t{\n \t\t/* if suspending, then power off and wait */\n \t\tif (unlikely(freezing(current))) {\n -\t\t\trefrigerator(PF_FREEZE);\n +\t\t\trefrigerator();\n \n \t\t}\n \t}\n"))
+ (bugon.res Ok) (cards.res Ok) (cast.res Ok) (cast_iso.res Ok)
+ (compare.res Ok) (const.res Ok) (const1bis.res Ok) (const_adding.res Ok)
+ (const_array.res Ok) (const_implicit_iso.res Ok) (constty.res Ok)
+ (constx.res Ok) (cs_check.res Ok) (cst.res Ok) (csw.res Ok)
+ (dbg.res
+ (Pb
+ "INCORRECT:diff token: else VS (\nFile <COCCIOUTPUTFILE>, line 8, column 2, charpos = 133\n around = 'else', whole content = \t\telse pr = NULL;;\nFile \"tests/dbg.res\", line 7, column 5, charpos = 130\n around = '(', whole content = \t\tDBG(\"PCI\");\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,6 +4,6 @@\n \tstruct resource *pr, *r = &dev->resource[idx];\n \n \tif (pr)\n -\t\tDBG\n -\t\telse pr = NULL;;\n +\t\tDBG(\"PCI\");\n +\telse pr = NULL;\n }\n"))
+ (dc_close.res Ok) (debug.res Ok) (dec.res Ok) (decl.res Ok) (decl2.res Ok)
+ (decl_space.res Ok)
+ (decl_split.res
+ (Pb
+ "INCORRECT:diff token: int VS }\nFile \"tests/decl_split.c\", line 2, column 8, charpos = 27\n around = 'int', whole content = int x, y;\nFile \"tests/decl_split.res\", line 2, column 0, charpos = 19\n around = '}', whole content = }\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,3 +1,2 @@\n int func(int i) { \n - int x, y;\n }\n"))
+ (define_exp.res Ok) (define_param.res Ok) (deftodo.res Ok) (deref.res Ok)
+ (devlink.res Ok) (disjexpr.res Ok) (disjexpr_ver1.res Ok)
+ (disjexpr_ver2.res Ok) (distribute.res Ok) (double.res Ok)
+ (double_assign.res Ok) (double_switch.res Ok) (doublepos.res Ok)
+ (doubleswitch.res Ok) (dowhile.res Ok) (dropf.res Ok) (dropparam.res Ok)
+ (edots.res Ok) (edots_ver1.res Ok) (empty.res Ok) (end_commas.res Ok)
+ (endif.res Ok) (exp.res Ok) (expnest.res Ok) (expopt.res Ok)
+ (expopt2.res Ok) (expopt3.res Ok) (expopt3_ver1.res Ok)
+ (expopt3_ver2.res Ok) (fields.res Ok) (fieldsmin.res Ok) (find_long.res Ok)
+ (fix_flow_need.res Ok) (fn_todo.res Ok) (fnptr.res Ok) (fnret.res Ok)
+ (four.res Ok) (foura.res Ok) (fp.res Ok) (fun.res Ok)
+ (gilles-question.res Ok) (gotobreak.res Ok) (hd.res Ok) (headers.res Ok)
+ (hex.res Ok) (hil1.res Ok) (if.res Ok) (ifbr.res Ok) (ifdef1.res Ok)
+ (ifdef2.res Ok)
+ (ifdef3.res
+ (Pb
+ "PROBLEM\n exn = Lexer_cocci.Lexical(\"unrecognised symbol, in token rule: #\")\n"))
+ (ifdef4.res Ok) (ifdef5.res Ok) (ifdef6.res Ok) (ifdef6a.res Ok)
+ (ifdefmeta.res Ok) (ifdefmeta1.res Ok) (ifdefmeta2.res Ok)
+ (ifdefmeta3.res
+ (Pb
+ "INCORRECT:diff token: g VS #ifdef ONE\nFile <COCCIOUTPUTFILE>, line 4, column 2, charpos = 32\n around = 'g', whole content = g();\nFile \"tests/ifdefmeta3.res\", line 4, column 0, charpos = 30\n around = '#ifdef ONE', whole content = #ifdef ONE\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,7 @@\n int main () {\n f();\n xxx();\n +#ifdef ONE\n +#endif\n g();\n }\n"))
+ (ifdefmeta4.res
+ (Pb
+ "PROBLEM\n exn = Unix.Unix_error(20, \"stat\", \"tests/ifdefmeta4.cocci\")\n"))
+ (ifend.res Ok) (ifzer.res Ok) (inc.res Ok)
+ (incdir.res
+ (Pb
+ "INCORRECT:diff token: x VS 12\nFile \"tests/incdir.c\", line 4, column 6, charpos = 46\n around = 'x', whole content = foo(x);\nFile \"tests/incdir.res\", line 4, column 6, charpos = 46\n around = '12', whole content = foo(12);\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n #include \"sub/incdir2.c\"\n \n int main () {\n - foo(x);\n + foo(12);\n }\n"))
+ (incl.res Ok) (inclifdef.res Ok) (include.res Ok)
+ (incompatible_value.res Ok) (inherited.res Ok) (inherited_ver1.res Ok)
+ (inhpos.res Ok) (initializer.res Ok) (initializer_many_fields.res Ok)
+ (inline.res Ok) (isococci.res Ok) (isotest.res Ok) (isotest2.res Ok)
+ (iterator.res Ok)
+ (jloop1.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"minus: parse error: \\n = File \\\"tests/jloop1.cocci\\\", line 10, column 3, charpos = 129\\n around = '...>', whole content = ...>\\n\")\n"))
+ (julia10.res Ok) (julia7.res Ok) (keep_comma.res Ok) (km.res Ok)
+ (kmalloc.res Ok) (kmc.res Ok) (ktype.res Ok)
+ (labels_metastatement.res
+ (Pb
+ "INCORRECT:diff token: { VS x\nFile <COCCIOUTPUTFILE>, line 4, column 2, charpos = 30\n around = '{', whole content = {\nFile \"tests/labels_metastatement.res\", line 4, column 4, charpos = 32\n around = 'x', whole content = x = 3; foo();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,15 +1,10 @@\n int foo(int i) {\n \n if(1) {\n - {\n - x = 3;\n - foo();\n - z = 4;\n - foo();\n - }\n - foo();\n - }\n - foo(); // we dont want that it add both foo on the } and on the endif\n + x = 3; foo();\n + z = 4; foo();\n + } // we dont want that it add both foo on the } and on the endif\n // (note: but need correct endif accrochage)\n + foo();\n \n }\n"))
+ (labels_metastatement_ver1.res Ok) (local.res Ok) (localid.res Ok)
+ (longconst.res Ok) (longlong.res Ok) (longlongint.res Ok) (loop.res Ok)
+ (lvalue.res Ok) (macro.res Ok) (macro_int16.res Ok) (match_no_meta.res Ok)
+ (max.res Ok)
+ (metahex.res
+ (Pb
+ "INCORRECT:diff token: f VS }\nFile \"tests/metahex.c\", line 2, column 2, charpos = 15\n around = 'f', whole content = f(3);\nFile \"tests/metahex.res\", line 2, column 0, charpos = 13\n around = '}', whole content = }\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,2 @@\n int main() {\n - f(3);\n - g(0x03);\n }\n"))
+ (metaruleelem.res Ok) (metastatement2.res Ok) (metastatement_for.res Ok)
+ (metastatement_if.res Ok) (minstruct.res Ok) (minusdots.res Ok)
+ (minusdots_ver1.res Ok)
+ (multi_func1.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"minus: parse error: \\n = File \\\"tests/multi_func1.cocci\\\", line 12, column 2, charpos = 102\\n around = 'fn2', whole content = fn2(...) {\\n\")\n"))
+ (multiplus.res Ok) (multitype.res Ok) (multitypedef.res Ok)
+ (multivars.res Ok) (nest.res Ok) (nestone.res Ok) (nestseq.res Ok)
+ (neststruct.res Ok) (nl.res Ok) (nocast.res Ok) (not.res Ok) (noty.res Ok)
+ (null_type.res Ok)
+ (oddifdef.res
+ (Pb
+ "INCORRECT:diff token: #else\n VS x\nFile <COCCIOUTPUTFILE>, line 10, column 0, charpos = 114\n around = '#else\n', whole content = #else\nFile \"tests/oddifdef.res\", line 10, column 2, charpos = 116\n around = 'x', whole content = x = 0;\n\n diff (result(<) vs expected_result(>)) = \n @@ -7,8 +7,9 @@\n a = 5;\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n \n @@ -21,8 +22,9 @@\n a = 3;\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n \n @@ -35,7 +37,8 @@\n #endif\n \n #ifdef FOO\n + x = 0;\n #else\n - \n + x = 0;\n #endif\n }\n"))
+ (of.res Ok) (oneline.res Ok) (opt.res Ok) (optional_qualifier.res Ok)
+ (optional_storage.res Ok) (orexp.res Ok) (param.res Ok) (param_end.res Ok)
+ (param_ver1.res Ok) (parameters_dots.res Ok) (partial.res Ok)
+ (pb_distribute_type.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -5,11 +5,11 @@\n \n \n int foo() {\n - int * *x;\n + int **x;\n return 0;\n }\n \n int foo() {\n - int[45] *x;\n + int (*x)[45];\n return 0;\n }\n"))
+ (pb_distribute_type2.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n int foo() {\n - int* x;\n + int *x;\n return 0;\n }\n \n @@ -10,6 +10,6 @@\n }\n \n int foo() {\n - int x[45]*;\n + int (*x)[45];\n return 0;\n }\n"))
+ (pb_distribute_type3.res
+ (Pb "PROBLEM\n exn = Failure(\"line 7: index 53 53 already used\\n\")\n"))
+ (pb_distribute_type4.res Ok) (pb_params_iso.res Ok)
+ (pb_parsing_macro.res Ok) (pb_tag_symbols.res Ok) (pmac.res Ok)
+ (posiso.res Ok) (positionc.res Ok) (post.res Ok) (print_return.res Ok)
+ (proto.res Ok) (proto2.res Ok) (proto_ver1.res Ok) (proto_ver2.res Ok)
+ (protoassert.res Ok) (protox.res Ok) (rcu3.res Ok)
+ (remstruct.res
+ (Pb
+ "INCORRECT:not same number of entities (func, decl, ...)\n diff (result(<) vs expected_result(>)) = \n @@ -1,10 +1,3 @@\n -\n - .ack = mpuio_ack_irq,\n - .mask = mpuio_mask_irq,\n - .unmask = mpuio_unmask_irq\n -\n - .b = 15,\n -\n int hello ( String input )\n {\n String input = input.lowercase();\n"))
+ (replace_typedef.res Ok) (reserved.res Ok) (retmacro.res Ok) (rets.res Ok)
+ (return.res Ok) (return_implicit.res Ok) (same_expr.res Ok)
+ (scope_problem.res
+ (Pb
+ "INCORRECT:diff token: } VS a\nFile <COCCIOUTPUTFILE>, line 6, column 2, charpos = 44\n around = '}', whole content = }\nFile \"tests/scope_problem.res\", line 7, column 4, charpos = 49\n around = 'a', whole content = a = 2;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,8 +1,10 @@\n void main(int i) {\n \n \n +\n if(1) {\n int a;\n + a = 2;\n }\n \n \n"))
+ (serio.res
+ (Pb
+ "INCORRECT:diff token: init_MUTEX VS mutex_init\nFile \"tests/serio.c\", line 7, column 1, charpos = 130\n around = 'init_MUTEX', whole content = \tinit_MUTEX(&serio->drv_sem);\nFile \"tests/serio.res\", line 7, column 1, charpos = 130\n around = 'mutex_init', whole content = \tmutex_init(&serio->new_lock);\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,5 +4,5 @@\n \n static void serio_init_port(struct serio *serio)\n {\n -\tinit_MUTEX(&serio->drv_sem);\n +\tmutex_init(&serio->new_lock);\n }\n"))
+ (shared_brace.res Ok) (signed.res Ok) (sis.res Ok) (sizeof.res Ok)
+ (sizeof_julia.res Ok) (skip.res Ok) (sp.res Ok) (spaces.res Ok) (spl.res Ok)
+ (static.res (Pb "PROBLEM\n exn = Common.Impossible\n")) (stm1.res Ok)
+ (stm10.res Ok) (stm10_ver1.res Ok) (stm2.res Ok) (stm3.res Ok) (stm4.res Ok)
+ (stm5.res Ok) (stm6.res Ok) (stm7.res Ok) (stm8.res Ok) (stmt.res Ok)
+ (strangeorder.res Ok) (string.res Ok) (struct.res Ok)
+ (struct_metavar.res Ok) (struct_typedef.res Ok) (structfoo.res Ok)
+ (substruct.res Ok) (sw.res Ok) (switch.res Ok) (td.res Ok) (test0.res Ok)
+ (test1.res Ok) (test10.res Ok) (test10_ver1.res Ok) (test11.res Ok)
+ (test11_ver1.res Ok) (test12.res Ok) (test2.res Ok) (test3.res Ok)
+ (test4.res Ok) (test5.res Ok) (test5_ver1.res Ok) (test6.res Ok)
+ (test7.res Ok) (test8.res Ok) (test9.res Ok) (test_unsigned_meta.res Ok)
+ (three_types.res Ok) (threea.res Ok) (top.res Ok) (topdec.res Ok)
+ (topdec_ver1.res Ok) (topdec_ver2.res Ok) (toplevel_macrostmt.res Ok)
+ (toplevel_struct.res Ok) (tup.res Ok) (twoproto.res Ok) (ty.res Ok)
+ (ty1.res Ok) (ty_tyexp.res Ok) (type.res Ok) (type1.res Ok)
+ (type_annotated.res Ok) (type_ver1.res Ok)
+ (type_ver2.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n int foo() {\n - int[10] *x;\n + int *x[10];\n return 0;\n }\n \n"))
+ (typedef.res Ok)
+ (typedef3.res
+ (Pb
+ "INCORRECT:diff token: link VS p_dev\nFile <COCCIOUTPUTFILE>, line 7, column 29, charpos = 137\n around = 'link', whole content = \tunsigned int iobase = info->link.io.BasePort1;\nFile \"tests/typedef3.res\", line 7, column 29, charpos = 137\n around = 'p_dev', whole content = \tunsigned int iobase = info->p_dev->io.BasePort1;\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,7 +4,7 @@\n \n static void should_work(foo *info)\n {\n -\tunsigned int iobase = info->link.io.BasePort1;\n +\tunsigned int iobase = info->p_dev->io.BasePort1;\n }\n \n static void does_work(struct bluecard_info_t *info)\n"))
+ (typedef_double.res Ok)
+ (typeof.res
+ (Pb
+ "INCORRECT:diff token: x VS sizeof\nFile <COCCIOUTPUTFILE>, line 3, column 4, charpos = 26\n around = 'x', whole content = f(x);\nFile \"tests/typeof.res\", line 3, column 4, charpos = 26\n around = 'sizeof', whole content = f(sizeof(struct foo));\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n int x;\n - f(x);\n + f(sizeof(struct foo));\n }\n"))
+ (useless_cast.res Ok) (varargs.res Ok) (video1bis.res Ok) (void.res Ok)
+ (vpos.res Ok) (whitespace.res Ok) (wierd_argument.res Ok)
+ (wierdinit.res
+ (Pb
+ "seems incorrect, but only because of code that was not parsablediff token: dev_link_t VS struct\nFile \"tests/wierdinit.c\", line 4, column 1, charpos = 27\n around = 'dev_link_t', whole content = \tdev_link_t *link;\nFile \"tests/wierdinit.res\", line 4, column 1, charpos = 27\n around = 'struct', whole content = \tstruct pcmcia_device *link;\n"))
+ (ws2.res Ok) (xfield.res Ok) (y2.res Ok) (zero.res Ok))
\ No newline at end of file
--- /dev/null
+((a3d.res Ok) (a_and_e.res Ok) (a_and_e_ver1.res Ok) (addelse.res Ok)
+ (addif.res Ok) (addif1.res Ok) (addif2.res Ok) (after_if.res Ok)
+ (anon.res Ok) (ar.res Ok) (arg.res Ok) (argument.res Ok) (array_init.res Ok)
+ (array_size.res Ok) (arraysz.res Ok) (b1.res Ok) (b2.res Ok)
+ (bad_iso_example.res
+ (Pb
+ "INCORRECT:diff token: ( VS x\nFile \"tests/bad_iso_example.c\", line 2, column 6, charpos = 19\n around = '(', whole content = if ((x = 3)) return;\nFile \"tests/bad_iso_example.res\", line 2, column 6, charpos = 19\n around = 'x', whole content = if (x) return;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n - if ((x = 3)) return;\n + if (x) return;\n }\n \n"))
+ (bad_ptr_print.res Ok) (bad_typedef.res Ok) (badexp.res Ok)
+ (badpos.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"rule starting on line 1: already tagged token:\\nFile \\\"tests/badpos.c\\\", line 5, column 30, charpos = 139\\n around = 'reg_ptr', whole content = \\t (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));\")\n"))
+ (badtypedef.res Ok) (badzero.res Ok) (ben.res Ok) (bitfield.res Ok)
+ (braces.res Ok) (break.res Ok) (bug1.res Ok)
+ (bugloop.res
+ (Pb
+ "INCORRECT:diff token: PF_FREEZE VS )\nFile <COCCIOUTPUTFILE>, line 12, column 16, charpos = 390\n around = 'PF_FREEZE', whole content = \t\t\trefrigerator(PF_FREEZE);\nFile \"tests/bugloop.res\", line 8, column 16, charpos = 160\n around = ')', whole content = \t\t\trefrigerator();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,7 +1,3 @@\n -/* this doesn't work, because on the paths where we don't find refrigerator,\n -we expect to reach Exit without first going through current->flags & PF_FREEZE,\n -but of course any path that goes around the loop does precisely that */\n -\n static int stir_transmit_thread(void *arg)\n {\n \n @@ -9,7 +5,7 @@\n \t{\n \t\t/* if suspending, then power off and wait */\n \t\tif (unlikely(freezing(current))) {\n -\t\t\trefrigerator(PF_FREEZE);\n +\t\t\trefrigerator();\n \n \t\t}\n \t}\n"))
+ (bugon.res Ok) (cards.res Ok) (cast.res Ok) (cast_iso.res Ok)
+ (compare.res Ok) (const.res Ok) (const1bis.res Ok) (const_adding.res Ok)
+ (const_array.res Ok) (const_implicit_iso.res Ok) (constty.res Ok)
+ (constx.res Ok) (cs_check.res Ok) (cst.res Ok) (csw.res Ok)
+ (dbg.res
+ (Pb
+ "INCORRECT:diff token: else VS (\nFile <COCCIOUTPUTFILE>, line 8, column 2, charpos = 133\n around = 'else', whole content = \t\telse pr = NULL;;\nFile \"tests/dbg.res\", line 7, column 5, charpos = 130\n around = '(', whole content = \t\tDBG(\"PCI\");\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,6 +4,6 @@\n \tstruct resource *pr, *r = &dev->resource[idx];\n \n \tif (pr)\n -\t\tDBG\n -\t\telse pr = NULL;;\n +\t\tDBG(\"PCI\");\n +\telse pr = NULL;\n }\n"))
+ (dc_close.res Ok) (debug.res Ok) (dec.res Ok) (decl.res Ok) (decl2.res Ok)
+ (decl_space.res Ok)
+ (decl_split.res
+ (Pb
+ "INCORRECT:diff token: int VS }\nFile \"tests/decl_split.c\", line 2, column 8, charpos = 27\n around = 'int', whole content = int x, y;\nFile \"tests/decl_split.res\", line 2, column 0, charpos = 19\n around = '}', whole content = }\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,3 +1,2 @@\n int func(int i) { \n - int x, y;\n }\n"))
+ (define_exp.res Ok) (define_param.res Ok) (deftodo.res Ok) (deref.res Ok)
+ (devlink.res Ok) (disjexpr.res Ok) (disjexpr_ver1.res Ok)
+ (disjexpr_ver2.res Ok) (distribute.res Ok) (double.res Ok)
+ (double_assign.res Ok)
+ (double_switch.res (Pb "PROBLEM\n exn = Common.Impossible\n"))
+ (doublepos.res Ok)
+ (doubleswitch.res (Pb "PROBLEM\n exn = Common.Impossible\n"))
+ (dowhile.res Ok) (dropf.res Ok) (dropparam.res Ok) (edots.res Ok)
+ (edots_ver1.res Ok) (empty.res Ok) (end_commas.res Ok) (endif.res Ok)
+ (exp.res Ok) (expnest.res Ok) (expopt.res Ok) (expopt2.res Ok)
+ (expopt3.res Ok) (expopt3_ver1.res Ok) (expopt3_ver2.res Ok) (fields.res Ok)
+ (fieldsmin.res Ok) (fix_flow_need.res Ok) (fn_todo.res Ok) (fnptr.res Ok)
+ (fnret.res Ok) (four.res Ok) (foura.res Ok) (fp.res Ok) (fun.res Ok)
+ (gilles-question.res Ok) (gotobreak.res Ok) (hd.res Ok) (headers.res Ok)
+ (hex.res Ok) (hil1.res Ok) (if.res Ok) (ifbr.res Ok) (ifdef1.res Ok)
+ (ifdef2.res Ok)
+ (ifdef3.res
+ (Pb
+ "PROBLEM\n exn = Lexer_cocci.Lexical(\"unrecognised symbol, in token rule: #\")\n"))
+ (ifdef4.res Ok) (ifdef5.res Ok) (ifdef6.res Ok) (ifdef6a.res Ok)
+ (ifdefmeta.res Ok) (ifdefmeta1.res Ok) (ifdefmeta2.res Ok)
+ (ifdefmeta3.res Ok)
+ (ifdefmeta4.res
+ (Pb
+ "PROBLEM\n exn = Unix.Unix_error(20, \"stat\", \"tests/ifdefmeta4.cocci\")\n"))
+ (ifend.res Ok) (ifzer.res Ok) (inc.res Ok)
+ (incdir.res
+ (Pb
+ "INCORRECT:diff token: x VS 12\nFile \"tests/incdir.c\", line 4, column 6, charpos = 46\n around = 'x', whole content = foo(x);\nFile \"tests/incdir.res\", line 4, column 6, charpos = 46\n around = '12', whole content = foo(12);\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n #include \"sub/incdir2.c\"\n \n int main () {\n - foo(x);\n + foo(12);\n }\n"))
+ (incl.res Ok) (inclifdef.res Ok) (include.res Ok)
+ (incompatible_value.res Ok) (inherited.res Ok) (inherited_ver1.res Ok)
+ (inhpos.res Ok) (initializer.res Ok) (initializer_many_fields.res Ok)
+ (inline.res Ok) (isococci.res Ok) (isotest.res Ok) (isotest2.res Ok)
+ (iterator.res Ok)
+ (jloop1.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"minus: parse error: \\n = File \\\"tests/jloop1.cocci\\\", line 10, column 3, charpos = 129\\n around = '...>', whole content = ...>\\n\")\n"))
+ (julia10.res Ok) (julia7.res Ok) (keep_comma.res Ok) (km.res Ok)
+ (kmalloc.res Ok) (kmc.res Ok) (ktype.res Ok)
+ (labels_metastatement.res
+ (Pb
+ "INCORRECT:diff token: { VS x\nFile <COCCIOUTPUTFILE>, line 4, column 2, charpos = 30\n around = '{', whole content = {\nFile \"tests/labels_metastatement.res\", line 4, column 4, charpos = 32\n around = 'x', whole content = x = 3; foo();\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,15 +1,10 @@\n int foo(int i) {\n \n if(1) {\n - {\n - x = 3;\n - foo();\n - z = 4;\n - foo();\n - }\n - foo();\n - }\n - foo(); // we dont want that it add both foo on the } and on the endif\n + x = 3; foo();\n + z = 4; foo();\n + } // we dont want that it add both foo on the } and on the endif\n // (note: but need correct endif accrochage)\n + foo();\n \n }\n"))
+ (labels_metastatement_ver1.res Ok) (local.res Ok) (localid.res Ok)
+ (longlong.res Ok) (longlongint.res Ok) (loop.res Ok) (lvalue.res Ok)
+ (macro.res Ok) (match_no_meta.res Ok) (max.res Ok)
+ (metahex.res
+ (Pb
+ "INCORRECT:diff token: f VS }\nFile \"tests/metahex.c\", line 2, column 2, charpos = 15\n around = 'f', whole content = f(3);\nFile \"tests/metahex.res\", line 2, column 0, charpos = 13\n around = '}', whole content = }\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,2 @@\n int main() {\n - f(3);\n - g(0x03);\n }\n"))
+ (metaruleelem.res Ok) (metastatement2.res Ok) (metastatement_for.res Ok)
+ (metastatement_if.res Ok) (minstruct.res Ok) (minusdots.res Ok)
+ (minusdots_ver1.res Ok)
+ (multi_func1.res
+ (Pb
+ "PROBLEM\n exn = Failure(\"minus: parse error: \\n = File \\\"tests/multi_func1.cocci\\\", line 12, column 2, charpos = 102\\n around = 'fn2', whole content = fn2(...) {\\n\")\n"))
+ (multiplus.res Ok) (multitype.res Ok) (multitypedef.res Ok)
+ (multivars.res Ok) (nest.res Ok) (nestone.res Ok) (nestseq.res Ok)
+ (neststruct.res Ok) (nl.res Ok) (nocast.res Ok) (not.res Ok) (noty.res Ok)
+ (null_type.res Ok) (of.res Ok) (oneline.res Ok) (opt.res Ok)
+ (optional_qualifier.res Ok) (optional_storage.res Ok) (orexp.res Ok)
+ (param.res Ok) (param_end.res Ok) (param_ver1.res Ok)
+ (parameters_dots.res Ok) (partial.res Ok)
+ (pb_distribute_type.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -5,11 +5,11 @@\n \n \n int foo() {\n - int * *x;\n + int **x;\n return 0;\n }\n \n int foo() {\n - int[45] *x;\n + int (*x)[45];\n return 0;\n }\n"))
+ (pb_distribute_type2.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n int foo() {\n - int* x;\n + int *x;\n return 0;\n }\n \n @@ -10,6 +10,6 @@\n }\n \n int foo() {\n - int x[45]*;\n + int (*x)[45];\n return 0;\n }\n"))
+ (pb_distribute_type3.res
+ (Pb "PROBLEM\n exn = Failure(\"line 7: index 53 53 already used\\n\")\n"))
+ (pb_distribute_type4.res Ok) (pb_params_iso.res Ok)
+ (pb_parsing_macro.res Ok) (pb_tag_symbols.res Ok) (pmac.res Ok)
+ (posiso.res Ok) (positionc.res Ok) (post.res Ok) (print_return.res Ok)
+ (proto.res Ok) (proto2.res Ok) (proto_ver1.res Ok) (proto_ver2.res Ok)
+ (protoassert.res Ok) (protox.res Ok) (rcu3.res Ok)
+ (remstruct.res
+ (Pb
+ "INCORRECT:not same number of entities (func, decl, ...)\n diff (result(<) vs expected_result(>)) = \n @@ -1,10 +1,3 @@\n -\n - .ack = mpuio_ack_irq,\n - .mask = mpuio_mask_irq,\n - .unmask = mpuio_unmask_irq\n -\n - .b = 15,\n -\n int hello ( String input )\n {\n String input = input.lowercase();\n"))
+ (replace_typedef.res Ok) (reserved.res Ok) (retmacro.res Ok) (rets.res Ok)
+ (return.res Ok) (return_implicit.res Ok) (same_expr.res Ok)
+ (scope_problem.res
+ (Pb
+ "INCORRECT:diff token: } VS a\nFile <COCCIOUTPUTFILE>, line 6, column 2, charpos = 45\n around = '}', whole content = }\nFile \"tests/scope_problem.res\", line 7, column 4, charpos = 49\n around = 'a', whole content = a = 2;\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,8 +1,10 @@\n void main(int i) {\n \n \n +\n if(1) {\n int a;\n + a = 2;\n }\n \n \n"))
+ (serio.res
+ (Pb
+ "INCORRECT:diff token: init_MUTEX VS mutex_init\nFile \"tests/serio.c\", line 7, column 1, charpos = 130\n around = 'init_MUTEX', whole content = \tinit_MUTEX(&serio->drv_sem);\nFile \"tests/serio.res\", line 7, column 1, charpos = 130\n around = 'mutex_init', whole content = \tmutex_init(&serio->new_lock);\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,5 +4,5 @@\n \n static void serio_init_port(struct serio *serio)\n {\n -\tinit_MUTEX(&serio->drv_sem);\n +\tmutex_init(&serio->new_lock);\n }\n"))
+ (shared_brace.res Ok) (signed.res Ok) (sis.res Ok) (sizeof.res Ok)
+ (sizeof_julia.res Ok) (skip.res Ok) (sp.res Ok) (spaces.res Ok) (spl.res Ok)
+ (static.res (Pb "PROBLEM\n exn = Common.Impossible\n")) (stm1.res Ok)
+ (stm10.res Ok) (stm10_ver1.res Ok) (stm2.res Ok) (stm3.res Ok) (stm4.res Ok)
+ (stm5.res Ok) (stm6.res Ok) (stm7.res Ok) (stm8.res Ok) (stmt.res Ok)
+ (strangeorder.res Ok) (string.res Ok) (struct.res Ok)
+ (struct_metavar.res Ok) (struct_typedef.res Ok) (structfoo.res Ok)
+ (substruct.res Ok) (sw.res Ok) (switch.res Ok) (td.res Ok) (test0.res Ok)
+ (test1.res Ok) (test10.res Ok) (test10_ver1.res Ok) (test11.res Ok)
+ (test11_ver1.res Ok) (test12.res Ok) (test2.res Ok) (test3.res Ok)
+ (test4.res Ok) (test5.res Ok) (test5_ver1.res Ok) (test6.res Ok)
+ (test7.res Ok) (test8.res Ok) (test9.res Ok) (test_unsigned_meta.res Ok)
+ (three_types.res Ok) (threea.res Ok) (top.res Ok) (topdec.res Ok)
+ (topdec_ver1.res Ok) (topdec_ver2.res Ok) (toplevel_macrostmt.res Ok)
+ (toplevel_struct.res Ok) (tup.res Ok) (twoproto.res Ok) (ty.res Ok)
+ (ty1.res Ok) (ty_tyexp.res Ok) (type.res Ok) (type1.res Ok)
+ (type_annotated.res Ok) (type_ver1.res Ok)
+ (type_ver2.res
+ (Pb
+ "INCORRECT:PB parsing only in generated-file\n diff (result(<) vs expected_result(>)) = \n @@ -1,5 +1,5 @@\n int foo() {\n - int[10] *x;\n + int *x[10];\n return 0;\n }\n \n"))
+ (typedef.res Ok)
+ (typedef3.res
+ (Pb
+ "INCORRECT:diff token: link VS p_dev\nFile <COCCIOUTPUTFILE>, line 7, column 29, charpos = 137\n around = 'link', whole content = \tunsigned int iobase = info->link.io.BasePort1;\nFile \"tests/typedef3.res\", line 7, column 29, charpos = 137\n around = 'p_dev', whole content = \tunsigned int iobase = info->p_dev->io.BasePort1;\n\n diff (result(<) vs expected_result(>)) = \n @@ -4,7 +4,7 @@\n \n static void should_work(foo *info)\n {\n -\tunsigned int iobase = info->link.io.BasePort1;\n +\tunsigned int iobase = info->p_dev->io.BasePort1;\n }\n \n static void does_work(struct bluecard_info_t *info)\n"))
+ (typedef_double.res Ok)
+ (typeof.res
+ (Pb
+ "INCORRECT:diff token: x VS sizeof\nFile <COCCIOUTPUTFILE>, line 3, column 4, charpos = 26\n around = 'x', whole content = f(x);\nFile \"tests/typeof.res\", line 3, column 4, charpos = 26\n around = 'sizeof', whole content = f(sizeof(struct foo));\n\n diff (result(<) vs expected_result(>)) = \n @@ -1,4 +1,4 @@\n int main() {\n int x;\n - f(x);\n + f(sizeof(struct foo));\n }\n"))
+ (useless_cast.res Ok) (varargs.res Ok) (video1bis.res Ok) (void.res Ok)
+ (vpos.res Ok) (whitespace.res Ok) (wierd_argument.res Ok)
+ (wierdinit.res
+ (Pb
+ "seems incorrect, but only because of code that was not parsablediff token: dev_link_t VS struct\nFile \"tests/wierdinit.c\", line 4, column 1, charpos = 27\n around = 'dev_link_t', whole content = \tdev_link_t *link;\nFile \"tests/wierdinit.res\", line 4, column 1, charpos = 27\n around = 'struct', whole content = \tstruct pcmcia_device *link;\n"))
+ (ws2.res Ok) (xfield.res Ok) (y2.res Ok) (zero.res Ok))
\ No newline at end of file
@@
g();
-+ f(Y,0);
++ f(Y, 0);
...
f(X,Y);
+ /* some comment */
+ int xxx() {
+ /* a comment by itself */
-+ return 12; /* another comment */ }
++ return 12;/* another comment */ }
+ #endif
int
f(...)
@@
+ #ifdef FOO
-+ int /*foo*/ xxx;
++ int/*foo*/ xxx;
+ #endif
int
f(...)
@@
- schedule_work(&device->fld)
-+ schedule_delayed_work(&device->fld,0)
++ schedule_delayed_work(&device->fld, 0)
@@
- f(1,2,3);
-+ g(3,2,1);
++ g(3, 2, 1);
@@
identifier rule3.I;
expression str;
type rule3.T;
+declarer name MODULE_PARM;
@@
- MODULE_PARM(I,str);
--- /dev/null
+int main () {
+ int *x;
+ int *y;
+ int z;
+ if (y - x == 0) return;
+ if ((y - x) == 0) return;
+ if (y - z == 0) return;
+ if ((y - z) == 0) return;
+}
+
--- /dev/null
+// A pointer should not be compared to NULL
+//
+// Confidence: High
+// Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU. GPLv2.
+// URL: http://www.emn.fr/x-info/coccinelle/rules/badzero.html
+// Options:
+
+@r disable is_zero,isnt_zero @
+expression *E;
+position p;
+@@
+
+(
+- E@p == 0
++ 27
+|
+- E@p != 0
++ 27
+|
+- 0 == E@p
++ 27
+|
+- 0 != E@p
++ 27
+)
+
--- /dev/null
+int main () {
+ int *x;
+ int *y;
+ int z;
+ if (y - x == 0) return;
+ if ((y - x) == 0) return;
+ if (27) return;
+ if (27) return;
+}
+
initialiser E ;
@@
+ static GType this_type = 0;
-+ static const GTypeInfo this_info = E ;
++ static const GTypeInfo this_info = E;
GType get_type () {
- static GType this_type = 0;
if (...) {
@@
identifier I;
expression str;
+declarer name MODULE_PARM;
@@
- MODULE_PARM(I,str);
@@
- snd_magic_cast(T, (void*) B ,...)
-+ (T *) B
++ (T *)B
@@
expression B;
--- /dev/null
+int main () {
+ f(one);
+ f(two);
+ f(three);
+ f(four);
+ f(five);
+}
--- /dev/null
+@r@
+expression E;
+@@
+
+f(E);
+
+@script:python@
+E << r.E;
+@@
+
+print E
--- /dev/null
+int main () {
+ g(five);
+ g(four);
+ g(three);
+ g(two);
+ g(one);
+ f(one, 1);
+ f(two, 2);
+ f(three, 3);
+ f(four, 4);
+ f(five, 5);
+ f(one, 10);
+ f(two, 20);
+ f(three, 30);
+ f(four, 40);
+ f(five, 50);
+}
--- /dev/null
+@s@
+expression E;
+@@
+
+g(E);
+
+@r@
+expression s.E, E1;
+@@
+
+f(E,E1);
+
+@script:python@
+E1 << r.E1;
+@@
+
+print E1
@@
- foo(X);
-+ foobar(X,X);
++ foobar(X, X);
@@
- pcmcia_get_first_tuple(handle,E1)
-+ pcmcia_get_first_tuple(link,E1)
++ pcmcia_get_first_tuple(link, E1)
@@
- f(E)
-+ f(E+3)
\ No newline at end of file
++ f(E + 3)
\ No newline at end of file
--- /dev/null
+long function()
+{
+ long a;
+ int b;
+
+ a + b;
+ b + a;
+
+ return a;
+}
--- /dev/null
+@ C @
+long E1;
+int E2;
+@@
+(
+- E1;
++ (long)E1;
+|
+- E2;
++ (int)E2;
+)
--- /dev/null
+long function()
+{
+ long a;
+ int b;
+
+ (long)a + b;
+ (long)b + a;
+
+ return a;
+}
@@
@@
-+struct a {int a;};
++struct a{int a;};
f(int x) { return x; }
@@
- f(int x, int y) {
-+ f(int x) {
++ f(int x){
...
}
identifier p1, p2;
@@
-- void f (struct urb *p1, struct pt_regs *p2)
-+ void f (struct urb *p1)
+- void f(struct urb *p1, struct pt_regs *p2)
++ void f(struct urb *p1)
{
... when != p2
}
{
<...
+ #ifdef CONFIG_NKERNEL
-+ if (irq < IRQ_LIMIT)
++ if(irq < IRQ_LIMIT)
+ #endif
*desc = irq_desc;
...>
+ #ifdef CONFIG_NKERNEL
+ #ifndef TIMER_32K_SYNCHRONIZED
-+ #define TIMER_32K_SYNCHRONIZED 0xffffffff
++ #define TIMER_32K_SYNCHRONIZED 0xffffffff
+ #endif
+ unsigned long nk_vtick_read_stamp(void)
--- /dev/null
+int main() {
+ buf = alloca(3
+ #ifdef PLATFORM_A
+// platform a stuff
+ +5
+ +50
+ #endif
+ #ifdef PLATFORM_B
+/* platform b stuff */
+ +2
+ #endif
+ );
+ buf = alloca(3
+ #ifdef PLATFORM_A
+// platform a stuff
+ +5
+ +50
+ #endif
+ #ifdef PLATFORM_B
+/* platform b stuff */
+ +2
+ #endif
+ );
+}
+
+int other() {
+ buf = alloca(3
+ #ifdef PLATFORM_A
+// platform a stuff
+ +5
+ #endif
+ #ifdef PLATFORM_B
+/* platform b stuff */
+ +2
+ #endif
+ );
+ buf = alloca(3
+ +5
+ +2
+ );
+}
+
+int third() {
+ buf = alloca(3+5+2);
+ buf = alloca(3
+ +5
+ +2
+ );
+}
--- /dev/null
+@@ expression E; @@
+
+-alloca(E)
++malloc(E)
+ ...
+-alloca(E)
++malloc(E)
--- /dev/null
+int main() {
+ buf = malloc(3
+#ifdef PLATFORM_A
+ + 5 + 50
+#endif
+
+#ifdef PLATFORM_B
+ + 2
+#endif
+);
+ buf = malloc(3
+#ifdef PLATFORM_A
+ + 5 + 50
+#endif
+
+#ifdef PLATFORM_B
+ + 2
+#endif
+);
+}
+
+int other() {
+ buf = alloca(3
+ #ifdef PLATFORM_A
+// platform a stuff
+ +5
+ #endif
+ #ifdef PLATFORM_B
+/* platform b stuff */
+ +2
+ #endif
+ );
+ buf = alloca(3
+ +5
+ +2
+ );
+}
+
+int third() {
+ buf = malloc(3 + 5 + 2);
+ buf = malloc(3 + 5 + 2);
+}
--- /dev/null
+int main() {
+ buf = alloca(3
+ #ifdef PLATFORM_A
+// platform a stuff
+
+
+ +5
+
+
+
+ #endif
+ #ifdef PLATFORM_B
+/* platform b stuff */
+ +2
+ #endif
+ );
+}
--- /dev/null
+@@ expression E,E1; @@
+
+-E1=alloca(E);
--- /dev/null
+int main() {
+}
--- /dev/null
+int main() {
+ buf = alloca(3
+
+
+ +5
+
+
+
+
+ +2
+ );
+}
--- /dev/null
+@@ expression E,E1; @@
+
+-E1=alloca(E);
--- /dev/null
+int main() {
+}
--- /dev/null
+int main () {
+ f();
+ if (foo) {
+ one();
+#ifdef ONE
+ two();
+#endif
+ three();
+ }
+ g();
+}
--- /dev/null
+@@
+statement S;
+@@
+
+ f();
+- S
++ xxx();
+ g();
--- /dev/null
+int main () {
+ f();
+ xxx();
+ g();
+}
--- /dev/null
+int main () {
+ // a comment
+}
--- /dev/null
+
+int f(void)
+{
+if (x1)
+ w++;
+else if (y1)
+ z--;
+else if (z1)
+ a--;
+
+if (x2)
+ w++;
+else if (y2)
+ z--;
+
+if (x3)
+ {
+ w++;
+ }
+else if (y3)
+ {
+ z--;
+ }
+
+if (x4)
+ w++;
+else if (y4)
+ z--;
+else if (z4)
+ a--;
+else if (a4)
+ a--;
+}
+
+
+function if_if(void)
+{
+if (x4)
+ w++;
+if (y4)
+ z--;
+
+dummy--;
+
+if (x5)
+ w++;
+A++;
+if (y5)
+ z--;
+
+}
+
--- /dev/null
+@ if_else_3 @
+position p_3_1, p_3_2;
+expression E_3_1, E_3_2, E_3_3, E_3_4;
+statement S_3_1, S_3_2, S_3_3, S_3_4;
+@@
+if (E_3_1)
+ S_3_1
+else if (E_3_2)
+ S_3_2
+else if@p_3_1 (E_3_3)
+ S_3_3
+else if@p_3_2 (E_3_4)
+ S_3_4
+// + foo_3();
+
+@
+
+script:python @ expr_1 << if_else_3.E_3_1;
+ expr_2 << if_else_3.E_3_2;
+ expr_3 << if_else_3.E_3_3;
+ expr_4 << if_else_3.E_3_4;
+ @@
+print "--- 4"
+print expr_1
+print expr_2
+print expr_3
+print expr_4
+
+@ if_else_2 @
+position p_2 != if_else_3.p_3_2;
+expression E_2_1, E_2_2, E_2_3;
+statement S_2_1, S_2_2, S_2_3;
+@@
+if (E_2_1)
+ S_2_1
+else if (E_2_2)
+ S_2_2
+else if@p_2 (E_2_3)
+ S_2_3
+// + foo_2();
+
+@
+
+script:python @ expr_1 << if_else_2.E_2_1;
+ expr_2 << if_else_2.E_2_2;
+ expr_3 << if_else_2.E_2_3;
+ @@
+print "--- 3"
+print expr_1
+print expr_2
+print expr_3
+
+@ if_else_1 @
+// @@
+// position p1;
+expression E_1_1, E_1_2;
+statement S_1_1, S_1_2;
+position p_1_1 != if_else_3.p_3_1;
+position p_1_2 != if_else_2.p_2;
+@@
+if@p_1_1 (E_1_1)
+ S_1_1
+else if@p_1_2 (E_1_2)
+ S_1_2
+// + foo_1();
+
+@
+
+script:python @ expr_1 << if_else_1.E_1_1;
+ expr_2 << if_else_1.E_1_2;
+ @@
+print "--- 2"
+print expr_1
+print expr_2
+
+@ if_if_1 @
+expression E_10_1, E_10_2;
+statement S_10_1, S_10_2;
+@@
+if (E_10_1)
+ S_10_1
+if (E_10_2)
+ S_10_2
+// + bar();
+@
+
+script:python @ expr_1 << if_if_1.E_10_1;
+ expr_2 << if_if_1.E_10_2;
+ @@
+print "- 2"
+print expr_1
+print expr_2
+
@@
- x = (T)kmalloc(E1,E2)
-+ x = kzalloc(E1,E2)
++ x = kzalloc(E1, E2)
...
(
- memset((T2)x,0,E1);
int main() {
int *data = kzalloc(element->string.length + 1, GFP_KERNEL);
foo();
- memset(data, 0, element->string.length + 1);
}
x =
- (T)kmalloc(E1,E2)
-+ kzalloc(E1,E2)
++ kzalloc(E1, E2)
...
- memset(x,0,E1);
\ No newline at end of file
@@
- x = kmalloc(sizeof(T1),E2)
-+ x = kzalloc(sizeof(T1),E2)
++ x = kzalloc(sizeof(T1), E2)
...
- memset(x,0,sizeof(*y));
--- /dev/null
+ int main(){
+ int a, b;
+ int c = a + b;
+ return 0;
+}
--- /dev/null
+@test@
+int E1, E2;
+int E3;
+@@
+ E3 =
+- E1 + E2
++ E1 - E2
--- /dev/null
+long function1()
+{
+ long a;
+ int b;
+ a = 1l << b;
+ a = 1u << b;
+ a = 65536l << b;
+ a = 65536u << b;
+ a = 65536 << b;
+ a = 4294967296 << b;
+ a = 65535 << b;
+ a = 4294967295 << b;
+ a = 0x7fffffff << b;
+ a = 0x1fl << b;
+ a = 0x1fu << b;
+ a = 0x1FL << b;
+ a = 0x1FU << b;
+ return a;
+}
--- /dev/null
+@@
+expression E;
+long E1;
+int E2;
+@@
+- E1 = E2 << E;
++ E1 = f(E2, "int");
+
+@@
+expression E;
+long E1;
+unsigned int E2;
+@@
+- E1 = E2 << E;
++ E1 = f(E2, "unsigned");
+
+@@
+expression E;
+long E1;
+long E2;
+@@
+- E1 = E2 << E;
++ E1 = f(E2, "long");
+
+@@
+expression E;
+long E1;
+unsigned long E2;
+@@
+- E1 = E2 << E;
++ E1 = f(E2, "unsigned long");
--- /dev/null
+long function1()
+{
+ long a;
+ int b;
+ a = f(1l, "long");
+ a = f(1u, "unsigned");
+ a = f(65536l, "long");
+ a = f(65536u, "unsigned");
+ a = f(65536, "int");
+ a = f(4294967296, "int");
+ a = f(65535, "int");
+ a = f(4294967295, "int");
+ a = f(0x7fffffff, "int");
+ a = f(0x1fl, "long");
+ a = f(0x1fu, "unsigned");
+ a = f(0x1FL, "long");
+ a = f(0x1FU, "unsigned");
+ return a;
+}
--- /dev/null
+#define INT16 int
+//typedef int INT16;
+
+void main(void)
+{
+ INT16 a, b, c;
+ c = a + b;
+}
+
--- /dev/null
+@testint16@
+int E1, E2, E3;
+@@
+- E1 = E2 + E3;
++E1 = E2 - E3;
--- /dev/null
+#define INT16 int
+//typedef int INT16;
+
+void main(void)
+{
+ INT16 a, b, c;
+ c = b - a;
+}
+
f();
- S
-+ foo(); S
++ foo();S
@@
- g(E)
-+ g(E,NULL)
++ g(E, NULL)
@@
- x = kmalloc(sizeof(E),E2)
-+ x = kzalloc(sizeof(E),E2)
++ x = kzalloc(sizeof(E), E2)
--- /dev/null
+void one () {
+ if (errno != ENOENT
+#ifdef ENOTDIR
+ && errno != ENOTDIR
+#endif
+ )
+ a = 5;
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
+
+void two() {
+#ifdef ENOTTY
+ if (errno == ENOTTY)
+ is_a_tty=0;
+ else
+#endif
+ a = 3;
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
+
+void three() {
+ if (x)
+ a = 3;
+#ifndef OPENSSL_NO_SSL2
+ else if (strcmp(*argv,"-ssl2") == 0)
+ meth=SSLv2_client_method();
+#endif
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
--- /dev/null
+@@
+@@
+
+- x = 0;
+ ...
+- x = 0;
--- /dev/null
+void one () {
+ if (errno != ENOENT
+#ifdef ENOTDIR
+ && errno != ENOTDIR
+#endif
+ )
+ a = 5;
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
+
+void two() {
+#ifdef ENOTTY
+ if (errno == ENOTTY)
+ is_a_tty=0;
+ else
+#endif
+ a = 3;
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
+
+void three() {
+ if (x)
+ a = 3;
+#ifndef OPENSSL_NO_SSL2
+ else if (strcmp(*argv,"-ssl2") == 0)
+ meth=SSLv2_client_method();
+#endif
+
+#ifdef FOO
+ x = 0;
+#else
+ x = 0;
+#endif
+}
--- /dev/null
+void blk_queue_prep_rq(struct request_queue *q, prep_rq_fn *pfn)
+{
+ q->prep_rq_fn = pfn;
+}
--- /dev/null
+#ifdef SIGALRM
+#if defined(__STDC__) || defined(sgi) || defined(_AIX)
+#define SIGRETTYPE void*
+#else
+#define SIGRETTYPE int*
+#endif
+
+
+SIGRETTYPE foo(void)
+{
+ void x;
+
+ int x$y;
+}
--- /dev/null
+@@
+identifier x;
+@@
+
+//- void* x;
+//+ int* x;
+- void*
++ int*
@@
+ static struct pcmcia_driver ZZZ_driver = {
-+ .owner = THIS_MODULE,
++ .owner = THIS_MODULE,
+ };
int init (...) {
@@
- list_entry(I,T,E2)
-+ list_entry(_X(I),T,E2)
++ list_entry(_X(I), T, E2)
--- /dev/null
+qboolean SV_ReadClientMessage (void)
+{
+ int ret;
+ int cmd;
+ char *s;
+
+ if (host_client->privileged)
+ ret = 2;
+ else
+ ret = 0;
+ if (Q_strncasecmp(s, "status", 6) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "god", 3) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "notarget", 8) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "fly", 3) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "name", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "noclip", 6) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "say", 3) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "say_team", 8) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "tell", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "color", 5) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "kill", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "pause", 5) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "spawn", 5) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "begin", 5) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "prespawn", 8) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "kick", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "ping", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "give", 4) == 0)
+ ret = 1;
+ else if (Q_strncasecmp(s, "ban", 3) == 0)
+ ret = 1;
+ if (ret == 2)
+ Cbuf_InsertText (s);
+ else if (ret == 1)
+ Cmd_ExecuteString (s, src_client);
+ else
+ Con_DPrintf("%s tried to %s\n", host_client->name, s);
+
+}
+
f();
- S
-+ g(); S
++ g();S
@@
- struct dvb_frontend {
-+ struct dvb2_frontend {
++ struct dvb2_frontend{
...
- struct dvb_frontend_ops* ops;
+ struct dvb_frontend_ops ops;
g(Z);
...
- h(Y);
-+ h(X,Y,Z);
++ h(X, Y, Z);
g(X)
...
- h(X)
-+ h(X,X)
++ h(X, X)
\ No newline at end of file
g(X)
...
- h(X)
-+ h(X,X)
++ h(X, X)
\ No newline at end of file
@@
- f(X)
-+ f(X,Y)
++ f(X, Y)
...
g(Y)
f(X);
...
- g(Y);
-+ h(X,Y);
++ h(X, Y);
//error words = [f]
\ No newline at end of file
@@
- f(X)
-+ f(X,"foo")
++ f(X, "foo")
//error words = [f]
\ No newline at end of file
@@
- f(X);
-+ f(X,"foo");
-+ f(X,"bar");
++ f(X, "foo");
++ f(X, "bar");
f(X);
...
- h(Y);
-+ h(X,Y);
++ h(X, Y);
...
}
@@
+declarer name MODULE_PARM;
@@
- MODULE_PARM(...);
-// better perhaps to use a
-// declaration MODULE_PARM;
-// declaration module_parm;
-// ?
@@
expression x,y;
+declarer name MODULE_PARM;
+declarer name module_param;
@@
- MODULE_PARM(x,y);
-+ module_param(x,int,y);
++ module_param(x, int, y);
@@
- foo(E);
-+ foo(E,12);
++ foo(E, 12);
--- /dev/null
+FOO(a2,b2,c2);
+
+/*
+int y;
+
+struct foo {
+ FOO(a,b,c);
+ FOO(a1,b1,c1);
+};
+*/
--- /dev/null
+@@
+declarer name FOO;
+expression a,b,c;
+@@
+
+- FOO(a,b,c);
++ int x;
--- /dev/null
+int x;
+
+/*
+int y;
+
+struct foo {
+ FOO(a,b,c);
+ FOO(a1,b1,c1);
+};
+*/