📄 lexi.c
字号:
case ('('): l_enum = false; unary_delim = true; code = lparen; break; case ('['): if (parser_state_tos->in_or_st) { parser_state_tos->in_or_st++; } unary_delim = true; code = lparen; break; case (')'): l_enum = false; code = rparen; break; case (']'): if (parser_state_tos->in_or_st > 1) { parser_state_tos->in_or_st--; } code = rparen; break; case '#': unary_delim = parser_state_tos->last_u_d; code = preesc; /* Make spaces between '#' and the directive be part of the token if user specified "-lps" */ if (settings.leave_preproc_space) { while (*buf_ptr == ' ' && buf_ptr < buf_end) { buf_ptr++; } token_end = buf_ptr; } break; case '?': unary_delim = true; code = question; break; case (':'): /* Deal with C++ class::method */ if (*buf_ptr == ':') { code = doublecolon; buf_ptr++; token_end = buf_ptr; break; } code = colon; unary_delim = true; if (squest && *e_com != ' ') { if (e_code == s_code) { parser_state_tos->want_blank = false; } else { parser_state_tos->want_blank = true; } } break; case (';'): l_enum = false; unary_delim = true; code = semicolon; break; case ('{'): if (parser_state_tos->matching_brace_on_same_line < 0) { parser_state_tos->matching_brace_on_same_line = 1; } else { parser_state_tos->matching_brace_on_same_line++; } if (l_enum) { /* Keep all variables in the same column: * ONE, * TWO, etc * instead of * ONE, * TWO, * Use a special code for `block_init' however, because we still * want to do the line breaks when `settings.braces_on_struct_decl_line' * is not set. */ parser_state_tos->block_init = 2; parser_state_tos->block_init_level = 0; l_enum = false; } unary_delim = true; code = lbrace; break; case ('}'): parser_state_tos->matching_brace_on_same_line--; l_enum = false; unary_delim = true; code = rbrace; break; case 014: /* a form feed */ unary_delim = parser_state_tos->last_u_d; parser_state_tos->last_nl = true; /* remember this so we can set 'parser_state_tos->col_1' right */ code = form_feed; break; case (','): unary_delim = true; code = comma; break; case '.': if (parser_state_tos->in_decl && (buf_ptr[0] == '.') && (buf_ptr[1] == '.')) { /* check for '...' in a declaration */ if ((buf_ptr += 2) >= buf_end) { fill_buffer (); } unary_delim = true; code = decl; token_end = buf_ptr; break; } unary_delim = false; code = struct_delim; if (*buf_ptr == '*') /* object .* pointer-to-member */ { ++buf_ptr; token_end = buf_ptr; } break; case '-': case '+': /* check for -, +, --, ++ */ code = (parser_state_tos->last_u_d ? unary_op : binary_op); unary_delim = true; if (*buf_ptr == token[0]) { /* check for doubled character */ buf_ptr++; /* buffer overflow will be checked at end of loop */ if (last_code == ident || last_code == rparen) { code = (parser_state_tos->last_u_d ? unary_op : postop); /* check for following ++ or -- */ unary_delim = false; } } else if (*buf_ptr == '=') { /* check for operator += */ buf_ptr++; } else if (*buf_ptr == '>') { /* check for operator -> */ buf_ptr++; code = struct_delim; /* check for operator ->* */ if (*buf_ptr == '*') { buf_ptr++; } } token_end = buf_ptr; break; /* buffer overflow will be checked at end of switch */ case '=': if (parser_state_tos->in_or_st && (parser_state_tos->last_token != cpp_operator)) { parser_state_tos->block_init = 1; parser_state_tos->block_init_level = 0; } if (*buf_ptr == '=') /* == */ { buf_ptr++; } else if ((*buf_ptr == '-') || (*buf_ptr == '+') || (*buf_ptr == '*') || (*buf_ptr == '&')) { /* Something like x=-1, which can mean x -= 1 ("old style" in K&R1) * or x = -1 (ANSI). Note that this is only an ambiguity if the * character can also be a unary operator. If not, just produce * output code that produces a syntax error (the theory being that * people want to detect and eliminate old style assignments but * they don't want indent to silently change the meaning of their * code). */ WARNING (_("old style assignment ambiguity in \"=%c\". Assuming \"= %c\"\n"), (unsigned long) *((unsigned char *) buf_ptr), (unsigned long) *((unsigned char *) buf_ptr)); } code = binary_op; unary_delim = true; token_end = buf_ptr; break; /* can drop thru!!! */ case '>': case '<': case '!': /* ops like <, <<, <=, !=, <<=, etc */ /* This will of course scan sequences like "<=>", "!=>", "<<>", etc. as * one token, but I don't think that will cause any harm. */ /* in C++ mode also scan <?[=], >?[=] GNU C++ operators * maybe some flag to them ? */ while (*buf_ptr == '>' || *buf_ptr == '<' || *buf_ptr == '=' || (settings.c_plus_plus && *buf_ptr == '?')) { if (++buf_ptr >= buf_end) { fill_buffer (); } if (*buf_ptr == '=') { if (++buf_ptr >= buf_end) { fill_buffer (); } } } code = (parser_state_tos->last_u_d ? unary_op : binary_op); unary_delim = true; token_end = buf_ptr; break; default: if (token[0] == '/' && (*buf_ptr == '*' || *buf_ptr == '/')) { /* A C or C++ comment */ if (*buf_ptr == '*') { code = comment; } else { code = cplus_comment; } if (++buf_ptr >= buf_end) { fill_buffer (); } if (code == comment) { /* Threat comments of type / *UPPERCASE* / not as comments */ char *p = buf_ptr; while (isupper (*p++)) { /* There is always at least one * newline in the buffer; so no * need to check for buf_end. */ } if (p < buf_end && p[-1] == '*' && *p == '/') { buf_ptr = p + 1; code = ident; parser_state_tos->want_blank = true; } } unary_delim = parser_state_tos->last_u_d; } else if (parser_state_tos->last_token == cpp_operator) { /* For C++ overloaded operators. */ code = overloaded; last_code = overloaded; } else { while (*(buf_ptr - 1) == *buf_ptr || *buf_ptr == '=') { /* handle ||, &&, etc, and also things as in int *****i */ if (++buf_ptr >= buf_end) { fill_buffer (); } } code = (parser_state_tos->last_u_d ? unary_op : binary_op); unary_delim = true; } token_end = buf_ptr; } /* end of switch */ if (code != newline) { l_struct = false; last_code = code; } if (buf_ptr >= buf_end) { fill_buffer (); } parser_state_tos->last_u_d = unary_delim; if (parser_state_tos->last_token == cpp_operator) { return overloaded; } return (code);}/* Add the given keyword to the keyword table, using val as * the keyword type */void addkey ( char *key, rwcodes_ty val){ templ_ty *p; /* Check to see whether key is a reserved word or not. */ if ( (settings.c_plus_plus && is_reserved_cc (key, strlen (key)) != 0) || (!settings.c_plus_plus && is_reserved (key, strlen (key)) != 0)) { return; } if (user_specials == 0) { user_specials = (templ_ty *) xmalloc (5 * sizeof (templ_ty)); user_specials_max = 5; user_specials_idx = 0; } else if (user_specials_idx == user_specials_max) { user_specials_max += 5; user_specials = (templ_ty *) xrealloc ((char *) user_specials, user_specials_max * sizeof (templ_ty)); } p = &user_specials[user_specials_idx++]; p->rwd = key; p->rwcode = val; return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -