aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/lexer/enum_type.h7
-rw-r--r--include/lexer/symbol_property.h15
2 files changed, 18 insertions, 4 deletions
diff --git a/include/lexer/enum_type.h b/include/lexer/enum_type.h
index 9de3dc7..e1c5b6f 100644
--- a/include/lexer/enum_type.h
+++ b/include/lexer/enum_type.h
@@ -25,4 +25,11 @@ enum guard_type
GUARD_STRONG,
};
+enum child_existance_type
+{
+ NOT_EXIST,
+ OPTIONAL,
+ EXIST,
+};
+
}
diff --git a/include/lexer/symbol_property.h b/include/lexer/symbol_property.h
index 3d85623..2e94cf7 100644
--- a/include/lexer/symbol_property.h
+++ b/include/lexer/symbol_property.h
@@ -15,6 +15,12 @@ public:
int operand_number = 0;
bool continuable = true;
int pivot_priority = -1;
+
+ // require: MUST
+ // accept: optional, but if it doesn't accept, but there is indeed a child, then error
+ child_existance_type left;
+ child_existance_type right;
+
enum_token_type enum_type = TEXT;
};
@@ -28,10 +34,11 @@ unordered_map<string, T_property> symbol_property = {
{")", {.continuable = false, .enum_type = RIGHT_BRACKET}},
// operator
- {"&", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .enum_type = ASYNC}},
- {"|", {.operand_number = 1, .continuable = true, .pivot_priority = 100, .enum_type = PIPE}},
- {"&&", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .enum_type = LOGIC_AND}},
- {"||", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .enum_type = LOGIC_OR}},
+ {"&", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .left = EXIST, .right = NOT_EXIST, .enum_type = ASYNC}},
+ {"|", {.operand_number = 1, .continuable = true, .pivot_priority = 100, .left = EXIST, .right = EXIST, .enum_type = PIPE}},
+ {"&&", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .left = EXIST, .right = EXIST, .enum_type = LOGIC_AND}},
+ {"||", {.operand_number = 1, .continuable = true, .pivot_priority = 1000, .left = EXIST, .right = EXIST, .enum_type = LOGIC_OR}},
+
};
}