Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Catch missing parens #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

benbc
Copy link

@benbc benbc commented Aug 5, 2022

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)'

benbc added 2 commits August 5, 2022 17:19
Prior to this change missing parens are silently ignored and an
incorrect formula is constructed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant