help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why bison doesn't like my grammar?


From: SirZooro
Subject: Why bison doesn't like my grammar?
Date: Sun, 17 Sep 2006 06:22:00 -0700 (PDT)

Hello,
I was found this problem while trying to eliminate shift/reduce conflicts
from my grammar. Bison (version 2.3, Cygwin) reports that some of my rules
are useless, and I don't know why. Could you look on this and tell me what's
wrong?

I want to describe something like this (array dimensions, default value and
'global' are optional):

variables
{
  var_aaa[3][2] : 8 = 123  global
  other_var : x
}

Daniel

Useless rules:
   11 variable_decl: TOK_SYMBOL const_var_dim_list ':' const_int_function
var_default var_global
   12 const_var_dim_list: const_var_dim_list const_var_dim
   13 const_var_dim: '[' const_int_function ']'

Grammar file:

%token TOK_VARIABLES TOK_SYMBOL TOK_X TOK_GLOBAL TOK_NUMBER '{' '}' '[' ']'
':' '='
%token TOK_NUMBER

%glr-parser

%%

variables : TOK_VARIABLES '{' variables_list '}' ;

variables_list : /* empty */
        | variables_list variable_decl ;

variable_decl :  TOK_SYMBOL ':' const_int_function var_default var_global
        | TOK_SYMBOL const_var_dim_list ':' const_int_function var_default
var_global
        | TOK_SYMBOL ':' TOK_X ;

const_var_dim_list :  const_var_dim_list const_var_dim ;

const_var_dim : '[' const_int_function ']' ;

var_default : /* empty */
        | '=' const_int_function ;

var_global : /* empty */
        | TOK_GLOBAL ;

const_int_function:
        TOK_NUMBER ;

-- 
View this message in context: 
http://www.nabble.com/Why-bison-doesn%27t-like-my-grammar--tf2286045.html#a6349993
Sent from the Gnu - Bison - Help forum at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]