* keywords, parse.y (__ENCODING__): represent script encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-21 03:22:22 +00:00
Родитель 2b62714866
Коммит 9fbc6596cc
5 изменённых файлов: 97 добавлений и 85 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Fri Dec 21 12:22:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* keywords, parse.y (__ENCODING__): represent script encoding.
Fri Dec 21 12:16:50 2007 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_is_ascii_only_p): new method ascii_only?.

Просмотреть файл

@ -6,6 +6,7 @@ const struct kwtable *rb_reserved_word _((const char *, unsigned int));
struct kwtable;
%%
__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END
__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END

168
lex.c.blt
Просмотреть файл

@ -36,12 +36,12 @@ const struct kwtable *rb_reserved_word _((const char *, unsigned int));
#line 7 "keywords"
struct kwtable;
#define TOTAL_KEYWORDS 40
#define TOTAL_KEYWORDS 41
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 8
#define MIN_HASH_VALUE 6
#define MAX_WORD_LENGTH 12
#define MIN_HASH_VALUE 8
#define MAX_HASH_VALUE 50
/* maximum key range = 45, duplicates = 0 */
/* maximum key range = 43, duplicates = 0 */
#ifdef __GNUC__
__inline
@ -63,8 +63,8 @@ hash (str, len)
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 23, 51, 51, 13, 51, 1, 1,
11, 12, 51, 51, 51, 51, 10, 51, 12, 51,
51, 51, 51, 26, 51, 51, 14, 51, 16, 8,
11, 13, 51, 51, 51, 51, 10, 51, 13, 51,
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
51, 51, 51, 51, 51, 11, 51, 13, 1, 26,
4, 1, 8, 28, 51, 23, 51, 1, 1, 27,
@ -109,89 +109,89 @@ rb_reserved_word (str, len)
{
static const struct kwtable wordlist[] =
{
{""}, {""}, {""}, {""}, {""}, {""},
#line 12 "keywords"
{"END", {keyword_END, keyword_END}, EXPR_END},
{""},
#line 16 "keywords"
{"break", {keyword_break, keyword_break}, EXPR_MID},
#line 22 "keywords"
{"else", {keyword_else, keyword_else}, EXPR_BEG},
#line 32 "keywords"
{"nil", {keyword_nil, keyword_nil}, EXPR_END},
#line 25 "keywords"
{"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG},
#line 24 "keywords"
{"end", {keyword_end, keyword_end}, EXPR_END},
#line 41 "keywords"
{"then", {keyword_then, keyword_then}, EXPR_BEG},
#line 33 "keywords"
{"not", {keyword_not, keyword_not}, EXPR_VALUE},
#line 26 "keywords"
{"false", {keyword_false, keyword_false}, EXPR_END},
#line 39 "keywords"
{"self", {keyword_self, keyword_self}, EXPR_END},
#line 23 "keywords"
{"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
#line 36 "keywords"
{"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
#line 42 "keywords"
{"true", {keyword_true, keyword_true}, EXPR_END},
#line 45 "keywords"
{"until", {keyword_until, modifier_until}, EXPR_VALUE},
#line 44 "keywords"
{"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
#line 38 "keywords"
{"return", {keyword_return, keyword_return}, EXPR_MID},
#line 19 "keywords"
{"def", {keyword_def, keyword_def}, EXPR_FNAME},
#line 14 "keywords"
{"and", {keyword_and, keyword_and}, EXPR_VALUE},
#line 21 "keywords"
{"do", {keyword_do, keyword_do}, EXPR_BEG},
#line 48 "keywords"
{"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
#line 27 "keywords"
{"for", {keyword_for, keyword_for}, EXPR_VALUE},
#line 43 "keywords"
{"undef", {keyword_undef, keyword_undef}, EXPR_FNAME},
#line 34 "keywords"
{"or", {keyword_or, keyword_or}, EXPR_VALUE},
#line 29 "keywords"
{"in", {keyword_in, keyword_in}, EXPR_VALUE},
#line 46 "keywords"
{"when", {keyword_when, keyword_when}, EXPR_VALUE},
#line 37 "keywords"
{"retry", {keyword_retry, keyword_retry}, EXPR_END},
#line 28 "keywords"
{"if", {keyword_if, modifier_if}, EXPR_VALUE},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
#line 17 "keywords"
{"case", {keyword_case, keyword_case}, EXPR_VALUE},
#line 35 "keywords"
{"redo", {keyword_redo, keyword_redo}, EXPR_END},
#line 31 "keywords"
{"next", {keyword_next, keyword_next}, EXPR_MID},
{"break", {keyword_break, keyword_break}, EXPR_MID},
#line 23 "keywords"
{"else", {keyword_else, keyword_else}, EXPR_BEG},
#line 33 "keywords"
{"nil", {keyword_nil, keyword_nil}, EXPR_END},
#line 26 "keywords"
{"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG},
#line 25 "keywords"
{"end", {keyword_end, keyword_end}, EXPR_END},
#line 42 "keywords"
{"then", {keyword_then, keyword_then}, EXPR_BEG},
#line 34 "keywords"
{"not", {keyword_not, keyword_not}, EXPR_VALUE},
#line 27 "keywords"
{"false", {keyword_false, keyword_false}, EXPR_END},
#line 40 "keywords"
{"super", {keyword_super, keyword_super}, EXPR_ARG},
#line 30 "keywords"
{"module", {keyword_module, keyword_module}, EXPR_VALUE},
#line 15 "keywords"
{"begin", {keyword_begin, keyword_begin}, EXPR_BEG},
#line 9 "keywords"
{"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END},
#line 10 "keywords"
{"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END},
#line 11 "keywords"
{"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
{"self", {keyword_self, keyword_self}, EXPR_END},
#line 24 "keywords"
{"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE},
#line 37 "keywords"
{"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID},
#line 43 "keywords"
{"true", {keyword_true, keyword_true}, EXPR_END},
#line 46 "keywords"
{"until", {keyword_until, modifier_until}, EXPR_VALUE},
#line 45 "keywords"
{"unless", {keyword_unless, modifier_unless}, EXPR_VALUE},
#line 39 "keywords"
{"return", {keyword_return, keyword_return}, EXPR_MID},
#line 20 "keywords"
{"defined?", {keyword_defined, keyword_defined}, EXPR_ARG},
#line 13 "keywords"
{"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
{""}, {""},
{"def", {keyword_def, keyword_def}, EXPR_FNAME},
#line 15 "keywords"
{"and", {keyword_and, keyword_and}, EXPR_VALUE},
#line 22 "keywords"
{"do", {keyword_do, keyword_do}, EXPR_BEG},
#line 49 "keywords"
{"yield", {keyword_yield, keyword_yield}, EXPR_ARG},
#line 28 "keywords"
{"for", {keyword_for, keyword_for}, EXPR_VALUE},
#line 44 "keywords"
{"undef", {keyword_undef, keyword_undef}, EXPR_FNAME},
#line 35 "keywords"
{"or", {keyword_or, keyword_or}, EXPR_VALUE},
#line 30 "keywords"
{"in", {keyword_in, keyword_in}, EXPR_VALUE},
#line 47 "keywords"
{"when", {keyword_when, keyword_when}, EXPR_VALUE},
#line 38 "keywords"
{"retry", {keyword_retry, keyword_retry}, EXPR_END},
#line 29 "keywords"
{"if", {keyword_if, modifier_if}, EXPR_VALUE},
#line 18 "keywords"
{"case", {keyword_case, keyword_case}, EXPR_VALUE},
#line 36 "keywords"
{"redo", {keyword_redo, keyword_redo}, EXPR_END},
#line 32 "keywords"
{"next", {keyword_next, keyword_next}, EXPR_MID},
#line 41 "keywords"
{"super", {keyword_super, keyword_super}, EXPR_ARG},
#line 31 "keywords"
{"module", {keyword_module, keyword_module}, EXPR_VALUE},
#line 16 "keywords"
{"begin", {keyword_begin, keyword_begin}, EXPR_BEG},
#line 10 "keywords"
{"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END},
#line 11 "keywords"
{"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END},
#line 9 "keywords"
{"__ENCODING__", {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
#line 13 "keywords"
{"END", {keyword_END, keyword_END}, EXPR_END},
#line 14 "keywords"
{"alias", {keyword_alias, keyword_alias}, EXPR_FNAME},
#line 12 "keywords"
{"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
#line 21 "keywords"
{"defined?", {keyword_defined, keyword_defined}, EXPR_ARG},
#line 19 "keywords"
{"class", {keyword_class, keyword_class}, EXPR_CLASS},
{""}, {""},
#line 47 "keywords"
#line 48 "keywords"
{"while", {keyword_while, modifier_while}, EXPR_VALUE}
};
@ -209,6 +209,6 @@ rb_reserved_word (str, len)
}
return 0;
}
#line 49 "keywords"
#line 50 "keywords"
#endif

Просмотреть файл

@ -6,6 +6,7 @@ const struct kwtable *rb_reserved_word _((const char *, unsigned int));
struct kwtable;
%%
__ENCODING__, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END
__LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END

Просмотреть файл

@ -645,6 +645,7 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
keyword_END
keyword__LINE__
keyword__FILE__
keyword__ENCODING__
%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
%token <node> tINTEGER tFLOAT tSTRING_CONTENT tCHAR
@ -1759,7 +1760,8 @@ op : '|' { ifndef_ripper($$ = '|'); }
| '`' { ifndef_ripper($$ = '`'); }
;
reswords : keyword__LINE__ | keyword__FILE__ | keyword_BEGIN | keyword_END
reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
| keyword_BEGIN | keyword_END
| keyword_alias | keyword_and | keyword_begin
| keyword_break | keyword_case | keyword_class | keyword_def
| keyword_defined | keyword_do | keyword_else | keyword_elsif
@ -3923,6 +3925,7 @@ variable : tIDENTIFIER
| keyword_false {ifndef_ripper($$ = keyword_false);}
| keyword__FILE__ {ifndef_ripper($$ = keyword__FILE__);}
| keyword__LINE__ {ifndef_ripper($$ = keyword__LINE__);}
| keyword__ENCODING__ {ifndef_ripper($$ = keyword__ENCODING__);}
;
var_ref : variable
@ -7569,6 +7572,9 @@ gettable_gen(struct parser_params *parser, ID id)
else if (id == keyword__LINE__) {
return NEW_LIT(INT2FIX(ruby_sourceline));
}
else if (id == keyword__ENCODING__) {
return NEW_LIT(rb_enc_from_encoding(parser->enc));
}
else if (is_local_id(id)) {
if (dyna_in_block() && dvar_defined(id)) return NEW_DVAR(id);
if (local_id(id)) return NEW_LVAR(id);