dev-cafe / parselglossy

Generic input parsing library, speaking in tongues.
https://parselglossy.readthedocs.io
MIT License
7 stars 2 forks source link

Input parsing is silent on some type errors #108

Open stigrj opened 3 years ago

stigrj commented 3 years ago

Description

The following type error in the input file (getkw grammar)

some_int = a

correctly spits out error message

Actual (str) and declared (int) types do not match.

but if the leading character is a number

some_int = 1a

then there is a silent exit, and all input parameters defined below this point in the input file will not be parsed and thus get their default values. This means that the user will not get notified unless some of those lower keywords don't have defaults.

robertodr commented 3 years ago

Did you observe this in MRChem? If yes, could you retry your example with has_complex=False? See here: https://github.com/MRChemSoft/mrchem/blob/master/python/mrchem/input_parser/plumbing/lexer.py#L33 I suspect wanting to parse complex numbers messes up here, but I could be mistaken.

stigrj commented 3 years ago

Yes, @ilfreddy reported this for MRChem. I get the same behavior with has_complex=False

robertodr commented 3 years ago

Annoying. The definition of integers and floating point numbers comes directly from pyparsing: https://github.com/dev-cafe/parselglossy/blob/master/parselglossy/grammars/atoms.py#L67-L69