Browse thread
Assert
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: Assert |
> From what I can see from the sources, for every error and warning > message the whole source file is parsed again with a special > lexer to determine the line number (parsing/linenum.mll). Could > anybody comment on this approach to printing error messages? (It > seems very very very strange to me.) Well, keeping track of character numbers during lexing is trivial, while keeping track of line numbers requires a bit more work (especially with the # lineno construct). So, the idea was to lex and parse source files at full speed when there is no error, and pay the price of computing line numbers only when an error needs to be reported. Also, this separates concerns between the two lexers: one deals with the language proper, the other with line numbers. Call it aspect-oriented programming if you wish :-) This said, it's one of those ideas that look nice at first sight, but have some practical drawbacks, e.g. no line numbers are printed for Match_failure and Assert_failure exceptions, and the debugger has problems coping with # lineno "filename" directives. We've been considering going back to a more traditional approach, with line and column numbers computed during lexing and stored in the abstract syntax tree. - Xavier Leroy