Updated the indention for emacs
This commit is contained in:
28
common.c
28
common.c
@@ -153,8 +153,8 @@ static void next(void) {
|
|||||||
|
|
||||||
/* multi/single char operators */
|
/* multi/single char operators */
|
||||||
src_pos++;
|
src_pos++;
|
||||||
#define PEEK src[src_pos]
|
#define PEEK src[src_pos]
|
||||||
#define EAT src_pos++
|
#define EAT src_pos++
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '+': if(PEEK=='+'){ EAT; tok.kind=TK_INC; }
|
case '+': if(PEEK=='+'){ EAT; tok.kind=TK_INC; }
|
||||||
else if(PEEK=='='){ EAT; tok.kind=TK_ADDEQ; }
|
else if(PEEK=='='){ EAT; tok.kind=TK_ADDEQ; }
|
||||||
@@ -191,8 +191,8 @@ static void next(void) {
|
|||||||
case '?': tok.kind=TK_QUESTION;break;
|
case '?': tok.kind=TK_QUESTION;break;
|
||||||
default: die("Unknown char '%c'", c);
|
default: die("Unknown char '%c'", c);
|
||||||
}
|
}
|
||||||
#undef PEEK
|
#undef PEEK
|
||||||
#undef EAT
|
#undef EAT
|
||||||
}
|
}
|
||||||
|
|
||||||
static void expect(TKind k) {
|
static void expect(TKind k) {
|
||||||
@@ -359,7 +359,7 @@ static Node *unary(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define BINOP(name, next_fn, ...) \
|
#define BINOP(name, next_fn, ...) \
|
||||||
static Node *name(void) { \
|
static Node *name(void) { \
|
||||||
Node *l=next_fn(), *t; TKind ops[]={__VA_ARGS__, TK_EOF}; \
|
Node *l=next_fn(), *t; TKind ops[]={__VA_ARGS__, TK_EOF}; \
|
||||||
for(;;) { \
|
for(;;) { \
|
||||||
int found=0; \
|
int found=0; \
|
||||||
@@ -368,18 +368,18 @@ static Node *name(void) { \
|
|||||||
TKind op=tok.kind; next(); \
|
TKind op=tok.kind; next(); \
|
||||||
t=alloc_node(N_BOPN); t->op=op; t->ch[0]=l; t->ch[1]=next_fn(); l=t; \
|
t=alloc_node(N_BOPN); t->op=op; t->ch[0]=l; t->ch[1]=next_fn(); l=t; \
|
||||||
} return l; \
|
} return l; \
|
||||||
}
|
}
|
||||||
|
|
||||||
BINOP(mul_expr, unary, TK_STAR, TK_SLASH, TK_MOD)
|
BINOP(mul_expr, unary, TK_STAR, TK_SLASH, TK_MOD)
|
||||||
BINOP(add_expr, mul_expr, TK_PLUS, TK_MINUS)
|
BINOP(add_expr, mul_expr, TK_PLUS, TK_MINUS)
|
||||||
BINOP(shf_expr, add_expr, TK_SHL, TK_SHR)
|
BINOP(shf_expr, add_expr, TK_SHL, TK_SHR)
|
||||||
BINOP(cmp_expr, shf_expr, TK_LT, TK_LEQ, TK_GT, TK_GEQ)
|
BINOP(cmp_expr, shf_expr, TK_LT, TK_LEQ, TK_GT, TK_GEQ)
|
||||||
BINOP(eq_expr, cmp_expr, TK_EQ, TK_NEQ)
|
BINOP(eq_expr, cmp_expr, TK_EQ, TK_NEQ)
|
||||||
BINOP(band_expr, eq_expr, TK_AMP)
|
BINOP(band_expr, eq_expr, TK_AMP)
|
||||||
BINOP(bxor_expr, band_expr,TK_CARET)
|
BINOP(bxor_expr, band_expr,TK_CARET)
|
||||||
BINOP(bor_expr, bxor_expr,TK_PIPE)
|
BINOP(bor_expr, bxor_expr,TK_PIPE)
|
||||||
|
|
||||||
static Node *land_expr(void) {
|
static Node *land_expr(void) {
|
||||||
Node *l=bor_expr(), *t;
|
Node *l=bor_expr(), *t;
|
||||||
while (tok.kind==TK_AND) {
|
while (tok.kind==TK_AND) {
|
||||||
next(); t=alloc_node(N_BOPN); t->op=TK_AND;
|
next(); t=alloc_node(N_BOPN); t->op=TK_AND;
|
||||||
|
|||||||
Reference in New Issue
Block a user