Example for a text grammar file

%token id     "[A-Za-z]+";
%token number "[0-9]+";

%right mult   "\*";
%right div    "/";
%right plus   "\+";
%right minus  "\-";

%token pleft  "\(";
%token pright "\)";

%ignore "(\r\n\ \t)+";

%start exp;

%%

exp : exp   plus  exp
    | exp   minus exp
    | exp   mult  exp 
    | exp   div   exp
    | pleft exp   pright
    | id
    | number
    ;
by Stephan Michels