systems
systems copied to clipboard
Catch missing parens
Not sure that I'm holding the error hierarchy right. I tried to use the fancy DeferLineInfo
stuff, but I couldn't make that work at this point in the parser.
So the error that this produces isn't particularly user-friendly.
This line (missing a terminal paren):
Ideas > Options @ Rate(IdentificationR * (PMs - (PMDeliveryBurden * Deliverables))
Gives this error:
$ cat error.sys | systems-run
Traceback (most recent call last):
File "/home/benbc/.pyenv/versions/3.10.5/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/benbc/.pyenv/versions/3.10.5/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/benbc/src/lethain/systems/systems/parse.py", line 143, in <module>
main()
File "/home/benbc/src/lethain/systems/systems/parse.py", line 129, in main
model = parse(txt)
File "/home/benbc/src/lethain/systems/systems/parse.py", line 86, in parse
_, tokens = lexer.lex(txt)
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 179, in lex
line.append(lex_flow(char_buff))
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 134, in lex_flow
return lex_caller(TOKEN_FLOW, txt)
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 113, in lex_caller
params = lex_parameters(rest)
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 97, in lex_parameters
return (TOKEN_PARAMS, tuple([lex_formula(x) for x in params]))
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 97, in <listcomp>
return (TOKEN_PARAMS, tuple([lex_formula(x) for x in params]))
File "/home/benbc/src/lethain/systems/systems/lexer.py", line 76, in lex_formula
raise systems.errors.MismatchedParens(txt)
systems.errors.MismatchedParens: MismatchedParens for formula 'IdentificationR*(PMs-(PMDeliveryBurden*Deliverables)'