28 #include <QStringList>    34 #include <QSharedData>    37 #include <QDataStream>    39 #include "priorityqueue.h"    43 #if defined(__GNUC__) \    44     && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)) \    45     && QT_VERSION < QT_VERSION_CHECK(5, 0, 0)    46 #define qFatal(x...) (qFatal(x), __builtin_unreachable())    50 #define DYNGENPAR_DECLARE_TYPEINFO(type, typeclass) \    52   Q_DECLARE_TYPEINFO(DynGenPar::type, typeclass); \    59 #ifdef DYNGENPAR_INTEGER_CATEGORIES    61 #define IS_EPSILON(cat) (!(cat))    72 #define IS_EPSILON(cat) ((cat).isNull())   106     return expect == other.
expect && taboo == other.
taboo;
   110     return stream << expect << 
taboo;
   114     return stream >> expect >> 
taboo;
   124 inline QDataStream &
operator<<(QDataStream &stream,
   134     explicit Rule(
const QVariant &label)
   135       : 
QList<
Cat>(), action(0), lbl(label) {}
   137       : 
QList<
Cat>(list), action(0), lbl() {}
   139       : 
QList<
Cat>(list), action(0), lbl(label) {}
   140     QVariant 
label()
 const {
return lbl;}
   141     void setLabel(
const QVariant &label) {lbl = label;}
   152     Rule &operator<<(const QList<Cat> &other) {
   168                                bool writeAction = 
true)
 const {
   173              << (writeAction ? action : 
static_cast<Action *
>(0));
   184 DYNGENPAR_DECLARE_TYPEINFO(
Rule, Q_MOVABLE_TYPE);
   195   Cfg() : rules(), tokens(), startCat() {}
   197     : rules(r), tokens(t), startCat(sc) {}
   205     return stream << rules << tokens << startCat;
   209     return stream >> rules >> tokens >> startCat;
   212 DYNGENPAR_DECLARE_TYPEINFO(
Cfg, Q_MOVABLE_TYPE);
   221     : fullLiteral(fullLit), cat(c) {}
   239     : fullLiteral(), cat(), nextTokenConstraints() {}
   241     : fullLiteral(fullLit), cat(c), nextTokenConstraints() {}
   244     : fullLiteral(fullLit), cat(c), nextTokenConstraints(ntc) {}
   263   FullRule() : cat(), rule(), epsilonsSkipped(0), ruleno(0) {}
   265     : cat(c), rule(r), epsilonsSkipped(epsSkipped), ruleno(n) {}
   274 DYNGENPAR_DECLARE_TYPEINFO(
FullRule, Q_MOVABLE_TYPE);
   287     QVariant 
label()
 const {
return lbl;}
   288     void setLabel(
const QVariant &label) {lbl = label;}
   317 DYNGENPAR_DECLARE_TYPEINFO(
Alternative, Q_MOVABLE_TYPE);
   331     return cat == other.
cat && data == other.
data && children == other.
children;
   334 DYNGENPAR_DECLARE_TYPEINFO(
Node, Q_MOVABLE_TYPE);
   346     QHash<Cat, QPair<QPair<Node, NextTokenConstraints>, 
int> > 
pConstraints;
   358     QHash<Cat, QPair<QPair<Node, NextTokenConstraints>, 
int> > &
pConstraints() {
   360       return d->pConstraints;
   364       return d->mcfgConstraints;
   367       return d ? d->pConstraints.contains(cat) : 
false;
   370       return d ? d->mcfgConstraints.contains(cat) : 
false;
   374       return d ? d->pConstraints.value(cat)
   375                : QPair<QPair<Node, NextTokenConstraints>, 
int>();
   378       return d ? d->mcfgConstraints.value(cat) : QPair<int, PseudoCatScope>();
   380     bool isNull()
 const { 
return !d.constData(); }
   385     QSharedDataPointer<PseudoCatScopeData> d;
   386     void ensureNonNull() {
   399   Match() : len(0), tree(), ruleno(0), scope(), nextTokenConstraints() {}
   401     : len(l), tree(t), ruleno(n), scope(s), nextTokenConstraints() {}
   403     : len(l), tree(t), ruleno(n), scope(s), nextTokenConstraints(nt) {}
   411 DYNGENPAR_DECLARE_TYPEINFO(
Match, Q_MOVABLE_TYPE);
   422 DYNGENPAR_DECLARE_TYPEINFO(
ActionInfo, Q_MOVABLE_TYPE);
   428     virtual Action *readAction(QDataStream &) = 0;
   435     static QHash<QString, ActionDeserializer *> deserializers;
   439       deserializers.insert(name, deserializer);
   443     virtual void execute(
const ActionInfo &info) = 0;
   450       qWarning(
"action not serializable");
   457       if (type.isEmpty()) {
   460       } 
else if (deserializers.contains(type)) {
   461         data = deserializers.value(type)->readAction(stream);
   463       } 
else qFatal(
"action deserializer \"%s\" not found",
   464                     type.toLocal8Bit().data());
   467 DYNGENPAR_DECLARE_TYPEINFO(
Action, Q_MOVABLE_TYPE);
   479     virtual int type() 
const = 0;
   481     virtual void addParent(
const StackItem &parent) = 0;
   497               int i, 
const Node &tree, 
int ruleno,
   506     int type()
 const {
return d ? d->type() : -1;}
   507     int depth()
 const {
return d ? d->depth() : -1;}
   512       return depth() < other.
depth();
   515     QSharedDataPointer<StackItemData> d;
   517 DYNGENPAR_DECLARE_TYPEINFO(
StackItem, Q_MOVABLE_TYPE);
   524       : 
StackItemData(0), m_parents(parents), m_cat(cat), m_effCat(effCat),
   525         m_pos(pos), m_scope(scope) {
   526           foreach(
const StackItem &parent, parents) {
   527             int newDepth = parent.
depth() + 1;
   528             if (m_depth < newDepth) m_depth = newDepth;
   533     virtual int type()
 const {
return 0;}
   535       m_parents.append(parent);
   536       int newDepth = parent.
depth() + 1;
   537       if (m_depth < newDepth) m_depth = newDepth;
   542       foreach(
const StackItem &parent, parents) {
   543         int newDepth = parent.
depth() + 1;
   544         if (m_depth < newDepth) m_depth = newDepth;
   550     int pos()
 const {
return m_pos;}
   565       StackItemData(0), m_parents(parents), m_cat(cat), m_effCat(effCat),
   567           foreach(
const StackItem &parent, parents) {
   568             int newDepth = parent.
depth() + 1;
   569             if (m_depth < newDepth) m_depth = newDepth;
   574     virtual int type()
 const {
return 1;}
   577       qFatal(
"cannot call addParent on type 1 item");
   581       qFatal(
"cannot call setParents on type 1 item");
   602     virtual int type()
 const {
return 2;}
   604       qFatal(
"cannot call addParent on type 2 item");
   607       qFatal(
"cannot call setParents on type 2 item");
   619                    int i, 
const Node &tree, 
int ruleno,
   621       : 
StackItemData(parent.depth() + 1), m_parent(parent), m_rule(rule),
   622         m_len(len), m_curr(curr), m_i(i), m_tree(tree), m_ruleno(ruleno),
   623         m_nextTokenConstraints(nextTokenConstraints) {}
   626     virtual int type()
 const {
return 3;}
   628       qFatal(
"cannot call addParent on type 3 item");
   631       qFatal(
"cannot call setParents on type 3 item");
   635     int len()
 const {
return m_len;}
   636     int curr()
 const {
return m_curr;}
   637     int i()
 const {
return m_i;}
   641       return m_nextTokenConstraints;
   646     int m_len, m_curr, m_i;
   658       : 
StackItemData(parent.depth() + 1), m_parent(parent), m_target(target),
   659         m_pos(pos), m_len(len) {}
   662     virtual int type()
 const {
return 4;}
   664       qFatal(
"cannot call addParent on type 4 item");
   667       qFatal(
"cannot call setParents on type 4 item");
   671     int pos()
 const {
return m_pos;}
   672     int len()
 const {
return m_len;}
   686       : 
StackItemData(parent.depth() + 1), m_parent(parent), m_cat(cat),
   690     virtual int type()
 const {
return 5;}
   692       qFatal(
"cannot call addParent on type 5 item");
   695       qFatal(
"cannot call setParents on type 5 item");
   713       : 
StackItemData(parent.depth() + 1), m_parent(parent), m_leaves(leaves),
   714         m_i(i), m_tree(tree), m_scope(scope),
   715         m_nextTokenConstraints(nextTokenConstraints) {}
   718     virtual int type()
 const {
return 6;}
   720       qFatal(
"cannot call addParent on type 6 item");
   723       qFatal(
"cannot call setParents on type 6 item");
   727     int i()
 const {
return m_i;}
   731       return m_nextTokenConstraints;
   762                             int curr, 
int i, 
const Node &tree, 
int ruleno,
   766                          nextTokenConstraints);
   782                             int i, 
const Node &tree,
   786   d = 
new StackItemType6(parent, leaves, i, tree, scope, nextTokenConstraints);
   805     bool isNull()
 const { 
return !d.constData(); }
   809     QSharedDataPointer<AbstractLexerStateData> d;
   811 DYNGENPAR_DECLARE_TYPEINFO(
LexerState, Q_MOVABLE_TYPE);
   824       Cat result = readToken();
   828         if (tree.children.isEmpty()) tree = 
Node(result);
   846       return treeToMatch.
cat == tree.cat;
   864       return (pos == currPos);
   876       bool ret = rewindTo(pos, lexerState);
   884     virtual Cat readToken() = 0;
   889       if (rewindOnly && pos > currPos) 
   904 DYNGENPAR_DECLARE_TYPEINFO(
TokenSource, Q_MOVABLE_TYPE);
   913       return simpleRewind(pos);
   918       if (currPos < inputTokens.size())
   919         return inputTokens.at(currPos);
   938     if (c == 
'\r') 
return;
   949 DYNGENPAR_DECLARE_TYPEINFO(
TextPosition, Q_PRIMITIVE_TYPE);
   957   Term() : arg(-1), component(0), token() {}
   958   Term(
int a, 
int c) : arg(a), component(c), token() {}
   970            && token == other.
token;
   973 DYNGENPAR_DECLARE_TYPEINFO(
Term, Q_MOVABLE_TYPE);
   982       : 
QList<
Term>(), nextTokenConstraints(ntc) {}
   984       : 
QList<
Term>(list), nextTokenConstraints() {}
   986       : 
QList<
Term>(list), nextTokenConstraints(ntc) {}
  1012 DYNGENPAR_DECLARE_TYPEINFO(
Sequence, Q_MOVABLE_TYPE);
  1044 DYNGENPAR_DECLARE_TYPEINFO(
Function, Q_MOVABLE_TYPE);
  1096     int index = functions.size();
  1097     functions.append(
function);
  1098     functionNames.insert(index, name);
  1099     functionIndices.insert(name, index);
  1102     if (
id.type() == QVariant::Int) 
return functions.at(
id.toInt());
  1104     QString name = 
id.toString();
  1105     if (!functionIndices.contains(name)) 
return Function();
  1106     return functions.at(functionIndices.value(name));
  1110 DYNGENPAR_DECLARE_TYPEINFO(
Pmcfg, Q_MOVABLE_TYPE);
  1116     : pmcfgRule(rule), argPositions(rule.size()) {}
  1133     : errorPos(-1), errorToken(), incrementalPos(-1), incrementalStacks(),
  1134       incrementalMatches(), lexerState() {}
  1137     : errorPos(other.errorPos), errorToken(other.errorToken),
  1138       incrementalPos(other.incrementalPos),
  1139       incrementalStacks(other.incrementalStacks),
  1140       incrementalMatches(other.incrementalMatches), lexerState(other.lexerState)
  1152 DYNGENPAR_DECLARE_TYPEINFO(
ParseState, Q_MOVABLE_TYPE);
  1162       : inputSource(tokenSource), lastGeneratedCat(0) {}
  1166     bool isLiteral(
const QList<Cat> &list) 
const;
  1177     bool loadPmcfg(
const Pmcfg &pmcfg);
  1180                        int *incrementalPos = 0,
  1197       if (nextStacks.isEmpty() && currentMatches.isEmpty() && errPos < 0) {
  1198         parseState->
reset(); 
  1205         parseState->
lexerState = inputSource->saveState();
  1213     QHash<Cat, QSet<Cat> > expandNonterminalPrediction(
CatArg cat) 
const;
  1214     QHash<Cat, QSet<Cat> > expandNonterminalPredictionC(
CatArg cat);
  1222     QHash<Cat, QSet<QList<Cat> > >
  1223       expandNonterminalPredictionMulti(
CatArg cat) 
const;
  1224     QHash<Cat, QSet<QList<Cat> > >
  1225       expandNonterminalPredictionMultiC(
CatArg cat);
  1226     ConstrainedPredictions computeConstrainedPredictions(
  1233     QHash<Cat, QSet<Cat> > expandNonterminalPredictionC(
CatArg cat,
  1235     QHash<Cat, QSet<Cat> > expandNonterminalPredictionC(
CatArg cat,
  1245     QHash<Cat, QSet<QList<Cat> > >
  1246       expandNonterminalPredictionMultiC(
CatArg cat,
  1248     QHash<Cat, QSet<QList<Cat> > >
  1249       expandNonterminalPredictionMultiC(
CatArg cat,
  1310     void processRule(
CatArg cat, 
const Rule &rule, 
int skip, 
int ruleno,
  1311                      QQueue<Cat> &nullableQueue, 
bool &clearEpsilonMatches);
  1312     bool computePmcfgDimension(
CatArg cat, 
const Rule &rule,
  1313                                const Pmcfg &pmcfg);
  1314     bool convertPmcfgRule(
CatArg cat, 
const Rule &rule, 
const Pmcfg &pmcfg,
  1316     bool reachable(
CatArg cat, 
CatArg target, QSet<Cat> mark);
  1326     bool matchesTokenRecurse(
CatArg cat, 
CatArg token, QSet<Cat> mark) 
const;
  1329     bool validateNextTokenConstraints(
CatArg token,
  1334     bool verifyLookaheadRule(
const Rule &rule, 
int i, 
int &curr,
  1335                              int &remaining, QSet<Cat> &mark);
  1342                                   &nextTokenConstraints);
  1343     Cat findFirstToken(
const Node &tree);
  1349                         QSet<Cat> mark = QSet<Cat>());
  1353     bool shift(
int pos);
  1354     void expandNonterminalPredictionRecurse(
CatArg cat,
  1355                                             QHash<
Cat, QSet<Cat> > &result,
  1356                                             QSet<Cat> &mark) 
const;
  1357     void expandNonterminalPredictionRecurseC(
CatArg cat,
  1358                                              QHash<
Cat, QSet<Cat> > &result,
  1359                                              QSet<Cat> mark, 
int ruleno,
  1362                                                &nextTokenConstraints);
  1363     void expandNonterminalPredictionMultiRecurse(
CatArg cat,
  1364       QHash<
Cat, QSet<
QList<Cat> > > &result, QSet<Cat> &mark) 
const;
  1365     void expandNonterminalPredictionMultiRecurseC(
CatArg cat,
  1366       QHash<
Cat, QSet<
QList<Cat> > > &result, QSet<Cat> mark, 
int ruleno,
  1369     int generateCat() { 
return --lastGeneratedCat; }
  1372     QMultiHash<Cat, FullRule> initialGraph;
  1378     QHash<Cat, QList<Match> > epsilonMatches;
  1387     QHash<Cat, int> type0Indices;
  1396     QHash<const StackItemData *, QPair<bool, QList<Match> > > collectedMatches;
  1398     Private::PriorityQueue<StackItem> priorityQueue;
  1407     int lastGeneratedCat;
  1409 DYNGENPAR_DECLARE_TYPEINFO(
Parser, Q_MOVABLE_TYPE);
  1422     *QSharedDataPointer<DynGenPar::StackItemData>::clone()
  1429     *QSharedDataPointer<DynGenPar::AbstractLexerStateData>::clone()
  1468   } 
else return stream << QString();
  1475 #endif // DYNGENPAR_H const StackItem & parent() const
 
virtual ~StackItemType5()
 
ParseState(const ParseState &other)
 
const AbstractLexerStateData * data() const
 
MultiPredictions computeMultiPredictions(const ParseState &parseState) const
overloaded version using ParseState, for bindings 
 
virtual StackItemData * clone()
 
PseudoCatScope scope() const
 
virtual void writeExternal(QDataStream &stream) const
implementation of the QDataStream operator<< 
 
QList< Cat > fullLiteral
the entire literal completed by the prediction 
 
bool operator==(const Term &other) const
needed for QList 
 
void add(const DynGenPar::Node &value)
Java-style + the binding generator doesn't detect the inherited append. 
 
ConstrainedMultiPrediction(const QList< Cat > &fullLit, CatArg c)
 
ConstrainedMultiPrediction(const QList< Cat > &fullLit, CatArg c, NextTokenConstraints ntc)
 
Term()
dummy default constructor for bindings 
 
QList< Term > & toList()
for bindings 
 
QDataStream & operator>>(QDataStream &stream, DynGenPar::Action *&data)
 
Function(const QList< Sequence > &list)
 
QHash< Cat, QPair< Cat, int > > componentCats
maps categories which represent components of a multi-component category to the category and componen...
 
Sequence(const QList< Term > &list)
 
const StackItem & parent() const
 
static QDataStream & constructAndRead(QDataStream &stream, Action *&data)
implementation of the QDataStream operator>> 
 
QHash< Cat, QList< Rule > > RuleSet
 
PseudoCatScope scope() const
 
type 6 item: during match, we're matching a P constraint 
 
virtual LexerState saveState()
saves the current lexer state, by default a null LexerState 
 
QDataStream & writeExternal(QDataStream &stream, bool writeLabel=true, bool writeAction=true) const
implementation of the QDataStream operator<< 
 
static void registerDeserializer(const QString &name, ActionDeserializer *deserializer)
 
QPair< QPair< Node, NextTokenConstraints >, int > pConstraint(CatArg cat) const
 
Sequence(const QList< Term > &list, const NextTokenConstraints &ntc)
 
Match(int l, Node t, int n, PseudoCatScope s, const NextTokenConstraints &nt)
 
QHash< Cat, QPair< int, PseudoCatScope > > mcfgConstraints
hash table recording MCFG constraints 
 
virtual Cat readToken()
just fetch the next token from the list 
 
void addParent(const StackItem &parent)
 
virtual StackItemData * clone()
 
An object representing a CFG (or a PMCFG in our internal representation) 
 
virtual ~AbstractLexerStateData()
 
const QList< StackItem > & parents() const
 
QList< Cat > fullLiteral
the entire literal completed by the prediction 
 
Sequence(const NextTokenConstraints &ntc)
 
data passed to parser actions 
 
bool operator==(const ConstrainedMultiPrediction &other) const
needed for QList, QMultiHash 
 
Alternative & operator+=(const DynGenPar::Node &value)
 
virtual void addParent(const StackItem &)
 
bool operator==(const Node &other) const
needed for QList 
 
void add(const Term &value)
Java-style (for consistency, even though append is detected here) 
 
LexerState(AbstractLexerStateData *data)
 
uint qHash(const NextTokenConstraints &nextTokenConstraints)
simple hash function for next token constraints 
 
bool hasPConstraint(CatArg cat) const
 
virtual int lookaheadTokens() const
the number of tokens to look ahead before deciding to execute the action 
 
interface for parser action deserializers 
 
virtual void setParents(const QList< StackItem > &)
 
NextTokenConstraints nextTokenConstraints
 
QList< Cat > expect
list of context-free categories the next token MUST match 
 
QString Cat
Category type: string or integer depending on DYNGENPAR_INTEGER_CATEGORIES. 
 
QHash< Cat, QPair< QPair< Node, NextTokenConstraints >, int > > & pConstraints()
 
NextTokenConstraints nextTokenConstraints() const
 
virtual ~ListTokenSource()
 
type 0 item: during match, we're waiting for a token to shift 
 
NextTokenConstraints nextTokenConstraints
only for nonterminals 
 
term in the expression of a component of a PMCFG function 
 
component of a PMCFG function, a sequence of terms 
 
const QList< StackItem > & parents() const
 
virtual void addParent(const StackItem &parent)
 
void setLabel(const QVariant &label)
 
StackItemType1(const QList< StackItem > &parents, CatArg cat, CatArg effCat, const PseudoCatScope &scope)
 
QHash< int, QString > functionNames
 
bool simpleRewind(int pos, bool rewindOnly=false)
basic implementation of rewindTo for subclasses which support it 
 
Cfg()
dummy default constructor for bindings 
 
RuleSet cfRules
optional context-free rules 
 
Match(int l, Node t, int n, PseudoCatScope s)
 
QDataStream & operator<<(QDataStream &stream, const DynGenPar::Action *data)
 
virtual void addParent(const StackItem &)
 
Sequence & operator<<(const Term &value)
 
virtual void addParent(const StackItem &)
 
Node parseTree()
get the parse tree for the last shifted token 
 
StackItemType5(const StackItem &parent, CatArg cat, const PseudoCatScope &scope)
 
QList< DynGenPar::Node > & toList()
for bindings 
 
virtual ~ActionDeserializer()
 
QHash< Cat, QPair< int, PseudoCatScope > > & mcfgConstraints()
 
QList< Cat > & toList()
for bindings 
 
const StackItem & parent() const
 
TokenSet tokens
set of true tokens 
 
void countCharacter(unsigned char c)
convenience method to count a character 
 
Alternative(const QList< DynGenPar::Node > &list)
 
MultiPrediction()
dummy default constructor for bindings 
 
QHash< Cat, QPair< QPair< Node, NextTokenConstraints >, int > > pConstraints
hash table recording parallel constraints 
 
ConstrainedPredictions computeConstrainedPredictions(const ParseState &parseState) const
overloaded version using ParseState, for bindings 
 
Rule & operator<<(const Cat &value)
 
QHash< Cat, QList< Cat > > catComponents
maps multi-component categories to the list of their components 
 
static bool serializeActions
whether the operator<<(QDataStream &, const Rule &) should serialize actions 
 
virtual ~StackItemType6()
 
Predictions computePredictions(const ParseState &parseState) const
overloaded version using ParseState, for bindings 
 
Function lookupFunction(const QVariant &id) const
 
Sequence & operator+=(const QList< Term > &other)
 
virtual StackItemData * clone()=0
 
StackItemType6(const StackItem &parent, const QList< Node > &leaves, int i, const Node &tree, const PseudoCatScope &scope, const NextTokenConstraints &nextTokenConstraints)
 
Cat startCat
start category 
 
virtual ~StackItemType3()
 
Rule & operator+=(const QList< Cat > &other)
 
type 3 item: during matchRemaining, we're executing a match 
 
attached to the parse trees as rule labels to allow obtaining syntax trees 
 
bool isToken(CatArg cat) const
 
void saveState(ParseState *parseState)
saves the current parser state, only meaningful during a parse operation 
 
void addToken(CatArg cat)
 
type 1 item: during type 0 item processing, we're executing a reduce 
 
virtual StackItemData * clone()
 
virtual void setParents(const QList< StackItem > &parents)
 
QDataStream & readExternal(QDataStream &stream)
implementation of the QDataStream operator>> 
 
virtual void setParents(const QList< StackItem > &)
 
ConstrainedMultiPredictions computeConstrainedMultiPredictions(const ParseState &parseState) const
overloaded version using ParseState, for bindings 
 
bool hasMcfgConstraint(CatArg cat) const
 
QList< Cat > taboo
list of context-free categories the next token MUST NOT match 
 
virtual void setParents(const QList< StackItem > &)
 
Cfg(const RuleSet &r, const TokenSet &t, CatArg sc)
 
virtual bool rewindTo(int pos, const LexerState &=LexerState())
rewind to an older position (requires buffering) 
 
PseudoCatScope scope() const
 
TokenSource * inputSource
input source 
 
QList< Match > incrementalMatches
 
virtual AbstractLexerStateData * clone()=0
 
Rule & operator+=(const Cat &value)
 
FullRule(CatArg c, const Rule &r, int epsSkipped, int n)
 
Function & operator+=(const QList< Sequence > &other)
 
bool operator==(const LexerState &other) const
 
StackItemType4(const StackItem &parent, CatArg target, int pos, int len)
 
API for stateful lexers to save their state for rewinding. 
 
FullRule()
dummy default constructor for bindings 
 
QDataStream & writeExternal(QDataStream &stream) const
implementation of the QDataStream operator<< 
 
Match()
dummy default constructor for bindings 
 
Function & operator<<(const Sequence &value)
 
bool operator==(const PseudoCatScope &other) const
 
Sequence & operator+=(const Term &value)
 
Node(CatArg c, const QVariant &d)
 
Rule(const QList< Cat > &list)
 
ConstrainedMultiPrediction()
dummy default constructor for bindings 
 
QMultiHash< QList< Cat >, ConstrainedMultiPrediction > ConstrainedMultiPredictions
 
Cat cat
the nonterminal generating the literal 
 
QMultiHash< Cat, NextTokenConstraints > ConstrainedPredictions
 
MultiPrediction(const QList< Cat > &fullLit, CatArg c)
 
void add(const Sequence &value)
Java-style (for consistency, even though append is detected here) 
 
RuleSet rules
set of PMCFG rules 
 
Node tree
sub-parse-tree for hierarchical parsing 
 
virtual bool rewindTo(int pos, const LexerState &=LexerState())
overridden because lists can be rewound 
 
virtual StackItemData * clone()
 
virtual ~StackItemType4()
 
int currentPosition()
get the current input position 
 
Rule(const QVariant &label)
 
Cat startCat
start category 
 
int ruleno
used for PMCFGs 
 
TextPosition(int l, int c)
 
StackItemType0(const QList< StackItem > &parents, CatArg cat, CatArg effCat, int pos, const PseudoCatScope &scope)
 
QMultiHash< QList< Cat >, MultiPrediction > MultiPredictions
 
StackItemType3(const StackItem &parent, const Rule &rule, int len, int curr, int i, const Node &tree, int ruleno, const NextTokenConstraints &nextTokenConstraints)
 
type 4 item: during reduce, we're executing a matchRemaining 
 
QList< Function > functions
list of PMCFG functions 
 
RuleSet rules
grammar rules 
 
multi-token predictions with next token constraints 
 
virtual StackItemData * clone()
 
interface for parser actions 
 
type 2 item: during reduce, we're recursively executing another reduce 
 
Parser(TokenSource *tokenSource)
 
Cat cat
the nonterminal generating the literal / the nonterminal itself 
 
const StackItem & parent() const
 
const Cat & CatArg
Category type (string or integer) when passed as an argument. 
 
bool rewindTo(int pos, const Node &parseTree, const LexerState &lexerState=LexerState())
rewind to an older position (requires buffering) and restore the parse tree (needed for lookahead) ...
 
QList< StackItem > incrementalStacks
 
virtual bool matchParseTree(const Node &treeToMatch)
match the parse tree for the last shifted token against the given tree 
 
void addFunction(const QString &name, const Function &function)
 
ActionInfo(const Node &t, Parser *p)
 
virtual ~StackItemType2()
 
virtual void setParents(const QList< StackItem > &)
 
Alternative(const QVariant &label)
 
virtual ~StackItemType0()
 
bool operator==(const MultiPrediction &other) const
needed for QList, QMultiHash 
 
void add(const Cat &value)
Java-style + the binding generator doesn't detect the inherited append. 
 
Alternative & operator<<(const DynGenPar::Node &value)
 
QHash< Cat, QPair< Cat, QList< Cat > > > pseudoCats
pseudo-categories, used to represent PMCFGs internally 
 
void setLabel(const QVariant &label)
 
QHash< QString, int > functionIndices
 
QDataStream & readExternal(QDataStream &stream)
implementation of the QDataStream operator>> 
 
virtual void setParents(const QList< StackItem > &)
 
PmcfgComponentInfo(const Rule &rule)
 
QList< Sequence > & toList()
for bindings 
 
QList< Node > leaves() const
 
void setParents(const QList< StackItem > &parents)
 
int ruleno
needed for PMCFGs (to match components of rules to each other) 
 
QDataStream & readExternal(QDataStream &stream)
implementation of the QDataStream operator>> 
 
Alternative(const QList< DynGenPar::Node > &list, const QVariant &label)
 
Cfg getCfg()
get a Cfg object back from the parser, for serialization 
 
PseudoCatScope scope() const
 
StackItemType2(const StackItem &parent)
 
QVector< QVector< int > > argPositions
 
full rule as found in the initial graph 
 
bool operator==(const NextTokenConstraints &other) const
needed for hash tables 
 
virtual StackItemData * clone()
 
virtual void addParent(const StackItem &)
 
Rule(const QList< Cat > &list, const QVariant &label)
 
Function & operator+=(const Sequence &value)
 
const StackItemData * data() const
 
void loadCfg(const Cfg &cfg)
 
bool isToken(CatArg cat) const
 
static bool serializeLabels
whether the operator<<(QDataStream &, const Rule &) should serialize labels 
 
virtual void setParents(const QList< StackItem > &)
 
QDataStream & writeExternal(QDataStream &stream) const
implementation of the QDataStream operator<< 
 
int col
column, zero-based 
 
virtual void addParent(const StackItem &)
 
NextTokenConstraints nextTokenConstraints
 
const PseudoCatScopeData * data() const
needed for hash tables 
 
type 5 item: during match (of an MCFG constraint), we're executing a matchRemaining ...
 
rule constraints affecting the next token, for scannerless parsing 
 
QList< Alternative > children
 
QList< Match > parse(ParseState *parseState)
overloaded version using ParseState, for bindings 
 
void addToken(CatArg cat)
 
virtual StackItemData * clone()
 
Node parseTreeToPmcfgSyntaxTree(const Node &parseTree)
converts a parse tree obtained from a PMCFG to a PMCFG syntax tree 
 
QPair< int, PseudoCatScope > mcfgConstraint(CatArg cat) const
 
Cat nextToken()
get the next token from the input, increment current position, save parse tree 
 
bool operator<(const StackItem &other) const
 
const StackItem & parent() const
 
NextTokenConstraints nextTokenConstraints
 
virtual void addParent(const StackItem &)
 
Alternative & operator+=(const QList< DynGenPar::Node > &other)
 
parse state struct, for bindings 
 
ActionInfo()
dummy default constructor for bindings 
 
virtual ~StackItemType1()
 
NextTokenConstraints nextTokenConstraints() const