AQL ANTLR4-grammar

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 :smiley:

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 :slight_smile:

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

quick answer for now - there are base patterns that should be used across other projects like AQL

  * here in the specifictions-BASE repository
    <https://github.com/openEHR/specifications-BASE/tree/master/docs/odin&gt;
  * here in the specifications-AM repository
    <https://github.com/openEHR/specifications-AM/tree/master/docs/ADL2&gt;

look for the .g4 files. See particularly the 'base_patterns' one.

These files are currenty mixed in with the specs. I'll move them to a more obvious place (so they stand alone, but also enable spec publishing).

If you just want to look at these grammars, go to the ADL2 and ODIN specs (home page -> Specifications button ->...)

They are still being worked on, so don't trust them yet.

But do note that most terminal types in ADL apply to AQL, so we should aim for a base_patterns and also odin_values grammars across openEHR.

- thomas

<https://github.com/openEHR/specifications-BASE/tree/master/docs/odin&gt;On 24/08/2015 05:32, ANASTASIOU A. wrote:

(attachments)

oceanfullsmall.jpg
btnliprofileblue80x15.png