Posted 18 years ago
by Bob Rundle
-
Director, Dynamic Workflow,
JOA Oil & Gas BV
I have a language that does not have explicit terminations for blocks. Blocks are introduced by keywords and there are two levels of blocks. Here is a simple example...
RUNSPEC
OIL
WATER
GAS
DISGAS
GRID
NEWTRAN
END
Needless to say this is highly simplified. The "RUNSPEC" keyword starts one top level section and the "GRID" keyword starts another.
The problem is that I don't know that the RUNSPEC section ends until I see the GRID keyword. This keyword in turn starts another section. The GRID keyword also indicates the end of the previous statement (which can have a lot of different formats...only the one line version is shown here).
So I have a language definition that includes this...(again, highly simplified)
<SyntaxLanguage Key="Eclipse" LanguageDefinitionVersion="3.0" Secure="False" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<States>
<State Key="DefaultState">
<ChildStates>
<ChildState Key="DeckSectionState"/>
</ChildStates>
</State>
<State Key="DeckSectionState">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" TokenKey="DeckSectionStartToken" PatternValue="^RUNSPEC|^GRID|^EDIT|^PROPS|^REGIONS|^SOLUTION|^SUMMARY|^SCHEDULE|^OPTIMIZE|^END" Style="ReservedWordStyle"/>
<RegexPatternGroup Type="EndScope" TokenKey="DeckSectionEndToken" PatternValue="{LineTerminatorMacro}" LookAhead="^RUNSPEC|^GRID|^EDIT|^PROPS|^REGIONS|^SOLUTION|^SUMMARY|^SCHEDULE|^OPTIMIZE|^END" IsWhitespace="True"/>
</Scope>
</Scopes>
<ChildStates>
<ChildState Key="StatementState"/>
</ChildStates>
</State>
<State Key="StatementState">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" TokenKey="StatementBlockStartToken" PatternValue="^[A-Z][A-Z0-9]*" Style="ReservedWordStyle"/>
<RegexPatternGroup Type="EndScope" TokenKey="StatementBlockEndToken" PatternValue="{LineTerminatorMacro}" LookAhead="^[A-Z][A-Z0-9]*" IsWhitespace="True"/>
</Scope>
</Scopes>
</State>
</States>
</SyntaxLanguage>
I find that this *almost works*. I find that I can fire "StatementBlockEndToken". However if the keyword that ended the statement is "GRID", then I want a "DeckSectionEndToken" also. This will not happen because the pattern that matched StatementBlockEndToken ate the line terminator and therefore the pattern in the parent state for StatementBlockEndToken will never match.
I have been fooling around with various formulations to make this work. I am convinced that this is no way to make this work in the SyntaxEditor.
Am I wrong? Any help is appreciated.
Regards,
Bob Rundle
RUNSPEC
OIL
WATER
GAS
DISGAS
GRID
NEWTRAN
END
Needless to say this is highly simplified. The "RUNSPEC" keyword starts one top level section and the "GRID" keyword starts another.
The problem is that I don't know that the RUNSPEC section ends until I see the GRID keyword. This keyword in turn starts another section. The GRID keyword also indicates the end of the previous statement (which can have a lot of different formats...only the one line version is shown here).
So I have a language definition that includes this...(again, highly simplified)
<SyntaxLanguage Key="Eclipse" LanguageDefinitionVersion="3.0" Secure="False" xmlns="http://ActiproSoftware/SyntaxEditor/3.0/LanguageDefinition">
<States>
<State Key="DefaultState">
<ChildStates>
<ChildState Key="DeckSectionState"/>
</ChildStates>
</State>
<State Key="DeckSectionState">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" TokenKey="DeckSectionStartToken" PatternValue="^RUNSPEC|^GRID|^EDIT|^PROPS|^REGIONS|^SOLUTION|^SUMMARY|^SCHEDULE|^OPTIMIZE|^END" Style="ReservedWordStyle"/>
<RegexPatternGroup Type="EndScope" TokenKey="DeckSectionEndToken" PatternValue="{LineTerminatorMacro}" LookAhead="^RUNSPEC|^GRID|^EDIT|^PROPS|^REGIONS|^SOLUTION|^SUMMARY|^SCHEDULE|^OPTIMIZE|^END" IsWhitespace="True"/>
</Scope>
</Scopes>
<ChildStates>
<ChildState Key="StatementState"/>
</ChildStates>
</State>
<State Key="StatementState">
<Scopes>
<Scope>
<RegexPatternGroup Type="StartScope" TokenKey="StatementBlockStartToken" PatternValue="^[A-Z][A-Z0-9]*" Style="ReservedWordStyle"/>
<RegexPatternGroup Type="EndScope" TokenKey="StatementBlockEndToken" PatternValue="{LineTerminatorMacro}" LookAhead="^[A-Z][A-Z0-9]*" IsWhitespace="True"/>
</Scope>
</Scopes>
</State>
</States>
</SyntaxLanguage>
I find that this *almost works*. I find that I can fire "StatementBlockEndToken". However if the keyword that ended the statement is "GRID", then I want a "DeckSectionEndToken" also. This will not happen because the pattern that matched StatementBlockEndToken ate the line terminator and therefore the pattern in the parent state for StatementBlockEndToken will never match.
I have been fooling around with various formulations to make this work. I am convinced that this is no way to make this work in the SyntaxEditor.
Am I wrong? Any help is appreciated.
Regards,
Bob Rundle