I am trying to convert the Grammar EBNF file to infragistics EBNF but unfortunately it fails with various problems. I've attached the source file with an example and the EBNF file which I've tried to converted using Infragistics syntax engine parser.
Is the available any help to create from scratch the EBNF file? I found an example with EBNF parser on https://es.infragistics.com/help/wpf/wpf-netadvantage-for-wpf-samples.
Also some documentation:
https://es.infragistics.com/help/wpf/infragisticswpf.documents.textdocument~infragistics.documents.parsing.languageelement for other parts
but not how to create EBNF file.
Please help to convert attached files:
8130.EBNF files.zip
Hello Tomas,
I have been investigating the EBNF file that you have provided, and currently, there unfortunately does not exist any documentation or a "pre-defined" way of creating an EBNF file from scratch.
The best thing that I can really recommend in this case is to view the EBNF files that we send out with our source code for an example. To access the source code, though, you will need to obtain a licensed version of the Infragistics for WPF toolset, and then you will be able to download the source code from your My Keys and Downloads page. Once you have obtained this, you can find the language files from the SyntaxEditor directory.
As an alternative, we also have a custom EBNF file from the Infragistics for WPF samples browser, and so as a Trial, you can see an example EBNF file from the source code of the samples browser at the following directory:
C:\Users\Public\Documents\Infragistics\2018.2\WPF\Samples\CLR4.0\IGSyntaxParsingEngine\Samples\Languages\XML.ebnf
Regarding the actual issues in your ".infragistics" EBNF file, I am not entirely sure what exactly is wrong. Comparing the tags on lines that are mentioned in the error messages with the EBNF files that we have internally, though, it does not appear that most of the items outside of the </Grammar> tag exist in our EBNF files. It is possible that this is not correct markup, but I am rather unsure at the moment, as I personally have very limited experience with EBNF file creation.
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew,
I've already looked into this file and based on this file sample I've tried to create our new custom language (as attached before). Unfortunately our Custom Language is very different than XML and this makes difficult to transform.
I've create a sample project with our manually used syntax editor containing only keywords. This works but it does not have all features listed in EBNF file. Without documentation it is still hard to define other TerminalSymbol elements correctly.
TranslatorEditor.zip
Thank you for the sample project. I can see that some of the keywords that you have defined do not seem to be working in the XamSyntaxEditor. I am under the impression that this is because the grammar of the XamSyntaxEditor is not picking up that it should highlight these elements, although at the moment, I am unsure as to why.
I did some digging, and I found a documentation article about EBNF File Formats that might help you in this case as well as how you can currently generate an EBNF file from a Grammar object. You can also read about creation of a Grammar object here.
You have mentioned that your language is very different than XML. Is there a language that it is more similar to? I ask, as our source code includes full EBNF files for C#, Visual Basic, and Transact-SQL.
Hello Andrew,
Thanks a lot for the article. I will have to look at this.
The highlighting is working for me in the sample project but it also happens in quoted strings (not expected). It is using only the manually added keyword highlighting. The EBNF file I couldn't parse it to the C# code so this is just added to the solution but not used anywhere.
Our language is combination of two languages. But it is not too complicated. In the example project I've already provided sample file of our language (SecsCodeSample.txt which needs to be reformatted with new line characters if opened in Notepad). Also if you run the sample project this file will be loaded to the editor correctly.
I don't know any other language similar to our one as it is developed by our company and it is very specific to the our communication needs with tools. The code exposes few method types (listed as keywords: Request, Response and etc) then message type and fallowed by message body which could be compared to XML but having injection elements to the body from arguments.
Thank you very much for supporting on conversion. This provided a good starting point for understanding the grammar. Yesterday I also noticed that highlighting does not work the way it was implemented. But based on downloaded WPF samples I found out how to do this.
I have reached out to one of our senior developers who knows a bit more about EBNF, and they have taken a look at the sample project you have provided. They have added some error logging and some productions to your EBNF file, and now the highlighting is working as is defined in the grammar file.
Note, the performance in this new sample will be a little slower as there is output window error logging. Most of this error logging is an indication that your grammar is ambiguous, but other things are definitely working – for example, the “Using” statements.
Regarding the highlighting happening in the quoted strings, this is happening because your grammar file does not have anything to tell it not to highlight within quoted strings. The XamSyntaxEditor highlighting is purely based on the grammar/EBNF files used, and so if you do not tell the editor to not highlight within quotations, it will continue to highlight there. I am unsure of what exactly you need to add to prevent this highlight, but this is likely related to my inexperience with EBNF and grammar file creation.
It is worth noting that the revised sample I am attaching here is beginning to exceed the scope of what developer support provides, and that we are essentially beginning to be in the realm of a consulting service. If you have specific questions about certain pieces of the XamSyntaxEditor, we can answer them to the best of our ability, but creation of a custom EBNF file is not something that we can generally provide support for.
TranslatorEditor_Revised.zip