I'm confronted with the following situation during parsing Mathematica code: I have an expression which looks as follows
EXPR1 was already sucessfully parsed and closed with done(..). The "::" indicates that it is a Mathematica named message and therefore my starting point is in the appropriate parsing function for the NamedMessage construct.
Such a construct is only valid, if EXPR1 is a symbol. Two questions:
1. I still have the marker which was done() at the end of EXPR1 because I need it anyway to call preceed on it. Is there a convinient way to extract the IElement which was used to call marker.done(..) for EXPR1? If not, can I extract the last created AST node or call builder.lookAhead(-1) (which would work in this special case since Identifier and String are tokens of my lexer) or what is the best way to handle this?
2. Ideally, if EXPR1 is no symbol then I don't want to mark the whole expression as error [EXPR1::EXPR2].error("expr1 should be a symbol") because it is possible that although EXPR1 is no symbol, the rest of the named message is quite OK. Therefore I would like to have only EXPR1 underlined with the error. This implies that I would need to replace the done() marker for EXPR1 with a new marker which is an error. Or can I just use preceede and wrap another pair of markers around EXPR1? Is something like that possible? The only alternative I can think of is to call builder.error directly after EXPR1 because this is the position where I am at moment of parsing this construct.
Any help is highly appriciated.