AQL ANTLR4-grammar

Bert Verhees bert.verhees at
Mon Aug 24 10:38:37 EDT 2015

On 24-08-15 15:36, Thomas Beale wrote:
> Antlr4 rule capabilities and particularly pattern matching is weaker 
> than yacc/lex (in some cases quite a lot weaker),
Of course, Yacc/lex can only be used to generate C-code. It's 
functionality in pattern matching is limited to this.

To do whatever you need to do, writing a compiler, translating 
programming languages into another (transpiler), translating a query 
language into another, processing data, JSON,. XML, CSV, to many custom 
made targets, generated code accessible to choose for a listener/visitor 
or tree pattern, and having scoped symbol tables, that  is where Antlr 
comes in.
That is why I have seriously picked up in learning to work with this. 
Regarding to pattern matching, its left/right associativity and direct 
left recursion make it an unique tool.
It is also very matured, as it is now in version 4.5. Especially it has 
grown a lot in the 4.x-version. Terence Parr researched 25 years parsers 
and parser generators.

Translating AQL to xQuery, must be very easy.
I think it is very suitable for the task Erik is mentioning, he is only 
wanting to define the grammar, as far as I understand.
What to do with it then, it is reasonably easy by using the 
Antlr-generated code pattern.

You can even translate the generated Java code to Eiffel by using Antlr ;-)
I think that is not very hard to do.

I checked it with parsing Pascal, Java, CSV, JSON, XML, I did  not 
encounter any weakness.
I was pleasantly surprised by the simplicity of some grammars.
There are grammars and test files for many other languages.

Maybe the weakness is C-related? It is what one expects because the 
nature of Yacc/lex.
Although Java has a lot of syntax similarities with C.
Of course, there are bugs in Antlr, quite a few (105 open at this moment 
for Antlr4.5), but I do not consider them yet as a weakness of the concept.
But maybe some are.
I did not see anyone else referring in that way to it.

So I was not aware of any issues in pattern recognition. It sounds like 
a serious issue.
I think there must be good information about this.
Can you give more information or an example of this pattern-matching 


More information about the openEHR-technical mailing list