The token a metadata operator name stands for (`op_Addition` -> `+`): the * name the scope records an operator under. NULL for a name that is none. */
| 3489 | /* The token a metadata operator name stands for (`op_Addition` -> `+`): the |
| 3490 | * name the scope records an operator under. NULL for a name that is none. */ |
| 3491 | static const char *operator_token(const char *name, size_t len) { |
| 3492 | static const struct { |
| 3493 | const char *meta; |
| 3494 | const char *token; |
| 3495 | } ops[] = { |
| 3496 | {"Addition", "+"}, |
| 3497 | {"UnaryPlus", "+"}, |
| 3498 | {"Subtraction", "-"}, |
| 3499 | {"UnaryNegation", "-"}, |
| 3500 | {"Multiply", "*"}, |
| 3501 | {"Division", "/"}, |
| 3502 | {"Modulus", "%"}, |
| 3503 | {"BitwiseAnd", "&"}, |
| 3504 | {"BitwiseOr", "|"}, |
| 3505 | {"ExclusiveOr", "^"}, |
| 3506 | {"LeftShift", "<<"}, |
| 3507 | {"RightShift", ">>"}, |
| 3508 | {"UnsignedRightShift", ">>>"}, |
| 3509 | {"Equality", "=="}, |
| 3510 | {"Inequality", "!="}, |
| 3511 | {"LessThan", "<"}, |
| 3512 | {"GreaterThan", ">"}, |
| 3513 | {"LessThanOrEqual", "<="}, |
| 3514 | {"GreaterThanOrEqual", ">="}, |
| 3515 | {"LogicalNot", "!"}, |
| 3516 | {"OnesComplement", "~"}, |
| 3517 | {"Increment", "++"}, |
| 3518 | {"Decrement", "--"}, |
| 3519 | {"True", "true"}, |
| 3520 | {"False", "false"}, |
| 3521 | {"Implicit", "implicit"}, |
| 3522 | {"Explicit", "explicit"}, |
| 3523 | {"CheckedAddition", "+"}, |
| 3524 | {"CheckedSubtraction", "-"}, |
| 3525 | {"CheckedMultiply", "*"}, |
| 3526 | {"CheckedDivision", "/"}, |
| 3527 | {"CheckedUnaryNegation", "-"}, |
| 3528 | {"CheckedIncrement", "++"}, |
| 3529 | {"CheckedDecrement", "--"}, |
| 3530 | {"CheckedExplicit", "explicit"}, |
| 3531 | }; |
| 3532 | for (size_t i = 0; i < sizeof(ops) / sizeof(ops[0]); i++) { |
| 3533 | if (strlen(ops[i].meta) == len && memcmp(ops[i].meta, name, len) == 0) { |
| 3534 | return ops[i].token; |
| 3535 | } |
| 3536 | } |
| 3537 | return NULL; |
| 3538 | } |
| 3539 | |
| 3540 | static bool starts_word(const char *s, const char *word) { |
| 3541 | size_t n = strlen(word); |