Posted 14 years ago by Russell Mason
Avatar
Hi

I'm using a regular expression application (RegexBuddy) to make sure I get my regular expressions correct before adding them to my language definition.

If I use ABC|XYZ or (ABC)|(XYZ) in RegexBuddy these are equivalent, i.e they match ABC or XYZ, however SytaxEditor only matches the first version and not the second.

I thought these 2 expressions were the same just 1 uses groups and the other does not. Can you explain how your regular expression engine sees this?

Thanks
Russell Mason

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Russell,

Do you have the latest build? It seems to work fine in the current build. We recently made an fix to alternation code for the regex engine which was added one or two builds ago I believe.


Actipro Software Support

Posted 14 years ago by Russell Mason
Avatar
Hi

Yes, I'm using 181. Try the following with ABC xx XYZ xx. I get blue red blue red. Change ABC|XYZ to (ABC)|(XYZ) and I get all red. I'm perfectly happy to accept I'm missing something here, but what?

Thanks
Russell Mason

<SyntaxLanguage Key="SQL" LanguageDefinitionVersion="3.0" Secure="True" WordContainsAdditionalCharacters="@_" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">

<Styles>
<Style Key="A" ForeColor="Blue" BackColor="Default" Bold="False" Italic="False" Underline="False" />
<Style Key="B" ForeColor="Red" BackColor="Default" Bold="False" Italic="False" Underline="False" />
</Styles>

<States>
<State Key="DefaultState">
<PatternGroups>
<RegexPatternGroup TokenKey="OrIdentifierToken" PatternValue="ABC|XYZ" Style="A" />
<RegexPatternGroup TokenKey="IdentifierToken" PatternValue="{AlphaMacro}({WordMacro})*" LookAhead="{NonWordMacro}" Style="B" />
</PatternGroups>
</State>
</States>

</SyntaxLanguage>
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the sample, I can repro it now. From your first post I did a find using the regular expression and it finds either ABC or XYZ fine with either method. Since the lexical parser uses the same regex code as the find/replace model, both should operate the same but they are not for some reason. I'll look into it.


Actipro Software Support

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, found the issue. It was due to a bug in the pattern optimization code for lexical parsing. It's fixed for the next maintenance release.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 10 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.