improve parsing of function-like macros in declarations
authorBT Templeton <bt@hcoop.net>
Wed, 17 Jul 2013 20:44:00 +0000 (16:44 -0400)
committerBT Templeton <bt@hcoop.net>
Sat, 20 Jul 2013 19:43:17 +0000 (15:43 -0400)
parsing_c/parsing_hacks.ml

index db9d4ef..e1b3893 100644 (file)
@@ -1864,6 +1864,12 @@ let lookahead2 ~pass next before =
          else
            TCommentCpp (Token_c.CppDirective, i1)
 
+        (* exception to next rule *)
+  | (TIdent (s2, i2)::TOPar _::_ , TIdent (s1, i1)::seen::_)
+    when not_struct_enum before
+        && is_macro s2 && is_type seen ->
+          TIdent (s2, i2)
+
   | (TIdent (s2, i2)::_  , TIdent (s, i1)::seen::_) 
     when not_struct_enum before
        && is_macro s2 && is_type seen ->
@@ -1884,6 +1890,11 @@ let lookahead2 ~pass next before =
          else
            TCommentCpp (Token_c.CppDirective, i1)
 
+  (* exception to next rule *)
+  | (TIdent (s2, i2)::TOPar _::_ , TIdent (s1, i1)::ptr)
+      when not_struct_enum before
+        && is_macro s2 && pointer ptr ->
+    TIdent (s2, i2)
        (* tt * xx yy *)
   | (TIdent(s2, i2)::_  , TIdent (s, i1)::ptr) 
     when not_struct_enum before
@@ -1910,8 +1921,9 @@ let lookahead2 ~pass next before =
       TypedefIdent (s, i1)
 
   (* xx MM ( *)
-  | (TIdent (s, i1)::TIdent (s2, i2)::TOPar _::_  , type_::_) when not_struct_enum before
-      && ok_typedef s && is_macro s2 && is_type type_
+  (* exception to next rule *)
+  | (TIdent (s, i1)::TIdent (s2, i2)::TOPar _::_  , _) when not_struct_enum before
+      && ok_typedef s && is_macro s2
         ->
          TIdent (s, i1)
   (* xx yy *)