10#define QLALR_NO_DEBUG_NULLABLES
11#define QLALR_NO_DEBUG_LOOKBACKS
12#define QLALR_NO_DEBUG_DIRECT_READS
13#define QLALR_NO_DEBUG_READS
14#define QLALR_NO_DEBUG_INCLUDES
15#define QLALR_NO_DEBUG_LOOKAHEADS
81 out << *
r.lhs <<
" ::=";
83 for (NameList::const_iterator
name =
r.rhs.begin ();
name !=
r.rhs.end (); ++
name)
93 for (NameSet::const_iterator
n =
ns.begin ();
n !=
ns.end (); ++
n)
120 out << *
r->lhs <<
":";
121 for (NameList::iterator
name =
r->rhs.begin ();
name !=
r->rhs.end (); ++
name)
131 if (
item.isReduceItem ())
138 defaultReduce (
g->rules.
end ())
198 for (NameList::iterator
it =
rule->rhs.begin ();
it !=
rule->rhs.end (); ++
it)
206 fprintf (stderr,
"*** Warning. Symbol `%s' is not defined\n",
qPrintable (*
name));
287 NameList::iterator nn = std::find_if(
rule->rhs.begin(),
rule->rhs.end(),
NotNullable(
this));
289 if (nn ==
rule->rhs.end ())
294#ifndef QLALR_NO_DEBUG_NULLABLES
321 st.insert(
item->next());
329 if (!
state->closure.empty ())
334 bucket_map_type buckets;
342 while (! working_list.
empty ())
347 if (
item->isReduceItem ())
365 working_list.
push (
r.first);
372 for (bucket_map_type::iterator bucket = buckets.begin (); bucket != buckets.end (); ++bucket)
384 while (! todo.
empty ())
395 for (Bundle::iterator
a =
p->bundle.begin ();
a !=
p->bundle.end (); ++
a)
408 for (NameList::iterator
dot =
rule->rhs.begin ();
dot !=
rule->rhs.end (); ++
dot)
415 for (;
item !=
q->closure.end (); ++
item)
421 if (
item ==
q->closure.end ())
426 for (
item =
q->closure.begin ();
item !=
q->closure.end (); ++
item)
437#ifndef QLALR_NO_DEBUG_LOOKBACKS
449 for (Bundle::iterator
a =
q->bundle.begin ();
a !=
q->bundle.end (); ++
a)
456 for (Bundle::iterator
z =
r->bundle.begin ();
z !=
r->bundle.end (); ++
z)
463 q->reads [
a.key ()].insert (sym);
467#ifndef QLALR_NO_DEBUG_DIRECT_READS
469 qerr() <<
"*** DR(" <<
id (
q) <<
", " << dr.key () <<
") = " << dr.value () <<
Qt::endl;
478 for (Bundle::iterator
a =
q->bundle.begin ();
a !=
q->bundle.end (); ++
a)
485 for (Bundle::iterator
z =
r->bundle.begin ();
z !=
r->bundle.end (); ++
z)
497#ifndef QLALR_NO_DEBUG_READS
533 int N = node->dfn = ++_M_reads_dfn;
534 _M_reads_stack.
push (node);
536#ifndef QLALR_NO_DEBUG_INCLUDES
546 node->dfn =
qMin (N,
r->dfn);
548 NameSet &
dst = node->data.state->reads [node->data.nt];
558 tos = _M_reads_stack.
top ();
559 _M_reads_stack.
pop ();
561 }
while (tos != node);
568 p->follows =
p->reads;
590 for (Bundle::iterator
a = pp->bundle.begin ();
a != pp->bundle.end (); ++
a)
603 for (NameList::iterator
A =
rule->rhs.begin ();
A !=
rule->rhs.end (); ++
A)
605 NameList::iterator
dot =
A;
616#ifndef QLALR_NO_DEBUG_INCLUDES
617 qerr() <<
"*** (" <<
id (
p) <<
", " << *
A <<
") includes (" <<
id (pp) <<
", " << *
name <<
")" <<
Qt::endl;
623 p =
p->bundle.value (*
A);
628 NameList::iterator first_not_nullable = std::find_if(
dot,
rule->rhs.end(),
NotNullable(
this));
629 if (first_not_nullable !=
rule->rhs.end ())
638#ifndef QLALR_NO_DEBUG_INCLUDES
639 qerr() <<
"*** (" <<
id (
p) <<
", " << *
A <<
") includes (" <<
id (pp) <<
", " << *
name <<
")" <<
Qt::endl;
652 int N = node->dfn = ++_M_includes_dfn;
653 _M_includes_stack.
push (node);
655#ifndef QLALR_NO_DEBUG_INCLUDES
665 node->dfn =
qMin (N,
r->dfn);
667#ifndef QLALR_NO_DEBUG_INCLUDES
668 qerr() <<
"*** Merge. follows";
670 qerr() <<
" += follows";
675 NameSet &
dst = node->data.state->follows [node->data.nt];
686 tos = _M_includes_stack.
top ();
687 _M_includes_stack.
pop ();
689 }
while (tos != node);
705#ifndef QLALR_NO_DEBUG_LOOKAHEADS
706 qerr() <<
"(" <<
id (
p) <<
", " << *
item->rule <<
") lookbacks ";
708 qerr() <<
" with follows (" <<
id (
q) <<
", " << lookback.
nt <<
") = " <<
q->follows [lookback.
nt] <<
Qt::endl;
719 for (; k !=
p->kernel.end (); ++k, ++
c)
737 if (def ==
state->closure.end () || la >
size)
744 if (def !=
state->closure.end ())
747 state->defaultReduce = def->rule;
754 out <<
"(" <<
id (incl->data.state) <<
", " << incl->data.nt <<
")";
759 out <<
"(" <<
id (
rd->data.state) <<
", " <<
rd->data.nt <<
")";
ReadsGraph::iterator ReadNode
void buildDefaultReduceActions()
void visitReadNode(ReadNode node)
void dump(QTextStream &out, IncludeNode incl)
void buildIncludesDigraph()
IncludesGraph::iterator IncludeNode
void buildIncludesAndFollows()
QPair< StatePointer, bool > internState(const State &state)
void visitIncludeNode(IncludeNode node)
QMultiMap< ItemPointer, Lookback > lookbacks
void closure(StatePointer state)
QMap< ItemPointer, NameSet > lookaheads
QMap< Name, QString > spells
int expected_reduce_reduce
bool isNonTerminal(Name name) const
std::list< QString > names
bool isTerminal(Name name) const
void buildExtendedGrammar()
Name intern(const QString &id)
int expected_shift_reduce
bool operator<(const Include &other) const
bool isReduceItem() const
bool operator<(const Lookback &other) const
static iterator get(_Tp data)
static iterator begin_nodes()
std::list< iterator >::iterator edge_iterator
Repository::iterator iterator
static iterator end_nodes()
bool empty() const noexcept
void push_back(parameter_type t)
void pop_front() noexcept
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
iterator find(const Key &key)
iterator insert(const Key &key, const T &value)
T & top()
Returns a reference to the stack's top item.
T pop()
Removes the top item from the stack and returns it.
void push(const T &t)
Adds element t to the top of the stack.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool operator<(const Read &other) const
QSet< QString >::iterator it
QTextStream & operator<<(QTextStream &out, const Name &n)
QT_BEGIN_NAMESPACE QTextStream & qerr()
ItemList::iterator ItemPointer
StateList::iterator StatePointer
std::list< QString >::iterator Name
debug_infot::iterator RulePointer
QT_BEGIN_NAMESPACE QTextStream & qerr()
Combined button and popup list for selecting options.
QTextStream & endl(QTextStream &stream)
Writes '\n' to the stream and flushes the stream.
bool operator<(Name a, Name b)
std::pair< T1, T2 > QPair
DBusConnection const char * rule
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei GLsizei GLchar * source
GLdouble GLdouble GLdouble GLdouble q
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
static qreal dot(const QPointF &a, const QPointF &b)
#define qPrintable(string)
QRandomGenerator64 rd
[10]
QTextStream out(stdout)
[7]
NotNullable(Automaton *aut)
bool operator()(Name name) const
QPair< ItemPointer, bool > insert(const Item &item)
QPair< ItemPointer, bool > insertClosure(const Item &item)
std::list< ItemPointer > items
State toState(Automaton *aut)
void insert(ItemPointer item)