Previous Up Next

2  Position

The module for position is rather basic and low-level. It basically is used to be able to relate the concrete syntax, i.e., positions in the real input string, with the abstract syntax. Thus, a core structure of the module is the lexical position. Additionally, there are some functions to manipulate and access the lexical position.

We cannot put the lex-position into the lexer module itself, as we want this type already in the abstract syntax. Nevertheless, the instance of the line counter is created in the lexer.

Since the manipulation functions do not belong into the abstract syntax, I externalized those into this module.

Isn’t it possible to make it superfluous to reset the counter before starting the lexer? Perhaps the counter can be created locally somewhere?

Why is the syntax error message part of the position?

[Clean up] Try to unify, if possible, the various position-manipulating functions, make a uniform naming scheme. For instance the ones from parse.mly and from the module Absynt. Of course, the functions in the latter module cannot be shifted to Pos, as they depend on the abstract syntax.

The functions pos_of_binexpr and pos_of_uexpr in the parser are a hack to suppress the option that expressions may not have position information. In this case they fill in a dummy position.

Perhaps it’s better, even if the abstract syntax does not support positions in all clauses, to give back positions in all cases?

To do:
In the line counter, is there only a “Syntax error” possible? That’s pretty unspecific.
Previous Up Next