From 6f0a6f274c8650520003b6408684a3f0bcdece5c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 27 Dec 2012 10:01:58 +0100 Subject: [PATCH] skeletons: fix comments The commit 38de4e570fdc7c8db9633c3b2054e565d8c1c6b9 underquoted the content of the comments, which resulted in losing square brackets in the comments. Besides, some other invocations were underquoting the effective arguments. * data/c.m4 (b4_comment_): Properly quote the comment. (b4_comment_, b4_comment): Move to... * data/c-like.m4: here, so that... * data/java.m4: can use it instead of its own copy. * data/bison.m4 (b4_integral_parser_tables_map): Fix some comments. * data/lalr1.cc, data/lalr1.java, data/yacc.c: Comment fixes. * data/lalr1.cc: Reorder a bit to factor some CPP directives. --- data/bison.m4 | 12 ++++++------ data/c-like.m4 | 22 ++++++++++++++++++++++ data/c.m4 | 20 -------------------- data/java.m4 | 8 +------- data/lalr1.cc | 11 ++++------- data/lalr1.java | 6 +++--- data/yacc.c | 2 +- 7 files changed, 37 insertions(+), 44 deletions(-) diff --git a/data/bison.m4 b/data/bison.m4 index 0697529..23273ce 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -250,30 +250,30 @@ m4_define([b4_integral_parser_tables_map], STATE-NUM.]]) $1([defact], [b4_defact], - [[YYDEFACT[S] -- default reduction number in state S. Performed when -YYTABLE does not specify something else to do. Zero means the default -is an error.]]) + [[YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. +Performed when YYTABLE does not specify something else to do. Zero +means the default is an error.]]) $1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]]) $1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]]) $1([table], [b4_table], - [[YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + [[YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error.]]) $1([check], [b4_check]) $1([stos], [b4_stos], - [[STOS_[STATE-NUM] -- The (internal number of the) accessing + [[YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM.]]) $1([r1], [b4_r1], [[YYR1[YYN] -- Symbol number of symbol that rule YYN derives.]]) $1([r2], [b4_r2], - [[YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.]]) + [[YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.]]) ]) diff --git a/data/c-like.m4 b/data/c-like.m4 index 732d18d..c8cd46b 100644 --- a/data/c-like.m4 +++ b/data/c-like.m4 @@ -17,6 +17,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# b4_comment_(TEXT, OPEN, CONTINUE, END) +# -------------------------------------- +# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. +# Avoid adding indentation to the first line, as the indentation comes +# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]). +# +# Prefix all the output lines with PREFIX. +m4_define([b4_comment_], +[$2[]m4_bpatsubst(m4_expand([[$1]]), [ +\(.\)], [ +$3\1])$4]) + + +# b4_comment(TEXT, [PREFIX]) +# -------------------------- +# Put TEXT in comment. Prefix all the output lines with PREFIX. +m4_define([b4_comment], +[b4_comment_([$1], [$2/* ], [$2 ], [ */])]) + + + + # b4_dollar_dollar_(VALUE, FIELD, DEFAULT-FIELD) # ---------------------------------------------- # If FIELD (or DEFAULT-FIELD) is non-null, return "VALUE.FIELD", diff --git a/data/c.m4 b/data/c.m4 index 9342ebe..accf047 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -51,26 +51,6 @@ m4_define([b4_cpp_guard_close], ## Identification. ## ## ---------------- ## -# b4_comment_(TEXT, OPEN, CONTINUE, END) -# -------------------------------------- -# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines. -# Avoid adding indentation to the first line, as the indentation comes -# from OPEN. That's why we don't patsubst([$1], [^\(.\)], [ \1]). -# -# Prefix all the output lines with PREFIX. -m4_define([b4_comment_], -[$2[]m4_bpatsubst(m4_expand([$1]), [ -\(.\)], [ -$3\1])$4]) - - -# b4_comment(TEXT, [PREFIX]) -# -------------------------- -# Put TEXT in comment. Prefix all the output lines with PREFIX. -m4_define([b4_comment], -[b4_comment_([$1], [$2/* ], [$2 ], [ */])]) - - # b4_identification # ----------------- # Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or diff --git a/data/java.m4 b/data/java.m4 index 90d01b3..2be2359 100644 --- a/data/java.m4 +++ b/data/java.m4 @@ -19,15 +19,9 @@ m4_include(b4_pkgdatadir/[c-like.m4]) -# b4_comment(TEXT) -# ---------------- -m4_define([b4_comment], [/* m4_bpatsubst([$1], [ -], [ - ]) */]) - # b4_list2(LIST1, LIST2) -# -------------------------- +# ---------------------- # Join two lists with a comma if necessary. m4_define([b4_list2], [$1[]m4_ifval(m4_quote($1), [m4_ifval(m4_quote($2), [[, ]])])[]$2]) diff --git a/data/lalr1.cc b/data/lalr1.cc index c51f05c..91cb5cf 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -227,6 +227,9 @@ b4_location_define])])[ static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_; static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_; + /// Convert a scanner token number \a t to a symbol number. + static inline token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t); + // Tables. ]b4_parser_tables_declare[]b4_error_verbose_if([ @@ -238,7 +241,7 @@ b4_location_define])])[ static const char* const yytname_[]; ]b4_token_table_if([[#if ]b4_api_PREFIX[DEBUG]])[ ]b4_integral_parser_table_declare([rline], [b4_rline], - [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ + [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[ /// Report on the debug stream that the rule \a r is going to be reduced. virtual void yy_reduce_print_ (int r); /// Print the state stack on the debug stream. @@ -247,12 +250,7 @@ b4_location_define])])[ // Debugging. int yydebug_; std::ostream* yycdebug_; -#endif // ]b4_api_PREFIX[DEBUG - /// Convert a scanner token number \a t to a symbol number. - static inline token_number_type yytranslate_ (]b4_token_ctor_if([token_type], [int])[ t); - -#if ]b4_api_PREFIX[DEBUG /// \brief Display a symbol type, value and location. /// \param yyo The output stream. /// \param yysym The symbol. @@ -269,7 +267,6 @@ b4_location_define])])[ inline void yy_destroy_ (const char* yymsg, symbol_base_type& yysym) const; - private: /// Element of the stack: a state and its attributes. struct stack_symbol_type : symbol_base_type { diff --git a/data/lalr1.java b/data/lalr1.java index 02079fd..3474b80 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -815,15 +815,15 @@ b4_dollar_popdef])[]dnl ]b4_parser_tables_define[ ]b4_integral_parser_table_define([token_number], [b4_toknum], - [TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding - to YYLEX-NUM.])[ + [[YYTOKEN_NUMBER[YYLEX-NUM] -- Internal symbol number corresponding + to YYLEX-NUM.]])[ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at \a yyntokens_, nonterminals. */ ]b4_typed_parser_table_define([String], [tname], [b4_tname])[ ]b4_integral_parser_table_define([rline], [b4_rline], - [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ + [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[ // Report on the debug stream that the rule yyrule is going to be reduced. private void yy_reduce_print (int yyrule, YYStack yystack) diff --git a/data/yacc.c b/data/yacc.c index 66acbda..9b227ae 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -604,7 +604,7 @@ static const ]b4_int_type_for([b4_translate])[ yytranslate[] = #if ]b4_api_PREFIX[DEBUG ]b4_integral_parser_table_define([rline], [b4_rline], - [YYRLINE[YYN] -- Source line where rule number YYN was defined.])[ + [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[ #endif #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[ -- 2.7.4