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

Re: Bug in SableCC 2.17.2?

Hi Xuân,

You are absolutely right, the current syntax for sets is cumbersome and
not nice. I belive Etienne is planning for new (major) release of SableCC
to address it and give much more intuitive and simple syntax.

The functional difference between list of alternatives and set of
"characters" is really in the ability to "substract" - one can create
a bigger set and then declare smaller ones by reducing/substracting
another set from the bigger set.
In your case it would be better to use sets as you want to declare
tokenchars as such characters which are not separators. But as you have
pointed out the current syntax is not nice at all for that.

As to the second part of your question, I do not really understand the
problem (apart again that you have pointed out not-nice error handling and
not meaningful error message).  Brackets () in sablecc grammar file are
used to group list of productions/tokens.  However, grouping something
without a reason is treated as an error ;o)  So, if something does not
need to be grouped, do not group it ;o)
I hope you will know what I mean by reading the code below, if you do not
know how to express something tell me what exactly you want the tail to
represent and I may help you with that.


best regards


        tokenchar = [[0x0000..0xFFFF]-','];


        token =       tokenchar+;
        comma =       ',';


        token_list      =       token token_list_tail*;

//token_list_tail       = token;         // works
//token_list_tail       = (token)+;      // works
//token_list_tail       = comma token;   // works
//token_list_tail       = (comma token)+;// works