Improve missing after directive error
What does this MR do and why?
- Change parser such that a katscript line with just a valid element or function name gets a proper error message showing the correct syntax, instead of a general syntax error
Examples of different behaviour
Using test script:
import finesse
scripts = ["mirror", "non_existing_element"]
for script in scripts:
model = finesse.Model()
try:
model.parse(script)
except Exception as e:
print(e.args[0]
fix/improve-missing-after-directive-error
behaviour
line 1: 'mirror' should be written in the form 'mirror name R=none T=none L=none phi=0 Rc=inf xbeta=0 ybeta=0 misaligned=false'
-->1: mirror
^^^^^^
line 1: unknown element or function 'non_existing_element'
-->1: non_existing_element
^^^^^^^^^^^^^^^^^^^^
develop
behaviour
line 1: syntax error
1: mirror
line 1: syntax error
1: non_existing_element
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
Includes tests for added/modified code -
Added or modified the documentation if relevant -
Docstrings added/modified for new/modified functions