Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005409OCamlOCaml generalpublic2011-11-25 18:092012-03-29 10:48
Reporternb 
Assigned Toprotz 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionno change required 
PlatformOSOS Version
Product Version3.12.0 
Target VersionFixed in Version 
Summary0005409: lexbuf.lex_start_p.pos_lnum and pos_bol are incorrect in exceptions thrown by ocaml grammar parse
DescriptionIssue similar to 0002954 but in ocaml parser.

When a parse_error exception is thrown during parsing the grammar with ocaml (caml-toplevel), lexbuf.lex_start_p returns the position. In the returned value pos_lnum and pos_bol are incorrect while pos_cnum represents the real position in the file where exception was thrown.
TagsNo tags attached.
Attached Filesgz file icon parser_sample.tar.gz [^] (6,097 bytes) 2012-03-26 18:59

- Relationships

-  Notes
(0007168)
lefessan (developer)
2012-03-26 16:01

Could you please provide us an example ?
(0007173)
nb (reporter)
2012-03-26 19:03

Please find the attached project. It is large enough but the issue-related code is contained in the file use.ml . Run make, then parse any text file in order to have a parsing error. Currently use.ml contains the line

Printf.printf "Wrong character %s at position %i." (Lexing.lexeme lexbuf) (errorPosition.pos_cnum)

If change errorPosition.pos_cnum to errorPosition.pos_lnum, the printed string will look like "Wrong character ... at position 0."
(0007225)
protz (manager)
2012-03-29 10:46

I'm not sure there's an issue here. I did not read your grammar through but you seem to have a parsing error at the very beginning of the file (I would suggest compiling and running your parser with menhir --trace to see what's happening).
- pos_lnum is 1 : the line number is indeed 1
- pos_cnum is 0 : since the error is at the very beginning of the file, this is column 0 (columns always start with 0)
- pos_bol is 0 : we're still at offset 0, i.e. the beginning of the file.

Tested with OCaml version 4.01.0+dev0 (2012-03-12)
(0007226)
protz (manager)
2012-03-29 10:48

I'm closing since there doesn't seem to be anything wrong here.

- Issue History
Date Modified Username Field Change
2011-11-25 18:09 nb New Issue
2012-03-26 16:01 lefessan Note Added: 0007168
2012-03-26 16:01 lefessan Status new => feedback
2012-03-26 18:59 nb File Added: parser_sample.tar.gz
2012-03-26 19:03 nb Note Added: 0007173
2012-03-26 19:03 nb Status feedback => new
2012-03-29 10:46 protz Note Added: 0007225
2012-03-29 10:48 protz Note Added: 0007226
2012-03-29 10:48 protz Status new => resolved
2012-03-29 10:48 protz Resolution open => no change required
2012-03-29 10:48 protz Assigned To => protz


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker