diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-01 06:42:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-01 06:42:23 +0000 |
commit | 402cbc870dc9a5646e60c4a0e3b3f1a1aa8c4fbf (patch) | |
tree | 5f54e72fc83083496caae8e3d97ecdb60254d1e8 | |
parent | d441e3b959721be536978d37bc492b444a4a1d7b (diff) | |
download | ruby-402cbc870dc9a5646e60c4a0e3b3f1a1aa8c4fbf.tar.gz |
* parse.y (peek_n): new macro to see next nth char.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | parse.y | 12 |
2 files changed, 11 insertions, 5 deletions
@@ -1,3 +1,7 @@ +Wed Jun 1 15:42:18 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (peek_n): new macro to see next nth char. + Wed Jun 1 15:40:46 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * tool/rbinstall.rb (gem): fix for rubygems change. @@ -5364,7 +5364,8 @@ parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *e } #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend) -#define peek(c) (lex_p < lex_pend && (c) == *lex_p) +#define peek(c) peek_n((c), 0) +#define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n]) static inline int parser_nextc(struct parser_params *parser) @@ -6531,6 +6532,8 @@ parser_prepare(struct parser_params *parser) #define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG || lex_state == EXPR_ENDFN) #define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS) #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c)) +#define IS_LABEL_POSSIBLE() ((lex_state == EXPR_BEG && !cmd_state) || IS_ARG()) +#define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1)) #ifndef RIPPER #define ambiguous_operator(op, syn) ( \ @@ -7742,7 +7745,7 @@ parser_yylex(struct parser_params *parser) else { if (lex_state == EXPR_FNAME) { if ((c = nextc()) == '=' && !peek('~') && !peek('>') && - (!peek('=') || (lex_p + 1 < lex_pend && lex_p[1] == '>'))) { + (!peek('=') || (peek_n('>', 1)))) { result = tIDENTIFIER; tokadd(c); tokfix(); @@ -7759,9 +7762,8 @@ parser_yylex(struct parser_params *parser) } } - if ((lex_state == EXPR_BEG && !cmd_state) || - IS_ARG()) { - if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) { + if (IS_LABEL_POSSIBLE()) { + if (IS_LABEL_SUFFIX(0)) { lex_state = EXPR_BEG; nextc(); set_yylval_name(TOK_INTERN(!ENC_SINGLE(mb))); |