You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3930 Reporter: aballier Status: closed (set by @damiendoligez on 2008-01-22T16:24:00Z) Resolution: fixed Priority: normal Severity: feature Version: 3.09.0 Fixed in version: 3.11+dev Category: ~DO NOT USE (was: OCaml general) Monitored by: n8gray
Bug description
The 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:
Original bug ID: 3930
Reporter: aballier
Status: closed (set by @damiendoligez on 2008-01-22T16:24:00Z)
Resolution: fixed
Priority: normal
Severity: feature
Version: 3.09.0
Fixed in version: 3.11+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: n8gray
Bug description
The 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.
File attachments
The text was updated successfully, but these errors were encountered: