struct Operator_Info{ Intern_String op; String name; Token_Kind op_kind; bool valid_binary_expr; bool valid_unary_expr; }; /*#import meta print("Operator_Info op_info_table[] = {") for i in meta.token_simple_expr: if i[1] != "SPECIAL": print(f""" {{{{}}, "{i[0].upper()}"_s, TK_{i[0]}, {int(i[2]&meta.BINARY_EXPR>0)}, {int(i[2]&meta.UNARY_EXPR>0)}}},""") print("};") print("""CORE_Static Operator_Info * get_operator_info(Token_Kind op){ switch(op){""") index = 0 for i in meta.token_simple_expr: if i[1] != "SPECIAL": print(f""" case TK_{i[0]}: return op_info_table + {index};""") index += 1 print(" default: {}\n }") print(" return 0;\n}") print("""CORE_Static Operator_Info * get_operator_info(Intern_String op){ if(0){}""") index = 0 for i in meta.token_simple_expr: if i[1] != "SPECIAL": print(f""" else if(op_info_table[{index}].op.str == op.str) return op_info_table + {index};""") index += 1 print(" return 0;\n}") */ Operator_Info op_info_table[] = { {{}, "MUL"_s, TK_Mul, 1, 0}, {{}, "DIV"_s, TK_Div, 1, 0}, {{}, "MOD"_s, TK_Mod, 1, 0}, {{}, "LEFTSHIFT"_s, TK_LeftShift, 1, 0}, {{}, "RIGHTSHIFT"_s, TK_RightShift, 1, 0}, {{}, "ADD"_s, TK_Add, 1, 1}, {{}, "SUB"_s, TK_Sub, 1, 1}, {{}, "EQUALS"_s, TK_Equals, 1, 0}, {{}, "LESSERTHENOREQUAL"_s, TK_LesserThenOrEqual, 1, 0}, {{}, "GREATERTHENOREQUAL"_s, TK_GreaterThenOrEqual, 1, 0}, {{}, "LESSERTHEN"_s, TK_LesserThen, 1, 0}, {{}, "GREATERTHEN"_s, TK_GreaterThen, 1, 0}, {{}, "NOTEQUALS"_s, TK_NotEquals, 1, 0}, {{}, "BITAND"_s, TK_BitAnd, 1, 0}, {{}, "BITOR"_s, TK_BitOr, 1, 0}, {{}, "BITXOR"_s, TK_BitXor, 1, 0}, {{}, "AND"_s, TK_And, 1, 0}, {{}, "OR"_s, TK_Or, 1, 0}, {{}, "NEG"_s, TK_Neg, 0, 1}, {{}, "NOT"_s, TK_Not, 0, 1}, }; CORE_Static Operator_Info * get_operator_info(Token_Kind op){ switch(op){ case TK_Mul: return op_info_table + 0; case TK_Div: return op_info_table + 1; case TK_Mod: return op_info_table + 2; case TK_LeftShift: return op_info_table + 3; case TK_RightShift: return op_info_table + 4; case TK_Add: return op_info_table + 5; case TK_Sub: return op_info_table + 6; case TK_Equals: return op_info_table + 7; case TK_LesserThenOrEqual: return op_info_table + 8; case TK_GreaterThenOrEqual: return op_info_table + 9; case TK_LesserThen: return op_info_table + 10; case TK_GreaterThen: return op_info_table + 11; case TK_NotEquals: return op_info_table + 12; case TK_BitAnd: return op_info_table + 13; case TK_BitOr: return op_info_table + 14; case TK_BitXor: return op_info_table + 15; case TK_And: return op_info_table + 16; case TK_Or: return op_info_table + 17; case TK_Neg: return op_info_table + 18; case TK_Not: return op_info_table + 19; default: {} } return 0; } CORE_Static Operator_Info * get_operator_info(Intern_String op){ if(0){} else if(op_info_table[0].op.str == op.str) return op_info_table + 0; else if(op_info_table[1].op.str == op.str) return op_info_table + 1; else if(op_info_table[2].op.str == op.str) return op_info_table + 2; else if(op_info_table[3].op.str == op.str) return op_info_table + 3; else if(op_info_table[4].op.str == op.str) return op_info_table + 4; else if(op_info_table[5].op.str == op.str) return op_info_table + 5; else if(op_info_table[6].op.str == op.str) return op_info_table + 6; else if(op_info_table[7].op.str == op.str) return op_info_table + 7; else if(op_info_table[8].op.str == op.str) return op_info_table + 8; else if(op_info_table[9].op.str == op.str) return op_info_table + 9; else if(op_info_table[10].op.str == op.str) return op_info_table + 10; else if(op_info_table[11].op.str == op.str) return op_info_table + 11; else if(op_info_table[12].op.str == op.str) return op_info_table + 12; else if(op_info_table[13].op.str == op.str) return op_info_table + 13; else if(op_info_table[14].op.str == op.str) return op_info_table + 14; else if(op_info_table[15].op.str == op.str) return op_info_table + 15; else if(op_info_table[16].op.str == op.str) return op_info_table + 16; else if(op_info_table[17].op.str == op.str) return op_info_table + 17; else if(op_info_table[18].op.str == op.str) return op_info_table + 18; else if(op_info_table[19].op.str == op.str) return op_info_table + 19; return 0; } /*END*/