Dynamic Languages:Need some help with defining string groups

SyntaxEditor for Windows Forms Forum

Posted 9 years ago by Marina
Version: 4.0.0285
Avatar
Hello,

I am stuсk with creating a State group in a dynamic language definition that should parse the following multiline string definition:

"line0 \
line1 \
line2"

This is C++ multiline string.

I have tried to modify C# example of multiline (see the code below) but with no luck.

<State Key="VerbatimStringState" TokenKey="VerbatimStringDefaultToken" Style="StringDefaultStyle">
            <!-- Scopes -->
            <Scopes>
                <Scope>
                    <ExplicitPatternGroup Type="StartScope" TokenKey="VerbatimStringStartToken" Style="StringDelimiterStyle" PatternValue="@&quot;" />
                    <ExplicitPatternGroup Type="EndScope" TokenKey="VerbatimStringEndToken" Style="StringDelimiterStyle" PatternValue="[\]|[&quot;]" LookAhead="[\s]*\n"/>    
                </Scope>
            </Scopes>
            <!-- Patterns Groups -->
            <PatternGroups>
                <ExplicitPatternGroup TokenKey="VerbatimStringEscapedQuoteToken" PatternValue="&quot;&quot;" />
                <RegexPatternGroup TokenKey="VerbatimStringWhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
                <RegexPatternGroup TokenKey="VerbatimStringWordToken" PatternValue="\w+" />
        <RegexPatternGroup TokenKey="VerbatimStringWordToken1" PatternValue="[\\][\n\r]" />
        <RegexPatternGroup TokenKey="VerbatimStringDefaultToken" PatternValue="[^\&quot;]" />
      </PatternGroups>
        </State>
Any help is appreciated.

Marina

Comments (1)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marina,

Check out your scopes. I think your patterns are wrong there and make sure you are using a RegexPatternGroup when you are indicating regex pattern values (such as in EndScope).

Also a good example of what you need to do is in our C#'s XML comments area since that shows how to consult a line terminator without exiting the comment if the line is followed by another XML comment line. It's sort of similar to your scenario except you want to consume "\\\n".

Note that you don't need to look for \r since we strip those out while the text is in our control to make things easier to parse. We only use \n as line terminators but then Document.Text props etc. will restore \r\n later.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.