Exemplo n.º 1
0
static bool
read_statement(SerdReader* reader)
{
	SerdStatementFlags flags = 0;
	ReadContext ctx = { 0, 0, 0, &flags };
	read_ws_star(reader);
	bool ate_dot = false;
	switch (peek_byte(reader)) {
	case '\0':
		reader->eof = true;
		return true;
	case '@':
		TRY_RET(read_directive(reader));
		read_ws_star(reader);
		return (eat_byte_check(reader, '.') == '.');
	default:
		if (!read_triples(reader, ctx, &ate_dot)) {
			return false;
		} else if (ate_dot) {
			return true;
		} else {
			read_ws_star(reader);
			return (eat_byte_check(reader, '.') == '.');
		}
		break;
	}
	read_ws_star(reader); // remove?
	return true;
}
Exemplo n.º 2
0
Arquivo: cpp.c Projeto: rui314/8cc-old
static Token *read_token_int(CppContext *ctx) {
    for (;;) {
        Token *tok = read_cpp_token(ctx);
        if (!tok)
            return NULL;
        if (tok->toktype == TOKTYPE_NEWLINE) {
            ctx->at_bol = true;
            return tok;
        }
        if (ctx->at_bol && is_punct(tok, '#')) {
            read_directive(ctx);
            ctx->at_bol = true;
            continue;
        }
        ctx->at_bol = false;
        unget_cpp_token(ctx, tok);
        return expand_one(ctx);
    }
}
Exemplo n.º 3
0
void ts::resources::Script_resource::load_resource_config(std::istream& stream)
{
    boost::filesystem::path root_path = root_directory_.string();

    for (std::string line, directive; std::getline(stream, line) && directive != "end";)
    {
        std::istringstream line_stream(line);
        read_directive(line_stream, directive);

        if (directive == "clientscript")
        {
            std::string script_path;
            line_stream >> std::ws;

            if (std::getline(line_stream, script_path))
            {
                auto path = root_path / script_path;

                client_script_files_.push_back(path.string());
            }
        }

        else if (directive == "serverscript")
Exemplo n.º 4
0
int main ()

{
	int		newline, t;
	char		token[MAXTOKEN];
	struct nlist	*np;
	
	newline = !0;
	t = gettoken(token, MAXTOKEN);
	for ( ; ; ) {
	
		if (t == EOF)

			break;

		else if (t == UNFINISHED_CONSTANT) {

			printf("\nUnfinished character or string constant!\n");
			return 1;

		} else if (t == TOKEN_TOO_LONG) {

			printf("\nToken too long!\n");
			return 1;

		} else if (t == INVALID_MACRO_NAME) {
	
			printf("\nInvalid macro name!\n");
			return 1;

		} else if (t == MACRO_TOO_LONG) {

			printf("\nMacro is too long!\n");
			return 1;

		} else if (newline && t == '#') {

			t = read_directive(token);
			continue;

		} else if (isalpha(t) || t == '_' || isdigit(t))

			/* Do macro replacement if needed. */

			if ((isalpha(t) || t == '_') 
			&& (np = lookup(token)) != NULL)

				printf("%s ", np->defn);

			else 
			
				printf("%s ", token);

		else

			printf("%s", token);

		/* Are we at the beginning of a new line? */

		newline = t == '\n';

		t = gettoken(token, MAXTOKEN);

	}

	return 0;
}