Hello,

I've been experiencing with bison's lr.type option yesterday and I found
a strange thing.

When changing the lr.type option in my bison file I made a typo and I
encountered this error message :

test.yy:1.1-21: error: invalid value for %define variable ‘lr.type’: ‘lalrr’
    1 | %define lr.type ielrr
      | ^~~~~~~~~~~~~~~~~~~~~
test.yy:1.1-21: note: accepted value: ‘lr(0)’
test.yy:1.1-21: note: accepted value: ‘lalr’
test.yy:1.1-21: note: accepted value: ‘ielr’
test.yy:1.1-21: note: accepted value: ‘canonical-lr’


Then I saw that there was a mention of lr(0) as a valid value for this
field and when trying to use it I got this error message :

test.yy:1.19: error: invalid character: ‘(’
    1 | %define lr.type lr(0)
      |                   ^
test.yy:1.21: error: invalid character: ‘)’
    1 | %define lr.type lr(0)
      |                     ^
test.yy:7.3-8.0: error: unexpected epilogue
    7 | %%
      |   ^
test.yy:1.1-18: error: invalid value for %define variable ‘lr.type’: ‘lr’
    1 | %define lr.type lr(0)
      | ^~~~~~~~~~~~~~~~~~
test.yy:1.1-18: note: accepted value: ‘lr(0)’
test.yy:1.1-18: note: accepted value: ‘lalr’
test.yy:1.1-18: note: accepted value: ‘ielr’
test.yy:1.1-18: note: accepted value: ‘canonical-lr’

I am doing something wrong here to define that option ?

Is this maybe a translation artifact or something that used to exist
and doesn't anymore. I've searched the ChangeLog without any luck of
finding some sort of deprecation of this option.

If found the function responsible for the parsing of that option and
it seems that ~prepare_percent_define_front_end_variables~ still has
it available. Maybe I'm doing something wrong in terms of quoting ?

I've tried putting the lr(0) value with double quotes and it lead to
a segmentation fault. You can try to replicate it with the following
grammar file :

%define lr.type "lr(0)"


%token NUM
%left '-' '+'

/* Grammar follows */
%%
input:    /* empty string */
             | input line
;

line:     '\n'
          | exp '\n'
;

exp:      NUM
        | exp '+' exp
        | exp '-' exp
;
%%

I'm testing on version 3.8.2 on NixOS.

Please let me know if this is worth a bug report.

Have a good day,

--
Simon Scatton

Reply via email to