diff options
author | Akim Demaille <akim@lrde.epita.fr> | 2012-11-13 10:59:55 +0100 |
---|---|---|
committer | Akim Demaille <akim@lrde.epita.fr> | 2012-11-13 10:59:55 +0100 |
commit | 06ec0105b12cdfa2994283e345154e6720354808 (patch) | |
tree | 845bbd1beeb65fc84d85f5cb3c78e506f73464b8 | |
parent | 2c08dc504c9f4ed12414a130bcebff8f0d3f43df (diff) | |
parent | 05c93b7d844e59ecaa5dec3bd6d9091f5aa5d1b0 (diff) | |
download | bison-06ec0105b12cdfa2994283e345154e6720354808.tar.gz |
Merge remote-tracking branch 'origin/maint'
* origin/maint:
tests: close files in glr-regression
xml: match DOT output and xml2dot.xsl processing
xml: factor xslt space template
graph: fix a memory leak
xml: documentation
output: capitalize State
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | data/xslt/bison.xsl | 12 | ||||
-rw-r--r-- | data/xslt/xml2dot.xsl | 185 | ||||
-rw-r--r-- | data/xslt/xml2text.xsl | 52 | ||||
-rw-r--r-- | doc/bison.texi | 53 | ||||
-rw-r--r-- | src/graphviz.c | 35 | ||||
-rw-r--r-- | src/print.c | 2 | ||||
-rw-r--r-- | src/print_graph.c | 7 | ||||
-rw-r--r-- | tests/conflicts.at | 64 | ||||
-rw-r--r-- | tests/existing.at | 40 | ||||
-rw-r--r-- | tests/glr-regression.at | 16 | ||||
-rw-r--r-- | tests/local.at | 8 | ||||
-rw-r--r-- | tests/output.at | 322 | ||||
-rw-r--r-- | tests/reduce.at | 198 | ||||
-rw-r--r-- | tests/regression.at | 44 | ||||
-rw-r--r-- | tests/sets.at | 22 |
16 files changed, 654 insertions, 413 deletions
@@ -282,7 +282,7 @@ GNU Bison NEWS position_type are deprecated in favor of api.location.type and api.position.type. -** Graphviz improvements +** Graph improvements in DOT and XSLT The graphical presentation of the states is more readable: their shape is now rectangular, the state number is clearly displayed, and the items are @@ -291,6 +291,11 @@ GNU Bison NEWS The reductions are now explicitly represented as transitions to other diamond shaped nodes. + These changes are present in both --graph output and xml2dot.xsl XSLT + processing, with minor (documented) differences. + + Two nodes were added to the documentation: Xml and Graphviz. + * Noteworthy changes in release 2.6.5 (2012-11-07) [stable] We consider compiler warnings about Bison generated parsers to be bugs. diff --git a/data/xslt/bison.xsl b/data/xslt/bison.xsl index 353c75a0..40575efd 100644 --- a/data/xslt/bison.xsl +++ b/data/xslt/bison.xsl @@ -90,4 +90,16 @@ <xsl:value-of select="string-length(translate($conflict-data, 's', ''))"/> </xsl:template> +<xsl:template name="space"> + <xsl:param name="repeat">0</xsl:param> + <xsl:param name="fill" select="' '"/> + <xsl:if test="number($repeat) >= 1"> + <xsl:call-template name="space"> + <xsl:with-param name="repeat" select="$repeat - 1"/> + <xsl:with-param name="fill" select="$fill"/> + </xsl:call-template> + <xsl:value-of select="$fill"/> + </xsl:if> +</xsl:template> + </xsl:stylesheet> diff --git a/data/xslt/xml2dot.xsl b/data/xslt/xml2dot.xsl index 111613ce..dceb8e1e 100644 --- a/data/xslt/xml2dot.xsl +++ b/data/xslt/xml2dot.xsl @@ -55,7 +55,7 @@ <xsl:call-template name="escape"> <xsl:with-param name="subject" select="$filename"/> </xsl:call-template> - <xsl:text> { + <xsl:text>" { node [fontname = courier, shape = box, colorscheme = paired6] edge [fontname = courier] @@ -68,11 +68,87 @@ <xsl:call-template name="output-node"> <xsl:with-param name="number" select="@number"/> <xsl:with-param name="label"> - <xsl:value-of select="@number"/> <xsl:apply-templates select="itemset/item"/> </xsl:with-param> </xsl:call-template> <xsl:apply-templates select="actions/transitions"/> + <xsl:apply-templates select="actions/reductions"> + <xsl:with-param name="staten"> + <xsl:value-of select="@number"/> + </xsl:with-param> + </xsl:apply-templates> +</xsl:template> + +<xsl:template match="actions/reductions"> + <xsl:param name="staten"/> + <xsl:for-each select='reduction'> + <!-- These variables are needed because the current context can't be + refered to directly in XPath expressions. --> + <xsl:variable name="rul"> + <xsl:value-of select="@rule"/> + </xsl:variable> + <xsl:variable name="ena"> + <xsl:value-of select="@enabled"/> + </xsl:variable> + <!-- The foreach's body is protected by this, so that we are actually + going to iterate once per reduction rule, and not per lookahead. --> + <xsl:if test='not(preceding-sibling::*[@rule=$rul and @enabled=$ena])'> + <xsl:variable name="rule"> + <xsl:choose> + <!-- The acceptation state is refered to as 'accept' in the XML, but + just as '0' in the DOT. --> + <xsl:when test="@rule='accept'"> + <xsl:text>0</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@rule"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- The edge's beginning --> + <xsl:call-template name="reduction-edge-start"> + <xsl:with-param name="state" select="$staten"/> + <xsl:with-param name="rule" select="$rule"/> + <xsl:with-param name="enabled" select="@enabled"/> + </xsl:call-template> + + <!-- The edge's tokens --> + <!-- Don't show labels for the default action. In other cases, there will + always be at least one token, so 'label="[]"' will not occur. --> + <xsl:if test='$rule!=0 and not(../reduction[@enabled=$ena and @rule=$rule and @symbol="$default"])'> + <xsl:text>label="[</xsl:text> + <xsl:for-each select='../reduction[@enabled=$ena and @rule=$rule]'> + <xsl:call-template name="escape"> + <xsl:with-param name="subject" select="@symbol"/> + </xsl:call-template> + <xsl:if test="position() != last ()"> + <xsl:text>, </xsl:text> + </xsl:if> + </xsl:for-each> + <xsl:text>]", </xsl:text> + </xsl:if> + + <!-- The edge's end --> + <xsl:text>style=solid] </xsl:text> + + <!-- The diamond representing the reduction --> + <xsl:call-template name="reduction-node"> + <xsl:with-param name="state" select="$staten"/> + <xsl:with-param name="rule" select="$rule"/> + <xsl:with-param name="color"> + <xsl:choose> + <xsl:when test='@enabled="true"'> + <xsl:text>3</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>5</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:if> + </xsl:for-each> </xsl:template> <xsl:template match="actions/transitions"> @@ -80,17 +156,48 @@ </xsl:template> <xsl:template match="item"> + <xsl:param name="prev-rule-number" + select="preceding-sibling::item[1]/@rule-number"/> <xsl:apply-templates select="key('bison:ruleByNumber', @rule-number)"> <xsl:with-param name="point" select="@point"/> + <xsl:with-param name="num" select="@rule-number"/> + <xsl:with-param name="prev-lhs" + select="key('bison:ruleByNumber', $prev-rule-number)/lhs[text()]" + /> </xsl:apply-templates> <xsl:apply-templates select="lookaheads"/> </xsl:template> <xsl:template match="rule"> <xsl:param name="point"/> + <xsl:param name="num"/> + <xsl:param name="prev-lhs"/> <xsl:text> </xsl:text> - <xsl:value-of select="lhs"/> - <xsl:text> -></xsl:text> + <xsl:choose> + <xsl:when test="$num < 10"> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:when test="$num < 100"> + <xsl:text> </xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text></xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:value-of select="$num"/> + <xsl:text> </xsl:text> + <xsl:choose> + <xsl:when test="$prev-lhs = lhs[text()]"> + <xsl:call-template name="lpad"> + <xsl:with-param name="str" select="'|'"/> + <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="lhs"/> + <xsl:text>:</xsl:text> + </xsl:otherwise> + </xsl:choose> <xsl:if test="$point = 0"> <xsl:text> .</xsl:text> </xsl:if> @@ -110,7 +217,7 @@ <xsl:template match="empty"/> <xsl:template match="lookaheads"> - <xsl:text>[</xsl:text> + <xsl:text> [</xsl:text> <xsl:apply-templates select="symbol"/> <xsl:text>]</xsl:text> </xsl:template> @@ -122,6 +229,50 @@ </xsl:if> </xsl:template> +<xsl:template name="reduction-edge-start"> + <xsl:param name="state"/> + <xsl:param name="rule"/> + <xsl:param name="enabled"/> + + <xsl:text> </xsl:text> + <xsl:value-of select="$state"/> + <xsl:text> -> "</xsl:text> + <xsl:value-of select="$state"/> + <xsl:text>R</xsl:text> + <xsl:value-of select="$rule"/> + <xsl:if test='$enabled = "false"'> + <xsl:text>d</xsl:text> + </xsl:if> + <xsl:text>" [</xsl:text> +</xsl:template> + +<xsl:template name="reduction-node"> + <xsl:param name="state"/> + <xsl:param name="rule"/> + <xsl:param name="color"/> + + <xsl:text> "</xsl:text> + <xsl:value-of select="$state"/> + <xsl:text>R</xsl:text> + <xsl:value-of select="$rule"/> + <xsl:if test="$color = 5"> + <xsl:text>d</xsl:text> + </xsl:if> + <xsl:text>" [label="</xsl:text> + <xsl:choose> + <xsl:when test="$rule = 0"> + <xsl:text>Acc", fillcolor=1</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>R</xsl:text> + <xsl:value-of select="$rule"/> + <xsl:text>", fillcolor=</xsl:text> + <xsl:value-of select="$color"/> + </xsl:otherwise> + </xsl:choose> + <xsl:text>, shape=diamond, style=filled] </xsl:text> +</xsl:template> + <xsl:template match="transition"> <xsl:call-template name="output-edge"> <xsl:with-param name="src" select="../../../@number"/> @@ -153,10 +304,13 @@ <xsl:text> </xsl:text> <xsl:value-of select="$number"/> <xsl:text> [label="</xsl:text> + <xsl:text>State </xsl:text> + <xsl:value-of select="$number"/> + <xsl:text>\n</xsl:text> <xsl:call-template name="escape"> <xsl:with-param name="subject" select="$label"/> </xsl:call-template> - <xsl:text>"] </xsl:text> + <xsl:text>\l"] </xsl:text> </xsl:template> <xsl:template name="output-edge"> @@ -197,7 +351,7 @@ </xsl:call-template> </xsl:with-param> <xsl:with-param name="search" select="' '"/> - <xsl:with-param name="replace" select="'\n'"/> + <xsl:with-param name="replace" select="'\l'"/> </xsl:call-template> </xsl:template> @@ -223,4 +377,21 @@ </xsl:choose> </xsl:template> +<xsl:template name="lpad"> + <xsl:param name="str" select="''"/> + <xsl:param name="pad" select="0"/> + <xsl:variable name="diff" select="$pad - string-length($str)" /> + <xsl:choose> + <xsl:when test="$diff < 0"> + <xsl:value-of select="$str"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="space"> + <xsl:with-param name="repeat" select="$diff"/> + </xsl:call-template> + <xsl:value-of select="$str"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + </xsl:stylesheet> diff --git a/data/xslt/xml2text.xsl b/data/xslt/xml2text.xsl index d776bb17..8b3f5ae4 100644 --- a/data/xslt/xml2text.xsl +++ b/data/xslt/xml2text.xsl @@ -230,7 +230,7 @@ <xsl:template match="automaton/state"> <xsl:param name="pad"/> <xsl:text> </xsl:text> - <xsl:text>state </xsl:text> + <xsl:text>State </xsl:text> <xsl:value-of select="@number"/> <xsl:text> </xsl:text> <xsl:apply-templates select="itemset/item"> @@ -253,9 +253,9 @@ <xsl:text> </xsl:text> <xsl:apply-templates select="transition[@type = $type]"> <xsl:with-param name="pad"> - <xsl:call-template name="max-width-symbol"> - <xsl:with-param name="node" select="transition[@type = $type]"/> - </xsl:call-template> + <xsl:call-template name="max-width-symbol"> + <xsl:with-param name="node" select="transition[@type = $type]"/> + </xsl:call-template> </xsl:with-param> </xsl:apply-templates> </xsl:if> @@ -266,9 +266,9 @@ <xsl:text> </xsl:text> <xsl:apply-templates select="error"> <xsl:with-param name="pad"> - <xsl:call-template name="max-width-symbol"> - <xsl:with-param name="node" select="error"/> - </xsl:call-template> + <xsl:call-template name="max-width-symbol"> + <xsl:with-param name="node" select="error"/> + </xsl:call-template> </xsl:with-param> </xsl:apply-templates> </xsl:if> @@ -279,9 +279,9 @@ <xsl:text> </xsl:text> <xsl:apply-templates select="reduction"> <xsl:with-param name="pad"> - <xsl:call-template name="max-width-symbol"> - <xsl:with-param name="node" select="reduction"/> - </xsl:call-template> + <xsl:call-template name="max-width-symbol"> + <xsl:with-param name="node" select="reduction"/> + </xsl:call-template> </xsl:with-param> </xsl:apply-templates> </xsl:if> @@ -290,7 +290,7 @@ <xsl:template match="item"> <xsl:param name="pad"/> <xsl:param name="prev-rule-number" - select="preceding-sibling::item[1]/@rule-number"/> + select="preceding-sibling::item[1]/@rule-number"/> <xsl:apply-templates select="key('bison:ruleByNumber', current()/@rule-number)" > @@ -329,14 +329,14 @@ <xsl:choose> <xsl:when test="$itemset != 'true' and $prev-lhs = lhs[text()]"> <xsl:call-template name="lpad"> - <xsl:with-param name="str" select="'|'"/> - <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/> + <xsl:with-param name="str" select="'|'"/> + <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/> </xsl:call-template> </xsl:when> <xsl:when test="$itemset = 'true' and $prev-lhs = lhs[text()]"> <xsl:call-template name="lpad"> - <xsl:with-param name="str" select="'|'"/> - <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/> + <xsl:with-param name="str" select="'|'"/> + <xsl:with-param name="pad" select="number(string-length(lhs[text()])) + 1"/> </xsl:call-template> </xsl:when> <xsl:otherwise> @@ -442,7 +442,7 @@ <xsl:value-of select="@rule"/> <xsl:text> (</xsl:text> <xsl:value-of - select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/> + select="key('bison:ruleByNumber', current()/@rule)/lhs[text()]"/> <xsl:text>)</xsl:text> </xsl:otherwise> </xsl:choose> @@ -479,9 +479,9 @@ <xsl:variable name="longest"> <xsl:for-each select="$node"> <xsl:sort data-type="number" select="string-length(@symbol)" - order="descending"/> + order="descending"/> <xsl:if test="position() = 1"> - <xsl:value-of select="string-length(@symbol)"/> + <xsl:value-of select="string-length(@symbol)"/> </xsl:if> </xsl:for-each> </xsl:variable> @@ -498,7 +498,7 @@ </xsl:when> <xsl:otherwise> <xsl:call-template name="space"> - <xsl:with-param name="repeat" select="$diff"/> + <xsl:with-param name="repeat" select="$diff"/> </xsl:call-template> <xsl:value-of select="$str"/> </xsl:otherwise> @@ -516,24 +516,12 @@ <xsl:otherwise> <xsl:value-of select="$str"/> <xsl:call-template name="space"> - <xsl:with-param name="repeat" select="$diff"/> + <xsl:with-param name="repeat" select="$diff"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> -<xsl:template name="space"> - <xsl:param name="repeat">0</xsl:param> - <xsl:param name="fill" select="' '"/> - <xsl:if test="number($repeat) >= 1"> - <xsl:call-template name="space"> - <xsl:with-param name="repeat" select="$repeat - 1"/> - <xsl:with-param name="fill" select="$fill"/> - </xsl:call-template> - <xsl:value-of select="$fill"/> - </xsl:if> -</xsl:template> - <xsl:template name="line-wrap"> <xsl:param name="line-length"/> <!-- required --> <xsl:param name="first-line-length" select="$line-length"/> diff --git a/doc/bison.texi b/doc/bison.texi index 9b7b14fd..6a35422b 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -299,6 +299,7 @@ Debugging Your Parser * Understanding:: Understanding the structure of your parser. * Graphviz:: Getting a visual representation of the parser. +* Xml:: Getting a markup representation of the parser. * Tracing:: Tracing the execution of your parser. Tracing Your Parser @@ -8426,6 +8427,7 @@ automaton, and how to enable and understand the parser run-time traces. @menu * Understanding:: Understanding the structure of your parser. * Graphviz:: Getting a visual representation of the parser. +* Xml:: Getting a markup representation of the parser. * Tracing:: Tracing the execution of your parser. @end menu @@ -8842,6 +8844,9 @@ precedence of @samp{/} with respect to @samp{+}, @samp{-}, and @samp{*}, but also because the associativity of @samp{/} is not specified. +Note that Bison may also produce an HTML version of this output, via an XML +file and XSLT processing (@pxref{Xml}). + @c ================================================= Graphical Representation @node Graphviz @@ -8949,6 +8954,54 @@ is shown as a blue diamond, labelled "Acc". The @samp{go to} jump transitions are represented as dotted lines bearing the name of the rule being jumped to. +Note that a DOT file may also be produced via an XML file and XSLT +processing (@pxref{Xml}). + +@c ================================================= XML + +@node Xml +@section Visualizing your parser in multiple formats +@cindex xml + +Bison supports two major report formats: textual output +(@pxref{Understanding}) when invoked with option @option{--verbose}, and DOT +(@pxref{Graphviz}) when invoked with option @option{--graph}. However, +another alternative is to output an XML file that may then be, with +@command{xsltproc}, rendered as either a raw text format equivalent to the +verbose file, or as an HTML version of the same file, with clickable +transitions, or even as a DOT. The @file{.output} and DOT files obtained via +XSLT have no difference whatsoever with those obtained by invoking +@command{bison} with options @option{--verbose} or @option{--graph}. + +The textual file is generated when the options @option{-x} or +@option{--xml[=FILE]} are specified, see @ref{Invocation,,Invoking Bison}. +If not specified, its name is made by removing @samp{.tab.c} or @samp{.c} +from the parser implementation file name, and adding @samp{.xml} instead. +For instance, if the grammar file is @file{foo.y}, the default XML output +file is @file{foo.xml}. + +Bison ships with a @file{data/xslt} directory, containing XSL Transformation +files to apply to the XML file. Their names are non-ambiguous: + +@table @file +@item xml2dot.xsl +Used to output a copy of the DOT visualization of the automaton. +@item xml2text.xsl +Used to output a copy of the .output file. +@item xml2xhtml.xsl +Used to output an xhtml enhancement of the .output file. +@end table + +Sample usage (requires @code{xsltproc}): +@example +$ bison -x input.y +@group +$ bison --print-datadir +/usr/local/share/bison +@end group +$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl input.xml > input.html +@end example + @c ================================================= Tracing @node Tracing diff --git a/src/graphviz.c b/src/graphviz.c index 3ae0b546..16ea8b9e 100644 --- a/src/graphviz.c +++ b/src/graphviz.c @@ -106,7 +106,7 @@ conclude_red (struct obstack *out, int source, rule_number ruleno, return (void) obstack_finish0 (out); else { - char const *ed = enabled ? "e" : "d"; + char const *ed = enabled ? "" : "d"; char const *color = enabled ? ruleno ? "3" : "1" : "5"; /* First, build the edge's head. The name of reduction nodes is "nRm", @@ -116,24 +116,28 @@ conclude_red (struct obstack *out, int source, rule_number ruleno, fprintf (fout, " %1$d -> \"%1$dR%2$d%3$s\" [", source, ruleno, ed); + /* (The lookahead tokens have been added to the beginning of the + obstack, in the caller function.) */ if (! obstack_empty_p (out)) - /* (The lookahead tokens have been added to the beginning of the - obstack, in the caller function.) */ - fprintf (fout, "label = \"[%s]\" ", obstack_finish0 (out)); + { + char *label = obstack_finish0 (out); + fprintf (fout, "label=\"[%s]\", ", label); + obstack_free (out, label); + } /* Then, the edge's tail. */ - fprintf (fout, "style = solid]\n"); + fprintf (fout, "style=solid]\n"); /* Build the associated diamond representation of the target rule. */ - fprintf (fout, " \"%dR%d%s\" [style = filled, " - "shape = diamond, fillcolor = %s, ", - source, ruleno, ed, color); - - if (ruleno) - fprintf (fout, "label = \"R%d\"]\n", ruleno); + fprintf (fout, " \"%dR%d%s\" [label=\"", + source, ruleno, ed); + if (ruleno) + fprintf (fout, "R%d", ruleno); else - fprintf (fout, "label = \"Acc\"]\n"); + fprintf (fout, "Acc"); + fprintf (fout, "\", fillcolor=%s, shape=diamond, style=filled]\n", + color); } } @@ -171,7 +175,7 @@ output_red (state const *s, reductions const *reds, FILE *fout) bool defaulted = false; bool firstd = true; bool firste = true; - rule_number ruleno = reds->rules[j]->user_number; + rule_number ruleno = reds->rules[j]->number; rule *default_reduction = NULL; if (yydefact[s->number] != 0) @@ -199,11 +203,12 @@ output_red (state const *s, reductions const *reds, FILE *fout) } /* Do the actual output. */ - conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout); conclude_red (&dout, source, ruleno, false, firstd, fout); + conclude_red (&eout, source, ruleno, true, firste && !defaulted, fout); } - obstack_free (&eout, 0); obstack_free (&dout, 0); + obstack_free (&eout, 0); + bitset_free (no_reduce_set); } void diff --git a/src/print.c b/src/print.c index f21aade5..2eecae4c 100644 --- a/src/print.c +++ b/src/print.c @@ -370,7 +370,7 @@ static void print_state (FILE *out, state *s) { fputs ("\n\n", out); - fprintf (out, _("state %d"), s->number); + fprintf (out, _("State %d"), s->number); fputc ('\n', out); print_core (out, s); print_actions (out, s); diff --git a/src/print_graph.c b/src/print_graph.c index 918a3df8..31e0e382 100644 --- a/src/print_graph.c +++ b/src/print_graph.c @@ -77,7 +77,7 @@ print_core (struct obstack *oout, state *s) } obstack_printf (oout, _("State %d"), s->number); - obstack_sgrow (oout, "\\n"); + obstack_sgrow (oout, "\\n\\l"); for (i = 0; i < snritems; i++) { item_number *sp; @@ -143,9 +143,6 @@ print_actions (state const *s, FILE *fgraph) transitions const *trans = s->transitions; int i; - /* Display reductions. */ - output_red (s, s->reductions, fgraph); - if (!trans->num && !s->reductions) return; @@ -168,6 +165,8 @@ print_actions (state const *s, FILE *fgraph) TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag, style, fgraph); } + /* Display reductions. */ + output_red (s, s->reductions, fgraph); } diff --git a/tests/conflicts.at b/tests/conflicts.at index 37c54050..8b04449c 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -574,7 +574,7 @@ exp (6) on left: 1 2, on right: 0 1 -state 0 +State 0 0 $accept: . exp $end 1 exp: . exp OP exp @@ -585,14 +585,14 @@ state 0 exp go to state 2 -state 1 +State 1 2 exp: NUM . $default reduce using rule 2 (exp) -state 2 +State 2 0 $accept: exp . $end 1 exp: exp . OP exp @@ -601,14 +601,14 @@ state 2 OP shift, and go to state 4 -state 3 +State 3 0 $accept: exp $end . $default accept -state 4 +State 4 1 exp: . exp OP exp 1 | exp OP . exp @@ -619,7 +619,7 @@ state 4 exp go to state 5 -state 5 +State 5 1 exp: exp . OP exp 1 | exp OP exp . [$end, OP] @@ -677,7 +677,7 @@ exp (6) on left: 1 2, on right: 0 1 -state 0 +State 0 0 $accept: . exp $end 1 exp: . exp OP exp @@ -688,14 +688,14 @@ state 0 exp go to state 2 -state 1 +State 1 2 exp: NUM . $default reduce using rule 2 (exp) -state 2 +State 2 0 $accept: exp . $end 1 exp: exp . OP exp @@ -704,14 +704,14 @@ state 2 OP shift, and go to state 4 -state 3 +State 3 0 $accept: exp $end . $default accept -state 4 +State 4 1 exp: . exp OP exp 1 | exp OP . exp @@ -722,7 +722,7 @@ state 4 exp go to state 5 -state 5 +State 5 1 exp: exp . OP exp 1 | exp OP exp . [$end, OP] @@ -873,7 +873,7 @@ id (7) on left: 4, on right: 2 -state 0 +State 0 0 $accept: . exp $end 1 exp: . num @@ -888,7 +888,7 @@ state 0 id go to state 4 -state 1 +State 1 3 num: '0' . [$end] 4 id: '0' . [$end] @@ -898,28 +898,28 @@ state 1 $default reduce using rule 3 (num) -state 2 +State 2 0 $accept: exp . $end $end shift, and go to state 5 -state 3 +State 3 1 exp: num . $default reduce using rule 1 (exp) -state 4 +State 4 2 exp: id . $default reduce using rule 2 (exp) -state 5 +State 5 0 $accept: exp $end . @@ -1218,7 +1218,7 @@ reported_conflicts (9) on left: 8 9 10, on right: 1 -state 0 +State 0 0 $accept: . start $end 1 start: . resolved_conflict 'a' reported_conflicts 'a' @@ -1233,28 +1233,28 @@ state 0 Conflict between rule 3 and token 'a' resolved as reduce (%left 'a'). -state 1 +State 1 0 $accept: start . $end $end shift, and go to state 3 -state 2 +State 2 1 start: resolved_conflict . 'a' reported_conflicts 'a' 'a' shift, and go to state 4 -state 3 +State 3 0 $accept: start $end . $default accept -state 4 +State 4 1 start: resolved_conflict 'a' . reported_conflicts 'a' 8 reported_conflicts: . 'a' @@ -1268,7 +1268,7 @@ state 4 reported_conflicts go to state 6 -state 5 +State 5 8 reported_conflicts: 'a' . ['a'] 9 | 'a' . ['a'] @@ -1278,14 +1278,14 @@ state 5 $default reduce using rule 8 (reported_conflicts) -state 6 +State 6 1 start: resolved_conflict 'a' reported_conflicts . 'a' 'a' shift, and go to state 7 -state 7 +State 7 1 start: resolved_conflict 'a' reported_conflicts 'a' . @@ -1340,8 +1340,8 @@ empty_c2: %prec 'c' ; empty_c3: %prec 'd' ; ]]) AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore]) -AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0, -[[state 0 +AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0, +[[State 0 0 $accept: . start $end 1 start: . 'a' @@ -1377,7 +1377,7 @@ AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0, Conflict between rule 13 and token 'c' resolved as reduce ('c' < 'd'). -state 1 +State 1 ]]) AT_CLEANUP @@ -1416,8 +1416,8 @@ empty_c3: %prec 'c' ; ]]) AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore]) -AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0, -[[state 0 +AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0, +[[State 0 0 $accept: . start $end 1 start: . 'a' @@ -1453,7 +1453,7 @@ AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0, Conflict between rule 11 and token 'c' resolved as an error (%nonassoc 'c'). -state 1 +State 1 ]]) AT_CLEANUP diff --git a/tests/existing.at b/tests/existing.at index 20dbde82..9d30479e 100644 --- a/tests/existing.at +++ b/tests/existing.at @@ -489,7 +489,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' $default reduce using rule 45 (statement) + + -+state 320 ++State 320 + + 139 non_post_simp_exp: . '!' simp_exp + 140 | . '(' exp r_paren @@ -527,7 +527,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 63 + + -+state 321 ++State 321 + + 146 non_post_simp_exp: INCREMENT . variable + 154 variable: . NAME @@ -540,7 +540,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 50 + + -+state 322 ++State 322 + + 147 non_post_simp_exp: DECREMENT . variable + 154 variable: . NAME @@ -553,7 +553,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 51 + + -+state 323 ++State 323 + + 130 simp_exp: . non_post_simp_exp + 131 | . simp_exp '^' simp_exp @@ -601,7 +601,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 57 + + -+state 324 ++State 324 + + 130 simp_exp: . non_post_simp_exp + 131 | . simp_exp '^' simp_exp @@ -649,7 +649,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 57 + + -+state 325 ++State 325 + + 130 simp_exp: . non_post_simp_exp + 131 | . simp_exp '^' simp_exp @@ -697,7 +697,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + variable go to state 57 + + -+state 326 ++State 326 + + 131 simp_exp: simp_exp . '^' simp_exp + 132 | simp_exp . '*' simp_exp @@ -718,7 +718,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + Conflict between rule 151 and token '-' resolved as reduce ('-' < UNARY). + + -+state 327 ++State 327 + + 131 simp_exp: simp_exp . '^' simp_exp + 132 | simp_exp . '*' simp_exp @@ -739,7 +739,7 @@ dnl - 61 -> 328: reduce -> shift on '*', '/', and '%' + Conflict between rule 150 and token '-' resolved as reduce ('-' < UNARY). + + -+state 328 ++State 328 + + 131 simp_exp: simp_exp . '^' simp_exp + 132 | simp_exp . '*' simp_exp @@ -2042,7 +2042,7 @@ dnl - 383 -> 427 nth_primitive go to state 105 @@ -3256,7 +3256,7 @@ - state 102 + State 102 - 146 place: label . [$end, LABEL, VARIABLE, NUMBER, TEXT, ORDINAL, LEFT_ARROW_HEAD, RIGHT_ARROW_HEAD, DOUBLE_ARROW_HEAD, LAST, UP, DOWN, LEFT, RIGHT, HEIGHT, RADIUS, WIDTH, DIAMETER, FROM, TO, AT, WITH, BY, THEN, SOLID, DOTTED, DASHED, CHOP, SAME, INVISIBLE, LJUST, RJUST, ABOVE, BELOW, AND, HERE, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, SIN, COS, ATAN2, LOG, EXP, SQRT, K_MAX, K_MIN, INT, RAND, SRAND, CW, CCW, THICKNESS, FILL, COLORED, OUTLINED, SHADED, ALIGNED, SPRINTF, '(', '`', ',', '>', '+', '-', '!', ';', '}', '@:>@', ')'] + 146 place: label . [$end, LABEL, VARIABLE, NUMBER, TEXT, ORDINAL, LEFT_ARROW_HEAD, RIGHT_ARROW_HEAD, DOUBLE_ARROW_HEAD, LAST, UP, DOWN, LEFT, RIGHT, HEIGHT, RADIUS, WIDTH, DIAMETER, FROM, TO, AT, WITH, BY, THEN, SOLID, DOTTED, DASHED, CHOP, SAME, INVISIBLE, LJUST, RJUST, ABOVE, BELOW, HERE, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, SIN, COS, ATAN2, LOG, EXP, SQRT, K_MAX, K_MIN, INT, RAND, SRAND, CW, CCW, THICKNESS, FILL, COLORED, OUTLINED, SHADED, ALIGNED, SPRINTF, '(', '`', '+', '-', '!', ';', '}', '@:>@'] @@ -2207,7 +2207,7 @@ dnl - 383 -> 427 + expr go to state 424 - state 165 + State 165 @@ -7987,7 +7987,7 @@ text_expr go to state 112 text go to state 113 @@ -2324,7 +2324,7 @@ dnl - 383 -> 427 + between go to state 425 - state 193 + State 193 @@ -10152,7 +10152,7 @@ expr_pair go to state 317 @@ -2492,7 +2492,7 @@ dnl - 383 -> 427 + expr go to state 424 - state 238 + State 238 @@ -12937,7 +12937,7 @@ '!' shift, and go to state 94 @@ -2579,7 +2579,7 @@ dnl - 383 -> 427 + expr go to state 424 - state 315 + State 315 @@ -16124,7 +16124,7 @@ $default reduce using rule 239 (expr) @@ -2630,7 +2630,7 @@ dnl - 383 -> 427 + expr go to state 424 - state 383 + State 383 @@ -18071,7 +18071,7 @@ '!' shift, and go to state 94 @@ -2673,7 +2673,7 @@ dnl - 383 -> 427 $default reduce using rule 29 (placeless_element) + + -+state 423 ++State 423 + + 146 place: label . [$end, AND, DOT_X, DOT_Y, DOT_HT, DOT_WID, DOT_RAD, ',', '>', '+', '-', ';', '}', '@:>@', ')'] + 147 | label . corner @@ -2744,7 +2744,7 @@ dnl - 383 -> 427 + corner go to state 205 + + -+state 424 ++State 424 + + 140 position_not_place: expr . between position AND position + 141 | expr . '<' position ',' position '>' @@ -2787,7 +2787,7 @@ dnl - 383 -> 427 + between go to state 425 + + -+state 425 ++State 425 + + 134 position: . position_not_place + 135 | . place @@ -2943,7 +2943,7 @@ dnl - 383 -> 427 + expr go to state 424 + + -+state 426 ++State 426 + + 137 position_not_place: position . '+' expr_pair + 138 | position . '-' expr_pair @@ -2954,7 +2954,7 @@ dnl - 383 -> 427 + '-' shift, and go to state 198 + + -+state 427 ++State 427 + + 134 position: . position_not_place + 135 | . place diff --git a/tests/glr-regression.at b/tests/glr-regression.at index ab6e1437..a826a5e3 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -196,8 +196,12 @@ int main (int argc, char **argv) { input = stdin; - if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3; - return yyparse (); + if (argc == 2 && !(input = fopen (argv[1], "r"))) + return 3; + int res = yyparse (); + if (argc == 2 && fclose (input)) + return 4; + return res; } ]]) AT_BISON_OPTION_POPDEFS @@ -324,8 +328,12 @@ int main(int argc, char* argv[]) { input = stdin; - if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3; - return yyparse (); + if (argc == 2 && !(input = fopen (argv[1], "r"))) + return 3; + int res = yyparse (); + if (argc == 2 && fclose (input)) + return 4; + return res; } ]]) AT_BISON_OPTION_POPDEFS diff --git a/tests/local.at b/tests/local.at index 42040829..e24c0acb 100644 --- a/tests/local.at +++ b/tests/local.at @@ -537,10 +537,10 @@ m4_define([AT_BISON_CHECK_XML], AT_CHECK([[$XSLTPROC \ `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2text.xsl \ xml-tests/test.xml]], [[0]], [expout]) - [cp xml-tests/test.dot expout] + [sort xml-tests/test.dot > expout] AT_CHECK([[$XSLTPROC \ `]]AT_QUELL_VALGRIND[[ bison --print-datadir`/xslt/xml2dot.xsl \ - xml-tests/test.xml]], [[0]], [expout]) + xml-tests/test.xml | sort]], [[0]], [expout]) [rm -rf xml-tests expout] AT_RESTORE_SPECIAL_FILES [fi]]) @@ -849,9 +849,9 @@ m4_if(m4_index(m4_quote($3), [no-xml]), -1, [0], [], m4_dquote($7)) m4_if(m4_index(m4_quote($3), [last-state]), -1, - [AT_CHECK([[sed -n '/^state 0$/,$p' input.output]], [[0]], + [AT_CHECK([[sed -n '/^State 0$/,$p' input.output]], [[0]], m4_dquote($8))], - [AT_CHECK([[sed -n 's/^state //p' input.output | tail -1]], [[0]], + [AT_CHECK([[sed -n 's/^State //p' input.output | tail -1]], [[0]], m4_dquote($8)[[ ]])]) diff --git a/tests/output.at b/tests/output.at index 81710245..4a8253a3 100644 --- a/tests/output.at +++ b/tests/output.at @@ -284,27 +284,27 @@ a: ; b: 'b'; ]], [[ - 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"] - 0 -> "0R2e" [style = solid] - "0R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] + 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a '?' b\l 2 a: .\l"] 0 -> 1 [style=dashed label="exp"] 0 -> 2 [style=dashed label="a"] - 1 [label="State 1\n 0 $accept: exp . $end\l"] + 0 -> "0R2" [style=solid] + "0R2" [label="R2", fillcolor=3, shape=diamond, style=filled] + 1 [label="State 1\n\l 0 $accept: exp . $end\l"] 1 -> 3 [style=solid label="$end"] - 2 [label="State 2\n 1 exp: a . '?' b\l"] + 2 [label="State 2\n\l 1 exp: a . '?' b\l"] 2 -> 4 [style=solid label="'?'"] - 3 [label="State 3\n 0 $accept: exp $end .\l"] - 3 -> "3R0e" [style = solid] - "3R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] - 4 [label="State 4\n 1 exp: a '?' . b\l 3 b: . 'b'\l"] + 3 [label="State 3\n\l 0 $accept: exp $end .\l"] + 3 -> "3R0" [style=solid] + "3R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] + 4 [label="State 4\n\l 1 exp: a '?' . b\l 3 b: . 'b'\l"] 4 -> 5 [style=solid label="'b'"] 4 -> 6 [style=dashed label="b"] - 5 [label="State 5\n 3 b: 'b' .\l"] - 5 -> "5R3e" [style = solid] - "5R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 6 [label="State 6\n 1 exp: a '?' b .\l"] - 6 -> "6R1e" [style = solid] - "6R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] + 5 [label="State 5\n\l 3 b: 'b' .\l"] + 5 -> "5R3" [style=solid] + "5R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 6 [label="State 6\n\l 1 exp: a '?' b .\l"] + 6 -> "6R1" [style=solid] + "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] ]]) ## ------------------------ ## @@ -326,13 +326,7 @@ empty_b: %prec 'b'; empty_c: %prec 'c'; ]], [[ - 0 [label="State 0\n 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"] - 0 -> "0R7d" [label = "['a']" style = solid] - "0R7d" [style = filled, shape = diamond, fillcolor = 5, label = "R7"] - 0 -> "0R8d" [label = "['b']" style = solid] - "0R8d" [style = filled, shape = diamond, fillcolor = 5, label = "R8"] - 0 -> "0R9d" [label = "['c']" style = solid] - "0R9d" [style = filled, shape = diamond, fillcolor = 5, label = "R9"] + 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . ['b']\l 9 empty_c: . ['c']\l"] 0 -> 1 [style=solid label="'a'"] 0 -> 2 [style=solid label="'b'"] 0 -> 3 [style=solid label="'c'"] @@ -340,35 +334,41 @@ empty_c: %prec 'c'; 0 -> 5 [style=dashed label="empty_a"] 0 -> 6 [style=dashed label="empty_b"] 0 -> 7 [style=dashed label="empty_c"] - 1 [label="State 1\n 1 start: 'a' .\l"] - 1 -> "1R1e" [style = solid] - "1R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] - 2 [label="State 2\n 3 start: 'b' .\l"] - 2 -> "2R3e" [style = solid] - "2R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 3 [label="State 3\n 5 start: 'c' .\l"] - 3 -> "3R5e" [style = solid] - "3R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] - 4 [label="State 4\n 0 $accept: start . $end\l"] + 0 -> "0R7d" [label="['a']", style=solid] + "0R7d" [label="R7", fillcolor=5, shape=diamond, style=filled] + 0 -> "0R8d" [label="['b']", style=solid] + "0R8d" [label="R8", fillcolor=5, shape=diamond, style=filled] + 0 -> "0R9d" [label="['c']", style=solid] + "0R9d" [label="R9", fillcolor=5, shape=diamond, style=filled] + 1 [label="State 1\n\l 1 start: 'a' .\l"] + 1 -> "1R1" [style=solid] + "1R1" [label="R1", fillcolor=3, shape=diamond, style=filled] + 2 [label="State 2\n\l 3 start: 'b' .\l"] + 2 -> "2R3" [style=solid] + "2R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 3 [label="State 3\n\l 5 start: 'c' .\l"] + 3 -> "3R5" [style=solid] + "3R5" [label="R5", fillcolor=3, shape=diamond, style=filled] + 4 [label="State 4\n\l 0 $accept: start . $end\l"] 4 -> 8 [style=solid label="$end"] - 5 [label="State 5\n 2 start: empty_a . 'a'\l"] + 5 [label="State 5\n\l 2 start: empty_a . 'a'\l"] 5 -> 9 [style=solid label="'a'"] - 6 [label="State 6\n 4 start: empty_b . 'b'\l"] + 6 [label="State 6\n\l 4 start: empty_b . 'b'\l"] 6 -> 10 [style=solid label="'b'"] - 7 [label="State 7\n 6 start: empty_c . 'c'\l"] + 7 [label="State 7\n\l 6 start: empty_c . 'c'\l"] 7 -> 11 [style=solid label="'c'"] - 8 [label="State 8\n 0 $accept: start $end .\l"] - 8 -> "8R0e" [style = solid] - "8R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] - 9 [label="State 9\n 2 start: empty_a 'a' .\l"] - 9 -> "9R2e" [style = solid] - "9R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] - 10 [label="State 10\n 4 start: empty_b 'b' .\l"] - 10 -> "10R4e" [style = solid] - "10R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] - 11 [label="State 11\n 6 start: empty_c 'c' .\l"] - 11 -> "11R6e" [style = solid] - "11R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] + 8 [label="State 8\n\l 0 $accept: start $end .\l"] + 8 -> "8R0" [style=solid] + "8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] + 9 [label="State 9\n\l 2 start: empty_a 'a' .\l"] + 9 -> "9R2" [style=solid] + "9R2" [label="R2", fillcolor=3, shape=diamond, style=filled] + 10 [label="State 10\n\l 4 start: empty_b 'b' .\l"] + 10 -> "10R4" [style=solid] + "10R4" [label="R4", fillcolor=3, shape=diamond, style=filled] + 11 [label="State 11\n\l 6 start: empty_c 'c' .\l"] + 11 -> "11R6" [style=solid] + "11R6" [label="R6", fillcolor=3, shape=diamond, style=filled] ]]) ## ---------------------- ## @@ -393,41 +393,41 @@ empty_b: %prec 'b'; empty_c: %prec 'c'; ]], [[ - 0 [label="State 0\n 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"] - 0 -> "0R7e" [style = solid] - "0R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] + 0 [label="State 0\n\l 0 $accept: . start $end\l 1 start: . 'a'\l 2 | . empty_a 'a'\l 3 | . 'b'\l 4 | . empty_b 'b'\l 5 | . 'c'\l 6 | . empty_c 'c'\l 7 empty_a: . ['a']\l 8 empty_b: . []\l 9 empty_c: . []\l"] 0 -> 1 [style=solid label="'b'"] 0 -> 2 [style=solid label="'c'"] 0 -> 3 [style=dashed label="start"] 0 -> 4 [style=dashed label="empty_a"] 0 -> 5 [style=dashed label="empty_b"] 0 -> 6 [style=dashed label="empty_c"] - 1 [label="State 1\n 3 start: 'b' .\l"] - 1 -> "1R3e" [style = solid] - "1R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 2 [label="State 2\n 5 start: 'c' .\l"] - 2 -> "2R5e" [style = solid] - "2R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] - 3 [label="State 3\n 0 $accept: start . $end\l"] + 0 -> "0R7" [style=solid] + "0R7" [label="R7", fillcolor=3, shape=diamond, style=filled] + 1 [label="State 1\n\l 3 start: 'b' .\l"] + 1 -> "1R3" [style=solid] + "1R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 2 [label="State 2\n\l 5 start: 'c' .\l"] + 2 -> "2R5" [style=solid] + "2R5" [label="R5", fillcolor=3, shape=diamond, style=filled] + 3 [label="State 3\n\l 0 $accept: start . $end\l"] 3 -> 7 [style=solid label="$end"] - 4 [label="State 4\n 2 start: empty_a . 'a'\l"] + 4 [label="State 4\n\l 2 start: empty_a . 'a'\l"] 4 -> 8 [style=solid label="'a'"] - 5 [label="State 5\n 4 start: empty_b . 'b'\l"] + 5 [label="State 5\n\l 4 start: empty_b . 'b'\l"] 5 -> 9 [style=solid label="'b'"] - 6 [label="State 6\n 6 start: empty_c . 'c'\l"] + 6 [label="State 6\n\l 6 start: empty_c . 'c'\l"] 6 -> 10 [style=solid label="'c'"] - 7 [label="State 7\n 0 $accept: start $end .\l"] - 7 -> "7R0e" [style = solid] - "7R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] - 8 [label="State 8\n 2 start: empty_a 'a' .\l"] - 8 -> "8R2e" [style = solid] - "8R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] - 9 [label="State 9\n 4 start: empty_b 'b' .\l"] - 9 -> "9R4e" [style = solid] - "9R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] - 10 [label="State 10\n 6 start: empty_c 'c' .\l"] - 10 -> "10R6e" [style = solid] - "10R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] + 7 [label="State 7\n\l 0 $accept: start $end .\l"] + 7 -> "7R0" [style=solid] + "7R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] + 8 [label="State 8\n\l 2 start: empty_a 'a' .\l"] + 8 -> "8R2" [style=solid] + "8R2" [label="R2", fillcolor=3, shape=diamond, style=filled] + 9 [label="State 9\n\l 4 start: empty_b 'b' .\l"] + 9 -> "9R4" [style=solid] + "9R4" [label="R4", fillcolor=3, shape=diamond, style=filled] + 10 [label="State 10\n\l 6 start: empty_c 'c' .\l"] + 10 -> "10R6" [style=solid] + "10R6" [label="R6", fillcolor=3, shape=diamond, style=filled] ]]) ## ---------------- ## @@ -441,25 +441,25 @@ a: ; b: ; ]], [[ - 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"] - 0 -> "0R3e" [style = solid] - "0R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 0 -> "0R4d" [label = "[$end]" style = solid] - "0R4d" [style = filled, shape = diamond, fillcolor = 5, label = "R4"] + 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a\l 2 | . b\l 3 a: . [$end]\l 4 b: . [$end]\l"] 0 -> 1 [style=dashed label="exp"] 0 -> 2 [style=dashed label="a"] 0 -> 3 [style=dashed label="b"] - 1 [label="State 1\n 0 $accept: exp . $end\l"] + 0 -> "0R3" [style=solid] + "0R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 0 -> "0R4d" [label="[$end]", style=solid] + "0R4d" [label="R4", fillcolor=5, shape=diamond, style=filled] + 1 [label="State 1\n\l 0 $accept: exp . $end\l"] 1 -> 4 [style=solid label="$end"] - 2 [label="State 2\n 1 exp: a .\l"] - 2 -> "2R1e" [style = solid] - "2R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] - 3 [label="State 3\n 2 exp: b .\l"] - 3 -> "3R2e" [style = solid] - "3R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] - 4 [label="State 4\n 0 $accept: exp $end .\l"] - 4 -> "4R0e" [style = solid] - "4R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] + 2 [label="State 2\n\l 1 exp: a .\l"] + 2 -> "2R1" [style=solid] + "2R1" [label="R1", fillcolor=3, shape=diamond, style=filled] + 3 [label="State 3\n\l 2 exp: b .\l"] + 3 -> "3R2" [style=solid] + "3R2" [label="R2", fillcolor=3, shape=diamond, style=filled] + 4 [label="State 4\n\l 0 $accept: exp $end .\l"] + 4 -> "4R0" [style=solid] + "4R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] ]]) ## ---------------------------------------- ## @@ -474,51 +474,51 @@ b: ; c: ; ]], [[ - 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"] - 0 -> "0R8e" [style = solid] - "0R8e" [style = filled, shape = diamond, fillcolor = 3, label = "R8"] - 0 -> "0R9e" [label = "['?', '!']" style = solid] - "0R9e" [style = filled, shape = diamond, fillcolor = 3, label = "R9"] - 0 -> "0R10d" [label = "[';', '?']" style = solid] - "0R10d" [style = filled, shape = diamond, fillcolor = 5, label = "R10"] + 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . a ';'\l 2 | . a ';'\l 3 | . a '.'\l 4 | . b '?'\l 5 | . b '!'\l 6 | . c '?'\l 7 | . c ';'\l 8 a: . [';', '.']\l 9 b: . ['?', '!']\l 10 c: . [';', '?']\l"] 0 -> 1 [style=dashed label="exp"] 0 -> 2 [style=dashed label="a"] 0 -> 3 [style=dashed label="b"] 0 -> 4 [style=dashed label="c"] - 1 [label="State 1\n 0 $accept: exp . $end\l"] + 0 -> "0R8" [style=solid] + "0R8" [label="R8", fillcolor=3, shape=diamond, style=filled] + 0 -> "0R9" [label="['?', '!']", style=solid] + "0R9" [label="R9", fillcolor=3, shape=diamond, style=filled] + 0 -> "0R10d" [label="[';', '?']", style=solid] + "0R10d" [label="R10", fillcolor=5, shape=diamond, style=filled] + 1 [label="State 1\n\l 0 $accept: exp . $end\l"] 1 -> 5 [style=solid label="$end"] - 2 [label="State 2\n 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"] + 2 [label="State 2\n\l 1 exp: a . ';'\l 2 | a . ';'\l 3 | a . '.'\l"] 2 -> 6 [style=solid label="';'"] 2 -> 7 [style=solid label="'.'"] - 3 [label="State 3\n 4 exp: b . '?'\l 5 | b . '!'\l"] + 3 [label="State 3\n\l 4 exp: b . '?'\l 5 | b . '!'\l"] 3 -> 8 [style=solid label="'?'"] 3 -> 9 [style=solid label="'!'"] - 4 [label="State 4\n 6 exp: c . '?'\l 7 | c . ';'\l"] + 4 [label="State 4\n\l 6 exp: c . '?'\l 7 | c . ';'\l"] 4 -> 10 [style=solid label="';'"] 4 -> 11 [style=solid label="'?'"] - 5 [label="State 5\n 0 $accept: exp $end .\l"] - 5 -> "5R0e" [style = solid] - "5R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] - 6 [label="State 6\n 1 exp: a ';' . [$end]\l 2 | a ';' . [$end]\l"] - 6 -> "6R1e" [style = solid] - "6R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] - 6 -> "6R2d" [label = "[$end]" style = solid] - "6R2d" [style = filled, shape = diamond, fillcolor = 5, label = "R2"] - 7 [label="State 7\n 3 exp: a '.' .\l"] - 7 -> "7R3e" [style = solid] - "7R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 8 [label="State 8\n 4 exp: b '?' .\l"] - 8 -> "8R4e" [style = solid] - "8R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] - 9 [label="State 9\n 5 exp: b '!' .\l"] - 9 -> "9R5e" [style = solid] - "9R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] - 10 [label="State 10\n 7 exp: c ';' .\l"] - 10 -> "10R7e" [style = solid] - "10R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] - 11 [label="State 11\n 6 exp: c '?' .\l"] - 11 -> "11R6e" [style = solid] - "11R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] + 5 [label="State 5\n\l 0 $accept: exp $end .\l"] + 5 -> "5R0" [style=solid] + "5R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] + 6 [label="State 6\n\l 1 exp: a ';' . [$end]\l 2 | a ';' . [$end]\l"] + 6 -> "6R1" [style=solid] + "6R1" [label="R1", fillcolor=3, shape=diamond, style=filled] + 6 -> "6R2d" [label="[$end]", style=solid] + "6R2d" [label="R2", fillcolor=5, shape=diamond, style=filled] + 7 [label="State 7\n\l 3 exp: a '.' .\l"] + 7 -> "7R3" [style=solid] + "7R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 8 [label="State 8\n\l 4 exp: b '?' .\l"] + 8 -> "8R4" [style=solid] + "8R4" [label="R4", fillcolor=3, shape=diamond, style=filled] + 9 [label="State 9\n\l 5 exp: b '!' .\l"] + 9 -> "9R5" [style=solid] + "9R5" [label="R5", fillcolor=3, shape=diamond, style=filled] + 10 [label="State 10\n\l 7 exp: c ';' .\l"] + 10 -> "10R7" [style=solid] + "10R7" [label="R7", fillcolor=3, shape=diamond, style=filled] + 11 [label="State 11\n\l 6 exp: c '?' .\l"] + 11 -> "11R6" [style=solid] + "11R6" [label="R6", fillcolor=3, shape=diamond, style=filled] ]]) ## ------------------------------------------------------ ## @@ -534,85 +534,85 @@ opexp: exp '+' exp; imm: '0'; ]], [[ - 0 [label="State 0\n 0 $accept: . exp $end\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] 0 -> 1 [style=solid label="\"if\""] 0 -> 2 [style=solid label="'0'"] 0 -> 3 [style=dashed label="exp"] 0 -> 4 [style=dashed label="ifexp"] 0 -> 5 [style=dashed label="opexp"] 0 -> 6 [style=dashed label="imm"] - 1 [label="State 1\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" . exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 1 [label="State 1\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" . exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] 1 -> 1 [style=solid label="\"if\""] 1 -> 2 [style=solid label="'0'"] 1 -> 7 [style=dashed label="exp"] 1 -> 4 [style=dashed label="ifexp"] 1 -> 5 [style=dashed label="opexp"] 1 -> 6 [style=dashed label="imm"] - 2 [label="State 2\n 8 imm: '0' .\l"] - 2 -> "2R8e" [style = solid] - "2R8e" [style = filled, shape = diamond, fillcolor = 3, label = "R8"] - 3 [label="State 3\n 0 $accept: exp . $end\l 7 opexp: exp . '+' exp\l"] + 2 [label="State 2\n\l 8 imm: '0' .\l"] + 2 -> "2R8" [style=solid] + "2R8" [label="R8", fillcolor=3, shape=diamond, style=filled] + 3 [label="State 3\n\l 0 $accept: exp . $end\l 7 opexp: exp . '+' exp\l"] 3 -> 8 [style=solid label="$end"] 3 -> 9 [style=solid label="'+'"] - 4 [label="State 4\n 1 exp: ifexp .\l"] - 4 -> "4R1e" [style = solid] - "4R1e" [style = filled, shape = diamond, fillcolor = 3, label = "R1"] - 5 [label="State 5\n 2 exp: opexp .\l"] - 5 -> "5R2e" [style = solid] - "5R2e" [style = filled, shape = diamond, fillcolor = 3, label = "R2"] - 6 [label="State 6\n 3 exp: imm .\l"] - 6 -> "6R3e" [style = solid] - "6R3e" [style = filled, shape = diamond, fillcolor = 3, label = "R3"] - 7 [label="State 7\n 4 ifexp: \"if\" exp . \"then\" exp elseexp\l 7 opexp: exp . '+' exp\l"] + 4 [label="State 4\n\l 1 exp: ifexp .\l"] + 4 -> "4R1" [style=solid] + "4R1" [label="R1", fillcolor=3, shape=diamond, style=filled] + 5 [label="State 5\n\l 2 exp: opexp .\l"] + 5 -> "5R2" [style=solid] + "5R2" [label="R2", fillcolor=3, shape=diamond, style=filled] + 6 [label="State 6\n\l 3 exp: imm .\l"] + 6 -> "6R3" [style=solid] + "6R3" [label="R3", fillcolor=3, shape=diamond, style=filled] + 7 [label="State 7\n\l 4 ifexp: \"if\" exp . \"then\" exp elseexp\l 7 opexp: exp . '+' exp\l"] 7 -> 10 [style=solid label="\"then\""] 7 -> 9 [style=solid label="'+'"] - 8 [label="State 8\n 0 $accept: exp $end .\l"] - 8 -> "8R0e" [style = solid] - "8R0e" [style = filled, shape = diamond, fillcolor = 1, label = "Acc"] - 9 [label="State 9\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 7 | exp '+' . exp\l 8 imm: . '0'\l"] + 8 [label="State 8\n\l 0 $accept: exp $end .\l"] + 8 -> "8R0" [style=solid] + "8R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] + 9 [label="State 9\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 7 opexp: . exp '+' exp\l 7 | exp '+' . exp\l 8 imm: . '0'\l"] 9 -> 1 [style=solid label="\"if\""] 9 -> 2 [style=solid label="'0'"] 9 -> 11 [style=dashed label="exp"] 9 -> 4 [style=dashed label="ifexp"] 9 -> 5 [style=dashed label="opexp"] 9 -> 6 [style=dashed label="imm"] - 10 [label="State 10\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" exp \"then\" . exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 10 [label="State 10\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 4 | \"if\" exp \"then\" . exp elseexp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] 10 -> 1 [style=solid label="\"if\""] 10 -> 2 [style=solid label="'0'"] 10 -> 12 [style=dashed label="exp"] 10 -> 4 [style=dashed label="ifexp"] 10 -> 5 [style=dashed label="opexp"] 10 -> 6 [style=dashed label="imm"] - 11 [label="State 11\n 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"] - 11 -> "11R7e" [style = solid] - "11R7e" [style = filled, shape = diamond, fillcolor = 3, label = "R7"] - 11 -> "11R7d" [label = "['+']" style = solid] - "11R7d" [style = filled, shape = diamond, fillcolor = 5, label = "R7"] + 11 [label="State 11\n\l 7 opexp: exp . '+' exp\l 7 | exp '+' exp . [$end, \"then\", \"else\", '+']\l"] 11 -> 9 [style=solid label="'+'"] - 12 [label="State 12\n 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] - 12 -> "12R6e" [style = solid] - "12R6e" [style = filled, shape = diamond, fillcolor = 3, label = "R6"] - 12 -> "12R6d" [label = "[\"else\", '+']" style = solid] - "12R6d" [style = filled, shape = diamond, fillcolor = 5, label = "R6"] + 11 -> "11R7d" [label="['+']", style=solid] + "11R7d" [label="R7", fillcolor=5, shape=diamond, style=filled] + 11 -> "11R7" [style=solid] + "11R7" [label="R7", fillcolor=3, shape=diamond, style=filled] + 12 [label="State 12\n\l 4 ifexp: \"if\" exp \"then\" exp . elseexp\l 5 elseexp: . \"else\" exp\l 6 | . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] 12 -> 13 [style=solid label="\"else\""] 12 -> 9 [style=solid label="'+'"] 12 -> 14 [style=dashed label="elseexp"] - 13 [label="State 13\n 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 5 elseexp: \"else\" . exp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] + 12 -> "12R6d" [label="[\"else\", '+']", style=solid] + "12R6d" [label="R6", fillcolor=5, shape=diamond, style=filled] + 12 -> "12R6" [style=solid] + "12R6" [label="R6", fillcolor=3, shape=diamond, style=filled] + 13 [label="State 13\n\l 1 exp: . ifexp\l 2 | . opexp\l 3 | . imm\l 4 ifexp: . \"if\" exp \"then\" exp elseexp\l 5 elseexp: \"else\" . exp\l 7 opexp: . exp '+' exp\l 8 imm: . '0'\l"] 13 -> 1 [style=solid label="\"if\""] 13 -> 2 [style=solid label="'0'"] 13 -> 15 [style=dashed label="exp"] 13 -> 4 [style=dashed label="ifexp"] 13 -> 5 [style=dashed label="opexp"] 13 -> 6 [style=dashed label="imm"] - 14 [label="State 14\n 4 ifexp: \"if\" exp \"then\" exp elseexp .\l"] - 14 -> "14R4e" [style = solid] - "14R4e" [style = filled, shape = diamond, fillcolor = 3, label = "R4"] - 15 [label="State 15\n 5 elseexp: \"else\" exp . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] - 15 -> "15R5e" [style = solid] - "15R5e" [style = filled, shape = diamond, fillcolor = 3, label = "R5"] - 15 -> "15R5d" [label = "['+']" style = solid] - "15R5d" [style = filled, shape = diamond, fillcolor = 5, label = "R5"] + 14 [label="State 14\n\l 4 ifexp: \"if\" exp \"then\" exp elseexp .\l"] + 14 -> "14R4" [style=solid] + "14R4" [label="R4", fillcolor=3, shape=diamond, style=filled] + 15 [label="State 15\n\l 5 elseexp: \"else\" exp . [$end, \"then\", \"else\", '+']\l 7 opexp: exp . '+' exp\l"] 15 -> 9 [style=solid label="'+'"] + 15 -> "15R5d" [label="['+']", style=solid] + "15R5d" [label="R5", fillcolor=5, shape=diamond, style=filled] + 15 -> "15R5" [style=solid] + "15R5" [label="R5", fillcolor=3, shape=diamond, style=filled] ]]) m4_popdef([AT_TEST]) diff --git a/tests/reduce.at b/tests/reduce.at index d2a5c554..2d9093f0 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -437,7 +437,7 @@ dnl BISON-STDERR [], dnl TABLES -[[state 0 +[[State 0 0 $accept: . S $end 1 S: . 'a' A 'a' @@ -451,7 +451,7 @@ dnl TABLES S go to state 4 -state 1 +State 1 1 S: 'a' . A 'a' 4 A: . 'a' 'a' @@ -462,7 +462,7 @@ state 1 A go to state 6 -state 2 +State 2 2 S: 'b' . A 'b' 4 A: . 'a' 'a' @@ -473,7 +473,7 @@ state 2 A go to state 7 -state 3 +State 3 3 S: 'c' . c 4 A: . 'a' 'a' @@ -487,14 +487,14 @@ state 3 c go to state 10 -state 4 +State 4 0 $accept: S . $end $end shift, and go to state 11 -state 5 +State 5 4 A: 'a' . 'a' 5 | 'a' . ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[ @@ -505,21 +505,21 @@ state 5 Conflict between rule 5 and token 'a' resolved as reduce (%left 'a'). -state 6 +State 6 1 S: 'a' A . 'a' 'a' shift, and go to state 13 -state 7 +State 7 2 S: 'b' A . 'b' 'b' shift, and go to state 14 -state 8 +State 8 4 A: 'a' . 'a' 5 | 'a' . [$end] @@ -533,7 +533,7 @@ state 8 [[$default]])[ reduce using rule 5 (A) -state 9 +State 9 7 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -541,7 +541,7 @@ state 9 [[$default]])[ reduce using rule 7 (c) -state 10 +State 10 3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -549,14 +549,14 @@ state 10 [[$default]])[ reduce using rule 3 (S) -state 11 +State 11 0 $accept: S $end . $default accept -state 12 +State 12 4 A: 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[ @@ -564,7 +564,7 @@ state 12 [[$default]])[ reduce using rule 4 (A) -state 13 +State 13 1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -572,7 +572,7 @@ state 13 [[$default]])[ reduce using rule 1 (S) -state 14 +State 14 2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -580,7 +580,7 @@ state 14 [[$default]])[ reduce using rule 2 (S) -state 15 +State 15 6 c: 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -589,7 +589,7 @@ state 15 [[]], [[ -state 16 +State 16 4 A: 'a' . 'a' 5 | 'a' . ['b'] @@ -601,14 +601,14 @@ state 16 [[$default]])[ reduce using rule 5 (A)]AT_COND_CASE([[canonical LR]], [[ -state 17 +State 17 4 A: 'a' 'a' . [$end] $end reduce using rule 4 (A) -state 18 +State 18 4 A: 'a' 'a' . ['b'] @@ -653,7 +653,7 @@ dnl BISON-STDERR [], dnl TABLES -[[state 0 +[[State 0 0 $accept: . S $end 1 S: . 'a' A 'a' @@ -667,7 +667,7 @@ dnl TABLES S go to state 4 -state 1 +State 1 1 S: 'a' . A 'a' 4 A: . 'a' 'a' 'a' @@ -678,7 +678,7 @@ state 1 A go to state 6 -state 2 +State 2 2 S: 'b' . A 'b' 4 A: . 'a' 'a' 'a' @@ -689,7 +689,7 @@ state 2 A go to state 7 -state 3 +State 3 3 S: 'c' . c 4 A: . 'a' 'a' 'a' @@ -703,14 +703,14 @@ state 3 c go to state 10 -state 4 +State 4 0 $accept: S . $end $end shift, and go to state 11 -state 5 +State 5 4 A: 'a' . 'a' 'a' 5 | 'a' . 'a' @@ -718,21 +718,21 @@ state 5 'a' shift, and go to state 12 -state 6 +State 6 1 S: 'a' A . 'a' 'a' shift, and go to state 13 -state 7 +State 7 2 S: 'b' A . 'b' 'b' shift, and go to state 14 -state 8 +State 8 4 A: 'a' . 'a' 'a' 5 | 'a' . 'a' @@ -741,7 +741,7 @@ state 8 'a' shift, and go to state 15 -state 9 +State 9 7 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -749,7 +749,7 @@ state 9 [[$default]])[ reduce using rule 7 (c) -state 10 +State 10 3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -757,14 +757,14 @@ state 10 [[$default]])[ reduce using rule 3 (S) -state 11 +State 11 0 $accept: S $end . $default accept -state 12 +State 12 4 A: 'a' 'a' . 'a' 5 | 'a' 'a' . ]AT_COND_CASE([[LALR]], [[['a', 'b']]], [[['a']]])[ @@ -775,7 +775,7 @@ state 12 Conflict between rule 5 and token 'a' resolved as reduce (%left 'a'). -state 13 +State 13 1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -783,7 +783,7 @@ state 13 [[$default]])[ reduce using rule 1 (S) -state 14 +State 14 2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -791,7 +791,7 @@ state 14 [[$default]])[ reduce using rule 2 (S) -state 15 +State 15 4 A: 'a' 'a' . 'a' 5 | 'a' 'a' . [$end] @@ -805,7 +805,7 @@ state 15 [[$default]])[ reduce using rule 5 (A) -state 16 +State 16 4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[ @@ -813,7 +813,7 @@ state 16 [[$default]])[ reduce using rule 4 (A) -state 17 +State 17 6 c: 'a' 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -822,7 +822,7 @@ state 17 [[]], [[ -state 18 +State 18 4 A: 'a' . 'a' 'a' 5 | 'a' . 'a' @@ -831,7 +831,7 @@ state 18 [[19]])[ -state 19]AT_COND_CASE([[canonical LR]], [[ +State 19]AT_COND_CASE([[canonical LR]], [[ 4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -839,7 +839,7 @@ state 19]AT_COND_CASE([[canonical LR]], [[ [[$default]])[ reduce using rule 4 (A) -state 20]])[ +State 20]])[ 4 A: 'a' 'a' . 'a' 5 | 'a' 'a' . ['b'] @@ -851,7 +851,7 @@ state 20]])[ [[$default]])[ reduce using rule 5 (A)]AT_COND_CASE([[canonical LR]], [[ -state 21 +State 21 4 A: 'a' 'a' 'a' .]AT_COND_CASE([[canonical LR]], [[ ['b']]])[ @@ -900,7 +900,7 @@ dnl BISON-STDERR [], dnl TABLES -[[state 0 +[[State 0 0 $accept: . S $end 1 S: . 'a' A 'a' @@ -914,7 +914,7 @@ dnl TABLES S go to state 4 -state 1 +State 1 1 S: 'a' . A 'a' 4 A: . 'a' 'a' B @@ -924,7 +924,7 @@ state 1 A go to state 6 -state 2 +State 2 2 S: 'b' . A 'b' 4 A: . 'a' 'a' B @@ -934,7 +934,7 @@ state 2 A go to state 7 -state 3 +State 3 3 S: 'c' . c 4 A: . 'a' 'a' B @@ -947,35 +947,35 @@ state 3 c go to state 10 -state 4 +State 4 0 $accept: S . $end $end shift, and go to state 11 -state 5 +State 5 4 A: 'a' . 'a' B 'a' shift, and go to state 12 -state 6 +State 6 1 S: 'a' A . 'a' 'a' shift, and go to state 13 -state 7 +State 7 2 S: 'b' A . 'b' 'b' shift, and go to state 14 -state 8 +State 8 4 A: 'a' . 'a' B 7 c: 'a' . 'a' 'b' @@ -983,7 +983,7 @@ state 8 'a' shift, and go to state 15 -state 9 +State 9 8 c: A .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -991,7 +991,7 @@ state 9 [[$default]])[ reduce using rule 8 (c) -state 10 +State 10 3 S: 'c' c .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -999,14 +999,14 @@ state 10 [[$default]])[ reduce using rule 3 (S) -state 11 +State 11 0 $accept: S $end . $default accept -state 12 +State 12 4 A: 'a' 'a' . B 5 B: . 'a' @@ -1020,7 +1020,7 @@ state 12 Conflict between rule 6 and token 'a' resolved as reduce (%left 'a'). -state 13 +State 13 1 S: 'a' A 'a' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1028,7 +1028,7 @@ state 13 [[$default]])[ reduce using rule 1 (S) -state 14 +State 14 2 S: 'b' A 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1036,7 +1036,7 @@ state 14 [[$default]])[ reduce using rule 2 (S) -state 15 +State 15 4 A: 'a' 'a' . B 5 B: . 'a' @@ -1053,7 +1053,7 @@ state 15 B go to state ]AT_COND_CASE([[canonical LR]], [[21]], [[17]])[ -state 16 +State 16 5 B: 'a' .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[ @@ -1061,7 +1061,7 @@ state 16 [[$default]])[ reduce using rule 5 (B) -state 17 +State 17 4 A: 'a' 'a' B .]AT_COND_CASE([[canonical LR]], [[ ['a']]])[ @@ -1069,7 +1069,7 @@ state 17 [[$default]])[ reduce using rule 4 (A) -state 18 +State 18 7 c: 'a' 'a' 'b' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1077,7 +1077,7 @@ state 18 [[$default]])[ reduce using rule 7 (c)]AT_COND_CASE([[LALR]], [], [[ -state 19 +State 19 4 A: 'a' . 'a' B @@ -1085,21 +1085,21 @@ state 19 [[20]])[ -state 20]AT_COND_CASE([[canonical LR]], [[ +State 20]AT_COND_CASE([[canonical LR]], [[ 5 B: 'a' . [$end] $end reduce using rule 5 (B) -state 21 +State 21 4 A: 'a' 'a' B . [$end] $end reduce using rule 4 (A) -state 22]])[ +State 22]])[ 4 A: 'a' 'a' . B 5 B: . 'a' @@ -1114,14 +1114,14 @@ state 22]])[ B go to state ]AT_COND_CASE([[canonical LR]], [[24 -state 23 +State 23 5 B: 'a' . ['b'] 'b' reduce using rule 5 (B) -state 24 +State 24 4 A: 'a' 'a' B . ['b'] @@ -1195,7 +1195,7 @@ dnl BISON-STDERR ]], [])], dnl TABLES -[[state 0 +[[State 0 0 $accept: . S $end 1 S: . 'a' A 'f' @@ -1213,7 +1213,7 @@ dnl TABLES S go to state 4 -state 1 +State 1 1 S: 'a' . A 'f' 2 | 'a' . B @@ -1226,7 +1226,7 @@ state 1 B go to state 7 -state 2 +State 2 3 S: 'b' . A 'f' 4 | 'b' . B 'g' @@ -1240,7 +1240,7 @@ state 2 B go to state 10 -state 3 +State 3 6 S: 'c' . 'c' A 'g' 7 | 'c' . 'c' B @@ -1248,14 +1248,14 @@ state 3 'c' shift, and go to state 11 -state 4 +State 4 0 $accept: S . $end $end shift, and go to state 12 -state 5 +State 5 8 A: 'd' . 'e' 9 B: 'd' . 'e' @@ -1265,14 +1265,14 @@ state 5 [[20]])[ -state 6 +State 6 1 S: 'a' A . 'f' 'f' shift, and go to state 14 -state 7 +State 7 2 S: 'a' B .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1280,7 +1280,7 @@ state 7 [[$default]])[ reduce using rule 2 (S) -state 8 +State 8 5 S: 'b' 'd' . [$end] 8 A: 'd' . 'e' @@ -1293,21 +1293,21 @@ state 8 [[$default]])[ reduce using rule 5 (S) -state 9 +State 9 3 S: 'b' A . 'f' 'f' shift, and go to state 15 -state 10 +State 10 4 S: 'b' B . 'g' 'g' shift, and go to state 16 -state 11 +State 11 6 S: 'c' 'c' . A 'g' 7 | 'c' 'c' . B @@ -1321,14 +1321,14 @@ state 11 B go to state 18 -state 12 +State 12 0 $accept: S $end . $default accept]AT_COND_CASE([[LALR]], [[ -state 13 +State 13 8 A: 'd' 'e' . ['f', 'g'] 9 B: 'd' 'e' . [$end, 'g'] @@ -1339,7 +1339,7 @@ state 13 $default reduce using rule 8 (A)]], [[ -state 13 +State 13 8 A: 'd' 'e' . ['f'] 9 B: 'd' 'e' . ]AT_COND_CASE([[canonical LR]], [[[$end]]], [[['g']]])[ @@ -1350,7 +1350,7 @@ state 13 [[$default]])[ reduce using rule 8 (A)]])[ -state 14 +State 14 1 S: 'a' A 'f' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1358,7 +1358,7 @@ state 14 [[$default]])[ reduce using rule 1 (S) -state 15 +State 15 3 S: 'b' A 'f' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1366,7 +1366,7 @@ state 15 [[$default]])[ reduce using rule 3 (S) -state 16 +State 16 4 S: 'b' B 'g' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1374,14 +1374,14 @@ state 16 [[$default]])[ reduce using rule 4 (S) -state 17 +State 17 6 S: 'c' 'c' A . 'g' 'g' shift, and go to state 19 -state 18 +State 18 7 S: 'c' 'c' B .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1389,7 +1389,7 @@ state 18 [[$default]])[ reduce using rule 7 (S) -state 19 +State 19 6 S: 'c' 'c' A 'g' .]AT_COND_CASE([[canonical LR]], [[ [$end]]])[ @@ -1398,7 +1398,7 @@ state 19 [[]], [[ -state 20]AT_COND_CASE([[canonical LR]], [[ +State 20]AT_COND_CASE([[canonical LR]], [[ 8 A: 'd' 'e' . ['f'] 9 B: 'd' 'e' . ['g'] @@ -1407,7 +1407,7 @@ state 20]AT_COND_CASE([[canonical LR]], [[ 'g' reduce using rule 9 (B) -state 21 +State 21 8 A: 'd' . 'e' 9 B: 'd' . 'e' @@ -1415,7 +1415,7 @@ state 21 'e' shift, and go to state 22 -state 22 +State 22 8 A: 'd' 'e' . ['g'] 9 B: 'd' 'e' . [$end] @@ -1491,7 +1491,7 @@ c: ; ]], dnl Visit each state mentioned above. [['a', 'a']], -[[state 0 +[[State 0 0 $accept: . start $end 1 start: . a b @@ -1505,7 +1505,7 @@ dnl Visit each state mentioned above. a go to state 3 -state 1 +State 1 4 a: 'a' .]AT_COND_CASE([[accepting]], [[ [$end, 'a', 'b'] @@ -1516,14 +1516,14 @@ state 1 $default reduce using rule 4 (a)]])[ -state 2 +State 2 0 $accept: start . $end $end shift, and go to state 4 -state 3 +State 3 1 start: a . b 2 | a . b 'a' @@ -1542,14 +1542,14 @@ state 3 c go to state 6 -state 4 +State 4 0 $accept: start $end . $default accept -state 5 +State 5 1 start: a b . [$end] 2 | a b . 'a' @@ -1560,14 +1560,14 @@ state 5 [[$end]])[ reduce using rule 1 (start) -state 6 +State 6 3 start: a c . 'b' 'b' shift, and go to state 8 -state 7 +State 7 2 start: a b 'a' .]AT_COND_CASE([[accepting]], [[ [$end] @@ -1576,7 +1576,7 @@ state 7 $default reduce using rule 2 (start)]])[ -state 8 +State 8 3 start: a c 'b' .]AT_COND_CASE([[accepting]], [[ [$end] diff --git a/tests/regression.at b/tests/regression.at index 4d6e255a..76914200 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -293,7 +293,7 @@ $@2 (9) on left: 3, on right: 4 -state 0 +State 0 0 $accept: . expr $end @@ -305,7 +305,7 @@ state 0 $@2 go to state 3 -state 1 +State 1 2 expr: 'a' . $@1 'b' @@ -314,42 +314,42 @@ state 1 $@1 go to state 4 -state 2 +State 2 0 $accept: expr . $end $end shift, and go to state 5 -state 3 +State 3 4 expr: $@2 . 'c' 'c' shift, and go to state 6 -state 4 +State 4 2 expr: 'a' $@1 . 'b' 'b' shift, and go to state 7 -state 5 +State 5 0 $accept: expr $end . $default accept -state 6 +State 6 4 expr: $@2 'c' . $default reduce using rule 4 (expr) -state 7 +State 7 2 expr: 'a' $@1 'b' . @@ -598,7 +598,7 @@ $@1 (11) on left: 4, on right: 5 -state 0 +State 0 0 $accept: . CONST_DEC_PART $end @@ -610,14 +610,14 @@ state 0 $@1 go to state 4 -state 1 +State 1 0 $accept: CONST_DEC_PART . $end $end shift, and go to state 5 -state 2 +State 2 1 CONST_DEC_PART: CONST_DEC_LIST . 3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC @@ -629,56 +629,56 @@ state 2 $@1 go to state 4 -state 3 +State 3 2 CONST_DEC_LIST: CONST_DEC . $default reduce using rule 2 (CONST_DEC_LIST) -state 4 +State 4 5 CONST_DEC: $@1 . undef_id_tok '=' const_id_tok ';' undef_id_tok shift, and go to state 7 -state 5 +State 5 0 $accept: CONST_DEC_PART $end . $default accept -state 6 +State 6 3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC . $default reduce using rule 3 (CONST_DEC_LIST) -state 7 +State 7 5 CONST_DEC: $@1 undef_id_tok . '=' const_id_tok ';' '=' shift, and go to state 8 -state 8 +State 8 5 CONST_DEC: $@1 undef_id_tok '=' . const_id_tok ';' const_id_tok shift, and go to state 9 -state 9 +State 9 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok . ';' ';' shift, and go to state 10 -state 10 +State 10 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' . @@ -1116,8 +1116,8 @@ a: 'a' ; ]]) AT_BISON_CHECK([[--report=all input.y]]) -AT_CHECK([[sed -n '/^state 1$/,/^state 2$/p' input.output]], [[0]], -[[state 1 +AT_CHECK([[sed -n '/^State 1$/,/^State 2$/p' input.output]], [[0]], +[[State 1 2 start: 'a' . a 'a' 3 a: . 'a' @@ -1130,7 +1130,7 @@ AT_CHECK([[sed -n '/^state 1$/,/^state 2$/p' input.output]], [[0]], a go to state 5 -state 2 +State 2 ]]) AT_CLEANUP diff --git a/tests/sets.at b/tests/sets.at index 26664edf..4cbdfd62 100644 --- a/tests/sets.at +++ b/tests/sets.at @@ -287,16 +287,16 @@ mv stdout expout # Get the final state in the report, from the "accept" action.. AT_CHECK([sed -n ' - /^state \(.*\)/{ - s//final state \1/ - x - } - / accept/{ - x - p - q - } - ' input.output], - 0, [expout]) + /^State \(.*\)/{ + s//final state \1/ + x + } + / accept/{ + x + p + q + } + ' input.output], + 0, [expout]) AT_CLEANUP |