calling parser (making tokens) in inherited SyntaxLanguage

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Martin de Jong - Statistics Netherlands
Avatar
I have a class inherited from SyntaxLanguage. Now i want to associate my lexical parser (its Antlr-made) with it. I thought in the overridden

public override ActiproSoftware.SyntaxEditor.TextRange PerformLexicalParse(ActiproSoftware.SyntaxEditor.Document document, ActiproSoftware.SyntaxEditor.TextRange parseTextRange, ActiproSoftware.SyntaxEditor.ILexicalParseTarget parseTarget)
i should call the lexer? But how to return the tokens. In parsetarget there is a readonly tokencollection. Please give me a hint:)

Comments (2)

Posted 15 years ago by Martin de Jong - Statistics Netherlands
Avatar
For the time being i will inherit from MergableLanguage. Is this the better approach?
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

You need to call parseTarget.OnPreParse before calling your lexer.

Call OnTokenParsed for each token that is returned by your lexer. You will need to construct a class that implements IToken that you pass in there. Also pass the length of the token. SE will manage the tokens collection for you from that point on and update Document.Tokens. Note that tokens should be passed in sequentially in order that they occur.

Then call parseTarget.OnPostParse after everything is done.

Hope that helps!


Actipro Software Support

The latest build of this product (v24.1.0) 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.