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

Allow to specify start line number #362

Open
dnicolodi opened this issue Jan 18, 2025 · 3 comments
Open

Allow to specify start line number #362

dnicolodi opened this issue Jan 18, 2025 · 3 comments

Comments

@dnicolodi
Copy link
Collaborator

I've looked everywhere but I haven't found a way to specify the starting line number when scanning the input text. It is possible to specify a filename but not a start line number. Being able to do specify the start line number is handy when parsing text embedded into a larger document. If there is agreement that this is a desirable feature, I can work to implement it.

@apalala
Copy link
Collaborator

apalala commented Jan 19, 2025

The way to do what you want is to skip to a token that marks the start of the text of interest.

Another way to do it is to write a function that knows about line numbers and extracts the text of interest for the parser.

@dnicolodi
Copy link
Collaborator Author

I think I did a poor job explaining the issue. I would like to add an offset to the line number reported by parseinfo. I already pass to the parse() method only the portion of input that the parser should consider, I just would like the parseifo to reflect the fact that it is not located at the beginning of the file. The parse() method has a filename argument used to populate the filename filed in the parseifo. I would like a lineno argument that specifies an offset to be added to the line number reported by parseifo. This would be similar to the yyset_lineno() of flex.

@apalala
Copy link
Collaborator

apalala commented Jan 19, 2025

Now I understand.

This is very doable, though there are subtleties to be considered.

Let's see a pull request? If it's simple and nothing breaks, I'd be OK with it.

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