Posted 15 years ago by (Anonymous)
Avatar
I'd like to distinguish between functions and identifiers. I'm using the following regular expressions in my language definition file:

<!-- Function -->
<RegexPatternGroup Token="FunctionToken" PatternValue="(_ | {AlphaMacro})({WordMacro})*" LookAhead="{WhitespaceMacro}*[(]"/>
<!-- Identifier -->
<RegexPatternGroup Token="IdentifierToken" PatternValue="(_ | {AlphaMacro})({WordMacro})*"/>
The above definitions don't work when the last OR only text in the editor is a word. For example, if all that is in the editor is "customerID" (w/out the quotes), the token is FunctionToken. I was expecting it to be the IdentifierToken.

Why does the LookAhead for the FunctionToken match in this case?

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Look-aheads always match at the end of the document. Try this... instead of using the LookAhead attribute, put the look-ahead inline with the pattern. Maybe try something like this which will probably not match at the end of document although you're telling it to match the same thing:

(_ | {AlphaMacro})({WordMacro})* (?={WhitespaceMacro}*[(])


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.