melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
57 stars 7 forks source link

Error immediately on cycles in attribute evaluation #767

Closed krame505 closed 1 year ago

krame505 commented 1 year ago

Changes

This tracks whether an attribute has been demanded on a DecoratedNode, to immediately report an error when encountering a cycle, rather than crashing with a StackOverflowError.

Documentation

Added doc comments.

krame505 commented 1 year ago

Turns out that checking for a cycle on every thunk is actually more efficient than doing it for syn/inh accesses on DecoratedNode. This should also catch cycles that don't involve attribute accesses (e.g. local x::Expr = neg(x);.)