I noticed that the parser crashes whenever a scoped attribute is referenced outside of a scope context. This kind of situation arises when a rule B that is referencing a scoped attribute defined in a rule A may match on its own without requiring a previous match to A.
In my specific case the crash occurs because the following code is generated: scfSetAttrAsIntRef(curAttr,intRef, (SCOPE_TOP(record))->curRecord);. Since SCOPE_TOP(record) is null I get an access violation. One can obviously avoid this problem defining rules that are able to discriminate between the outside-scope and in-scope invocation of B. However I see a lot of redundancy in this approach so I propose to modify the generated code in the following way: scfSetAttrAsIntRef(curAttr,intRef, (SCOPE_TOP(record))==0 ? 0 : (SCOPE_TOP(record))->curRecord); Doing so one has two benefits: - The code doesn't crash. - Discrimination between the in-scope and outside-scope invocation can be detected and handled inside actions. Greets, Luca --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
