* parse.y: pragma support on ripper. [ruby-dev:26266]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-06-02 14:43:10 +00:00
Родитель 34adacb036
Коммит d2a81a3aa3
5 изменённых файлов: 28 добавлений и 8 удалений

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

@ -1,3 +1,7 @@
Thu Jun 2 23:42:57 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y: pragma support on ripper. [ruby-dev:26266]
Thu Jun 2 00:02:16 2005 Minero Aoki <aamine@loveruby.net>
* struct.c: accessing >10 member caused segmentation fault.
@ -54,7 +58,7 @@ Sat May 28 05:15:44 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
Sat May 28 02:00:11 2005 GOTOU Yuuzou <gotoyuzo@notwork.org>
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line):
* lib/webrick/cgi.rb (WEBrick::CGI::Socket#request_line):
ENV["REQUEST_URI"] is better to get correct Request-URI
than ENV["SCRIPT_NAME"] + ENV["PATH_INFO"]. [ruby-dev:26235]

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

@ -1,6 +1,5 @@
Makefile
eventids1.c
ripper.c
ripper.y
ripper.*
ids1
ids2

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

@ -1,7 +1,11 @@
common: src rb
src: ripper.c eventids1.c
rb: $(srcdir)/lib/ripper/core.rb
ripper.o: ripper.c $(hdrdir)/lex.c eventids1.c $(srcdir)/eventids2.c
ripper.c: ripper.y
bison -t -v -o$@ ripper.y
.y.c:
bison -t -v -o$@ $<
ripper.y: $(hdrdir)/parse.y $(srcdir)/tools/preproc.rb
$(RUBY) $(srcdir)/tools/preproc.rb $(hdrdir)/parse.y > $@
@ -15,8 +19,8 @@ ids1: $(srcdir)/tools/list-parse-event-ids.rb $(hdrdir)/parse.y
ids2: $(srcdir)/tools/list-scan-event-ids.rb $(srcdir)/eventids2.c
$(RUBY) $(srcdir)/tools/list-scan-event-ids.rb -a $(srcdir)/eventids2.c > $@
rb: $(srcdir)/lib/ripper/core.rb.in ids1 ids2 $(srcdir)/tools/generate-ripper_rb.rb
$(RUBY) $(srcdir)/tools/generate-ripper_rb.rb $(srcdir)/lib/ripper/core.rb.in ids1 ids2 > $(srcdir)/lib/ripper/core.rb
$(srcdir)/lib/ripper/core.rb: $(srcdir)/lib/ripper/core.rb.in ids1 ids2 $(srcdir)/tools/generate-ripper_rb.rb
$(RUBY) $(srcdir)/tools/generate-ripper_rb.rb $@.in ids1 ids2 > $@
#
# Entries for only ripper developpers: DO NOT USE

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

@ -93,6 +93,7 @@ class Ripper
:params => 4,
:paren => 1,
:parse_error => 1,
:pragma => 2,
:program => 1,
:qwords_add => 2,
:qwords_new => 0,
@ -509,6 +510,10 @@ class Ripper
a
end
def on_pragma(a, b)
a
end
def on_program(a)
a
end

10
parse.y
Просмотреть файл

@ -4559,7 +4559,7 @@ rb_compile_string(f, s, line)
{
VALUE volatile vparser = rb_parser_s_new();
struct parser_params *parser;
Data_Get_Struct(vparser, struct parser_params, parser);
lex_gets = lex_get_str;
lex_gets_ptr = 0;
@ -5359,6 +5359,7 @@ lvar_defined_gen(parser, id)
}
/* emacsen -*- hack */
#ifndef RIPPER
typedef void (*rb_pragma_setter_t) _((struct parser_params *parser, const char *name, const char *val));
static void pragma_encoding _((struct parser_params *, const char *, const char *));
@ -5380,6 +5381,7 @@ struct pragma {
static const struct pragma pragmas[] = {
{"coding", pragma_encoding},
};
#endif
static const char *
pragma_marker(str, len)
@ -5437,7 +5439,9 @@ parser_pragma(parser, str, len)
/* %r"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*" */
while (len > 0) {
#ifndef RIPPER
const struct pragma *p = pragmas;
#endif
int n = 0;
for (; len > 0 && *str; str++, --len) {
@ -5485,6 +5489,7 @@ parser_pragma(parser, str, len)
n = end - beg;
str_copy(name, beg, n);
rb_funcall(name, rb_intern("downcase!"), 0);
#ifndef RIPPER
do {
if (strncmp(p->name, RSTRING(name)->ptr, n) == 0) {
str_copy(val, vbeg, vend - vbeg);
@ -5492,6 +5497,9 @@ parser_pragma(parser, str, len)
break;
}
} while (++p < pragmas + sizeof(pragmas) / sizeof(*p));
#else
dispatch2(pragma, name, val);
#endif
}
return Qtrue;