Skip to content

Add a function to identify brace groups #3

@aroberge

Description

@aroberge

Consider the following example where we'd like to replace

x!
(x + 1)!

by

factorial(x)!
factorial(x + 1)!

Currently, the way to do this would be to process the string until we encounter a !, and then start backtracking workout out the logic.

Suppose we had access to groups of braces, perhaps something like:

braces = {"end_index": "begin_index"}

For example, the second case above would be

braces = {4:0}

when encoutering a ! at position index, we could simply do something like the following:

if tokens[index-1] == ")":
    begin_index = braces[index-1]
    tokens[begin_index].string = "factorial("

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