Differentiating between two different lines

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Tim Davis
I'm trying to differentiate, for purposes of outlining, two sets of strings..


I have a child state called function state.

It starts folding on a line begining with function ie ^funtion
and stops folding on a line beginning with end; ie ^end;

My problem is when I need to do an external function prototype
ie. function blah(blah, blah);

It is trying to fold starting at that function, I need to somehow tell the FunctionStartNode to only fold on lines that begin with function and do not end with a ";".

I've tried everything from ^function$[^;] to looking ahead for [^;]...

How can I do this?

Comments (4)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Each outlining node gets a OutliningNodeParseData put in its ParseData property. It's a bit tricky but if you do some parsing, and get a reference to the outlining nodes that should not fold, you can set the OutliningNodeParseData.IndicatorVisible property to false. That should hide it.

Actipro Software Support

Posted 19 years ago by Tim Davis
Turns out I made a mistake in the way I described it...

Both styles of functions (prototype or actual code) end with a ";"


function prototype();


function realfunction(String: Blah) : String;

So in this case it may or may not be easier, can I it fold only when it see's the next line begining with begin or var?
Posted 19 years ago by Tim Davis
Ok, i've found a regex pattern that will work but then I have problems with the IdentifierToken. I have it set to start outlining on a function token where the next line contains the word begin as the first word. This works. I have it set to stop outlining on a line that begins with end;

The identifier token is not letting me match the endscope pattern, it's registering it before the outlining does.

This is the last roadblock before my software gets tunred over to the beta team this friday and I'm extremely excited to show of this control :)

Any hints?

<State Key="FunctionState">
                <RegexPatternGroup Type="StartScope" Token="FunctionStartToken" PatternValue="^function" LookAhead=".*[\n\f\r]begin"/>
                <RegexPatternGroup Type="EndScope" Token="FunctionEndToken" Style="ReservedWordStyle" PatternValue="^end;[\n\f\r]" LookAhead="{NonWordMacro}" />
            <ExplicitPatternGroup Token="PascalReservedWordToken" Style="ReservedWordStyle" LookAhead="{NonWordMacro}">
                    keywords keywords
            <RegexPatternGroup Token="IdentifierToken" PatternValue="(_| {AlphaMacro})({WordMacro})*"/>
            <ChildState Key="CodeCommentState"/>
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Hmm... I'm not sure of the way to do this. The problem is that your end scope requires a beginning of line assertion. However end scopes are matched after everything else.

This is how the matching occurs in the lexical parser:
  1. Look for scope end in a parent language (if any)
  2. Look for child start scope start
  3. Match patterns in current state
  4. Look for scope end in current language
Putting it in a different language might work. It's a very tricky situation though.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.