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

Expose position information somehow #6

Open
emberian opened this issue Feb 7, 2016 · 4 comments
Open

Expose position information somehow #6

emberian opened this issue Feb 7, 2016 · 4 comments

Comments

@emberian
Copy link
Contributor

emberian commented Feb 7, 2016

In PLY, the lineno, lexpos, linespan, and lexspan methods of YaccProduction (the type of p) allow recovering position information from parsed terminals and non-terminals. This is often important in robust parsers, for error reporting during or after parsing. easyply doesn't yet support this, but it should.

@emberian
Copy link
Contributor Author

emberian commented Feb 7, 2016

One design: set those corresponding attributes on the named terms before passing them, in the wrapper function. Unfortunately, this might conflict with already-defined attributes. To work around that, it would check if hasattr(o, 'easyply_name_map'), and if so look up lineno etc in that to get the actual name for setattr.

@wa-dev
Copy link

wa-dev commented Jan 30, 2017

It would it nice to provide a list of attributes to copy in addition to lineno, lexpos, linespan, and lexspan. For instance, I normally attach a filename attribute to my tokens when parsing files with multiple includes.

@wa-dev
Copy link

wa-dev commented Oct 4, 2017

This functionality can be implemented with #7

@wa-dev
Copy link

wa-dev commented Oct 23, 2018

In #8 an additional function has been added to the api (easyply.location) to track term position.

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

2 participants