Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

sagetexparse: getTokensEndLoc no more supported by pyparsing #6

Open
jgmbenoit opened this issue Dec 30, 2016 · 3 comments
Open

sagetexparse: getTokensEndLoc no more supported by pyparsing #6

jgmbenoit opened this issue Dec 30, 2016 · 3 comments

Comments

@jgmbenoit
Copy link
Contributor

It appears that getTokensEndLoc was (silently ?) discarded from pyparsing, so sagetexparse and its friends are no more functionnal.

@pablo-angulo
Copy link

You can copy the old code from getTokensEndLoc, it still works:

def getTokensEndLoc():
    """Method to be called from within a parse action to determine the end
       location of the parsed tokens."""
    import inspect
    fstack = inspect.stack()
    try:
        # search up the stack (through intervening argument normalizers) for correct calling routine
        for f in fstack[2:]:
            if f[3] == "_parseNoCache":
                endloc = f[0].f_locals["loc"]
                return endloc
        else:
            raise ParseFatalException("incorrect usage of getTokensEndLoc - may only be called from within a parse action")
    finally:
        del fstack

@vincek59
Copy link
Contributor

def skipToMatching(opener, closer):
    """

    :param opener: opening token
    :param closer: closing token

    """
    nest = nestedExpr(opener, closer)
    return originalTextFor(nest)

This code works for me.

@dimpase
Copy link
Member

dimpase commented Apr 5, 2021

Would be great to get to specifics of this issue. How can one see breakage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants