KenKundert / psf_utils

Read Spectre PSF files
49 stars 14 forks source link

Parser error on END after HEADER #12

Closed KristofferC closed 1 year ago

KristofferC commented 2 years ago

The following file fails to parse:

HEADER
"PSFversion" "1.00"
"simulator" "spectre"
"version" "21.1.0.303.isr5"
"date" "4:45:29 PM, Fri May 27, 2022"
"design" "// Point Netlist Generated on: May 27 16:45:27 2022"
"analysis type" "info"
"analysis name" "modelParameter"
"analysis description" "Circuit Information"
"xVecSorted" "unknown"
"tolerance.relative" 0.00100000
END

with:

>>> psf = PSF('modelParameter.info', use_cache=False)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/psf_utils/psf.py", line 86, in __init__
    sections = parser.parse(filename, content)
  File "/usr/local/lib/python3.9/site-packages/psf_utils/parse.py", line 488, in parse
    result = self.parser.parse(content, tracking=False, lexer=self.lexer)
  File "/usr/local/lib/python3.9/site-packages/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/usr/local/lib/python3.9/site-packages/ply/yacc.py", line 1047, in parseopt_notrack
    tok = self.errorfunc(errtoken)
  File "/usr/local/lib/python3.9/site-packages/psf_utils/parse.py", line 473, in p_error
    raise ParseError("syntax error at '%s'." % (p.value), loc)
psf_utils.parse.ParseError: modelParameter.info(12): syntax error at 'END'.
    END
    ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/psf_utils/psf.py", line 88, in __init__
    raise Error(str(e))
inform.inform.Error: modelParameter.info(12): syntax error at 'END'.
    END
    ^

It seems an END after a HEADER section should be allowed?

KenKundert commented 2 years ago

I have modified the parser to accept a file that only contains a header. This fix will be contained in the next release.

KenKundert commented 2 years ago

I have pushed this fix on to GitHub. Please check it out and confirm that it works as expected. Once I hear back from you and things settle down, I will release it to PyPI.