Anything GenericXMLParser::ParseDtd()
{
	StartTrace(GenericXMLParser.ParseDtd);
	// we got already <! following a D
	String doctype("!");
	doctype.Append(ParseName());
	Anything result;
	Anything externalid;
	if (doctype != "!DOCTYPE") {
		Error("invalid <! tag");
		result[doctype] = SkipToClosingAngleBracket(); // best effort
		return result;
	}
	SkipWhitespace();
	String rootnodename = ParseName();
	result[doctype] = rootnodename;
	SkipWhitespace();
	int c = Peek();
	if ('S' == c || 'P' == c) {
		externalid = ParseExternalId();
	}
	result.Append(externalid);
	SkipWhitespace();
	if ('[' == Peek()) {
		result.Append(ParseDtdElements());
	}
	SkipWhitespace();
	if ('>' != Peek()) {
		Error("DTD syntax error");
		result.Append(SkipToClosingAngleBracket());
	} else {
		Get(); // read the end >
	}
	return result;
}
// <special-name> ::= TV <type>
//                ::= TT <type>
//                ::= TI <type>
//                ::= TS <type>
//                ::= Tc <call-offset> <call-offset> <(base) encoding>
//                ::= GV <(object) name>
//                ::= T <call-offset> <(base) encoding>
// G++ extensions:
//                ::= TC <type> <(offset) number> _ <(base) type>
//                ::= TF <type>
//                ::= TJ <type>
//                ::= GR <name>
//                ::= GA <encoding>
//                ::= Th <call-offset> <(base) encoding>
//                ::= Tv <call-offset> <(base) encoding>
//
// Note: we don't care much about them since they don't appear in
// stack traces.  The are special data.
static bool ParseSpecialName(State *state) {
  State copy = *state;
  if (ParseChar(state, 'T') &&
      ParseCharClass(state, "VTIS") &&
      ParseType(state)) {
    return true;
  }
  *state = copy;

  if (ParseTwoChar(state, "Tc") && ParseCallOffset(state) &&
      ParseCallOffset(state) && ParseEncoding(state)) {
    return true;
  }
  *state = copy;

  if (ParseTwoChar(state, "GV") &&
      ParseName(state)) {
    return true;
  }
  *state = copy;

  if (ParseChar(state, 'T') && ParseCallOffset(state) &&
      ParseEncoding(state)) {
    return true;
  }
  *state = copy;

  // G++ extensions
  if (ParseTwoChar(state, "TC") && ParseType(state) &&
      ParseNumber(state) && ParseChar(state, '_') &&
      DisableAppend(state) &&
      ParseType(state)) {
    RestoreAppend(state, copy.append);
    return true;
  }
  *state = copy;

  if (ParseChar(state, 'T') && ParseCharClass(state, "FJ") &&
      ParseType(state)) {
    return true;
  }
  *state = copy;

  if (ParseTwoChar(state, "GR") && ParseName(state)) {
    return true;
  }
  *state = copy;

  if (ParseTwoChar(state, "GA") && ParseEncoding(state)) {
    return true;
  }
  *state = copy;

  if (ParseChar(state, 'T') && ParseCharClass(state, "hv") &&
      ParseCallOffset(state) && ParseEncoding(state)) {
    return true;
  }
  *state = copy;
  return false;
}
// <encoding> ::= <(function) name> <bare-function-type>
//            ::= <(data) name>
//            ::= <special-name>
static bool ParseEncoding(State *state) {
  State copy = *state;
  if (ParseName(state) && ParseBareFunctionType(state)) {
    return true;
  }
  *state = copy;

  if (ParseName(state) || ParseSpecialName(state)) {
    return true;
  }
  return false;
}
Exemplo n.º 4
0
/* TODO(d'b): it is ugly. solution needed */
static void NameServer(struct Manifest *manifest, char *value)
{
  GPtrArray *dummy = g_ptr_array_new();
  ParseName(value, dummy);
  manifest->name_server = g_ptr_array_index(dummy, 0);
  g_ptr_array_free(dummy, TRUE);
}
Exemplo n.º 5
0
/* IScanner */
static inline int ParseSection(struct IParse *parse, struct ISettings *settings)
{
	ParseComment(parse);
	ParseSkip(parse);

	int code = ParsePeek(parse, 0);
	if (!(code == '[')) {
		return 0;
	}

	ParseRead(parse); /* [ */
	ParseSkip(parse);

	/* Section Name */
	char name[MAX_NAME];
	if (!ParseName(parse, name, MAX_NAME)) {
		return 0;
	}

	ParseSkip(parse);
	code = ParsePeek(parse, 0);
	if (!(code == ']')) {
		return 0;
	}

	ParseRead(parse); /* "]" */

	HSECTION section = NULL;
	if (!(section = CreateSection(settings, name))) {
		return 0;
	}

	while (ParseValue(parse, section));
	return 1;
}
Exemplo n.º 6
0
/* IScanner */
static inline int ParseValue(struct IParse *parse, struct ISection *section)
{
	ParseComment(parse);
	ParseSkip(parse);

	/* Value Name */
	char name[MAX_NAME];
	if (!ParseName(parse, name, MAX_NAME)) {
		return 0;
	}

	ParseSkip(parse);
	int code = ParsePeek(parse, 0);
	if (!(code == '=')) {
		return 0;
	}

	ParseRead(parse); /* = */
	ParseSkip(parse);

	/* Value Data */
	char data[MAX_VALUE];
	if (!ParseData(parse, data, MAX_VALUE)) {
		return 0;	
	}

	AddSectionString(section, name, data);
	return 1;
}
Exemplo n.º 7
0
HRESULT FusionBind::EmitToken(IMetaDataAssemblyEmit *pEmit, 
                              mdAssemblyRef *pToken)
{
    HRESULT hr;
    ASSEMBLYMETADATA AMD;

    IfFailRet(ParseName());

    AMD.usMajorVersion = m_context.usMajorVersion;
    AMD.usMinorVersion = m_context.usMinorVersion;
    AMD.usBuildNumber = m_context.usBuildNumber;
    AMD.usRevisionNumber = m_context.usRevisionNumber;

    if (m_context.szLocale) {
        AMD.cbLocale = MultiByteToWideChar(CP_ACP, 0, m_context.szLocale, -1, NULL, 0);
        AMD.szLocale = (LPWSTR) alloca(AMD.cbLocale);
        MultiByteToWideChar(CP_ACP, 0, m_context.szLocale, -1, AMD.szLocale, AMD.cbLocale);
    }
    else {
        AMD.cbLocale = 0;
        AMD.szLocale = NULL;
    }

    long pwNameLen = WszMultiByteToWideChar(CP_UTF8, 0, m_pAssemblyName, -1, 0, 0);
    CQuickBytes qb;
    LPWSTR pwName = (LPWSTR) qb.Alloc(pwNameLen*sizeof(WCHAR));

    WszMultiByteToWideChar(CP_UTF8, 0, m_pAssemblyName, -1, pwName, pwNameLen);
    return pEmit->DefineAssemblyRef(m_pbPublicKeyOrToken, m_cbPublicKeyOrToken,
                                    pwName,
                                    &AMD,
                                    NULL, 0,
                                    m_dwFlags, pToken);
}
Anything GenericXMLParser::ParseCdata()
{
	StartTrace(GenericXMLParser.ParseCdata);
	String key("![");
	Anything result;
	Get(); // read '['
	SkipWhitespace();
	key.Append(ParseName());
	SkipWhitespace();
	if ('[' == Get()) {
		if ("![CDATA" == key) {
			result[key] = SkipToCdataClosing(); // ]]>
			return result;
		}
//		else if ("![INCLUDE" == key)
//		{
//		}
//		else if ("![IGNORE" == key)
//		{
//		}
		else {
			String msg("wrong key (not CDATA) in <![:");
			msg.Append(key);
			Error(msg);
		}
	} else {
		Error("unexpected characer in <![ (not [)");
	}
	result[key] = SkipToClosingAngleBracket();
	return result;
}
Anything GenericXMLParser::ParseXmlOrProcessingInstruction()
{
	StartTrace(GenericXMLParser.ParseXmlOrProcessingInstruction);
	int c;
	String key;
	key.Append((char)Get()); // this is always a '?'
	key.Append(ParseName());
	String value;
	while ((c = Get()) != 0 && c != EOF) {
		if ('?' == c && '>' == Peek()) {
			// done.
			Get();
			Anything result;
			result[key] = value;
			return result;
		}
		value.Append(char(c));
	}
	// this is an Error
	String msg("unexpected EOF in processing instruction ");
	msg.Append(key);
	Error(msg);
	SkipToClosingAngleBracket();
	return Anything();
}
Exemplo n.º 10
0
bool LinkPartition::ParsePartitionSpec(LinkManager *manager, CmdFiles &files, LinkTokenizer &spec)
{
    if (!ParseOverlays(manager, files, spec))
        return false;
    if (!ParseName(spec))
        return false;
    return ParseAttributes(spec);
}
Exemplo n.º 11
0
	bool XMLReader::ParseAttribute(Attribute & attribute)
	{
		// Attribute ::= Name Eq AttValue
		if (ParseName(attribute)) {
			return ParseEq()
				&& ParseAttValue(attribute.mValue);
		}
		return false;
	}
Exemplo n.º 12
0
BOOL FusionBind::Compare(FusionBind *pSpec)
{
    // Normalize representations
    if (!m_fParsed)
        ParseName();
    if (!pSpec->m_fParsed)
        pSpec->ParseName();


    // Compare fields

    if (m_CodeInfo.m_fLoadFromParent != pSpec->m_CodeInfo.m_fLoadFromParent)
        return 0;

    if (m_pAssemblyName != pSpec->m_pAssemblyName
        && (m_pAssemblyName == NULL || pSpec->m_pAssemblyName == NULL
            || strcmp(m_pAssemblyName, pSpec->m_pAssemblyName)))
        return 0;

    if (m_cbPublicKeyOrToken != pSpec->m_cbPublicKeyOrToken
        || memcmp(m_pbPublicKeyOrToken, pSpec->m_pbPublicKeyOrToken, m_cbPublicKeyOrToken))
        return 0;

    if (m_dwFlags != pSpec->m_dwFlags)
        return 0;

    if (m_CodeInfo.m_pszCodeBase != pSpec->m_CodeInfo.m_pszCodeBase
        && (m_CodeInfo.m_pszCodeBase == NULL || pSpec->m_CodeInfo.m_pszCodeBase == NULL
            || wcscmp(m_CodeInfo.m_pszCodeBase, pSpec->m_CodeInfo.m_pszCodeBase)))
        return 0;

    if (m_context.usMajorVersion != pSpec->m_context.usMajorVersion)
        return 0;

    if (m_context.usMajorVersion != (USHORT) -1) {
        if (m_context.usMinorVersion != pSpec->m_context.usMinorVersion)
            return 0;

        if (m_context.usMinorVersion != (USHORT) -1) {
            if (m_context.usBuildNumber != pSpec->m_context.usBuildNumber)
                return 0;
            
            if (m_context.usBuildNumber != (USHORT) -1) {
                if (m_context.usRevisionNumber != pSpec->m_context.usRevisionNumber)
                    return 0;
            }
        }
    }

    if (m_context.szLocale != pSpec->m_context.szLocale
        && (m_context.szLocale == NULL || pSpec->m_context.szLocale == NULL
            || strcmp(m_context.szLocale, pSpec->m_context.szLocale)))
        return 0;

    return 1;
}
Anything GenericXMLParser::ParseExternalId()
{
	StartTrace(GenericXMLParser.ParseExternalId);
	String systemOrPublic = ParseName();
	SkipWhitespace();
	Anything result;
	if (systemOrPublic == "PUBLIC") {
		result[systemOrPublic] = ParseQuotedString();
	}
	result[systemOrPublic].Append(ParseQuotedString());
	return result;
}
Exemplo n.º 14
0
int main ()
{
    // get name to encode
    while(true) {
        cout << "Enter surname (RETURN to quit): ";
        string surname = GetLine();
        if (surname == "") exit(0); // exits program
        cout << "Soundex code for " << surname 
            << " is " << ParseName(surname) << endl;
    }
    return 0;
}
Exemplo n.º 15
0
bool ppInclude::CheckInclude(int token, const std::string &args)
{
    if (token == INCLUDE)
    {
        std::string line1 = args;
        define->Process(line1);
        ParseName(line1);
        FindFile(args);
        pushFile(name);
        return true;
    }
    return false;
}
Exemplo n.º 16
0
	bool XMLReader::ParseEndElement()
	{
		// ETag ::= '</' Name S? '>'
		if (ParseString("</") && ParseName(mCurrentName) && ParseOptionalWhitespace() && ParseString(">")) {
			if (mOpenTags.empty()) return false;
			Tag & currentTag = mOpenTags.back();
			if (currentTag.mName != mCurrentName.mName) return false;
			mNodeType = kEndElement;
			PopTag();
			return true;
		}
		return false;
	}
Exemplo n.º 17
0
void	CBlender_Compile::Stage_Texture	(LPCSTR name, u32 ,	u32	 fmin, u32 fmip, u32 fmag)
{
	sh_list& lst=	L_textures;
	int id		=	ParseName(name);
	LPCSTR N	=	name;
	if (id>=0)	{
		if (id>=int(lst.size()))	Debug.fatal(DEBUG_INFO,"Not enought textures for shader. Base texture: '%s'.",*lst[0]);
		N = *lst [id];
	}
	passTextures.push_back	(mk_pair( Stage(),ref_texture( DEV->_CreateTexture(N))));
//	i_Address				(Stage(),address);
	i_Filter				(Stage(),fmin,fmip,fmag);
}
Exemplo n.º 18
0
DWORD FusionBind::Hash()
{
    DWORD hash = 0;

    // Normalize representation
    if (!m_fParsed)
        ParseName();


    // Hash fields.

    if (m_pAssemblyName)
        hash ^= HashStringA(m_pAssemblyName);
    hash = _rotl(hash, 4);

    hash ^= HashBytes(m_pbPublicKeyOrToken, m_cbPublicKeyOrToken);
    hash = _rotl(hash, 4);
        
    hash ^= m_dwFlags;
    hash = _rotl(hash, 4);

    if (m_CodeInfo.m_pszCodeBase)
        hash ^= HashString(m_CodeInfo.m_pszCodeBase);
    hash = _rotl(hash, 4);

    hash ^= m_context.usMajorVersion;
    hash = _rotl(hash, 8);

    if (m_context.usMajorVersion != (USHORT) -1) {
        hash ^= m_context.usMinorVersion;
        hash = _rotl(hash, 8);
        
        if (m_context.usMinorVersion != (USHORT) -1) {
            hash ^= m_context.usBuildNumber;
            hash = _rotl(hash, 8);
        
            if (m_context.usBuildNumber != (USHORT) -1) {
                hash ^= m_context.usRevisionNumber;
                hash = _rotl(hash, 8);
            }
        }
    }

    if (m_context.szLocale)
        hash ^= HashStringA(m_context.szLocale);
    hash = _rotl(hash, 4);

    hash ^= m_CodeInfo.m_fLoadFromParent;

    return hash;
}
Exemplo n.º 19
0
already_AddRefed<WebGLUniformLocation>
WebGLProgram::GetUniformLocation(const nsAString& userName_wide) const
{
    if (!ValidateGLSLVariableName(userName_wide, mContext, "getUniformLocation"))
        return nullptr;

    if (!IsLinked()) {
        mContext->ErrorInvalidOperation("getUniformLocation: `program` must be linked.");
        return nullptr;
    }

    const NS_LossyConvertUTF16toASCII userName(userName_wide);

    nsDependentCString baseUserName;
    bool isArray = false;
    // GLES 2.0.25, Section 2.10, p35
    // If the the uniform location is an array, then the location of the first
    // element of that array can be retrieved by either using the name of the
    // uniform array, or the name of the uniform array appended with "[0]".
    // The ParseName() can't recognize this rule. So always initialize
    // arrayIndex with 0.
    size_t arrayIndex = 0;
    if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex))
        return nullptr;

    const WebGLActiveInfo* activeInfo;
    if (!LinkInfo()->FindUniform(baseUserName, &activeInfo))
        return nullptr;

    const nsCString& baseMappedName = activeInfo->mBaseMappedName;

    nsAutoCString mappedName(baseMappedName);
    if (isArray) {
        mappedName.AppendLiteral("[");
        mappedName.AppendInt(uint32_t(arrayIndex));
        mappedName.AppendLiteral("]");
    }

    gl::GLContext* gl = mContext->GL();
    gl->MakeCurrent();

    GLint loc = gl->fGetUniformLocation(mGLName, mappedName.BeginReading());
    if (loc == -1)
        return nullptr;

    RefPtr<WebGLUniformLocation> locObj = new WebGLUniformLocation(mContext, LinkInfo(),
                                                                   loc, arrayIndex,
                                                                   activeInfo);
    return locObj.forget();
}
Exemplo n.º 20
0
bool ppInclude::CheckLine(int token, const std::string &args)
{
    if (token == LINE)
    {
        std::string line1 = args;
        define->Process(line1);
        int npos = line1.find_first_of(',');
        if (npos == std::string::npos)
        {
            int n = expr.Eval(line1);
            ParseName(line1);
            current->SetErrlineInfo(name, n-1);
        }
        else
        {
            std::string temp = line1.substr(0, npos);
            int n = expr.Eval(temp);
            ParseName(line1.substr(npos+1));
            current->SetErrlineInfo(name, n-1);
        }
        return true;		
    }
    return false;
}
Exemplo n.º 21
0
// <local-name> := Z <(function) encoding> E <(entity) name>
//                 [<discriminator>]
//              := Z <(function) encoding> E s [<discriminator>]
static bool ParseLocalName(State *state) {
  State copy = *state;
  if (ParseChar(state, 'Z') && ParseEncoding(state) &&
      ParseChar(state, 'E') && MaybeAppend(state, "::") &&
      ParseName(state) && Optional(ParseDiscriminator(state))) {
    return true;
  }
  *state = copy;

  if (ParseChar(state, 'Z') && ParseEncoding(state) &&
      ParseTwoChar(state, "Es") && Optional(ParseDiscriminator(state))) {
    return true;
  }
  *state = copy;
  return false;
}
Exemplo n.º 22
0
	void File::ParseDefs(InputStream& s, Reference* pParentRef)
	{
		while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS)
		{
			NodePriority priority = PNormal;
			CAtlList<CStringW> types;
			CStringW name;

			int c = s.SkipWhiteSpace();

			if(c == '*') {s.GetChar(); priority = PLow;}
			else if(c == '!') {s.GetChar(); priority = PHigh;}

			ParseTypes(s, types);

			if(s.SkipWhiteSpace() == '#')
			{
				s.GetChar();
				ParseName(s, name);
			}

			if(types.IsEmpty())
			{
				if(name.IsEmpty()) s.ThrowError(_T("syntax error"));
				types.AddTail(L"?");
			}

			Reference* pRef = pParentRef;

			while(types.GetCount() > 1)
				pRef = CreateRef(CreateDef(pRef, types.RemoveHead()));

			Definition* pDef = NULL;

			if(!types.IsEmpty())
				pDef = CreateDef(pRef, types.RemoveHead(), name, priority);

			c = s.SkipWhiteSpace(L":=");

			if(c == '"' || c == '\'') ParseQuotedString(s, pDef);
			else if(iswdigit(c) || c == '+' || c == '-') ParseNumber(s, pDef);
			else if(pDef->IsType(L"@")) ParseBlock(s, pDef);
			else ParseRefs(s, pDef);
		}

		s.GetChar();
	}
Exemplo n.º 23
0
void
WebGLProgram::GetUniformIndices(const dom::Sequence<nsString>& uniformNames,
                                dom::Nullable< nsTArray<GLuint> >& retval) const
{
    const char funcName[] = "getUniformIndices";
    if (!IsLinked()) {
        mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
        return;
    }

    size_t count = uniformNames.Length();
    nsTArray<GLuint>& arr = retval.SetValue();

    gl::GLContext* gl = mContext->GL();
    gl->MakeCurrent();

    for (size_t i = 0; i < count; i++) {
        const NS_LossyConvertUTF16toASCII userName(uniformNames[i]);

        nsDependentCString baseUserName;
        bool isArray;
        size_t arrayIndex;
        if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex)) {
            arr.AppendElement(LOCAL_GL_INVALID_INDEX);
            continue;
        }

        webgl::UniformInfo* info;
        if (!LinkInfo()->FindUniform(baseUserName, &info)) {
            arr.AppendElement(LOCAL_GL_INVALID_INDEX);
            continue;
        }

        nsAutoCString mappedName(info->mActiveInfo->mBaseMappedName);
        if (isArray) {
            mappedName.AppendLiteral("[");
            mappedName.AppendInt(uint32_t(arrayIndex));
            mappedName.AppendLiteral("]");
        }

        const GLchar* mappedNameBytes = mappedName.BeginReading();

        GLuint index = 0;
        gl->fGetUniformIndices(mGLName, 1, &mappedNameBytes, &index);
        arr.AppendElement(index);
    }
}
Exemplo n.º 24
0
already_AddRefed<WebGLUniformLocation>
WebGLProgram::GetUniformLocation(const nsAString& userName_wide) const
{
    if (!ValidateGLSLVariableName(userName_wide, mContext, "getUniformLocation"))
        return nullptr;

    if (!IsLinked()) {
        mContext->ErrorInvalidOperation("getUniformLocation: `program` must be linked.");
        return nullptr;
    }

    const NS_LossyConvertUTF16toASCII userName(userName_wide);

    nsDependentCString baseUserName;
    bool isArray;
    size_t arrayIndex;
    if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex))
        return nullptr;

    const WebGLActiveInfo* activeInfo;
    if (!LinkInfo()->FindUniform(baseUserName, &activeInfo))
        return nullptr;

    const nsCString& baseMappedName = activeInfo->mBaseMappedName;

    nsAutoCString mappedName(baseMappedName);
    if (isArray) {
        mappedName.AppendLiteral("[");
        mappedName.AppendInt(uint32_t(arrayIndex));
        mappedName.AppendLiteral("]");
    }

    gl::GLContext* gl = mContext->GL();
    gl->MakeCurrent();

    GLint loc = gl->fGetUniformLocation(mGLName, mappedName.BeginReading());
    if (loc == -1)
        return nullptr;

    RefPtr<WebGLUniformLocation> locObj = new WebGLUniformLocation(mContext, LinkInfo(),
                                                                     loc, activeInfo);
    return locObj.forget();
}
bool GenericXMLParser::ParseTag(String &tag, Anything &tagAttributes)
{
	StartTrace(GenericXMLParser.ParseTag);
	tag = ParseName();
	Trace("tag = " << tag);
	while (!IsEof()) {
		SkipWhitespace();
		int c = Peek();
		switch (c) {
			case '>': // done with tag
				c = Get();
				return true;//lint !e438
			case '/': // an empty tag? i.e. <br />
				c = Get();
				if ('>' == Peek()) {
					c = Get();
					return false;//lint !e438
				}
				// an error occured, ignore '/' silently
				PutBack(c);
			default: {//lint !e616
				String name;
				String value;
				if (ParseAttribute(name, value)) {
					tagAttributes[name] = value;
				} else {
					// non-well formed XML...no value given
					if (name.Length() > 0) {
						tagAttributes.Append(name);
					} else {
						String msg("Unexpected character <");
						c = Get();
						msg.AppendAsHex((unsigned char)c).Append("> near ").Append(tag);
						Error(msg);
						tagAttributes.Append(String(char(c)));
					}
				}
			}
		}
	}
	Error("unexpected EOF in Tag");
	return false; // no body to expect
}
Exemplo n.º 26
0
/* set channels field */
static void Channel(struct Manifest *manifest, char *value)
{
  char **tokens;
  char **names;
  int i;
  struct ChannelDesc *channel;

  /* allocate a new channel */
  channel = g_malloc0(sizeof *channel);
  channel->source = g_ptr_array_new();

  /* get tokens from channel description */
  tokens = g_strsplit(value, VALUE_DELIMITER, ChannelTokensNumber);

  /* TODO(d'b): fix "invalid numeric value ', 0'" bug here */
  ZLOGFAIL(tokens[ChannelTokensNumber] != NULL || tokens[PutSize] == NULL,
      EFAULT, "invalid channel tokens number");

  /* parse alias and name(s) */
  channel->alias = g_strdup(g_strstrip(tokens[Alias]));
  names = g_strsplit(tokens[Name], TOKEN_DELIMITER, MANIFEST_TOKENS_LIMIT);
  for(i = 0; names[i] != NULL; ++i)
    ParseName(names[i], channel->source);

  channel->type = ToInt(tokens[Type]);

  i = ToInt(tokens[Tag]);
  ZLOGFAIL(i != 0 && i != 1, EFAULT, "invalid channel mumeric token");

  channel->tag = i == 0 ? NULL : TagCtor();

  for(i = 0; i < LimitsNumber; ++i)
  {
    channel->limits[i] = ToInt(tokens[i + Gets]);
    ZLOGFAIL(channel->limits[i] < 0, EFAULT,
        "negative limits for %s", channel->alias);
  }

  /* append a new channel */
  g_ptr_array_add(manifest->channels, channel);
  g_strfreev(names);
  g_strfreev(tokens);
}
bool GenericXMLParser::ParseAttribute(String &name, String &value)
{
	StartTrace(GenericXMLParser.ParseAttribute);
	name = ParseName();
	name.ToLower(); // XHTML conformance all attribute names are lower case
	Trace("attribute name:" << name);
	value = "";
	SkipWhitespace();
	int c = Peek();
	if (c != '=') {
		return false;
	}
	c = Get();
	(void)c;
	SkipWhitespace();
	value = ParseValue();
	return true;
	// otherwise it is a syntax error, we just ignore silently for now.
}
Exemplo n.º 28
0
int main(int argc, char *argv[]) {
	int i, size;

	if(argc == 3 && strncmp(argv[1], "-x", 2) == 0) {
	    hex++;
	    argv++;
	} else if(argc != 2) {
	    fprintf(stderr,"Usage: rmvalue variable name from rm_allocation\n");
	    exit(1);
	}
	rm_status=rm_open(antlist);
	if(rm_status != RM_SUCCESS) {
	    rm_error_message(rm_status,"rm_open()");
	    fprintf(stderr, "I can't do anything without reflective memory\n");
	    exit(1);
	}
	ParseName(argv[1]);
	fprintf(stderr, "Type %c, baseSize %d  ", type,
		baseSize);
	size = baseSize;
	if(ndims > 0) {
	    fprintf(stderr, "%d dimension(s) (", ndims);
	    for(i = ndims - 1; i >= 0; i--) {
		fprintf(stderr, " %d ", dimensions[i]);
		size *= dimensions[i];
	    }
	    putc(')', stderr);
	}
	putc('\n', stderr);
	arg = malloc(size);
	rm_status=rm_read(RM_ANT_0,argv[1], arg);
	if(rm_status != RM_SUCCESS) {
	    rm_error_message(rm_status,"rm_read()");
	}
	while(dimensions[1]-- > 0) {
	    for(i = 0; i < dimensions[0]; i++) {
		PrintValue();
	    }
	    putchar('\n');
	}
	putchar('\n');
	return(0);
}
Exemplo n.º 29
0
void CParser::ParseExpression() 
{
    Clear();
    SkipSpaces();
    ProceedUnary();

    while (pos < sz) {
        SkipSpaces();
        char curChar = src[pos];

        if (IsControl(curChar)) {
            break;
        } else if (IsDigit(curChar)) {
            ParseNumber();
        } else if (curChar == '(') {
            ops.push_front(0); // 0 instead '('
            ++pos;
            ProceedUnary();
        } else if (curChar == ')') {
            while (!ops.empty() && ops.front()!=0) {
                Simplify();
            }
            ops.pop_front();
            ++pos;
        } else if (OpPriority(curChar) >= 0) {
            ProceedOperator();
        } else { 
            ParseName();
        }
    } // !while (pos < lim) 

    while(st.size() > 1 || !ops.empty()) {
        Simplify();
    } // 
    if (st.size() != 1 || !ops.empty()) {
        Clear();
        throw AST::ASTException("Miss parameters");
    }

    _pProgram->AddExpression(st.front());
    st.pop_front();
} 
Exemplo n.º 30
0
	bool XMLReader::ParseElement()
	{
		// element ::= EmptyElemTag
		//				| STag content ETag
		// EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
		// STag	   ::=   	'<' Name (S Attribute)* S? '>'
		if (ParseString("<") && ParseName(mCurrentName)) {
			mNodeType = kElement;
			mAttributes.clear();
			while (ParseRequiredWhitespace()) {
				Attribute attribute;
				if (ParseString("/>")) {
					mIsEmptyElement = true;
					PopNamespaces(PushNamespaces());
					return true;
				}
				else if (ParseString(">")) {
					mIsEmptyElement = false;
					PushTag();
					return true;
				}
				else if (ParseAttribute(attribute)) {
					mAttributes.push_back(attribute);
				}
				else return false;
			}
			if (ParseString("/>")) {
				mIsEmptyElement = true;
				PopNamespaces(PushNamespaces());
				return true;
			}
			else if (ParseString(">")) {
				mIsEmptyElement = false;
				PushTag();
				return true;
			}
		}

		return false;
	}