let addInlineD = function
| ((true,ii), ({inlineD = (false,[])} as v)) -> { v with inlineD=(true,[ii])}
| ((true,ii), ({inlineD = (true, ii2)} as v)) -> warning "duplicate inline" v
- | _ -> raise Impossible
+ | _ -> raise (Impossible 86)
let addTypeD = function
| ((Middle3 x,ii), ({typeD = ((a,None,c),ii2)} as v)) ->
{v with typeD = (a, Some x,c),ii++ii2}
- | ((Right3 t,ii), ({typeD = ((a,b,Some _),ii2)} as _v)) ->
- raise (Semantic ("two or more data types", fake_pi))
+ | ((Right3 t,ii), ({typeD = ((a,b,Some x),ii2)} as _v)) ->
+ raise (Semantic ((Printf.sprintf "two or more data types: t %s ii %s\ntypeD %s ii2 %s\n" (Dumper.dump t) (Dumper.dump ii) (Dumper.dump x) (Dumper.dump ii2)), fake_pi))
| ((Right3 t,ii), ({typeD = ((a,b,None),ii2)} as v)) ->
{v with typeD = (a,b, Some t),ii++ii2}
| BaseType Void ->
ty
| _ ->
- pr2 ("SEMANTIC:parameter name omitted, but I continue");
+ pr2_once ("SEMANTIC:parameter name omitted, but I continue");
ty
)
match param with
| {p_namei = None} ->
(* if majuscule, then certainly macro-parameter *)
- pr2 ("SEMANTIC:parameter name omitted, but I continue");
+ pr2_once ("SEMANTIC:parameter name omitted, but I continue");
| _ -> ()
));
ty
%token <(string * Ast_c.isWchar) * Ast_c.info> TString
%token <string * Ast_c.info> TIdent
+%token <string * Ast_c.info> TKRParam
%token <string * Ast_c.info> Tconstructorname /* parsing_hack for c++ */
/*(* appears mostly after some fix_xxx in parsing_hack *)*/
%token <string * Ast_c.info> TypedefIdent
{
CppConcatenatedName (
match $3 with
- | [] -> raise Impossible
+ | [] -> raise (Impossible 87)
| (x,concatnull)::xs ->
assert(null concatnull);
(mk_string_wrap $1, [])::(x,[$2])::xs
let fty = mk_ty (Array (Some $3, ty.Ast_c.p_type)) [$2;$4] in
let pty = { ty with p_type = fty } in
Right(ArgType pty)
- | _ -> raise Impossible
+ | _ -> raise (Impossible 88)
}
unary_op:
| Tdo statement Twhile TOPar expr TCPar TPtVirg
{ DoWhile ($2,$5), [$1;$3;$4;$6;$7] }
| Tfor TOPar expr_statement expr_statement TCPar statement
- { For ($3,$4,(None, []),$6), [$1;$2;$5]}
+ { For (ForExp $3,$4,(None, []),$6), [$1;$2;$5]}
| Tfor TOPar expr_statement expr_statement expr TCPar statement
- { For ($3,$4,(Some $5, []),$7), [$1;$2;$6] }
+ { For (ForExp $3,$4,(Some $5, []),$7), [$1;$2;$6] }
/*(* c++ext: for(int i = 0; i < n; i++)*)*/
- | Tfor TOPar decl expr_statement expr_opt TCPar statement
- {
- (* pr2 "DECL in for"; *)
- MacroIteration ("toto", [], $7),[$1;$2;$6] (* TODOfake ast, TODO need decl2 ? *)
- }
+ | Tfor TOPar decl expr_statement TCPar statement
+ { For (ForDecl ($3 Ast_c.LocalDecl),$4,(None, []),$6), [$1;$2;$5]}
+ | Tfor TOPar decl expr_statement expr TCPar statement
+ { For (ForDecl ($3 Ast_c.LocalDecl),$4,(Some $5, []),$7), [$1;$2;$6] }
/*(* cppext: *)*/
| TMacroIterator TOPar argument_list_ne TCPar statement
{ MacroIteration (fst $1, $3, $5), [snd $1;$2;$4] }
parameter_decl2:
+ TKRParam {
+ let name = RegularName (mk_string_wrap $1) in
+ LP.add_ident (str_of_name name);
+ { p_namei = Some name;
+ p_type = mk_ty NoType [];
+ p_register = (false, []);
+ }
+ }
| decl_spec declaratorp
{ let ((returnType,hasreg),iihasreg) = fixDeclSpecForParam $1 in
let (name, ftyp) = $2 in
MacroDecl ((fst $3, $5, true), [snd $3;$4;$6;$7;fakeInfo();$1;$2])}
+ | TMacroDecl TOPar argument_list TCPar teq initialize TPtVirg
+ { function _ ->
+ MacroDeclInit ((fst $1, $3, $6), [snd $1;$2;$4;$5;$7;fakeInfo()]) }
+ | Tstatic TMacroDecl TOPar argument_list TCPar teq initialize TPtVirg
+ { function _ ->
+ MacroDeclInit ((fst $2, $4, $7),[snd $2;$3;$5;$6;$8;fakeInfo();$1]) }
+ | Tstatic TMacroDeclConst TMacroDecl TOPar argument_list TCPar
+ teq initialize TPtVirg
+ { function _ ->
+ MacroDeclInit
+ ((fst $3, $5, $8), [snd $3;$4;$6;$7;$9;fakeInfo();$1;$2])}
+
+
/*(*-----------------------------------------------------------------------*)*/
decl_spec2:
| storage_class_spec { {nullDecl with storageD = (fst $1, [snd $1]) } }
*)
}
- | spec_qualif_list TPtVirg
+ | spec_qualif_list TPtVirg
{
(* gccext: allow empty elements if it is a structdef or enumdef *)
let (returnType,storage) = fixDeclSpecForDecl $1 in
DefineType typ
}
-/* can be in conflict with decl_spec, maybe change fixDeclSpecForMacro
+/*(* 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 }
-/*
+ | stat_or_decl stat_or_decl_list
+ { DefineMulti
+ (List.map
+ (function
+ StmtElem e -> e
+ | _ -> failwith "unexpected statement for DefineMulti")
+ ($1 :: $2)) }
+/*(*
| statement statement { DefineTodo }
| decl function_definition { DefineTodo }
-*/
+*)*/
*)*/
-expr_opt:
- | expr { Some $1 }
- | /*(* empty *)*/ { None }
-