Example #1
0
File: Rjson.cpp Project: XoDeR/RE
		static const char* skipValue(const char* json)
		{
			RIO_ASSERT_NOT_NULL(json);

			switch (*json)
			{
			case '"': json = skipString(json); break;
			case '[': json = skipBlock(json, '[', ']'); break;
			case '{': json = skipBlock(json, '{', '}'); break;
			default: for (; *json != ',' && *json != '\n' && *json != ' ' && *json != '}' && *json != ']'; ++json); break;
			}

			return json;
		}
Example #2
0
void File::readProperties(QDict<QCString> & d) {
    d.setAutoDelete(TRUE);

    read("(");
    read("list");
    read("Attribute_Set");

    for (;;) {
        QCString s;

        switch (read(s)) {
        case ')':
            return;
        case '(':
            read("object");
            read("Attribute");
            read("tool");

            if (read(s) != STRING)
                syntaxError(s, "the tool");

            read("name");
            {
                QCString s2;

                if (read(s2) != STRING)
                    syntaxError(s2, "the name");

                s += "/" + s2;

                read("value");

                switch (read(s2)) {
                case '(':
                    if ((read(s2) == ATOM) && (s2 == "value")) {
                        read("Text");
                        if (read(s2) != STRING)
                            syntaxError(s2, "the value");
                        read(")");
                    }
                    else
                        skipBlock();
                // no break !
                case STRING:
                case ATOM:
                    d.insert(s, new QCString(s2));
                    break;
                default:
                    syntaxError(s, "the value");
                }
            }

            read(")");
            break;
        default:
            syntaxError(s);
        }
    }

}
Example #3
0
  void
