Example #1
0
/* Read in the first-stage syntax tree. This will be a Stylesheet node,
   containing AtRule and TopLevel nodes. 
*/
static node *read_stylesheet(mincss_context *context)
{
    node *sheetnod = new_node(context, nod_Stylesheet);

    while (1) {
        tokentype toktyp = context->nexttok.typ;
        if (toktyp == tok_EOF)
            break;

        if (toktyp == tok_CDO || toktyp == tok_CDC) {
            /* Comment delimiters are ignored at the top level. */
            read_token(context);
            continue;
        }

        if (toktyp == tok_Space) {
            /* We also ignore whitespace between statements. */
            read_token(context);
            continue;
        }

        node *nod = read_statement(context);
        if (nod)
            node_add_node(sheetnod, nod);
    }

    return sheetnod;
}
Example #2
0
static bool
read_turtleDoc(SerdReader* reader)
{
	while (!reader->eof) {
		TRY_RET(read_statement(reader));
	}
	return true;
}
Example #3
0
SERD_API
SerdStatus
serd_reader_read_chunk(SerdReader* me)
{
	if (!me->read_byte) {
		// Read initial byte
		const int c = fgetc(me->fd);
		me->read_byte = (c == EOF) ? 0 : (uint8_t)c;
		if (c == EOF) {
			me->eof = true;
			return SERD_FAILURE;
		}
	}
	return read_statement(me) ? SERD_SUCCESS : SERD_FAILURE;
}
Example #4
0
int main(int argc, char **argv) {
	Scheme *sc = alloc_scheme();
	Statement *st = NULL;
	String scheme = NULL;

	if (!scheme_init(sc)) {
		fprintf(stderr, "Initialize scheme environment error!\n");
		return 1;
	}

	if (!funny_init()) {
		fprintf(stderr, "Initialize funny environment error!\n");
		return 1;
	}

	printf("Welcome to FUNNY programming world. Type {exit} to exit.\n");

	while (TRUE) {
		printf("> ");
		st = read_statement(stdin);

		if (empty_statement(st)) {
			printf("can't parse the statement.\n");
			continue;
		}

		wait_to_exit(st);

		scheme = match(st);

		if (equals_string(scheme, ""))
			continue;

//#ifdef DEBUG
		printf("TARGET: %s\n", scheme);
//#endif

		Cell* result = eval(sc, scheme);
		printf("%s\n", cell2str(sc, result));
	}

	return 0;
}