Parser for dynamic lexer

SyntaxEditor for WPF Forum

Posted 13 years ago by Aurore
Version: 11.1.0543

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;
In my xaml window i just copy your code :

public MainWindow()

            // 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)
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 ?

Comments (2)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hello, you created a parser in your code but didn't assign it as a service on your language, so your language doesn't have a parser yet. For instance in Getting Started 4a's SimpleSyntaxLanguage, we do:
this.RegisterParser(new SimpleParser());
Since you don't have a parser on the language, no parse data won't be created and thus EditorDocumentParseDataChanged won't fire.

So once you register the parser on the language, things will probably start working.

Actipro Software Support

Posted 13 years ago by Aurore
Thanks a lot.

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.