Jörg Thalheim | 3e67e5c | 2017-05-01 02:26:56 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Zbigniew Jędrzejewski-Szmek | 5c23128 | 2017-04-04 23:03:47 -0400 | [diff] [blame] | 2 | |
| 3 | """Generate %-from-name.gperf from %-list.txt |
| 4 | """ |
| 5 | |
| 6 | import sys |
| 7 | |
| 8 | name, prefix, input = sys.argv[1:] |
| 9 | |
| 10 | print("""\ |
Shawn Landden | 4831981 | 2017-11-19 10:06:10 -0800 | [diff] [blame] | 11 | %{ |
| 12 | #if __GNUC__ >= 7 |
| 13 | _Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"") |
| 14 | #endif |
| 15 | %}""") |
| 16 | print("""\ |
Zbigniew Jędrzejewski-Szmek | 5c23128 | 2017-04-04 23:03:47 -0400 | [diff] [blame] | 17 | struct {}_name {{ const char* name; int id; }}; |
| 18 | %null-strings |
| 19 | %%""".format(name)) |
| 20 | |
| 21 | for line in open(input): |
| 22 | print("{0}, {1}{0}".format(line.rstrip(), prefix)) |