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

save the (...) bits into srcref #452

Open
mengwong opened this issue Oct 6, 2023 · 2 comments
Open

save the (...) bits into srcref #452

mengwong opened this issue Oct 6, 2023 · 2 comments

Comments

@mengwong
Copy link
Contributor

mengwong commented Oct 6, 2023

Currently the parser discards any cells of the form /^\(.*\)$/. We are using these cells to record upstream source citations, e.g. (Act1.2.3.a) or (Contract.pg3.para5).

Instead of discarding these elements, save them into a sourceCitation map of input line number to list of strings, saved inside the rule's srcref property.

It would be nice to add more granularity. Suppose we have a multiline rule; how do we preserve the citations for particular lines into the particular resulting syntactic structures in the AST?

Consider https://www.microsoft.com/en-us/research/uploads/prod/2016/11/trees-that-grow.pdf

@ym-han
Copy link
Contributor

ym-han commented Oct 6, 2023

It's also worth noting this sort of simpler approach to adding annotations / metadata / citations; the "as per" approach that Joe is taking can be thought of as an example of that. https://reasonablypolymorphic.com/blog/extension-patterns/index.html

@ym-han
Copy link
Contributor

ym-han commented Oct 16, 2023

FYI for the current usecase, Joe already has a convention for this / way of dealing with this. So no need to worry about this for now. We can make things even nicer, but that's not high priority.

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