skipClause(void)
{
	while (*pc != BLOCK_TAG)
		skipExpression;
	skipBlock();
}
Example #4
0
void File::skipNextForm() {
    QCString s;

    switch (read(s)) {
    case ')':
        ungetch(')');
        break;
    case '(':
        skipBlock();
        break;
    default:
        break;
    }

}
Example #5
0
void read_Application_Extension(SetjmpStreamState *in_out_pSetjmpStreamState, 
	ByteStreamInterface in_byteStreamReadInterface, void (*in_pfErrorHandler)(void *))
{
	// Precondition: we have a GIF 89a file
	Application_Extension applExt;

	(*in_byteStreamReadInterface.mpfRead)(in_out_pSetjmpStreamState, 
		&applExt, sizeof(applExt));

	longjmpIf(applExt.Block_Size != 11, in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, 
		ReadResultInvalidData, in_pfErrorHandler, "read_Application_Extension: Block Size has to be 11");

	if (strncmp(applExt.Application_Identifier, "NETSCAPE", 8) == 0 && 
		strncmp(applExt.Application_Authentication_Code, "2.0", 3) == 0)
	{
		uint8_t blockSize;
		uint8_t blockData[3];

		(*in_byteStreamReadInterface.mpfRead)(in_out_pSetjmpStreamState, 
			&blockSize, sizeof(blockSize));

		longjmpIf(blockSize != 3, in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, 
			ReadResultInvalidData, in_pfErrorHandler, 
			"read_Application_Extension: Block Size of NETSCAPE 2.0 Application Extension has to be 3");

		(*in_byteStreamReadInterface.mpfRead)(in_out_pSetjmpStreamState, 
			blockData, sizeof(blockData));

		// TODO: Interprete read data

		(*in_byteStreamReadInterface.mpfRead)(in_out_pSetjmpStreamState, 
			&blockSize, sizeof(blockSize));

		longjmpIf(blockSize != 0, in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, 
			ReadResultInvalidData, in_pfErrorHandler, 
			"read_Application_Extension: expecting terminator block after NETSCAPE 2.0 Application Extension");
	}
	else if (strncmp(applExt.Application_Identifier, "XMP Data", 8) == 0 && 
		strncmp(applExt.Application_Authentication_Code, "XMP", 3) == 0)
	{
		// TODO: Implement properly
		skipBlock(in_out_pSetjmpStreamState, in_byteStreamReadInterface);
	}
	else
	{
		longjmp(*in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, ReadResultNotImplemented);
	}
}
Example #6
0
bool ClrMameProReader::read(std::vector<DatSet>& set_collection)
{
	Token token;
	DatSet set;

	assert(m_loaded);

	set_collection.clear();

	m_parser.reset();

	/*
	 * Estructura principal de un dat en formato ClrMamePro:
	 *
	 * clrmamepro ( ... )
	 * emulator ( ... )
	 * biosset ( ... )
	 * game ( ... )
	 * resource ( ... )
	 *
	 */
	while (m_parser.hasMoreTokens())
	{
		token = m_parser.nextToken();
		switch (token.type)
		{
		case TK_GAME:
			set.is_bios = false;
			if (this->parseGameBlock(set))
			{
				set_collection.push_back(set);
			}
			break;
		// Los set bios están en este bloque en vez de biosset
		case TK_RESOURCE:
			set.is_bios = true;
			if (this->parseGameBlock(set))
			{
				set_collection.push_back(set);
			}
			break;
		default:
			skipBlock();
		}
	}
	clean();
	return true;
}
Example #7
0
bool ClrMameProReader::load(const char* buffer, const unsigned int size)
{
	Token token;

	assert(buffer);
	assert(size);

	if (m_parser.initFromMemory(buffer, size))
	{
		// Comprobamos si el primer token es "clrmamepro"
		token = m_parser.nextToken();
		if (token.type == TK_CLRMAMEPRO)
		{
			// Saltamos la cabecera ya que no haremos nada con ella
			skipBlock();
			m_loaded = true;
			return true;
		}
	}
	return false;
}
Example #8
0
int File::readDefinitionBeginning(QCString & s, QCString & id, QCString & ste, QCString & doc, QDict<QCString> & prop) {
    for (;;) {
        int k = read(s);

        switch(k) {
        case -1:
            eof();
            throw 0;
        case ')':
            return k;
        case '(':
            skipBlock();
        // no break !
        default:
            continue;
        case ATOM:
            break;
        }

        if (s == "quid") {
            if (read(id) != STRING)
                syntaxError(id, "quid value");
        }
        else if (s == "attributes") {
            readProperties(prop);
        }
        else if (s == "documentation") {
            if (read(doc) != STRING)
                syntaxError(doc, "the documentation");
        }
        else if (s == "stereotype") {
            if (read(ste) != STRING)
                syntaxError(ste, "the stereotype");
        }
        else
            return k;
    }
}
Example #9
0
void read_Data(SetjmpStreamState *in_out_pSetjmpStreamState, 
	ByteStreamInterface in_byteStreamReadInterface, 
	uint8_t in_introducer, bool in_is89a, 
	const Logical_Screen *in_cpLogicalScreen, 
	void (*in_pfErrorHandler)(void *))
{
	uint8_t lLabel;

	if (EXTENSION_INTRODUCER == in_introducer)
	{
		(*in_byteStreamReadInterface.mpfRead)(in_out_pSetjmpStreamState, 
			&lLabel, sizeof(lLabel));

		/*
		* We have the following situation:
		*
		* ┌───────────────────────────────────────────────────────┬─────────┬───────────────────────┐
		* │Extension Introducer                                   │ GIF 87a │ GIF 89a               │
		* ├───────────────────────────────────────────────────────┼─────────┼───────────────────────┤
		* │0xFE (COMMENT_LABEL) or 0xFF (APPLICATION_LABEL)       │         │ Special Purpose Block │
		* │0x01 (PLAIN_TEXT_LABEL) or 0xF9 (GRAPHIC_CONTROL_LABEL)│  skip   │     Graphic Block     │
		* │other                                                  │         │         skip          │
		* └───────────────────────────────────────────────────────┴─────────┴───────────────────────┘
		*/
		// CND:GIF_c_153
		if (in_is89a)
		{
			if (COMMENT_LABEL == lLabel || APPLICATION_LABEL == lLabel)
			{
				/*
				* Because of CND:GIF_c_153 the precondition
				* PRE:GIF_h_129 is satisfied.
				*/
				read_SpecialPurpose_Block(in_out_pSetjmpStreamState, 
					in_byteStreamReadInterface, lLabel, in_pfErrorHandler);
				return;
			}
			else if (PLAIN_TEXT_LABEL == lLabel || GRAPHIC_CONTROL_LABEL == lLabel)
			{
				read_Graphic_Block(in_out_pSetjmpStreamState, 
					in_byteStreamReadInterface, in_introducer, lLabel, 
					in_is89a, in_cpLogicalScreen, in_pfErrorHandler);
				return;
			}
			else
			{
				longjmpWithHandler(in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, 
					ReadResultInvalidData, in_pfErrorHandler, 
					"read_Data: the only accepted Extension Blocks are Graphic Control Extension and Plain Text Extension");
			}
		}
		else
		{
			skipBlock(in_out_pSetjmpStreamState, in_byteStreamReadInterface);
			return;
		}
	}
	else if (IMAGE_SEPARATOR == in_introducer)
	{
		read_Graphic_Block(in_out_pSetjmpStreamState, 
			in_byteStreamReadInterface, in_introducer, 0, 
			in_is89a, in_cpLogicalScreen, in_pfErrorHandler);
		return;
	}
	else
	{
		longjmpWithHandler(in_out_pSetjmpStreamState->setjmpState.mpJmpBuffer, 
			ReadResultInvalidData, in_pfErrorHandler, 
			"read_Data: expecting Image Descriptor or Extension Introducer");
	}
}
Example #10
0
bool ClrMameProReader::parseGameBlock(DatSet& set)
{
	Token token;

	/*
	 * Estructura de un bloque game o resource:
	 *
	 * game / resource (
	 *	name			""
	 *	description		""
	 *	year			"YYYYMMDD"
	 *	manufacturer	""
	 *	cloneof			""
	 *	romof			""
	 *	sourcefile		""
	 *	biosset ( ... )
	 *	rom ( ... )
	 *	...
	 *	rom ( ... )
	 *	disk ( ... )
	 *	...
	 *	disk ( ... )
	 *	sampleof		""
	 *	sample			""
	 *	...
	 *	sample			""
	 * )
	 *
	 */
	// Comenzamos justo en el parentesis izquierdo, lo leemos primero
	token = m_parser.nextToken();
	if (token.type == TK_LPAR)
	{
		set.name.clear();
		set.description.clear();
		set.year.clear();
		set.manufacturer.clear();
		set.clone_of.clear();
		set.crc.clear();
		while (m_parser.hasMoreTokens() && (token.type != TK_RPAR))
		{
			token = m_parser.nextToken();
			switch (token.type)
			{
			case TK_NAME:
				token = m_parser.nextToken();
				set.name = token.string;
				// HACK: Detectar bios en dats de no-intro
				if (set.name.substr(0,6) == "[BIOS]")
				{
					set.is_bios = true;
				}
				break;
			case TK_DESCRIPTION:
				token = m_parser.nextToken();
				set.description = token.string;
				break;
			case TK_YEAR:
				token = m_parser.nextToken();
				set.year = token.string;
				break;
			case TK_MANUFACTURER:
				token = m_parser.nextToken();
				set.manufacturer = token.string;
				break;
			case TK_CLONEOF:
				token = m_parser.nextToken();
				set.clone_of = token.string;
				break;
			// Estos bloques no los necesitamos, los pasamos
			case TK_ROMOF:
			case TK_SOURCEFILE:
				// Leemos un parámetro para llegar al siguiente bloque
				token = m_parser.nextToken();
				break;
			// Solamente leemos la primera rom o disk
			case TK_ROM:
				// Si ya hemos leido la rom, saltamos el bloque
				if (!set.crc.empty())
				{
					skipBlock();
					break;
				}
				set.crc = parseRomBlock();
				break;
			/*
			 * CHECKME: Estos bloques del dat los saltamos.
			 * No está claro cual es su utilidad. Parece que solo aparecen en
			 * ficheros dat muy viejos y únicamente de MAME.
			 */
			case TK_DISK:
			case TK_EMULATOR:
			case TK_BIOSSET:
				skipBlock();
				break;
			case TK_RPAR:
				break;
			default:
				break;
			}
		}
		return true;
	}
	return false;
}
Example #11
0
  void
skipExpression(void)
{
	if (pc == NULL)
		return;
	switch (*pc++) {
	    case IDENTIFIER_TAG:
		overSymbol();
		break;

	    case FUNCTION_CALL_TAG:
		skipFunctionCall();
		break;

	    case NUMBER_TAG:
	    case RELOCATABLE_TAG:
		overNumber();
		break;

	    case CONDITION_CODE_TAG:
		overByte();
		break;

	    case SUBEXPRESSION_TAG:
		skipExpression();
		break;

	    case UNOP_TAG:
		skipUnop();
		break;

	    case BINOP_TAG:
		skipBinop();
		break;

	    case PREOP_TAG:
		skipPreop();
		break;

	    case POSTOP_TAG:
		skipPostop();
		break;

	    case HERE_TAG:
		break;

	    case STRING_TAG:
		skipString();
		break;

	    case ARRAY_TAG:
		skipArray();
		break;

	    case VALUE_TAG:
		overNumber();
		break;

	    case NULL_TAG:
		break;

	    case BLOCK_TAG:
		skipBlock();
		break;

	    case MDEFINE_TAG:
		skipMdefine();
		break;

	    case MVARIABLE_TAG:
		skipMvariable();
		break;

	    case MIF_TAG:
		skipMif();
		break;

	    case MFOR_TAG:
		skipMfor();
		break;

	    case MWHILE_TAG:
		skipMwhile();
		break;

	    case MDOWHILE_TAG:
		skipMdoWhile();
		break;

	    case MDOUNTIL_TAG:
		skipMdoUntil();
		break;

	    case PERFORM_TAG:
		skipExpression();
		break;

	    case GROUP_TAG:
		skipBlock();
		break;

	    case ASSERT_TAG:
		skipAssert();
		break;

	    case MSWITCH_TAG:
		skipMswitch();
		break;

	    case CLAUSE_TAG:
		skipClause();
		break;

	    case END_TAG:
		break;
	}
}