diff options
| author | Tristan Gingold <tgingold@free.fr> | 2017-10-09 20:34:04 +0200 | 
|---|---|---|
| committer | Tristan Gingold <tgingold@free.fr> | 2017-10-09 20:34:04 +0200 | 
| commit | e1c3b171231c7fe50975775a2e904eed8aeaa098 (patch) | |
| tree | f05286d2261d88becf771750b01119e34ab5f887 /src/vhdl/python/pnodespy.py | |
| parent | f111087acd05068f8bdf1a191bbd47a0c7f39381 (diff) | |
| download | ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.tar.gz ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.tar.bz2 ghdl-e1c3b171231c7fe50975775a2e904eed8aeaa098.zip | |
python: add more interfaces.
Diffstat (limited to 'src/vhdl/python/pnodespy.py')
| -rwxr-xr-x | src/vhdl/python/pnodespy.py | 21 | 
1 files changed, 20 insertions, 1 deletions
| diff --git a/src/vhdl/python/pnodespy.py b/src/vhdl/python/pnodespy.py index c7f23f73f..89b288995 100755 --- a/src/vhdl/python/pnodespy.py +++ b/src/vhdl/python/pnodespy.py @@ -66,9 +66,28 @@ def do_class_fields():      print_enum('fields', [f.name for f in pnodes.funcs]) +def read_spec_enum(type_name, prefix, class_name): +    """Read an enumeration declaration from iirs.ads""" +    pat_decl = re.compile(r'   type {0} is$'.format(type_name)) +    pat_enum = re.compile(r'       {0}_(\w+),?(-- .*)?$'.format(prefix)) +    lr = pnodes.linereader(pnodes.spec_file) +    while not pat_decl.match(lr.get()): +        pass +    toks = [] +    while True: +        line = lr.get() +        if line == '      );\n': +            break +        m = pat_enum.match(line) +        if m: +            toks.append(m.group(1)) +    print_enum(class_name, toks) + +  def do_libghdl_iirs():      print 'from libghdl import libghdl'      do_class_kinds() +    read_spec_enum('Iir_Mode', 'Iir', 'Iir_Mode')      do_iirs_subprg() @@ -138,7 +157,7 @@ def do_libghdl_names():  def do_libghdl_tokens(): -    pat_token = re.compile('       Tok_(\w+),?\s*(--.*)?$') +    pat_token = re.compile(r'       Tok_(\w+),?\s*(--.*)?$')      lr = pnodes.linereader('tokens.ads')      toks = []      while True: | 
