Skip to content

Commit 57af1ee

Browse files
authored
Merge pull request #654 from ydah/can-remove-%%-union
Create parser without defining `%union`
2 parents 7d28186 + 92de868 commit 57af1ee

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/lrama/grammar/stdlib.y

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
**********************************************************************/
1010

11+
%%
12+
1113
// -------------------------------------------------------------------
1214
// Options
1315

@@ -138,7 +140,3 @@
138140
%rule separated_list(separator, X)
139141
: option(separated_nonempty_list(separator, X))
140142
;
141-
142-
%%
143-
144-
%union{};

template/bison/_yacc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ extern int yydebug;
2828
<%-# b4_declare_yylstype -%>
2929
<%-# b4_value_type_define -%>
3030
/* Value type. */
31+
<% if output.grammar.union %>
3132
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
3233
union YYSTYPE
3334
{
@@ -40,6 +41,13 @@ typedef union YYSTYPE YYSTYPE;
4041
# define YYSTYPE_IS_TRIVIAL 1
4142
# define YYSTYPE_IS_DECLARED 1
4243
#endif
44+
<% else %>
45+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
46+
typedef int YYSTYPE;
47+
# define YYSTYPE_IS_TRIVIAL 1
48+
# define YYSTYPE_IS_DECLARED 1
49+
#endif
50+
<% end %>
4351

4452
<%-# b4_location_type_define -%>
4553
/* Location type. */

0 commit comments

Comments
 (0)