]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Added a Parser_OSX class that can parse new-style (C-only) headers,
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 26 Jun 2001 21:53:25 +0000 (21:53 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 26 Jun 2001 21:53:25 +0000 (21:53 +0000)
such as the Core Foundation ones.

Tools/bgen/bgen/scantools.py

index 0a3dd55354224c7fdf4558c2d0bba80d2af79175..7dc46a9c5f45e7d41325d0708835f4e454281b09 100644 (file)
@@ -233,10 +233,8 @@ if missing: raise "Missing Types"
                self.includepath = [':', INCLUDEDIR]
 
        def initpatterns(self):
-#              self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
                self.head_pat = "^EXTERN_API[^_]"
                self.tail_pat = "[;={}]"
-#              self.type_pat = "pascal[ \t\n]+\(<type>[a-zA-Z0-9_ \t]*[a-zA-Z0-9_]\)[ \t\n]+"
                self.type_pat = "EXTERN_API" + \
                                                "[ \t\n]*([ \t\n]*" + \
                                                "\(<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*]\)" + \
@@ -244,8 +242,6 @@ if missing: raise "Missing Types"
                self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
                self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
                self.whole_pat = self.type_pat + self.name_pat + self.args_pat
-#              self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
-#                             "[ \t]*\(<defn>[-0-9'\"(][^\t\n,;}]*\),?"
                self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
                               "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
                self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
@@ -586,6 +582,25 @@ class Scanner_PreUH3(Scanner):
                               "[ \t]*\(<defn>[-0-9'\"][^\t\n,;}]*\),?"
                self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
 
+class Scanner_OSX(Scanner):
+       """Scanner for modern (post UH3.3) Universal Headers """
+       def initpatterns(self):
+               self.head_pat = "^EXTERN_API_C"
+               self.tail_pat = "[;={}]"
+               self.type_pat = "EXTERN_API_C" + \
+                                               "[ \t\n]*([ \t\n]*" + \
+                                               "\(<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*]\)" + \
+                                               "[ \t\n]*)[ \t\n]*"
+               self.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
+               self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
+               self.whole_pat = self.type_pat + self.name_pat + self.args_pat
+               self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
+                              "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
+               self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$"
+               self.comment1_pat = "\(<rest>.*\)//.*"
+               # note that the next pattern only removes comments that are wholly within one line
+               self.comment2_pat = "\(<rest1>.*\)/\*.*\*/\(<rest2>.*\)"
+
        
 def test():
        input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h"