diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-01 08:32:18 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-01 08:32:18 +0000 |
commit | 4eafec5ea61cd7578b85069a065c3794ca458bbb (patch) | |
tree | 0a4262bbc68f9e6206a873b33bb377872a245886 /parse.y | |
parent | fb29a4dcda2b9c4fde85c6cf237d5158c0fe583e (diff) |
parse.y: simplify parse_ident
* parse.y (parse_ident): simplified selecting identifier types by
the suffix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 33 |
1 files changed, 8 insertions, 25 deletions
@@ -7793,7 +7793,7 @@ parse_atmark(struct parser_params *parser, const enum lex_state_e last_state) static enum yytokentype parse_ident(struct parser_params *parser, int c, int cmd_state) { - enum yytokentype result = 0; + enum yytokentype result; int mb = ENC_CODERANGE_7BIT; const enum lex_state_e last_state = lex_state; ID ident; @@ -7804,37 +7804,20 @@ parse_ident(struct parser_params *parser, int c, int cmd_state) c = nextc(); } while (parser_is_identchar()); if ((c == '!' || c == '?') && !peek('=')) { + result = tFID; + tokadd(c); + } + else if (c == '=' && IS_lex_state(EXPR_FNAME) && + (!peek('~') && !peek('>') && (!peek('=') || (peek_n('>', 1))))) { + result = tIDENTIFIER; tokadd(c); } else { + result = ISUPPER(tok()[0]) ? tCONSTANT : tIDENTIFIER; pushback(c); } tokfix(); - if (toklast() == '!' || toklast() == '?') { - result = tFID; - } - else { - if (IS_lex_state(EXPR_FNAME)) { - register int c = nextc(); - if (c == '=' && !peek('~') && !peek('>') && - (!peek('=') || (peek_n('>', 1)))) { - result = tIDENTIFIER; - tokadd(c); - tokfix(); - } - else { - pushback(c); - } - } - if (result == 0 && ISUPPER(tok()[0])) { - result = tCONSTANT; - } - else { - result = tIDENTIFIER; - } - } - if (IS_LABEL_POSSIBLE()) { if (IS_LABEL_SUFFIX(0)) { SET_LEX_STATE(EXPR_ARG|EXPR_LABELED); |