Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
dotgraph.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "dotgraph.h"
5
6#include "lalr.h"
7
8#include <QtCore/qtextstream.h>
9
14
16{
17 Grammar *g = aut->_M_grammar;
18
19 out << "digraph {" << Qt::endl << Qt::endl;
20
21 out << "subgraph Includes {" << Qt::endl;
23 incl != Automaton::IncludesGraph::end_nodes (); ++incl)
24 {
25 for (Automaton::IncludesGraph::edge_iterator edge = incl->begin (); edge != incl->end (); ++edge)
26 {
27 out << "\t\"(" << aut->id (incl->data.state) << ", " << incl->data.nt << ")\"";
28 out << "\t->\t";
29 out << "\"(" << aut->id ((*edge)->data.state) << ", " << (*edge)->data.nt << ")\"\t";
30 out << "[label=\"" << incl->data.state->follows [incl->data.nt] << "\"]";
31 out << Qt::endl;
32 }
33 }
34 out << "}" << Qt::endl << Qt::endl;
35
36
37 out << "subgraph LRA {" << Qt::endl;
38 //out << "node [shape=record];" << Qt::endl << Qt::endl;
39
40 for (StatePointer q = aut->states.begin (); q != aut->states.end (); ++q)
41 {
42 int state = aut->id (q);
43
44 out << "\t" << state << "\t[shape=record,label=\"{";
45
46 out << "<0> State " << state;
47
48 int index = 1;
49 for (ItemPointer item = q->kernel.begin (); item != q->kernel.end (); ++item)
50 out << "| <" << index++ << "> " << *item;
51
52 out << "}\"]" << Qt::endl;
53
54 for (Bundle::iterator a = q->bundle.begin (); a != q->bundle.end (); ++a)
55 {
56 const char *clr = g->isTerminal (a.key ()) ? "blue" : "red";
57 out << "\t" << state << "\t->\t" << aut->id (*a) << "\t[color=\"" << clr << "\",label=\"" << a.key () << "\"]" << Qt::endl;
58 }
59 out << Qt::endl;
60 }
61
62 out << "}" << Qt::endl;
63 out << Qt::endl << Qt::endl << "}" << Qt::endl;
64}
int id(RulePointer rule)
Definition lalr.cpp:242
Grammar * _M_grammar
Definition lalr.h:351
StateList states
Definition lalr.h:352
void operator()(Automaton *a)
Definition dotgraph.cpp:15
DotGraph(QTextStream &out)
Definition dotgraph.cpp:10
static iterator begin_nodes()
Definition lalr.h:162
std::list< iterator >::iterator edge_iterator
Definition lalr.h:140
Repository::iterator iterator
Definition lalr.h:139
static iterator end_nodes()
Definition lalr.h:165
\inmodule QtCore
else opt state
[0]
ItemList::iterator ItemPointer
Definition lalr.h:34
StateList::iterator StatePointer
Definition lalr.h:43
QTextStream & endl(QTextStream &stream)
Writes '\n' to the stream and flushes the stream.
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLboolean GLboolean g
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
QTextStream out(stdout)
[7]
QGraphicsItem * item