mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
fb29a4dcda
commit
4eafec5ea6
1 changed files with 8 additions and 25 deletions
29
parse.y
29
parse.y
|
@ -7793,7 +7793,7 @@ parse_atmark(struct parser_params *parser, const enum lex_state_e last_state)
|
||||||
static enum yytokentype
|
static enum yytokentype
|
||||||
parse_ident(struct parser_params *parser, int c, int cmd_state)
|
parse_ident(struct parser_params *parser, int c, int cmd_state)
|
||||||
{
|
{
|
||||||
enum yytokentype result = 0;
|
enum yytokentype result;
|
||||||
int mb = ENC_CODERANGE_7BIT;
|
int mb = ENC_CODERANGE_7BIT;
|
||||||
const enum lex_state_e last_state = lex_state;
|
const enum lex_state_e last_state = lex_state;
|
||||||
ID ident;
|
ID ident;
|
||||||
|
@ -7804,36 +7804,19 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
|
||||||
c = nextc();
|
c = nextc();
|
||||||
} while (parser_is_identchar());
|
} while (parser_is_identchar());
|
||||||
if ((c == '!' || c == '?') && !peek('=')) {
|
if ((c == '!' || c == '?') && !peek('=')) {
|
||||||
tokadd(c);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pushback(c);
|
|
||||||
}
|
|
||||||
tokfix();
|
|
||||||
|
|
||||||
if (toklast() == '!' || toklast() == '?') {
|
|
||||||
result = tFID;
|
result = tFID;
|
||||||
|
tokadd(c);
|
||||||
}
|
}
|
||||||
else {
|
else if (c == '=' && IS_lex_state(EXPR_FNAME) &&
|
||||||
if (IS_lex_state(EXPR_FNAME)) {
|
(!peek('~') && !peek('>') && (!peek('=') || (peek_n('>', 1))))) {
|
||||||
register int c = nextc();
|
|
||||||
if (c == '=' && !peek('~') && !peek('>') &&
|
|
||||||
(!peek('=') || (peek_n('>', 1)))) {
|
|
||||||
result = tIDENTIFIER;
|
result = tIDENTIFIER;
|
||||||
tokadd(c);
|
tokadd(c);
|
||||||
tokfix();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
result = ISUPPER(tok()[0]) ? tCONSTANT : tIDENTIFIER;
|
||||||
pushback(c);
|
pushback(c);
|
||||||
}
|
}
|
||||||
}
|
tokfix();
|
||||||
if (result == 0 && ISUPPER(tok()[0])) {
|
|
||||||
result = tCONSTANT;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = tIDENTIFIER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_LABEL_POSSIBLE()) {
|
if (IS_LABEL_POSSIBLE()) {
|
||||||
if (IS_LABEL_SUFFIX(0)) {
|
if (IS_LABEL_SUFFIX(0)) {
|
||||||
|
|
Loading…
Reference in a new issue