Esempio n. 1
0
void XSDParser::ParseHeader()
{
// xml header
    TToken tok = GetNextToken();
    if (tok == K_XML) {
        for ( ; tok != K_ENDOFTAG; tok=GetNextToken())
            ;
        tok = GetNextToken();
    } else {
        if (m_SrcType == eSchema) {
            ERR_POST_X(4, "LINE " << Location() << " XML declaration is missing");
        }
    }
// schema    
    if (tok != K_SCHEMA) {
        ParseError("Unexpected token", "schema");
    }
    m_EnableNamespaceRedefinition = true;
    for ( tok = GetNextToken(); tok == K_ATTPAIR || tok == K_XMLNS; tok = GetNextToken()) {
        if (tok == K_ATTPAIR) {
            if (IsAttribute("targetNamespace")) {
                m_TargetNamespace = m_Value;
            } else if (IsAttribute("elementFormDefault")) {
                m_ElementFormDefault = IsValue("qualified");
            } else if (IsAttribute("attributeFormDefault")) {
                m_AttributeFormDefault = IsValue("qualified");
            }
        }
    }
    m_EnableNamespaceRedefinition = false;
    if (tok != K_CLOSING) {
        ParseError("tag closing");
    }
}
Esempio n. 2
0
void XSDParser::ParseInclude(void)
{
    TToken tok;
    string name;
    for ( tok = GetNextToken(); tok == K_ATTPAIR || tok == K_XMLNS; tok = GetNextToken()) {
        if (IsAttribute("schemaLocation")) {
            name = m_Value;
        }
    }
    if (tok != K_ENDOFTAG) {
        ParseError("endoftag");
    }
    if (name.empty()) {
        ParseError("schemaLocation");
    }
    DTDEntity& node = m_MapEntity[CreateEntityId(name, DTDEntity::eEntity)];
    if (node.GetName().empty()) {
        node.SetName(name);
        node.SetData(name);
        node.SetExternal();
        PushEntityLexer(name);
        Reset();
        ParseHeader();
    }
}
Esempio n. 3
0
void XSDParser::CreateTypeDefinition(DTDEntity::EType type)
{
    string id, name, data;
    TToken tok;
    data += "<" + m_Raw;
    for ( tok = GetNextToken(); tok == K_ATTPAIR || tok == K_XMLNS; tok = GetNextToken()) {
        data += " " + m_Raw;
        if (IsAttribute("name")) {
            name = m_Value;
            id = CreateEntityId(name,type);
            m_MapEntity[id].SetName(name);
        }
    }
    data += m_Raw;
    if (name.empty()) {
        ParseError("name");
    }
    m_MapEntity[id].SetData(data);
    m_MapEntity[id].SetType(type);
    m_MapEntity[id].SetParseAttributes( m_TargetNamespace,
        m_ElementFormDefault,m_AttributeFormDefault);
    if (tok == K_CLOSING) {
        ParseTypeDefinition(m_MapEntity[id]);
    }
}
	void ActionListSwitch::Update(WorldState& worldState)
	{
		if (mCaseMap == nullptr)
			return;

		Datum* conditionDatum = Search((*this)[ATTRIBUTE_SWITCH_VALUE].Get<std::string>());
		assert(conditionDatum != nullptr);

		Hashmap<Datum, ActionListSwitchCase*>::Iterator caseIterator = mCaseMap->Find(*conditionDatum);
		if (caseIterator == mCaseMap->end())
		{
			// execute default case
			if (IsAttribute(ActionListSwitchCase::ATTRIBUTE_DEFAULT))
			{
				Scope& defaultActionScope = (*this)[ActionListSwitchCase::ATTRIBUTE_DEFAULT].Get<Scope>();
				ActionListSwitchCase* defaultCase = defaultActionScope.AssertiveAs<ActionListSwitchCase>();

				worldState.action = defaultCase;
				defaultCase->Update(worldState);
			}
		}
		else
		{
			ActionListSwitchCase* matchingCase = (*caseIterator).second;
			worldState.action = matchingCase;
			matchingCase->Update(worldState);

			if (!matchingCase->MustBreak)
			{
				Datum& cases = Actions();
				std::uint32_t i;
				for (i = 0; i < cases.Size(); i++)
				{
					if (&cases.Get<Scope>(i) == matchingCase)
					{
						++i;
						break;
					}
				}
				for (; i < cases.Size(); i++)
				{
					Scope& nextCase = cases.Get<Scope>(i);
					assert(nextCase.Is(ActionListSwitchCase::TypeIdClass()));
					matchingCase = static_cast<ActionListSwitchCase*>(&nextCase);
					worldState.action = matchingCase;
					matchingCase->Update(worldState);
					if (matchingCase->MustBreak)
						break;
				}
			}
		}
	}
Esempio n. 5
0
bool Disasm::ParsePCL6() {
	uint8 byte;
	while (fStream->ReadUByte(byte)) {
		if (IsOperator(byte)) {
			if (!DecodeOperator(byte)) return false;
		} else if (IsDataType(byte)) {
			if (!PushData(byte)) return false;
		} else if (IsAttribute(byte)) {
			bool ok = DecodeAttribute(byte);
			ClearAttrs();
			if (!ok) return false;
		} else if (IsEmbedData(byte)) {
			if (!DecodeEmbedData(byte)) return false;
		} else if (IsWhiteSpace(byte)) {
			// nothing to do
		} else if (IsEsc(byte)) {
			return true;
		} else {
			Error("Unknown byte in input stream");
			return false;
		}
	}
	return true;
}
Esempio n. 6
0
	bool Attributed::IsAuxiliaryAttribute(const std::string& name) const
	{
		return IsAttribute(name) && !IsPrescribedAttribute(name);
	}