ContentToken.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __GNUG__
#pragma implementation
#endif
#include "splib.h"
#include <stdlib.h>
#include "ContentToken.h"
#include "macros.h"
#include "ElementType.h"
#include "Vector.h"
#include "Dtd.h"
#include "MessageArg.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
: ModelGroup(v, oi)
{
}
{
return andConnector;
}
: ModelGroup(v, oi)
{
setOrGroup();
}
{
return orConnector;
}
: ModelGroup(v, oi)
{
}
{
return seqConnector;
}
: ContentToken(oi)
{
}
unsigned long ModelGroup::grpgtcnt() const
{
unsigned long cnt = 1;
return cnt;
}
void ModelGroup::setOrGroup()
{
members_[i]->setOrGroupMember();
}
{
return this;
}
{
}
{
}
unsigned long ContentToken::grpgtcnt() const
{
return 1;
}
void ContentToken::setOrGroupMember()
{
}
{
return 0;
}
{
return 0;
}
{
}
{
return 0;
}
void LeafContentToken::setOrGroupMember()
{
orGroupMember_ = 1;
}
{
return this;
}
: LeafContentToken(0, rep)
{
}
: LeafContentToken(0, none)
{
}
{
return 1;
}
{
}
{
}
{
}
{
}
struct GroupInfo {
unsigned nextLeafIndex;
unsigned andStateSize;
};
{
}
{
}
{
initial_ = new InitialPseudoToken;
if (modelGroup_->inherentlyOptional())
pcdataUnreachable = 0;
if (!containsPcdata_)
pcdataUnreachable = 0;
}
{
for (unsigned i = 0; i < nMembers(); i++)
}
{
if (andInfo_) {
return;
}
// follow_ is in decreasing order of andDepth because of how it's
// constructed.
size_t j = 0;
for (size_t i = 0; i < n; i++) {
if (minDepth) {
minDepth = 0;
if (j != i)
if (i == requiredIndex_)
requiredIndex_ = j;
unsigned ei;
if (e == 0) {
}
else
ei = 0;
}
else
// This might not be true: consider (a & b?)*; after the
// a there are two different ways to get to the same b,
// with the same and depth.
a.from = this;
a.andDepth = 0;
}
}
elementTransition[ei] = j;
j++;
}
}
if (pcdataTransitionType_ == 0)
pcdataUnreachable = 1;
}
{
// Vector mapping element type index to index of leaf content token
// of that type to which there is a transition, which is the "worst"
// from the point of view of ambiguity.
// Vector mapping index of leaf content token
// to minimum AND depth of transition to that token.
unsigned pcdataMinCovered = 0;
// follow_ is in decreasing order of andDepth because of how it's
// constructed.
size_t j = 0;
for (size_t i = 0; i < n; i++) {
// ignore transitions to the same token with the same and depth.
if (j != i) {
}
if (i == requiredIndex_)
requiredIndex_ = j;
unsigned ei;
if (e == 0) {
if (pcdataTransitionType_ == 0) {
do {
Boolean hasNonNull = 0;
for (unsigned k = 0; k < andAncestor->nMembers(); k++)
if (k != groupIndex
hasNonNull = 1;
break;
}
if (hasNonNull) {
pcdataUnreachable = 1;
break;
}
} while (andAncestor);
}
else {
pcdataUnreachable = 1;
}
ei = 0;
}
else
// If we have transitions t1, t2, ... tN to tokens having
// the same element type, with
// and-depths d1, d2, ... dN, where d1 >= d2 >= ... >= dN,
// then there is an ambiguity unless
// d1 > d2 > ... > dN and t1, t2, ... , tN-1 are all isolated.
// This might not be true: consider (a & b?)*; after the
// a there are two different ways to get to the same b,
// with the same and depth.
a.from = this;
}
elementTransition[ei] = j;
}
else
elementTransition[ei] = j;
j++;
}
}
if (pcdataMinCovered > 0 || pcdataTransitionType_ == 0)
pcdataUnreachable = 1;
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
if (occurrenceIndicator_ & opt)
inherentlyOptional_ = 1;
if (inherentlyOptional_)
if (occurrenceIndicator_ & plus)
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
if (andAncestor) {
}
inherentlyOptional_ = 0;
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
for (unsigned i = 1; i < nMembers(); i++) {
}
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
for (unsigned i = 1; i < nMembers(); i++) {
if (inherentlyOptional_)
if (member(i).inherentlyOptional())
else
}
}
const AndModelGroup *andAncestor,
unsigned andGroupIndex,
{
unsigned i;
for (i = 1; i < nMembers(); i++) {
}
for (i = 0; i < nMembers(); i++) {
for (unsigned j = 0; j < nMembers(); j++)
if (j != i)
andDepth() + 1,
!member(j).inherentlyOptional(),
}
}
unsigned andClearIndex,
unsigned andDepth,
unsigned requireClear,
unsigned toSet)
{
for (unsigned i = 0; i < length; i++)
toSet);
}
unsigned andClearIndex,
unsigned andDepth,
unsigned requireClear,
unsigned toSet)
{
}
for (size_t i = 0; i < n; i++)
if (andInfo_) {
for (size_t i = 0; i < n; i++) {
t.requireClear = requireClear;
}
}
}
{
}
void AndState::clearFrom1(unsigned i)
{
while (clearFrom_ > i)
v_[--clearFrom_] = 0;
}
: andState_(0)
{
}
minAndDepth_(0)
{
}
const
{
return token;
else
return 0;
}
{
}
{
break;
return 0;
}
return 1;
}
const LeafContentToken *
unsigned minAndDepth) const
{
if (!andInfo_) {
if ((*p)->elementType() == to)
return *p;
}
else {
if ((*p)->elementType() == to
&& q->andDepth >= minAndDepth))
return (*p);
}
return 0;
}
unsigned &minAndDepth,
const LeafContentToken *&newpos) const
{
if (!andInfo_) {
if ((*p)->elementType() == to) {
newpos = *p;
return 1;
}
}
}
else {
if ((*p)->elementType() == to
&& q->andDepth >= minAndDepth)) {
newpos = *p;
return 1;
}
}
}
return 0;
}
void
unsigned minAndDepth,
Vector<const ElementType *> &v) const
{
if (!andInfo_) {
v.push_back((*p)->elementType());
}
else {
&& q->andDepth >= minAndDepth)
v.push_back((*p)->elementType());
}
}
{
return 0;
}
const LeafContentToken *
unsigned minAndDepth) const
{
if (!andInfo_)
return follow_[requiredIndex_];
&& t.andDepth >= minAndDepth)
return follow_[requiredIndex_];
}
return 0;
}
unsigned &minAndDepth,
const LeafContentToken *&newpos)
const
{
if (andInfo_) {
}
}
{
}
{
requiredIndex_ = 0;
}
{
}
}
{
}
#ifdef SP_NAMESPACE
}
#endif