
Hello,
I'm new in using your syntaxeditor, i make some test to understand.
I'd like first to define my own language and very simple grammar to understand how to use your AST to evaluate expressions on my datas.
To do simple i use your language designer to obtain the lexical part. I got the dynamiclexer.
Now, i'm trying to make a sample as your 4a sample. the editor, the AST and the grammar.
I defined a very simple grammar :In my xaml window i just copy your code :
But my first problem is that i can't use "editor.Document.Language.GetParser()" it returns always null.
Then i tried directly new parser, that ok, i've got the grammar text on enbfEditor.
My second problem, and i'm blocked is now that "EditorDocumentParseDataChanged" doesn't fire ? well I can't obtain the AST structure...
Have you an idea ?
Thanks
Aurore
I'm new in using your syntaxeditor, i make some test to understand.
I'd like first to define my own language and very simple grammar to understand how to use your AST to evaluate expressions on my datas.
To do simple i use your language designer to obtain the lexical part. I got the dynamiclexer.
Now, i'm trying to make a sample as your 4a sample. the editor, the AST and the grammar.
I defined a very simple grammar :
public class SphinxBasicGrammar : Grammar
{
public SphinxBasicGrammar() : base("SphinxBasic")
{
var @assignment = new Terminal(SphinxBasicTokenId.OpAssign, "Assignment") { ErrorAlias = "'='" };
var @identifier = new Terminal(SphinxBasicTokenId.Identifier, "Identifier");
var @sphvar = new Terminal(SphinxBasicTokenId.SphVariable, "Variable");
var @stringcontat = new Terminal(SphinxBasicTokenId.OpConcat, "concat") { ErrorAlias = "'&'" };
this.Root = new NonTerminal("CompilationUnit");
var assignmentStatement = new NonTerminal("AssignmentStatement");
this.Root.Production = assignmentStatement.ZeroOrMore();
assignmentStatement.Production = @identifier + @assignment + @sphvar + @stringcontat + @sphvar;
}
}
public MainWindow()
{
InitializeComponent();
// Load the EBNF language
ebnfEditor.Document.Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("SphinxBasic.langdef");
// Show the EBNF
ILLParser parser = new SphinxBasicParser(); //editor.Document.Language.GetParser() as ILLParser;
if (parser != null)
ebnfEditor.Document.SetText(parser.Grammar.ToEbnfString());
}
Then i tried directly new parser, that ok, i've got the grammar text on enbfEditor.
My second problem, and i'm blocked is now that "EditorDocumentParseDataChanged" doesn't fire ? well I can't obtain the AST structure...
Have you an idea ?
Thanks
Aurore