From 85f0b29e6d2d1c8a49df9f378e2979c043a47827 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Jul 2012 15:49:28 +0200 Subject: [PATCH] lalr1.cc: no longer require %defines. * data/lalr1.cc: Generate the parser header only when %defines is passed. * tests/calc.at: Check it. --- data/lalr1.cc | 11 +++++++++-- tests/calc.at | 8 ++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/data/lalr1.cc b/data/lalr1.cc index 3d6bdca9..57922578 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -336,7 +336,8 @@ b4_public_types_define])[ # We do want M4 expansion after # for CPP macros. m4_changecom() -m4_divert_push(0)dnl +b4_defines_if( +[m4_divert_push(0)dnl @output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) [ @@ -350,6 +351,11 @@ b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++]) ]b4_cpp_guard_open([b4_spec_defines_file])[ ]b4_shared_declarations[ ]b4_cpp_guard_close([b4_spec_defines_file]) +m4_divert_pop(0)dnl +]) + + +m4_divert_push(0)dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++]) b4_percent_code_get([[top]])[]dnl @@ -363,7 +369,8 @@ m4_if(b4_prefix, [yy], [], ]b4_null_define[ -#include "@basename(]b4_spec_defines_file[@)" +]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]], + [b4_shared_declarations])[ /* User implementation prologue. */ ]b4_user_post_prologue[ diff --git a/tests/calc.at b/tests/calc.at index 1eac92a1..8d0fcb39 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -693,12 +693,12 @@ AT_CHECK_CALC([%skeleton "lalr1.cc" %defines]) # Start a testing chunk which compiles `calc' grammar with # the C++ skeleton, and performs several tests over the parser. m4_define([AT_CHECK_CALC_LALR1_CC], -[AT_CHECK_CALC([%language "C++" %defines] $@)]) +[AT_CHECK_CALC([%language "C++"] $@)]) AT_CHECK_CALC_LALR1_CC([]) AT_CHECK_CALC_LALR1_CC([%locations]) AT_CHECK_CALC_LALR1_CC([%locations %define location_type Span]) -AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) @@ -706,10 +706,10 @@ AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-pref AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) AT_CHECK_CALC_LALR1_CC([%pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) -AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) -- 2.45.2