How to integrate own lexor, parse (or eg. CoCo parset

SyntaxEditor for WPF Forum

Posted 15 years ago by Bernie Schoch
Version: 9.1.0505
Unless we missed something in the documentation, there are not many specifics on how to integrate our own lexor and parser. We are either considering a recursive descent parser or using CoCo which generates recursive descent parser which are fast. The language we have to bring over has some particularitis such as having reserved words while still having multi-word function names that can contain reserved words. This can all be sorted about in the grammar. We know that some of these interfaces between lexor/parser/AST may not have been completly fleshed out, but it would be nice to better know the more formal interface points back to the syntax editor. For example we would proceed right now on lexor/parser to create AST trees, while you guys finish up the editor, if we knew where the conflicts are. For example can we just use our own AST? est We don't want start down an incompatible path and then stuck with an expensive conversion later when the editor is done

Thank you, Bernie

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Bernie,

At the time of this writing, the ILexer interface should be pretty stable. It's main component is pretty ambiguous so it should allow you to plug in any lexer that supports incremental parsing. You just need to wrap your lexer with this ILexer method:
TextRange Parse(TextSnapshotRange snapshotRange, ILexerTarget parseTarget);
Where you call parseTarget.OnPreParse, scan the snapshot range and update the parseTarget.OnTokenParsed as you find tokens, and call parseTarget.OnPostParse at the end.

We hope to finally get the documentation on this finished up soon, in either the upcoming build or the next.

Right now with the parser framework, you can call any third-party parser. It will be called using a worker thread if you have an AmbientParseRequestDispatcherProvider.Dispatcher set (see documentation). Its asynchronous result will be returned to your document's ParseData property. This result could really be anything. It could be an AST or it could be some other data as well.

As you mentioned we don't have an Actipro grammar or parser generator built yet for the WPF SyntaxEditor. Once we get to that we will have our own AST interface. But since everything will be interface driven, any features we build for our AST interface you should be able to retrofit into your own AST node classes later.

Hope that helps.

Actipro Software Support

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.