Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003930OCamlOCaml generalpublic2005-12-21 11:422008-01-22 17:24
Reporteraballier 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version3.09.0 
Target VersionFixed in Version3.11+dev 
Summary0003930: Wish: Helper function for maintaining lexer position info
DescriptionThe code required to maintain the line/col info in a lexer is identical in almost any lexer you can imagine. I propose that we add a function to Lexing called "start_next_line" (or any other sensible name) that can be called in a lexer action to update the position info after a line ending has been reached. For example:

rule tokenize = parse
   '\n' { start_next_line lexbuf; tokenize lexbuf }
 | . . .

The code is simple:

let start_next_line lexbuf =
   let lcp = lexbuf.lex_curr_p in
   lexbuf.lex_curr_p <- {
      lcp with
      pos_lnum = lcp.pos_lnum + 1;
      pos_bol = lcp.pos_cnum; }

I've attached a patch against lexing.ml and lexing.mli that implements this, including ocamldoc comments.
TagsNo tags attached.
Attached Filespatch file icon lexing_start_line-3.09.patch [^] (1,550 bytes) 2005-12-21 11:42 [Show Content]

- Relationships

-  Notes
(0003459)
anonymous (viewer)
2005-12-21 11:44

By the way, I reported this.
 n8gray /at/ caltech \dot\ edu
(0004433)
doligez (administrator)
2008-01-22 17:24

Done in 3.11+dev10 under the name "Lexing.new_line".

- Issue History
Date Modified Username Field Change
2005-12-21 11:42 anonymous New Issue
2005-12-21 11:42 anonymous File Added: lexing_start_line-3.09.patch
2005-12-21 11:44 anonymous Note Added: 0003459
2006-01-05 14:26 doligez Status new => acknowledged
2008-01-22 17:24 doligez Note Added: 0004433
2008-01-22 17:24 doligez Reporter anonymous => aballier
2008-01-22 17:24 doligez Status acknowledged => closed
2008-01-22 17:24 doligez Resolution open => fixed
2008-01-22 17:24 doligez Fixed in Version => 3.11+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker