summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-06-26 21:53:25 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-06-26 21:53:25 (GMT)
commitff1cc902fe80605fbc7d5fee8226e4c26832c5a9 (patch)
tree2c7acf1fb728f4f144e38fb5b4f51f6214d9dd45 /Tools
parentf4b9fb719a553c2fff1fb91a127bf7bbe50fb261 (diff)
downloadcpython-ff1cc902fe80605fbc7d5fee8226e4c26832c5a9.zip
cpython-ff1cc902fe80605fbc7d5fee8226e4c26832c5a9.tar.gz
cpython-ff1cc902fe80605fbc7d5fee8226e4c26832c5a9.tar.bz2
Added a Parser_OSX class that can parse new-style (C-only) headers,
such as the Core Foundation ones.
Diffstat (limited to 'Tools')
-rw-r--r--Tools/bgen/bgen/scantools.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index 0a3dd55..7dc46a9 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -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"