From: yu.dongliang <18588496441@163.com> Date: Tue, 9 Jun 2026 11:07:52 +0000 (+0800) Subject: ../lex/scf_lex_util.c X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=a28047953202896d8f0224009daf6574bafaffcd;p=scf.git ../lex/scf_lex_util.c --- diff --git a/lex/scf_lex_util.c b/lex/scf_lex_util.c index 2a09659..26e6417 100644 --- a/lex/scf_lex_util.c +++ b/lex/scf_lex_util.c @@ -2,6 +2,34 @@ int _find_key_word(const char* text); +static scf_key_word_t number_postfix[] = +{ + {"l", SCF_LEX_WORD_CONST_INT}, + {"ll", SCF_LEX_WORD_CONST_I64}, + + {"u", SCF_LEX_WORD_CONST_U32}, + {"ul", SCF_LEX_WORD_CONST_U32}, + {"ull", SCF_LEX_WORD_CONST_U64}, + + {"f", SCF_LEX_WORD_CONST_FLOAT}, + {"lf", SCF_LEX_WORD_CONST_DOUBLE}, +}; + +static int _lex_number_postfix(const char* postfix, int n) +{ + scf_key_word_t* key; + int i; + + for (i = 0; i < sizeof(number_postfix) / sizeof(number_postfix[0]); i++) { + key = &number_postfix[i]; + + if (!strncmp(key->text, postfix, n)) + return key->type; + } + + return -EINVAL; +} + static int __lex_getc(scf_lex_t* lex) { if (lex->fp) @@ -214,34 +242,6 @@ int _lex_op3_ll1(scf_lex_t* lex, scf_lex_word_t** pword, scf_char_t* c0, return 0; } -static scf_key_word_t number_postfix[] = -{ - {"l", SCF_LEX_WORD_CONST_INT}, - {"ll", SCF_LEX_WORD_CONST_I64}, - - {"u", SCF_LEX_WORD_CONST_U32}, - {"ul", SCF_LEX_WORD_CONST_U32}, - {"ull", SCF_LEX_WORD_CONST_U64}, - - {"f", SCF_LEX_WORD_CONST_FLOAT}, - {"lf", SCF_LEX_WORD_CONST_DOUBLE}, -}; - -static int _lex_number_postfix(const char* postfix, int n) -{ - scf_key_word_t* key; - int i; - - for (i = 0; i < sizeof(number_postfix) / sizeof(number_postfix[0]); i++) { - key = &number_postfix[i]; - - if (!strncmp(key->text, postfix, n)) - return key->type; - } - - return -EINVAL; -} - int _lex_number_base_10(scf_lex_t* lex, scf_lex_word_t** pword, scf_string_t* s) { scf_char_t* c2;