Hello everyone
Please see further below regarding a few first steps towards "converting" Chunlan's .g files in combination with Eiffel's lexer files to ANTLR's syntax. My main motivation for doing this was to produce syntax diagrams for ADL and AQL but very early on I realized that there was no point writing just the EBNF because I could be deriving the ANTLR representation of the grammar and from that be able to produce a parser as well.
This was going well, until I realised that:
1) Certain definitions could be defined once and re-used in multiple places
2) Some definitions looked almost exactly the same but had different names depending where they were applied
3) Some definitions would become obsolete / would not be able to co-exist because of the way ANTLR expresses a grammar
4) Some definitions included conditional parsing with states and they were becoming a bit indecipherable for me
5) Meantime, ADL 2.0 came along
I have specific examples for the above in a document were I kept notes as I was going on which I intend to share. Part of it was also put at an earlier email to Thomas...but this was long time ago by now.
The problem is that right now I am "on the road" (and have been for a few weeks now), writing this just before I go into class at St. Andrews and cannot talk about this to the level of detail I would love to ![]()
However, the key messages emerging from my experience are these:
A) I would appreciate help from people who wrote the .g and Eiffel YACC files because these are not exactly documented. We need to know how some definitions came to existence and more importantly, if we have two definitions that are almost identical, which one do we keep?
B) !!!We need testing cases!!! for each definition. This became essential as I was going on and had to jump back and forth changing definitions. Of course, when you do that, it has an impact on every definition uses the modified part. My tool of preference was Python. The Python ANTLR target code generation was recently reworked and it works almost exactly as its JAVA counterpart. It could be used to create quick test code through a makefile or something.
C) I found it easier to work bottom-up. So, if we were to quickly get elementary data types / definitions out of the way relatively quickly then the real work can start on parts of the grammar that are not exactly straightforward ![]()
Repositories at:
A first step for AQL can be found at:
https://bitbucket.org/aanastasiou/openehr-aql-syntax
Some progress has also been made towards EBNF for ADL at:
https://github.com/aanastasiou/adl_ebnf
I hope this helps, had a quick look at the MedInfo stuff and it looks really exciting!
All the best
Athanasios Anastasiou