diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-10-06 06:21:21 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-06 06:21:21 -0400 |
commit | bc3ba8ee506cc76c9170dc1edc09a7fdda76a354 (patch) | |
tree | 68975515b426680b2189e4a083eac280867a6ab9 /devtools | |
parent | 0e0bd294363e486b7e6c39bf104685c07524e2a4 (diff) | |
download | gpsd-bc3ba8ee506cc76c9170dc1edc09a7fdda76a354.tar.gz |
Subtable parsing works.
Diffstat (limited to 'devtools')
-rwxr-xr-x | devtools/tablegen.py | 27 |
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) |