diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-10-28 21:15:01 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-10-28 21:15:07 +0100 |
commit | d66776c1735bb4b3859e9d7f369d92a7f9b3da77 (patch) | |
tree | 2f0dd16c5020ed539eeac7b9e35321d48b9a725f | |
parent | simplifing the tree (diff) | |
download | auto-auto-complete-d66776c1735bb4b3859e9d7f369d92a7f9b3da77.tar.gz auto-auto-complete-d66776c1735bb4b3859e9d7f369d92a7f9b3da77.tar.bz2 auto-auto-complete-d66776c1735bb4b3859e9d7f369d92a7f9b3da77.tar.xz |
Partially the structure to make it easier for the generators
-rwxr-xr-x | auto-auto-complete.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/auto-auto-complete.py b/auto-auto-complete.py index 0865bca..a0e199d 100755 --- a/auto-auto-complete.py +++ b/auto-auto-complete.py @@ -167,7 +167,7 @@ if __name__ == '__main__': print("USAGE: auto-auto-complete SHELL --output OUTPUT_FILE --source SOURCE_FILE") exit(1) - shell = sys.argv[1] + shell = sys.argv[1].upper() output = None source = None @@ -206,6 +206,30 @@ if __name__ == '__main__': source = file.read().decode('utf8', 'replace') source = Parser.parse(source) Parser.simplify(source) - - print(source) + + program = source[0] + unargumented = [] + argumented = [] + variadic = [] + suggestion = [] + + for item in source[1:]: + if item[0] == 'unargumented': + unargumented.append(item[1:]); + elif item[0] == 'argumented': + argumented.append(item[1:]); + elif item[0] == 'variadic': + variadic.append(item[1:]); + elif item[0] == 'suggestion': + suggestion.append(item[1:]); + + for group in (unargumented, argumented, variadic): + for index in range(0, len(group)): + item = group[index] + map = {} + for elem in item: + map[elem[0]] = elem[1:] + group[index] = map + + print(shell) |