[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Tracking line numbers in source files

When compilers emit error messages to the programmer, it is generally a good idea to indicate which file and which line gave rise to the error. Syntax errors can be emitted fairly easily because the parser usually has access to the current line number. However, semantic errors are harder to report because the parser may no longer be active when the error is detected.

Treecc can generate code that automatically keeps track of what line in the source file was active when a node is created. Every node has two extra private fields that specify the name of the file and the line number. Semantic analysis routines can query this information when reporting errors.

Because treecc is not aware of how to obtain this information, the programmer must supply some additional functions. See section API's available in the generated output, for more information.

See section API's available in the generated output, for more information.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Klaus Treichel on January, 18 2009 using texi2html 1.78.