Re: Not able to use %union?

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>

> Le 18 févr. 2019 à 04:37, Peng Yu <[email protected]> a écrit :
> 
> Since %union cannot be used in this case, how to deal with this
> scenario in bison? Thanks.

You want to read the documentation of api.value.type.

For instance:

          ‘{TYPE}’
               Use this TYPE as semantic value.
                    %code requires
                    {
                      struct my_value
                      {
                        enum
                        {
                          is_int, is_str
                        } kind;
                        union
                        {
                          int ival;
                          char *sval;
                        } u;
                      };
                    }
                    %define api.value.type {struct my_value}
                    %token <u.ival> INT "integer"
                    %token <u.sval> STR "string"


_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.