Added a Parser_OSX class that can parse new-style (C-only) headers,

such as the Core Foundation ones.
This commit is contained in:
Jack Jansen 2001-06-26 21:53:25 +00:00
parent f4b9fb719a
commit ff1cc902fe
1 changed files with 19 additions and 4 deletions

View File

@ -233,10 +233,8 @@ if missing: raise "Missing Types"
self.includepath = [':', INCLUDEDIR] self.includepath = [':', INCLUDEDIR]
def initpatterns(self): def initpatterns(self):
# self.head_pat = "^extern pascal[ \t]+" # XXX Mac specific!
self.head_pat = "^EXTERN_API[^_]" self.head_pat = "^EXTERN_API[^_]"
self.tail_pat = "[;={}]" 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" + \ self.type_pat = "EXTERN_API" + \
"[ \t\n]*([ \t\n]*" + \ "[ \t\n]*([ \t\n]*" + \
"\(<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*]\)" + \ "\(<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.name_pat = "\(<name>[a-zA-Z0-9_]+\)[ \t\n]*"
self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))" self.args_pat = "(\(<args>\([^(;=)]+\|([^(;=)]*)\)*\))"
self.whole_pat = self.type_pat + self.name_pat + self.args_pat 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]*=" + \ self.sym_pat = "^[ \t]*\(<name>[a-zA-Z0-9_]+\)[ \t]*=" + \
"[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?" "[ \t]*\(<defn>[-0-9_a-zA-Z'\"(][^\t\n,;}]*\),?"
self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$" 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,;}]*\),?" "[ \t]*\(<defn>[-0-9'\"][^\t\n,;}]*\),?"
self.asplit_pat = "^\(<type>.*[^a-zA-Z0-9_]\)\(<name>[a-zA-Z0-9_]+\)$" 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(): def test():
input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h" input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h"