Is a parser very slow?

SyntaxEditor for Windows Forms Forum

Posted 8 years ago by Chao-Jen Huang - Industrial Technology Research Institute
Version: 12.1.0300
Avatar

Hello,

If I define "<ExplicitPatternGroup TokenKey="ReservedWordToken" Style="OptionWordStyle" LookBehind="(.option|.options) {AllMacro}*" LookAhead="{NonWordMacro}|\z">" in the SyntaxEditor's language. But, that parser is too slow surprisingly.

I want to set keyworks after ".option" that like .option method=gear post=1. Keyworks "method" and "post" must be after .option.

Example:
.option method=gear  <-- The word "method" is a keyword.
vac method=gear  <-- The word "method" isn't a keyword.

Have any method to improve parser performance?

Thanks.
e-Photon

Comments (1)

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

Hello, the problem here is that by using something like "{AllMacro}*" in your LookBehind, you are effectively telling the lexer to fully go to the beginning of the document on every character.  You probably want to limit ths to a single line look behind (everything except \n) or some other delimiter.

I assume that you also have some explicit patterns that are defined within the group?  But regardless, that sort of look-behind will slow things down.

A better way might be to change it so if you see a ".option", then you enter a new lexical state.  So make it a start scope.  And in that other lexical state, color your identifiers differently in the proper scenarios.  Then exit at the line terminator (\n) or equals (=).


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 0 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.