Skip to content

How to match addition expressions with brackets #622

@none-None1

Description

@none-None1

I tried matching addition expressions with brackets (e.g.: 1+1, 1+(2+3)+4) using the following code:

ParserElement.enable_left_recursion()
b=Forward()
a=b+'+'+b|'('+b+')'|Word(nums)
b<<a

However, it didn't work correctly: (1+1) can be matched, but not 1+1.

I tried many ways to fix like changing | into ^ and swapping the operands of |, but none of them worked.

What have I done wrong? Is it a bug or is it an unsupported feature?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions