This project has moved and is read-only. For the latest updates, please go here.

given a Terminal, can I get its parent NonTerminal?

Jul 31, 2012 at 10:00 PM

I'm working on a code completion problem. I'm using the ParserState.ExpectedTerminals to fill in my code completion list. However, I have a situation where I have the same terminal text/name in two different contexts. I'd like the ability to detect this context and modify the inserted text a smidgen. It seems that if I could just look at the name of the parent NonTerminal I could determine this information.

Jul 31, 2012 at 10:37 PM

you can inspect ParserState.BuilderData object (ParserStateData)

It has ShiftItems set (set of LRItem) - these are productions that may be shifted in the current state. To get to non terminal: 

LRItem.Core.Production.LValue  is a non-terminal on the left of the production rule (the owner of the rule)


Note: if ParserState.BuilderData is null - then make sure you disable clearing this field at the end of parser construction. Just find where it is set to null and disable it.

Aug 14, 2012 at 11:38 PM

Unfortunately BuilderData is marked internal.

Aug 16, 2012 at 5:44 AM

change it to Public, I will think about changing it main branch