diff options
| author | _ov4 <ov4@ov4.org> | 2026-09-08 13:43:06 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-09-08 13:43:06 +0000 |
| commit | 992487d4e425db4443b6f692f349e61de78ea43e (patch) | |
| tree | 58aab1ff7d16c7bafd365bc6d921f42c9700d833 /include/lexer | |
| parent | f546615bd22a2a9867b44a5870c7831ead9426f9 (diff) | |
add left/child requirement
Diffstat (limited to 'include/lexer')
| -rw-r--r-- | include/lexer/enum_type.h | 7 | ||||
| -rw-r--r-- | include/lexer/symbol_property.h | 15 |
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}}, + }; } |
