示例#1
0
文件: decl.c 项目: JamesLinus/mcc
static node_t *arrays(bool abstract)
{
    node_t *atype = array_type(NULL);

    if (abstract) {
        if (token->id == '*') {
            if (lookahead()->id != ']') {
                parse_assign(atype);
            } else {
                expect('*');
                TYPE_A_STAR(atype) = 1;
            }
        } else if (first_expr(token)) {
            parse_assign(atype);
        }
    } else {
        if (token->id == STATIC) {
            expect(STATIC);
            TYPE_A_STATIC(atype) = 1;
            if (token->kind == CONST)
                array_qualifiers(atype);
            parse_assign(atype);
        } else if (token->kind == CONST) {
            if (token->kind == CONST)
                array_qualifiers(atype);
            if (token->id == STATIC) {
                expect(STATIC);
                TYPE_A_STATIC(atype) = 1;
                parse_assign(atype);
            } else if (token->id == '*') {
                if (lookahead()->id != ']') {
                    parse_assign(atype);
                } else {
                    expect('*');
                    TYPE_A_STAR(atype) = 1;
                }
            } else if (first_expr(token)) {
                parse_assign(atype);
            }
        } else if (token->id == '*') {
            if (lookahead()->id != ']') {
                parse_assign(atype);
            } else {
                expect('*');
                TYPE_A_STAR(atype) = 1;
            }
        } else if (first_expr(token)) {
            parse_assign(atype);
        }
    }

    return atype;
}
示例#2
0
文件: parser.c 项目: gnar/zombo
/* Operators: =, +=, -=, /=, *= (right-associative) */
static ASTNode *parse_assign(Parser *p)
{
	ASTNode *expr = parse_comparison(p);

	switch (peek_id(p)) {
		case TOK_ASSIGN:
			accept(p); ignore_eols(p);
			expr = ast_create_2(AST_ASSIGN, expr, parse_assign(p));
			break;
	}

	return expr;
}
示例#3
0
文件: parser.c 项目: tmaciejewski/lcc
struct single *parse_single()
{
	struct single *s;

	s = parse_io();

	if (s != NULL)
		return s;

	s = parse_loop();

	if (s != NULL)
		return s;

	s = parse_if();

	if (s != NULL)
		return s;

	s = parse_assign();

	if (s != NULL)
		return s;

	s = parse_gtfo();

	if (s != NULL)
		return s;

	s = parse_halt();

	if (s != NULL)
		return s;

	return NULL;
}
示例#4
0
文件: parser.c 项目: gnar/zombo
static ASTNode *parse_expr(Parser *p)
{
	return parse_assign(p);
}