[antlr-interest] .g vs .g4
Norman Dunbar
Norman at dunbar-it.co.uk
Mon Nov 7 10:30:22 PST 2011
Evening everyone,
On 06/11/11 17:22, Terence Parr wrote:
> Hi, Sam Harwell and I are talking about the file extension for new ANTLR 4. We think it makes good sense to use .g4 to distinguish the new grammars. They're mostly compatible except that there is no need for syntactic predicates and .g4 allows immediate left recursion. I think it will reduce confusion about what version of ANTLR is necessary to compile a grammar.
I'm pretty new to this ANTLR stuff, and to compilers/translators in
general, so be gentle with me. ;-)
Why does the file need to have a specific extension at all? I only just
found out recently that Java classes have to live in a file with the
same name as the class. Why?
I can write a C++ class called Barney in a file called fred.cpp or
fred.cxx or fred.c or fred if I like, the compiler and/or make seem
quite happy with that.
Maybe there is a good reason, Java perhaps? But I fell over at the first
hurdle trying out the examples in the two books, I decided I didn't like
a rule called 'r' and a grammar called 'g' and renamed everything, then
saved in a filename of my choice. Boy did ANTLRWorks whinge at that - so
I get my telling off, and had to rename the file. After that, fine. But
I just don't see why it absolutely must be named like this?
Having said that, if *.g4 is required for version 4, then I can live
with it - I'd like the system to be extension agnostic though - but I'm
only a tiny little non-essential cog, so I'm happy to be overruled.
Thanks, however, for the ANTLR and ANTLRWorks system. I think I like it
much better than Flex/Bison. Can you mention those on this list? ;-)
Cheers,
Norm.
--
Norman Dunbar
Dunbar IT Consultants Ltd
Registered address:
Thorpe House
61 Richardshaw Lane
Pudsey
West Yorkshire
United Kingdom
LS28 7EL
Company Number: 05132767
More information about the antlr-interest
mailing list