summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-06 06:21:21 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-06 06:21:21 -0400
commitbc3ba8ee506cc76c9170dc1edc09a7fdda76a354 (patch)
tree68975515b426680b2189e4a083eac280867a6ab9 /devtools
parent0e0bd294363e486b7e6c39bf104685c07524e2a4 (diff)
downloadgpsd-bc3ba8ee506cc76c9170dc1edc09a7fdda76a354.tar.gz
Subtable parsing works.
Diffstat (limited to 'devtools')
-rwxr-xr-xdevtools/tablegen.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/devtools/tablegen.py b/devtools/tablegen.py
index fe284d48..1747afa6 100755
--- a/devtools/tablegen.py
+++ b/devtools/tablegen.py
@@ -473,15 +473,14 @@ if __name__ == '__main__':
# table - the table lines
# widths - array of table widths
# ranges - array of table offsets
- # trailing - bit length of the table or trailing array element
+ # trailing - bit length of the table or trailing array element
+ # subtables - list of following vocabulary tables.
tablename = arguments[0]
table = []
ranges = []
- keep = False
- i = 0
+ subtables = []
state = 0
for line in sys.stdin:
- i += 1
if state == 0 and line.startswith("//: Type") and tablename in line:
state = 1
continue
@@ -504,7 +503,25 @@ if __name__ == '__main__':
table.append(line)
continue
elif state == 3: # Found table end
- break
+ state = 4
+ continue
+ elif state == 4: # Skipping until subsidiary table
+ if line.startswith("//:") and "vocabulary" in line:
+ subtable_name = line.split()[1]
+ subtable_content = []
+ state = 5
+ elif state == 5: # Seen subtable header
+ if line.startswith("|="):
+ state = 6
+ continue
+ elif state == 6: # Parsing subtable content
+ if line.startswith("|="):
+ subtables.append((subtable_name, subtable_content))
+ state = 4
+ continue
+ elif line[0] == '|':
+ subtable_content.append([f.strip() for f in line[1:].strip().split("|")])
+ continue
if state == 0:
print >>sys.stderr, "Can't find named table."
sys.exit(1)