Skip to content

Parser can't handle extra parens #202

Description

@Agnishom

It seems that the RTAMT parser is stumped

  1. when there are extra parens in the formula such as '(((bx) - (ax)) >= (0.0))', and
  2. when there are a large number of left parens such as ((0 + 0) + 0) >= 0

Here are some examples.

Testing: bx - ax >= 0.0
✅ SUCCESS: 'bx - ax >= 0.0' parsed correctly.

Testing: bx - ax >= (0.0)
✅ SUCCESS: 'bx - ax >= (0.0)' parsed correctly.

Testing: (bx - ax >= 0.0)
✅ SUCCESS: '(bx - ax >= 0.0)' parsed correctly.

Testing: ((bx - ax) >= (0.0))
✅ SUCCESS: '((bx - ax) >= (0.0))' parsed correctly.

Testing: (((bx) - (ax)) >= (0.0))
❌ FAILED: '(((bx) - (ax)) >= (0.0))' could not be parsed.
   Error details: RTAMT Exception: 1:7: Syntax ERROR, mismatched input '-' expecting ')'

Variation 1: 0 >= 0
✅ SUCCESS

Variation 2: (0 + 0) >= 0
✅ SUCCESS

Variation 3: ((0 + 0) + 0) >= 0
❌ FAILED
   Error: RTAMT Exception: 1:9: Syntax ERROR, mismatched input '+' expecting ')' 

Variation 4: (((0 + 0) + 0) + 0) >= 0
❌ FAILED
   Error: RTAMT Exception: 1:10: Syntax ERROR, mismatched input '+' expecting ')' 

Variation 5: ((((0 + 0) + 0) + 0) + 0) >= 0
❌ FAILED
   Error: RTAMT Exception: 1:11: Syntax ERROR, mismatched input '+' expecting ')' 

Variation 1:
Formula: ax >= bx
✅ SUCCESS

Variation 2:
Formula: (ax >= bx) or (ax >= bx)
✅ SUCCESS

Variation 3:
Formula: ((ax >= bx) or (ax >= bx)) and (ax >= bx)
✅ SUCCESS

Variation 4:
Formula: (((ax >= bx) or (ax >= bx)) and (ax >= bx)) or (ax >= bx)
✅ SUCCESS

Variation 5:
Formula: ((((ax >= bx) or (ax >= bx)) and (ax >= bx)) or (ax >= bx)) and (ax >= bx)
✅ SUCCESS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions