示例#1
0
std::unique_ptr<const Expression> Parser::next(const Lex& lex) {
    switch (lex.lexType) {
        case LexType::EOFF:
            return std::unique_ptr<const Expression>();

        case LexType::STR:
            return nextString();

        case LexType::LEX:
            return scanTerm(static_cast<const StrLex&>(lex).str);

        case LexType::LST_START:
            return nextCol<List>(LexType::LST_END);

        case LexType::VEC_START:
            return nextCol<Vector>(LexType::VEC_END);

        case LexType::SET_START:
            return nextCol<Set>(LexType::SET_END);

        case LexType::CHR:
            return std::unique_ptr<const Expression>(new Quote(next()));

        case LexType::HSH:
            return std::unique_ptr<const Expression>(new Unquote(_lexer.expectAtom()));

        default:
            return std::unique_ptr<const Expression>(new Nil);
    }
}
示例#2
0
void getMagic( FILE* fi, char * buffer, int bufferSize ) {

	nextString( fi, buffer, bufferSize, 0 );

	if ( strcmp( buffer, "P2") != 0 && strcmp( buffer, "P5" ) != 0 ) {

		errorMessage( 10, "Invalid file format" );
	}
}
/*!
    \internal
    Loads the mime type to extensions mapping
*/
static void loadExtensions()
{
    QMutex mutex;
    mutex.lock();
    static bool loaded = false;

    if(loaded)
    {
        mutex.unlock();
        return;
    }

    QFile file(":qtopiamail/mime.types");
    if ( file.open(QIODevice::ReadOnly) ) {
        char line[1024];

        while (file.readLine(line, sizeof(line)) > 0) {
            if (line[0] == '\0' || line[0] == '#')
                continue;
            int posn = 0;
            QString id = nextString(line, posn);
            if ( id.isEmpty() )
                continue;
            id = id.toLower();

            QStringList exts = extFor()->value(id);

            for( QString ext = nextString( line, posn ); !ext.isEmpty(); ext = nextString(line, posn).toLower() )
            {
                if( !exts.contains( ext ) )
                {
                    exts.append( ext );

                    typeFor()->insert(ext, id);
                }
            }
            (*extFor())[ id ] = exts;
        }
        loaded = true;
    }
    mutex.unlock();
}
/**
 * @brief FolioNum::next
 * @return the next NumerotationContext nc at position i
 */
NumerotationContext FolioNum::next (const NumerotationContext &nc, const int i) const {
	return (nextString(nc, i));
}
示例#5
0
/* Show the width */
void getWidth( FILE* fi, char * buffer, int bufferSize, char last ) {

	nextString( fi, buffer, bufferSize, last );
}
示例#6
0
/* Get the data */
void getData( FILE* fi, char * magic,  Image * img ) {

	int width 	= img->width,
		height	= img->height,

		i;

	img->data = (byte**) malloc( height * sizeof(byte*) );

	for ( i = 0; i < height; i++ ) {

		img->data[i] = (byte*) malloc( width * sizeof(byte) );
	}

	int min		= img->depth,
		max		= 0,

		values[ width * height ],
		counter = 0,
		val;


 	char buffer[1024];

 	int c = fgetc(fi);

	while ( c != EOF ) {

		if ( strcmp( magic, "P2" ) == 0 ) {

			nextString( fi, buffer, sizeof(buffer), c );

			val = atoi(buffer);

		} else {

			val = c;
		}

		if ( val != '\0' ) {

			values[counter] = val;

			if ( val < min ) min = val;
			if ( val > max ) max = val;

			counter++;
		}

		c = fgetc(fi);
	}


	img->min = min;
	img->max = max;


	int y, x, pos;

	for ( y = 0; y < height; y++ ) {

		for ( x = 0; x < width; x++ ) {

			pos = ( y * width + x );

			img->data[y][x] = values[pos];
		}
	}

}
示例#7
0
/* Show the range */
void getDepth( FILE* fi, char * buffer, int bufferSize ) {

	nextString( fi, buffer, bufferSize, 0 );
}
示例#8
0
/* Show the height */
void getHeight( FILE* fi, char * buffer, int bufferSize ) {

	nextString( fi, buffer, bufferSize, 0 );
}
/**
 * @brief StringNum::previous
 * @return the previous NumerotationContext nc at posiiton i
 */
NumerotationContext StringNum::previous(const NumerotationContext &nc, const int i) const {
	return (nextString(nc, i));
}