Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error Messages in macro-expanded files are borked #10

Closed
lihaoyi opened this Issue May 9, 2013 · 3 comments

Comments

Projects
None yet
2 participants
Owner

lihaoyi commented May 9, 2013

'Nuff said. It would require some cleverness to fix.

Currently we are parsing the source code into an AST, modifying it, and then unparsing it before sending it to the compiler. Hence we lose all of the original source locations for each AST node.

In order to preserve the line numbers for errors to work, we would need to maintain the AST (with some line numbers intact, others messed up due to macros) and fill in the missing line numbers (and other metadata) directly on the AST before passing that to the compiler.

apalala commented May 9, 2013

Take a look at how Grako (https://bitbucket.org/apalala/grako) does it with
ParseInfo.

You won't be wanting to use Grako for parsing, but you can take the
ParseInfo idea, as an attribute that gets added to each AST node.

On Wed, May 8, 2013 at 10:02 PM, Li Haoyi notifications@github.com wrote:

'Nuff said. It would require some cleverness to fix.

Currently we are parsing the source code into an AST, modifying it, and
then unparsing it before sending it to the compiler. Hence we lose all of
the original source locations for each AST node.

In order to preserve the line numbers for errors to work, we would need to
maintain the AST (with some line numbers intact, others messed up due to
macros) and fill in the missing line numbers (and other metadata) directly
on the AST before passing that to the compiler.


Reply to this email directly or view it on GitHubhttps://github.com/lihaoyi/macropy/issues/10
.

Juancarlo Añez

Owner

lihaoyi commented May 9, 2013

The Python inbuilt parser/ast modules do something similar with their lineno and col_number attributes on each node. The difficulty isn't the parsing, but rather making sense of an AST where most of the line numbers are there, in some chunks they're missing, and in other chunks they're outright wrong, and straightening it out as best possible.

Owner

lihaoyi commented May 13, 2013

Basic line number tracking works: f38c1ae Doesn't work everywhere, but some significant fraction of stack traces messages in macro-expanded files should have some useful line numbers

@lihaoyi lihaoyi closed this May 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment