[antlr-interest] .g vs .g4

Sam Harwell sharwell at pixelminegames.com
Mon Nov 7 10:36:00 PST 2011


Hi Kirby,

The extension comes into play when searching for imported grammars.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Kirby Bohling
Sent: Monday, November 07, 2011 12:21 PM
To: Terence Parr
Cc: antlr-interest Interest
Subject: Re: [antlr-interest] .g vs .g4

On Mon, Nov 7, 2011 at 12:01 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> yeah, maybe forcing tool to do .g4 is good otherwise why use it. .g4 means
v4. .g means v3 (er
and v2).
> Ter

   Please don't do that.  If I want to call that file "foobar.g", or "silly"
what does it matter?  Have a declaration inside of the file if need be, or
be one of the wonderful handful and just add it as part of the documentation
at the top of the grammar?  When it doesn't work, I promise, I'll get around
to reading the docs at the top.

Every time I have a tool which refuses to do my bidding it just ends up
getting in my way.  What if I want to pipe it in over stdin so there is no
file name?  Virtually every time I write or use a tool with tight
constraints, later on I come across the counter example where it is a big
work around to get where I want to be because a tool decided to dictate
minor details.  It really irritates me that unzip thinks the file _has_ to
be named .zip, .z, or .Z.  I _know_ it is a zip file, just unzip the thing,
stop guessing at the file name.

Should the community say it is a best practice?  Absolutely, but I'm really
happy that the C/C++ pre-processor doesn't force me to name the files
"foo.h", or "foo.hpp" to get them to work.  At the very least, put in the
flags/switches for "expert mode", which will override any of the magic
auto-detection, so when I tell it what to, it just does it.  I have no idea
in what context that'll be useful, but in my experience, there's always one.

Kirby


> On Nov 7, 2011, at 9:59 AM, Jim Idle wrote:
>
>> We started down this path with v3 and never really took it anywhere. 
>> I would be in favor of using .g4 only.
>>
>> Jim
>>
>>> -----Original Message-----
>>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest- 
>>> bounces at antlr.org] On Behalf Of Terence Parr
>>> Sent: Sunday, November 06, 2011 9:56 AM
>>> To: Eric
>>> Cc: antlr-interest Interest
>>> Subject: Re: [antlr-interest] .g vs .g4
>>>
>>> Hi Eric,I think we are going to allow .g as well.   Rather than a 
>>> property in the grammar file itself that identifies the version, I 
>>> think we were going to use the file extension for this reason. all 
>>> v3 grammars will be .g and people building v4 grammar should name 
>>> them .g4 Ter On Nov 6, 2011, at 9:29 AM, Eric wrote:
>>>
>>>>
>>>>
>>>> On Sun, Nov 6, 2011 at 12:22 PM, Terence Parr <parrt at cs.usfca.edu>
>>> 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.
>>>>
>>>> Ter
>>>>
>>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>>> Unsubscribe: http://www.antlr.org/mailman/options/antlr-
>>> interest/your-email-address
>>>>
>>>>
>>>> Hi Ter,
>>>>
>>>> Will v4 require the file type to be .g4, or will it accept .g and
>>> .g4?
>>>>
>>>> My preference is for .g4 only.
>>>>
>>>> Also, will there be a property in the grammar file that identifies
>>> the minimum version or required version. I think it would help for 
>>> obvious reasons such as when a user post a grammar needing help or 
>>> an example grammar is given.
>>>>
>>>> Thanks, Eric
>>>>
>>>>
>>>
>>>
>>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>>> Unsubscribe: 
>>> http://www.antlr.org/mailman/options/antlr-interest/your-
>>> email-address
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list