
Hi,
following situation:
At runtime I expand the xml-langdef-file for our custom language with a new ExplicitPatternGroup like this.
XElement extension = new XElement("{http://schemas.actiprosoftware.com/langdef/1.0}ExplicitPatternGroup",
new XAttribute("Key", "GopMenge"),
new XAttribute("TokenId", 200),
new XAttribute("TokenKey", "GopMenge"),
new XAttribute("ClassificationTypeKey", "GopMenge"),
new XElement("{http://schemas.actiprosoftware.com/langdef/1.0}ExplicitPatterns",
new XCData(formattedExtensionMengen))
);
I can do it only at runtime, because the XData-String "formattedExtensionMengen" is only known when application started.
After that, I use a SyntaxLanguageDefinitionserializer to initialize the language with the extended langdef-File.
First question:
Is there another idea to add or extend a explicit pattern group during runtime?
Beside that I use the LLParserFramework with a CustomGrammar-class.
Now the problem - and following questions:
After parsing the editor document the string contained in the XDataString is recognized as a GopMenge-Token, but the recognized GopMenge-Token gets a red squiggleLine, although recognized as correct Token, and although the string is correct either.
The reason is, that the CustomGrammar-class does'nt have a definition of a Terminal or NonTerminal-Object of 'GopMenge'. And therefore the GopMenge-Token cannot be recognized as a valid AST.
The CustomGrammar-class have no Terminal-Definition for GopMenge, as the TokenId needed is only known at runtime and not before.
My idea now is to add a TokenId.GopMenge to the MengeTokenId class programmatically, by inheriting from the generated CustomTokenId.g.cs class
Then I can use this tokenId to define the appropriate Terminal and Non-Terminal in the Grammar class.
Is that useful? Are there any other Ideas? Perhaps a kind of placeholder somewhere in the Lexer?
Can you understand my problem?
I need a TokenId before runtime to use in CustomGrammar class, but it is earliest known at runtime.
Thanks for your appreciated help!!