Specification filtering refinement - no overview or issues sections

This commit is contained in:
Nigel Stewart 2015-08-06 10:33:23 +10:00
parent 5ae027a8cd
commit d80fd5514f

View File

@ -2,7 +2,7 @@
import re import re
section = re.compile('^(Name|Name Strings?|Number|Dependencies|New Procedures and Functions|New Tokens|Additions to .*|Changes to .*|Modifications to .*|Add new Section .*)\s*$') section = re.compile('^(Name|Name Strings?|Number|Dependencies|Overview|Issues|New Procedures and Functions|New Tokens|Additions to .*|Changes to .*|Modifications to .*|Add new Section .*)\s*$')
token = re.compile('^\s+(([A-Z0-9][A-Z0-9_x]*):?\s+((?:0x)?[0-9A-F]+)([^\?]*))?\s*$') token = re.compile('^\s+(([A-Z0-9][A-Z0-9_x]*):?\s+((?:0x)?[0-9A-F]+)([^\?]*))?\s*$')
if __name__ == '__main__': if __name__ == '__main__':
@ -16,14 +16,19 @@ if __name__ == '__main__':
for i in args: for i in args:
lines = open(i).readlines() lines = open(i).readlines()
f = open(i,'w') f = open(i,'w')
# Keep track of the current section as we iterate over the input
current = '' current = ''
for j in lines: for j in lines:
# Detect the start of a new section
m = section.match(j) m = section.match(j)
if m: if m:
current = m.group(1).strip() current = m.group(1).strip()
if current in [ 'Name', 'Name String', 'Name Strings', 'Number', 'Dependencies', 'New Procedures and Functions', 'New Tokens']: if current in [ 'Name', 'Name String', 'Name Strings', 'Number', 'Dependencies', 'New Procedures and Functions', 'New Tokens']:
print >>f, j, print >>f, j,
continue continue
if current=='New Tokens': if current=='New Tokens':
if token.match(j): if token.match(j):
print >>f, j, print >>f, j,