I have defined strings in my dynamic language as follows:
<States>
<State Key="StringState" TokenKey="StringDefaultToken" Style="StringDefaultStyle">
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="StringStartToken" Style="StringDelimiterStyle" PatternValue=""" />
<RegexPatternGroup Type="EndScope" TokenKey="StringEndToken" Style="StringDelimiterStyle" PatternValue="\"" />
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\x {HexDigitMacro}{1,4}" />
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\u {HexDigitMacro}{4,4}" />
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\U {HexDigitMacro}{8,8}" />
<RegexPatternGroup TokenKey="StringWhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
<RegexPatternGroup TokenKey="StringWordToken" PatternValue="\w+" />
<RegexPatternGroup TokenKey="StringDefaultToken" PatternValue="[^\"]" />
</PatternGroups>
</State>
<State Key="DefaultState">
...
<ChildStates>
<ChildState Key="StringState" />
</ChildStates>
</State>
</States>
In my parser I would like to recognize a string in the DefaultState and parse the string sequence into a ASTNode. I assume the way I would do this is by doing the following:
Match(StringStartToken);
//Slurp in the string content
Match(StringEndToken);
AstNode node = new StringNode();
Am I on the right track?
[Modified at 01/02/2007 01:09 PM]
<States>
<State Key="StringState" TokenKey="StringDefaultToken" Style="StringDefaultStyle">
<Scopes>
<Scope>
<ExplicitPatternGroup Type="StartScope" TokenKey="StringStartToken" Style="StringDelimiterStyle" PatternValue=""" />
<RegexPatternGroup Type="EndScope" TokenKey="StringEndToken" Style="StringDelimiterStyle" PatternValue="\"" />
</Scope>
</Scopes>
<PatternGroups>
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\x {HexDigitMacro}{1,4}" />
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\u {HexDigitMacro}{4,4}" />
<RegexPatternGroup TokenKey="StringEscapedCharacterToken" PatternValue="\\U {HexDigitMacro}{8,8}" />
<RegexPatternGroup TokenKey="StringWhitespaceToken" PatternValue="{WhitespaceMacro}+" IsWhitespace="True" />
<RegexPatternGroup TokenKey="StringWordToken" PatternValue="\w+" />
<RegexPatternGroup TokenKey="StringDefaultToken" PatternValue="[^\"]" />
</PatternGroups>
</State>
<State Key="DefaultState">
...
<ChildStates>
<ChildState Key="StringState" />
</ChildStates>
</State>
</States>
In my parser I would like to recognize a string in the DefaultState and parse the string sequence into a ASTNode. I assume the way I would do this is by doing the following:
Match(StringStartToken);
//Slurp in the string content
Match(StringEndToken);
AstNode node = new StringNode();
Am I on the right track?
[Modified at 01/02/2007 01:09 PM]