Compare commits

..

No commits in common. "genset" and "master" have entirely different histories.

2 changed files with 0 additions and 54 deletions

View file

@ -1,37 +0,0 @@
"""Example of a parser that handles a subset of C and can extract
structs and typedefs for later generation.
See test.h for example input.
"""
import fileinput
import pprint
from pyparsing import *
struct = Keyword('struct')
lbrace = Literal('{')
rbrace = Literal('}')
semi = Literal(';')
identifier = Word(alphas, alphanums + '_')
typedef = Keyword('typedef')
comment = Literal('//').suppress() + restOfLine
comments = Group(OneOrMore(comment))
type_alias = Optional(comments) + typedef + identifier + identifier
field_def = Optional(comments) + identifier + identifier + semi
struct_def = struct + Optional(identifier) + lbrace + OneOrMore(field_def) + rbrace
typedef_def = Optional(comments) + typedef + struct_def + identifier
bnf = ZeroOrMore((struct_def | typedef_def | type_alias) + semi)
def main():
for v in bnf.scanString('\n'.join(fileinput.input())):
results, start, end = v
results.pprint()
if __name__ == '__main__':
main()

View file

@ -1,17 +0,0 @@
// Typedef to allow reuse of ranges and units.
// range: 1000...2000; units: ns
typedef int16_t servoDrive_t;
// Comment
// and more
typedef struct servoParam_s2 {
// Short description. Longer description to show in detailed
// help. Basics are inherited from the typedef.
//
// default: 1000
servoDrive_t min;
// default: 2000
servoDrive_t max;
// default: 1500
servoDrive_t mid;
} foo_t;