Hoa\Compiler Locate Nodes in Source


#1

How would I retrieve the location (as line and column) of an erroneous token during semantic analysis?

Example:

int x = 4;
int x = -2;

When the compiler reaches the second line, I want it to produce an error like:

Duplicate variable 'x' in line 2 column 5


#2

Hello,

So far, this information is not held by the TreeNode. This is a good opportunity for a contribution! In anyway, I suggest you to open an issue on the Github repository: https://github.com/hoaproject/Compiler.