[antlr-interest] Composite grammars and "no start rule" warning

Peterson, Joe joe.peterson at intel.com
Mon Jul 13 10:33:51 PDT 2009


Howdy,

I have a question about how to eliminate the "no start rule" warning when using a composite grammar.

I've had to make a change to my grammar recently that requires me to use a rule in a file that I use elsewhere. The rule is in a separate file and I want to keep that to make it easier to maintain. Because I have two locations that I need to use it, I wind up with the warning: warning(138): another_file.g:0:0: grammar another_file: no start rule (no rule can obviously be followed by EOF).

Now, I want to figure out how to reuse the rule in a separate file without this warning. Below is a super stripped version of the files with the names changed to protect confidentiality. (And a lot of white space removed.)

The only way I've found to eliminate it to create a single rule to call the common rule.  For example, in the below, I could add a rule "common_list" in main.g and then change all the list references to common_list.  That is not a very satisfactory solution to me.  Is there another way?

-JEEP

//Main.g
grammar main;
options {    language = C; }
import a_file, another_file;
unit  : list? group;
// can add: common_list : list here, but seems no so good to me
HRM : 'Hrm';
SIGH : 'Sigh' ;
KEYWORD : 'Keyword' ;
ITEMS : 'Items' ;
SEMICOLON : ';'  ;

////
// a_file.g
parser grammar a_file;
group : section list? section2+  ;
section  : HRM    ;
section2   : SIGH ;

////
// another_file.g
parser grammar another_file;
list: stmt+;
stmt : KEYWORD items SEMICOLON;
items: ITEMS;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090713/bf2bda1b/attachment.html 


More information about the antlr-interest mailing list