[antlr-interest] File extensions for ANTLR 3

Jim Idle jimi at intersystems.com
Thu Nov 30 15:46:37 PST 2006


Hang on a mo ;-). When I proposed extensions (and I have adopted them and encoded them into the visual studio plug-in), everyone moaned and said they only wanted to use .g3 and only optionally. So we agreed that I would use the extensions I proposed:

.g3l
.g3p
.g3pl (or .g3 or .g)
.g3t

For visual studio if you wanted to use the plugin, but that we would not force it upon anyone. If we are now going to change our minds, then can we at least use the extensions I proposed.

I don't support T.g3t -> T.java in general as it is not orthogonal. But, whatever ;-)

Jim

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Thursday, November 30, 2006 2:19 PM
To: Antlr Interest
Cc: Kunle Odutola
Subject: Re: [antlr-interest] File extensions for ANTLR 3


On Nov 30, 2006, at 2:03 PM, Prashant Deva wrote:

> The current file extensions for antlr 3 (its .g or .g3, i guess) does
> not indicate in any way whether the grammar file contains a parser or
> lexer. Also the file name itself doesnt indicate the name of the
> parser/lexer.
>
> I propose to let the extension of grammar files be something like
> .gl,.gp & .glp which indicates instantly whether the file contains a
> lexer, parser or both. Also like java the name of the file should be
> the same as the name of the lexer inside.

In general I support this proposal.  The most common case is plain .g  
for a combined parser and lexer so nothing will change.  I like the  
idea that, from the extension, a build tool or IDE knows the Java  
class that will come out.

T.gl -> TLexer.java
T.gp -> TParser.java
T.gtp -> TTreeParser.java
T.g -> TLexer.java, TParser.java

Kunle also has a proposal that  tree parsers are different enough  
that we should translate literally

T.gtp -> T.java

His rationale is that normal grammars are named for the language and,  
hence, adding Lexer or Parser suffix makes sense, but tree parsers  
are usually named properly and adding the TreeParser suffix does  
not.  I noticed this a number of times myself.  For example,

DefineVariables.g -> DefineVariablesTreeParser.java  (or .gtp?)
SemanticAnalyzer.g -> SemanticAnalyzerTreeParser.java

weird, right? Because tree grammars are named for their functions, we  
should probably leave that alone.  With the addition of Prashant's  
proposal (a similar proposed by others) then we will know precisely  
what Java file will come out given the extension.

So, the proposal is that ANTLR specifically  
enforce .g, .gl, .gp, .gtp as well as the name of the file being the  
name of the grammar inside.  Further, ANTLR would deviate from  
regular grammars for tree grammars so that no suffix is added to the  
generated code.

How will this fly in other target languages?

Ter

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.430 / Virus Database: 268.15.2/559 - Release Date: 11/30/2006 5:07 AM
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.430 / Virus Database: 268.15.2/559 - Release Date: 11/30/2006 5:07 AM
 


More information about the antlr-interest mailing list