mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
Sometimes, understanding the derivations is difficult, because they
are serialized to fit in one line. For instance, the example taken
from the NEWS file:
%token ID
%%
s: a ID
a: expr
expr: expr ID ',' | "expr"
gave
First example expr • ID ',' ID $end
Shift derivation $accept → [ s → [ a → [ expr → [ expr • ID ',' ] ] ID ] $end ]
Second example expr • ID $end
Reduce derivation $accept → [ s → [ a → [ expr • ] ID ] $end ]
Printing as trees, it gives:
First example expr • ID ',' ID $end
Shift derivation
$accept
↳ s $end
↳ a ID
↳ expr
↳ expr • ID ','
Second example expr • ID $end
Reduce derivation
$accept
↳ s $end
↳ a ID
↳ expr •
* src/glyphs.h, src/glyphs.c (down_arrow, empty, derivation_separator):
New.
* src/derivation.c (derivation_print, derivation_print_impl): Rename
as...
(derivation_print_flat, derivation_print_flat_impl): These.
(fputs_if, derivation_depth, derivation_width, derivation_print_tree)
(derivation_print_tree_impl, derivation_print): New.
* src/counterexample.c (print_counterexample): Adjust.
* tests/conflicts.at, tests/counterexample.at, tests/diagnostics.at,
* tests/report.at: Adjust.
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/* Graphical symbols.
|
|
|
|
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
|
|
This file is part of Bison, the GNU Compiler Compiler.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef GLYPHS_H
|
|
# define GLYPHS_H
|
|
|
|
/* Initialize the following variables. */
|
|
void glyphs_init (void);
|
|
|
|
/* "→", separates the lhs of a rule from its rhs. */
|
|
extern const char *arrow;
|
|
extern int arrow_width;
|
|
|
|
/* "•", a point in an item (aka, a dotted rule). */
|
|
extern const char *dot;
|
|
extern int dot_width;
|
|
|
|
/* "↳ ", below an lhs to announce the rhs. */
|
|
extern const char *down_arrow;
|
|
extern int down_arrow_width;
|
|
|
|
/* "ε", an empty rhs. */
|
|
extern const char *empty;
|
|
extern int empty_width;
|
|
|
|
/* " ", separate symbols in the rhs of a derivation. */
|
|
extern const char *derivation_separator;
|
|
extern int derivation_separator_width;
|
|
|
|
#endif /* GLYPHS_H */
|