Supports bit shift operators.
I forgot...
This commit is contained in:
parent
ad3fbc58d9
commit
d0ff990914
16
biner.y
16
biner.y
@ -103,8 +103,8 @@ resolve_constant_(
|
|||||||
%type <ptr> struct_member_type array_struct_member_type unqualified_struct_member_type
|
%type <ptr> struct_member_type array_struct_member_type unqualified_struct_member_type
|
||||||
|
|
||||||
%type <ptr> expr or_expr and_expr bit_or_expr bit_xor_expr
|
%type <ptr> expr or_expr and_expr bit_or_expr bit_xor_expr
|
||||||
%type <ptr> bit_and_expr equality_expr relational_expr add_expr
|
%type <ptr> bit_and_expr equality_expr relational_expr shift_expr
|
||||||
%type <ptr> mul_expr unary_expr operand
|
%type <ptr> add_expr mul_expr unary_expr operand
|
||||||
|
|
||||||
%start decl_list
|
%start decl_list
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ equality_expr
|
|||||||
;
|
;
|
||||||
|
|
||||||
relational_expr
|
relational_expr
|
||||||
: add_expr
|
: shift_expr
|
||||||
| relational_expr '>' add_expr {
|
| relational_expr '>' add_expr {
|
||||||
$$ = create_operator_($1, BINER_TREE_EXPR_TYPE_OPERATOR_GREATER, $3);
|
$$ = create_operator_($1, BINER_TREE_EXPR_TYPE_OPERATOR_GREATER, $3);
|
||||||
}
|
}
|
||||||
@ -329,6 +329,16 @@ relational_expr
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
shift_expr
|
||||||
|
: add_expr
|
||||||
|
| shift_expr BIT_LSHIFT add_expr {
|
||||||
|
$$ = create_operator_($1, BINER_TREE_EXPR_TYPE_OPERATOR_BIT_LSHIFT, $3);
|
||||||
|
}
|
||||||
|
| shift_expr BIT_RSHIFT add_expr {
|
||||||
|
$$ = create_operator_($1, BINER_TREE_EXPR_TYPE_OPERATOR_BIT_RSHIFT, $3);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
add_expr
|
add_expr
|
||||||
: mul_expr
|
: mul_expr
|
||||||
| add_expr '+' mul_expr {
|
| add_expr '+' mul_expr {
|
||||||
|
@ -29,8 +29,8 @@ struct teacher_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct student_t {
|
struct student_t {
|
||||||
lu8[10] scores;
|
lu8[(1 << 4) - 6] scores;
|
||||||
lu8 absents;
|
lu8 absents;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct user_t {
|
struct user_t {
|
||||||
|
@ -56,6 +56,8 @@ static const char* const expr_operator_string_map_
|
|||||||
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_OR] = "|",
|
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_OR] = "|",
|
||||||
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_NOT] = "~",
|
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_NOT] = "~",
|
||||||
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_XOR] = "^",
|
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_XOR] = "^",
|
||||||
|
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_LSHIFT] = "<<",
|
||||||
|
[BINER_TREE_EXPR_TYPE_OPERATOR_BIT_RSHIFT] = ">>",
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct struct_member_info_t {
|
typedef struct struct_member_info_t {
|
||||||
|
2
tree.h
2
tree.h
@ -36,6 +36,8 @@ typedef enum biner_tree_expr_type_t {
|
|||||||
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_OR,
|
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_OR,
|
||||||
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_NOT,
|
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_NOT,
|
||||||
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_XOR,
|
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_XOR,
|
||||||
|
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_LSHIFT,
|
||||||
|
BINER_TREE_EXPR_TYPE_OPERATOR_BIT_RSHIFT,
|
||||||
|
|
||||||
BINER_TREE_EXPR_TYPE_OPERATOR_MAX_,
|
BINER_TREE_EXPR_TYPE_OPERATOR_MAX_,
|
||||||
} biner_tree_expr_type_t;
|
} biner_tree_expr_type_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user