[Cocci] "TODO: FunCall" in python match printing
Julia Lawall
julia at diku.dk
Fri Mar 6 22:23:44 CET 2009
Attached is another attempt at sending the patch. I downloaded a fresh
version of the sources from the web site, went into the coccinelle-0.1.5
directory and applied the patch with no problem using patch -p1 < cpatch
julia
-------------- next part --------------
diff -r -u -p coccinelle-0.1.5/parsing_cocci/parser_cocci_menhir.mly scratchcocci/parsing_cocci/parser_cocci_menhir.mly
--- coccinelle-0.1.5/parsing_cocci/parser_cocci_menhir.mly 2009-02-04 22:58:03.000000000 +0100
+++ scratchcocci/parsing_cocci/parser_cocci_menhir.mly 2009-03-06 08:47:20.000000000 +0100
@@ -1290,7 +1290,7 @@ unary_expr(r,pe):
{ Ast0.wrap(Ast0.Infix ($2, P.clt2mcode Ast.Inc $1)) }
| TDec unary_expr(r,pe)
{ Ast0.wrap(Ast0.Infix ($2, P.clt2mcode Ast.Dec $1)) }
- | unary_op unary_expr(r,pe)
+ | unary_op cast_expr(r,pe)
{ let mcode = $1 in Ast0.wrap(Ast0.Unary($2, mcode)) }
| TBang unary_expr(r,pe)
{ let mcode = P.clt2mcode Ast.Not $1 in
diff -r -u -p coccinelle-0.1.5/python/yes_pycocci_aux.ml scratchcocci/python/yes_pycocci_aux.ml
--- coccinelle-0.1.5/python/yes_pycocci_aux.ml 2009-02-04 22:58:04.000000000 +0100
+++ scratchcocci/python/yes_pycocci_aux.ml 2009-03-06 08:18:50.000000000 +0100
@@ -24,32 +24,6 @@ open Ast_c
open Common
open Pycaml
-let rec exprrep expr = match expr with
- Ast_c.Ident s -> s
-| Ast_c.Constant c -> constantrep c
-| Ast_c.FunCall (e,args) -> "TODO: FunCall"
-| Ast_c.CondExpr (e1,e2,e3) -> "TODO: CondExpr"
-| Ast_c.Sequence (e1,e2) -> "TODO: Sequence"
-| Ast_c.Assignment (e1,op,e2) -> "TODO: Assignment"
-| Ast_c.Postfix (e,op) -> "TODO: Postfix"
-| Ast_c.Infix (e,op) -> "TODO: Infix"
-| Ast_c.Unary (e,op) -> "TODO: Unary"
-| Ast_c.Binary (e1,op,e2) -> "TODO: Binary"
-| Ast_c.ArrayAccess (e1,e2) -> "TODO: ArrayAccess"
-| Ast_c.RecordAccess (e1,s) -> "TODO: RecordAccess"
-| Ast_c.RecordPtAccess (e,s) -> "TODO: RecordPtAccess"
-| Ast_c.SizeOfExpr e -> "TODO: SizeOfExpr"
-| Ast_c.SizeOfType t -> "TODO: SizeOfType"
-| Ast_c.Cast (t,e) -> "TODO: Cast"
-| Ast_c.StatementExpr c -> "TODO: StatementExpr"
-| Ast_c.Constructor (t,i) -> "TODO: Constructor"
-| Ast_c.ParenExpr e -> "TODO: ParenExpr"
-and constantrep c = match c with
- 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
let call_pretty f a =
let str = ref ([] : string list) in
@@ -58,11 +32,13 @@ let call_pretty f a =
f pr_elem pr_sp a;
String.concat " " (List.rev !str)
+let exprrep = call_pretty Pretty_print_c.pp_expression_gen
+
let stringrep mvb = match mvb with
Ast_c.MetaIdVal s -> s
| Ast_c.MetaFuncVal s -> s
| Ast_c.MetaLocalFuncVal s -> s
-| Ast_c.MetaExprVal ((expr,_),[il]) -> (exprrep expr)
+| Ast_c.MetaExprVal expr -> exprrep expr
| Ast_c.MetaExprVal e -> "TODO: <<MetaExprVal>>"
| Ast_c.MetaExprListVal expr_list -> "TODO: <<exprlist>>"
| Ast_c.MetaTypeVal typ -> call_pretty Pretty_print_c.pp_type_gen typ
diff -r -u -p coccinelle-0.1.5/python/yes_pycocci.ml scratchcocci/python/yes_pycocci.ml
--- coccinelle-0.1.5/python/yes_pycocci.ml 2009-01-20 22:40:45.000000000 +0100
+++ scratchcocci/python/yes_pycocci.ml 2009-03-06 08:19:18.000000000 +0100
@@ -199,7 +199,7 @@ let construct_variables mv e =
List.iter (function (py,(r,m)) ->
match find_binding (r,m) with
None -> ()
- | Some (_, Ast_c.MetaExprVal ((expr, _), info_list)) ->
+ | Some (_, Ast_c.MetaExprVal expr) ->
let expr_repr = instantiate_Expression(expr) in
let _ = build_variable py expr_repr in
()
More information about the Cocci
mailing list