
(I am trying to transition from SyntaxEditor/WinForms to WPF and am confused by many things on the syntax language implementation looking so different...)
I have tried to setup a simple project to get started with a programmatical lexer. However, it does not seem to be called and I do not see where the issue is.
I have a main window with the SyntaxEditor control, which initializes as follows:
public MainWindow()
{
InitializeComponent();
ActiproSoftware.Text.Parsing.AmbientParseRequestDispatcherProvider.Dispatcher =
new ActiproSoftware.Text.Parsing.Implementation.ThreadedParseRequestDispatcher();
SyntaxEditor.Document = new EditorDocument() { Language = new ScriptSyntaxLanguage() };
}
The syntax language I am trying to implement has just a lexer for now:
public class ScriptSyntaxLanguage : SyntaxLanguage
{
public ScriptSyntaxLanguage()
: base("script")
{
this.RegisterLexer(new ScriptSyntaxLexer());
}
}
The lexer is just a skelleton for now with no actual logic yet:
public class ScriptSyntaxLexer : MergableLexerBase
{
private LexicalStateCollection lexicalStates;
public ScriptSyntaxLexer()
{
// Create ID providers
this.LexicalStateIdProviderCore = new ScriptLexicalStateId();
this.TokenIdProviderCore = new ScriptTokenId();
// Create the default lexical state
ProgrammaticLexicalState lexicalState = new ProgrammaticLexicalState(ScriptLexicalStateId.Default, "Default");
lexicalStates = new LexicalStateCollection(this);
lexicalStates.Add(lexicalState);
this.DefaultLexicalStateCore = lexicalState;
}
public override IEnumerable<ILexicalStateTransition> GetAllLexicalStateTransitions()
{
return lexicalStates.GetAllLexicalStateTransitions();
}
public override MergableLexerResult GetNextToken(ITextBufferReader reader, ILexicalState lexicalState)
{
throw new System.NotImplementedException();
}
}
The actual GetNextToken method is not yet implemented.
However, running the application indicates that the method is never even called. What am I doing wrong for a very simple start into the languge?