* parse.y [ripper]: space event is on__sp, not on__lwsp. [ruby-dev:24257]
* ext/ripper/eventids2.c: ditto. * ext/ripper/lib/ripper.rb: ditto. * ext/ripper/depend (ripper.o): No action is needed. [ruby-dev:24260] * ext/ripper/depend: Borland make does not accept pipes in Makefile rules. [ruby-dev:24589] * ext/ripper/depend: separate rules for developpers. * ext/ripper/Makefile.dev: new file. * ext/ripper/MANIFEST: add Makefile.dev. * ext/ripper/tools/generate-eventids1.rb: read from file, not stdin. * ext/ripper/extconf.rb: clean ripper.E. * ext/ripper/tools/generate-ripper_rb.rb: #include ids1/ids2 function was lost. * ext/ripper/tools/generate-ripper_rb.rb: SCANNER_EVENTS wrongly contained parser events. * ext/ripper/lib/ripper.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26a828a605
commit
d3bce8cb5a
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
||||
Tue Sep 14 20:24:49 2004 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* parse.y [ripper]: space event is on__sp, not on__lwsp.
|
||||
[ruby-dev:24257]
|
||||
|
||||
* ext/ripper/eventids2.c: ditto.
|
||||
|
||||
* ext/ripper/lib/ripper.rb: ditto.
|
||||
|
||||
* ext/ripper/depend (ripper.o): No action is needed.
|
||||
[ruby-dev:24260]
|
||||
|
||||
* ext/ripper/depend: Borland make does not accept pipes in
|
||||
Makefile rules. [ruby-dev:24589]
|
||||
|
||||
* ext/ripper/depend: separate rules for developpers.
|
||||
|
||||
* ext/ripper/Makefile.dev: new file.
|
||||
|
||||
* ext/ripper/MANIFEST: add Makefile.dev.
|
||||
|
||||
* ext/ripper/tools/generate-eventids1.rb: read from file, not
|
||||
stdin.
|
||||
|
||||
* ext/ripper/extconf.rb: clean ripper.E.
|
||||
|
||||
* ext/ripper/tools/generate-ripper_rb.rb: #include ids1/ids2
|
||||
function was lost.
|
||||
|
||||
* ext/ripper/tools/generate-ripper_rb.rb: SCANNER_EVENTS wrongly
|
||||
contained parser events.
|
||||
|
||||
* ext/ripper/lib/ripper.rb: ditto.
|
||||
|
||||
Tue Sep 14 16:59:37 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tcltklib/tcltklib.c: fix SEGV
|
||||
|
4
ext/ripper/.cvsignore
Normal file
4
ext/ripper/.cvsignore
Normal file
@ -0,0 +1,4 @@
|
||||
Makefile
|
||||
eventids1.c
|
||||
ripper.c
|
||||
ripper.y
|
@ -1,4 +1,5 @@
|
||||
MANIFEST
|
||||
Makefile.dev
|
||||
README
|
||||
depend
|
||||
eventids2.c
|
||||
|
18
ext/ripper/Makefile.dev
Normal file
18
ext/ripper/Makefile.dev
Normal file
@ -0,0 +1,18 @@
|
||||
# Makefile for ripper developpers
|
||||
# !!! This file requires GNU make !!!
|
||||
|
||||
include Makefile
|
||||
|
||||
lib/ripper.rb: $(srcdir)/ripper.rb.in ids1 ids2 $(srcdir)/tools/generate-ripper_rb.rb
|
||||
$(RUBY) $(srcdir)/tools/generate-ripper_rb.rb $(srcdir)/ripper.rb.in ids1 ids2 > $@
|
||||
|
||||
test:
|
||||
$(RUBY) test/check-event-arity.rb $(hdrdir)/parse.y
|
||||
sh test/check-event-coverage.sh
|
||||
$(RUBY) test/check-scanner-event-coverage.rb
|
||||
$(RUBY) test/validate.rb > /dev/null
|
||||
@echo OK
|
||||
|
||||
preproc: ripper.E
|
||||
ripper.E: ripper.c
|
||||
$(CC) -E $(CPPFLAGS) ripper.c | ruby tools/strip.rb > $@
|
@ -1,6 +1,4 @@
|
||||
# Do not remove "./"; nmake requires this.
|
||||
ripper.o: ./ripper.c lex.c eventids1.c eventids2.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c ./ripper.c
|
||||
ripper.o: lex.c eventids1.c eventids2.c
|
||||
|
||||
ripper.c: ripper.y
|
||||
bison -t -v -o$@ ripper.y
|
||||
@ -8,31 +6,11 @@ ripper.c: ripper.y
|
||||
ripper.y: $(hdrdir)/parse.y $(srcdir)/tools/preproc.rb
|
||||
$(RUBY) $(srcdir)/tools/preproc.rb $(hdrdir)/parse.y > $@
|
||||
|
||||
eventids1.c: $(hdrdir)/parse.y $(srcdir)/tools/list-parse-event-ids.rb $(srcdir)/tools/generate-eventids1.rb
|
||||
$(RUBY) $(srcdir)/tools/list-parse-event-ids.rb $(hdrdir)/parse.y | $(RUBY) $(srcdir)/tools/generate-eventids1.rb > $@
|
||||
eventids1.c: $(hdrdir)/parse.y $(srcdir)/tools/generate-eventids1.rb ids1
|
||||
$(RUBY) $(srcdir)/tools/generate-eventids1.rb ids1 > $@
|
||||
|
||||
lex.c:
|
||||
cp $(hdrdir)/lex.c . || cp $(srcdir)/lex.c .
|
||||
ids1: $(srcdir)/tools/list-parse-event-ids.rb $(hdrdir)/parse.y
|
||||
$(RUBY) $(srcdir)/tools/list-parse-event-ids.rb -a $(hdrdir)/parse.y > $@
|
||||
|
||||
#
|
||||
# Entries for ripper developpers (no srcdir/objdir support)
|
||||
#
|
||||
lib/ripper.rb: ripper.rb.in ids1 ids2 tools/generate-ripper_rb.rb
|
||||
$(RUBY) tools/generate-ripper_rb.rb ripper.rb.in ids1 ids2 > $@
|
||||
|
||||
ids1: tools/list-parse-event-ids.rb ../../parse.y
|
||||
$(RUBY) tools/list-parse-event-ids.rb -a ../../parse.y > $@
|
||||
|
||||
ids2: $(srcdir)/tools/list-scan-event-ids.rb eventids2.c
|
||||
$(RUBY) tools/list-scan-event-ids.rb -a eventids2.c > $@
|
||||
|
||||
test: ripper.so test/*.*
|
||||
$(RUBY) test/check-event-arity.rb $(hdrdir)/parse.y
|
||||
sh test/check-event-coverage.sh
|
||||
$(RUBY) test/check-scanner-event-coverage.rb
|
||||
$(RUBY) test/validate.rb > /dev/null
|
||||
@echo OK
|
||||
|
||||
preproc: ripper.E
|
||||
ripper.E: ripper.c
|
||||
$(CC) -E $(CPPFLAGS) ripper.c | ruby tools/strip.rb > $@
|
||||
ids2: $(srcdir)/tools/list-scan-event-ids.rb $(srcdir)/eventids2.c
|
||||
$(RUBY) $(srcdir)/tools/list-scan-event-ids.rb -a $(srcdir)/eventids2.c > $@
|
||||
|
@ -1,14 +1,14 @@
|
||||
#define tIGNORED_NL (tLAST_TOKEN + 1)
|
||||
#define tCOMMENT (tLAST_TOKEN + 2)
|
||||
#define tEMBDOC_BEG (tLAST_TOKEN + 3)
|
||||
#define tEMBDOC (tLAST_TOKEN + 4)
|
||||
#define tEMBDOC_END (tLAST_TOKEN + 5)
|
||||
#define tLWSP (tLAST_TOKEN + 6)
|
||||
#define tHEREDOC_BEG (tLAST_TOKEN + 7)
|
||||
#define tIGNORED_NL (tLAST_TOKEN + 1)
|
||||
#define tCOMMENT (tLAST_TOKEN + 2)
|
||||
#define tEMBDOC_BEG (tLAST_TOKEN + 3)
|
||||
#define tEMBDOC (tLAST_TOKEN + 4)
|
||||
#define tEMBDOC_END (tLAST_TOKEN + 5)
|
||||
#define tSP (tLAST_TOKEN + 6)
|
||||
#define tHEREDOC_BEG (tLAST_TOKEN + 7)
|
||||
#define tHEREDOC_CONTENT (tLAST_TOKEN + 8)
|
||||
#define tHEREDOC_END (tLAST_TOKEN + 9)
|
||||
#define k__END__ (tLAST_TOKEN + 10)
|
||||
#define tCHAR (tLAST_TOKEN + 11)
|
||||
#define tHEREDOC_END (tLAST_TOKEN + 9)
|
||||
#define k__END__ (tLAST_TOKEN + 10)
|
||||
#define tCHAR (tLAST_TOKEN + 11)
|
||||
|
||||
static ID ripper_id_scan;
|
||||
|
||||
@ -51,7 +51,7 @@ static ID ripper_id_comment;
|
||||
static ID ripper_id_embdoc_beg;
|
||||
static ID ripper_id_embdoc;
|
||||
static ID ripper_id_embdoc_end;
|
||||
static ID ripper_id_lwsp;
|
||||
static ID ripper_id_sp;
|
||||
static ID ripper_id_heredoc_beg;
|
||||
static ID ripper_id_heredoc_content;
|
||||
static ID ripper_id_heredoc_end;
|
||||
@ -102,7 +102,7 @@ ripper_init_eventids2()
|
||||
ripper_id_embdoc_beg = rb_intern("on__embdoc_beg");
|
||||
ripper_id_embdoc = rb_intern("on__embdoc");
|
||||
ripper_id_embdoc_end = rb_intern("on__embdoc_end");
|
||||
ripper_id_lwsp = rb_intern("on__sp");
|
||||
ripper_id_sp = rb_intern("on__sp");
|
||||
ripper_id_heredoc_beg = rb_intern("on__heredoc_beg");
|
||||
ripper_id_heredoc_content = rb_intern("on__heredoc_content");
|
||||
ripper_id_heredoc_end = rb_intern("on__heredoc_end");
|
||||
@ -241,13 +241,14 @@ static struct token_assoc {
|
||||
{tUPLUS, &ripper_id_op},
|
||||
{tWORDS_BEG, &ripper_id_words_beg},
|
||||
{tXSTRING_BEG, &ripper_id_backtick},
|
||||
/* ripper specific tokens */
|
||||
|
||||
/* ripper specific tokens */
|
||||
{tIGNORED_NL, &ripper_id_ignored_nl},
|
||||
{tCOMMENT, &ripper_id_comment},
|
||||
{tEMBDOC_BEG, &ripper_id_embdoc_beg},
|
||||
{tEMBDOC, &ripper_id_embdoc},
|
||||
{tEMBDOC_END, &ripper_id_embdoc_end},
|
||||
{tLWSP, &ripper_id_lwsp},
|
||||
{tSP, &ripper_id_sp},
|
||||
{tHEREDOC_BEG, &ripper_id_heredoc_beg},
|
||||
{tHEREDOC_CONTENT, &ripper_id_heredoc_content},
|
||||
{tHEREDOC_END, &ripper_id_heredoc_end},
|
||||
|
@ -9,15 +9,17 @@ def main
|
||||
exit 1
|
||||
end
|
||||
$objs = %w(ripper.o)
|
||||
$cleanfiles.concat %w(ripper.y ripper.c ripper.output ids1 ids2)
|
||||
$cleanfiles.concat %w(ripper.y ripper.c ripper.E ripper.output eventids1.c ids1 ids2)
|
||||
$CPPFLAGS += ' -DRIPPER'
|
||||
$CPPFLAGS += ' -DRIPPER_DEBUG' if $debug
|
||||
create_makefile 'ripper'
|
||||
end
|
||||
|
||||
def have_command(cmd)
|
||||
ENV['PATH'].split(File::PATH_SEPARATOR).any? {|path|
|
||||
File.executable?("#{path}/#{cmd}#{Config::CONFIG['EXEEXT']}")
|
||||
checking_for(cmd) {
|
||||
ENV['PATH'].split(File::PATH_SEPARATOR).any? {|path|
|
||||
File.executable?("#{path}/#{cmd}#{Config::CONFIG['EXEEXT']}")
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -28,6 +28,7 @@ class Ripper
|
||||
end
|
||||
|
||||
PARSER_EVENTS = [
|
||||
|
||||
:BEGIN,
|
||||
:END,
|
||||
:alias,
|
||||
@ -151,126 +152,51 @@ class Ripper
|
||||
]
|
||||
|
||||
SCANNER_EVENTS = [
|
||||
:BEGIN,
|
||||
:END,
|
||||
:alias,
|
||||
:alias_error,
|
||||
:aref,
|
||||
:aref_field,
|
||||
:arg_ambiguous,
|
||||
:arg_paren,
|
||||
:arglist_add,
|
||||
:arglist_add_block,
|
||||
:arglist_add_star,
|
||||
:arglist_new,
|
||||
:arglist_prepend,
|
||||
:array,
|
||||
:assign,
|
||||
:assign_error,
|
||||
:assoc_new,
|
||||
:assoclist_from_args,
|
||||
:bare_assoc_hash,
|
||||
:begin,
|
||||
:binary,
|
||||
:blockvar_add_block,
|
||||
:blockvar_add_star,
|
||||
:blockvar_new,
|
||||
:bodystmt,
|
||||
:brace_block,
|
||||
:break,
|
||||
:call,
|
||||
:case,
|
||||
:class,
|
||||
:class_name_error,
|
||||
:command,
|
||||
:command_call,
|
||||
:const_ref,
|
||||
:constpath_field,
|
||||
:constpath_ref,
|
||||
:def,
|
||||
:defined,
|
||||
:defs,
|
||||
:do_block,
|
||||
:dot2,
|
||||
:dot3,
|
||||
:dyna_symbol,
|
||||
:else,
|
||||
:elsif,
|
||||
:ensure,
|
||||
:fcall,
|
||||
:field,
|
||||
:for,
|
||||
:hash,
|
||||
:if,
|
||||
:if_mod,
|
||||
:ifop,
|
||||
:iter_block,
|
||||
:massign,
|
||||
:method_add_arg,
|
||||
:mlhs_add,
|
||||
:mlhs_add_star,
|
||||
:mlhs_new,
|
||||
:mlhs_paren,
|
||||
:module,
|
||||
:mrhs_add,
|
||||
:mrhs_add_star,
|
||||
:mrhs_new,
|
||||
:mrhs_new_from_arglist,
|
||||
:next,
|
||||
:opassign,
|
||||
:param_error,
|
||||
:params,
|
||||
:paren,
|
||||
:parse_error,
|
||||
:program,
|
||||
:qwords_add,
|
||||
:qwords_new,
|
||||
:redo,
|
||||
:regexp_literal,
|
||||
:rescue,
|
||||
:rescue_mod,
|
||||
:restparam,
|
||||
:retry,
|
||||
:return,
|
||||
:return0,
|
||||
:sclass,
|
||||
:space,
|
||||
:stmts_add,
|
||||
:stmts_new,
|
||||
:string_add,
|
||||
:string_concat,
|
||||
:string_content,
|
||||
:string_dvar,
|
||||
:string_embexpr,
|
||||
:string_literal,
|
||||
:super,
|
||||
:symbol,
|
||||
:symbol_literal,
|
||||
:topconst_field,
|
||||
:topconst_ref,
|
||||
:unary,
|
||||
:undef,
|
||||
:unless,
|
||||
:unless_mod,
|
||||
:until,
|
||||
:until_mod,
|
||||
:var_alias,
|
||||
:var_field,
|
||||
:var_ref,
|
||||
:void_stmt,
|
||||
:when,
|
||||
:while,
|
||||
:while_mod,
|
||||
:word_add,
|
||||
:word_new,
|
||||
:words_add,
|
||||
:words_new,
|
||||
:xstring_add,
|
||||
:xstring_literal,
|
||||
:xstring_new,
|
||||
:yield,
|
||||
:yield0,
|
||||
:zsuper
|
||||
|
||||
:CHAR,
|
||||
:__end__,
|
||||
:backref,
|
||||
:backtick,
|
||||
:comma,
|
||||
:comment,
|
||||
:const,
|
||||
:cvar,
|
||||
:embdoc,
|
||||
:embdoc_beg,
|
||||
:embdoc_end,
|
||||
:embexpr_beg,
|
||||
:embexpr_end,
|
||||
:embvar,
|
||||
:float,
|
||||
:gvar,
|
||||
:heredoc_beg,
|
||||
:heredoc_content,
|
||||
:heredoc_end,
|
||||
:ident,
|
||||
:ignored_nl,
|
||||
:int,
|
||||
:ivar,
|
||||
:kw,
|
||||
:lbrace,
|
||||
:lbracket,
|
||||
:lparen,
|
||||
:nl,
|
||||
:op,
|
||||
:period,
|
||||
:qwords_beg,
|
||||
:rbrace,
|
||||
:rbracket,
|
||||
:regexp_beg,
|
||||
:regexp_end,
|
||||
:rparen,
|
||||
:semicolon,
|
||||
:sp,
|
||||
:symbeg,
|
||||
:tstring_beg,
|
||||
:tstring_content,
|
||||
:tstring_end,
|
||||
:words_beg,
|
||||
:words_sep
|
||||
]
|
||||
LEXER_EVENTS = SCANNER_EVENTS
|
||||
|
||||
@ -875,10 +801,6 @@ class Ripper
|
||||
token
|
||||
end
|
||||
|
||||
def on__lwsp(token)
|
||||
token
|
||||
end
|
||||
|
||||
def on__nl(token)
|
||||
token
|
||||
end
|
||||
@ -919,6 +841,10 @@ class Ripper
|
||||
token
|
||||
end
|
||||
|
||||
def on__sp(token)
|
||||
token
|
||||
end
|
||||
|
||||
def on__symbeg(token)
|
||||
token
|
||||
end
|
||||
|
@ -1,8 +1,6 @@
|
||||
#
|
||||
# generate-eventids1.rb
|
||||
#
|
||||
# $Id$
|
||||
|
||||
ids = ARGF.map {|s| s.strip }
|
||||
ids = File.readlines(ARGV[0]).map {|s| s.split[0] }
|
||||
|
||||
ids.each do |id|
|
||||
puts "static ID ripper_id_#{id};"
|
||||
|
@ -1,14 +1,13 @@
|
||||
#
|
||||
# generate-ripper_rb.rb
|
||||
# Creates ripper.rb, filling in default event handlers, given a basic
|
||||
# template, the list of parser events (ids1), and a list of lexer
|
||||
# events (ids2).
|
||||
#
|
||||
# $Id$
|
||||
|
||||
def main
|
||||
template, ids1, ids2 = *ARGV
|
||||
File.foreach(template) do |line|
|
||||
case line
|
||||
when /\A\#include ids1/
|
||||
print_items read_ids(ids1)
|
||||
when /\A\#include ids2/
|
||||
print_items read_ids(ids2)
|
||||
when /\A\#include handlers1/
|
||||
File.foreach(ids1) do |line|
|
||||
id, arity = line.split
|
||||
@ -35,9 +34,20 @@ def main
|
||||
end
|
||||
end
|
||||
|
||||
# Generate generic arg list depending on arity (n)
|
||||
# n:: [Integer] arity of method
|
||||
def argdecl( n )
|
||||
def print_items(ids)
|
||||
comma = "\n"
|
||||
ids.each do |id|
|
||||
print comma; comma = ",\n"
|
||||
print " #{id.intern.inspect}"
|
||||
end
|
||||
puts
|
||||
end
|
||||
|
||||
def read_ids(path)
|
||||
File.readlines(path).map {|line| line.split[0] }
|
||||
end
|
||||
|
||||
def argdecl(n)
|
||||
%w(a b c d e f g h i j k l m)[0, n].join(', ')
|
||||
end
|
||||
|
||||
|
4
parse.y
4
parse.y
@ -4226,8 +4226,8 @@ ripper_dispatch_space(parser)
|
||||
long len = parser->token_head - parser->old_lex_p;
|
||||
VALUE str = rb_str_new(parser->old_lex_p, len);
|
||||
|
||||
ripper_dispatch2(parser, ripper_id_scan, ID2SYM(ripper_id_lwsp), rb_str_dup(str));
|
||||
ripper_dispatch1(parser, ripper_id_lwsp, str);
|
||||
ripper_dispatch2(parser, ripper_id_scan, ID2SYM(ripper_id_sp), rb_str_dup(str));
|
||||
ripper_dispatch1(parser, ripper_id_sp, str);
|
||||
parser->current_position += len;
|
||||
parser->current_column += len;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user