Displaying undefined names from an external symbol table

SyntaxEditor for WPF Forum

Posted 5 years ago by Scott Haney
Version: 14.2.0610
Avatar

Hello,

New user here. I have a fairly simple expression language with syntax that looks like:

     "IR." + P(Currency)

where P is a keyword and the identifier in parentheses (e.g. 'Currency') should appear in a symbol table and, if not present, should be tagged with a red squiggle. I have defined a lexer, grammar, and parser, but I am unclear where to insert the check for the whether or not the idetnifier is defined. Can you point me in the right direction?

I also have a non-standard variant of this problem. It is possible to put the parameter reference inside a string:

     "IR.P(Currency)"

I wonder if it would be easiers to allow the lexer/parser to just tread strings as strings and to add specialized code that looks in the strings and tags accordingly. Can you provide some ideas here?

Thank you very much,

Scott Haney

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

For that sort of thing I would probably piggyback on the parsing phase.  If you make an IParser-based class, you could wrap the Parse method of the real parser.  Call the real parser first and get its results.  Then examine the AST and look at things like strings and invocation sort of calls such as what you show there.  If you find a scenario that is invalid, you can have your IParseData implement IParseErrorProvider to support reporting of errors.  Check out the "User Interface Features / Adornment Features / Squiggle Lines" topic in the documentation for more on that and how to get the squiggles to display.

I agree with you that for the special string case, it's probably better to let strings be strings per the lexer and add special handling for those later on.


Actipro Software Support

Posted 5 years ago by Scott Haney
Avatar

Hi,

Thanks for the advice. I have overridden the Parse() function, but I notice that AST appears to be periodically set to null. If the AST is null, I can't check the arguments to generate the semantic parse errors. Wouldn't this mean that the squiggles under an undefined name would flash on and off? If so, can you suggest a solution?

Thanks again,

Scott

P.S. Very nice job on this control. It has been remarkably easy to get some pretty impressive capabilities added to my application.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Scott,

Yes the AST being null would be a problem, but in those cases I suspect it is a problem with your parser where perhaps if there is a syntax error in the document, it's not recovering properly to at least return something in the AST.  If you are using our LL(*) Parser Framework, make sure you read through the sections on error handling and recovery.  Those are all key concepts to handle when using a parser with an editor since probably most of the time, an editor's text will be in an invalid state as the user is typing.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.