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

pos_lnum and pos_bol are worngs on exceptions from Grammar.Entry.parse #2954

Closed
vicuna opened this issue Jul 16, 2004 · 2 comments
Closed

pos_lnum and pos_bol are worngs on exceptions from Grammar.Entry.parse #2954

vicuna opened this issue Jul 16, 2004 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 16, 2004

Original bug ID: 2954
Reporter: administrator
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:26:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 3.10.0
Category: ~DO NOT USE (was: OCaml general)
Parent of: #3407
Monitored by: nogin

Bug description

Full_Name: Aleksey Nogin
Version:
OS:
Submission from: charter-242-009.caltech.edu (131.215.242.9)

I have a file that is being preprocessed by camlp4 with EXTEND'ed grammar. At
some point (after the file is fully read), the code needs to parse a string
(some of the quotations need to be parsed after the file is read in full), so it
does

Grammar.Entry.parse foo (Stream.of_string s)

If parsing fails and Grammar.Entry.parse ends up raising Stream.Error wrapped in
Stdpp.Exc_ocated, the loc in the exception will have a correct pos_cnum
(relative position in the string s being parsed), but the pos_lnum and pos_bol
seem to be inherited from the file that was originally parsed (in this case they
point at the end of file).

P.S. In addition to fixing Grammar.Entry.parse to start "counting" everything
from 0, it would be nice to also have a version of Grammar.Entry.parse that
would take an extra Lexing.position argument (representing the "offset" to start
counting at). This would make it unnecessary to catch Stdpp.Exc_located fro it,
re-raising them with a different (adjusted) loc.

Thank you!

@vicuna
Copy link
Author

vicuna commented Jan 4, 2005

Comment author: administrator

see also #3407
Assigned to MM.

@vicuna
Copy link
Author

vicuna commented Dec 17, 2007

Comment author: ertai

This has been fixed during the upgrade of camlp4. Parsing functions now takes an extra location argument that represent the starting location.

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

No branches or pull requests

1 participant