在Bison中启用变体

时间:2017-10-18 16:48:15

标签: bison variant

我无法让变种在野外工作。我投入了

%{
  ... 
%}

%define api.value.type variant
...
%%
...

但是我得到了

bison -d -t -o parser.cpp parser.ypp
parser.ypp:16.9-22: error: '"yacc.c"' does not support '%define api.value.type variant'
%define api.value.type variant
        ^^^^^^^^^^^^^^

我的版本应该支持变体。

bison --version
bison (GNU Bison) 3.0.2
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

1 个答案:

答案 0 :(得分:1)

当错误消息谈到“yacc.c”时,它指的是C语言的“yacc”骨架。变体是C ++的特性。使用%language "c++"将语言设置为C ++,它将起作用。