Aarkan
Aarkan

Reputation: 4109

error with bison

I have a simple rule in my grammar which looks for sequence of whitespaces:

    ws: ws|' ';

When bison sees this rule, it complains:

warning: rule useless in parser due to conflicts: ws: ws

Why it is so? Cant I have a simple rule in grammar which looks for a regex?

Upvotes: 1

Views: 317

Answers (1)

Andre Holzner
Andre Holzner

Reputation: 18675

what you are declaring is 'ws is ws or ws is a space', not 'ws is one or more spaces'.

If you want the latter, try something like:

ws:   ' '
    | ' ' ws;

See also http://www.gnu.org/software/bison/manual/bison.html#Recursion

Upvotes: 8

Related Questions