ripper 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README ADDED
@@ -0,0 +1,31 @@
1
+ Ripper README
2
+ =============
3
+
4
+ ** This is Ripper compiled for Ruby 1.8.x **
5
+
6
+ Ripper is a Ruby script parser. You can get information
7
+ by event-based style from the parser.
8
+
9
+ !! WARNING !!
10
+
11
+ Ripper is still early-alpha version.
12
+ I never assure any kind of backward compatibility.
13
+
14
+ Usage
15
+ -----
16
+
17
+ See test/ripper/* and sample/ripper/*.
18
+
19
+ License
20
+ -------
21
+
22
+ Ruby License.
23
+
24
+
25
+ Minero Aoki
26
+ aamine@loveruby.net
27
+ http://i.loveruby.net
28
+
29
+ Ported to 1.8.x by
30
+ Loren Segal
31
+ http://gnuu.org
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+
4
+ WINDOWS = (PLATFORM =~ /win32|cygwin/ ? true : false) rescue false
5
+ SUDO = WINDOWS ? '' : 'sudo'
6
+
7
+ desc "Builds the gem"
8
+ task :gem do
9
+ sh "cd ext && make clean"
10
+ load 'ripper.gemspec'
11
+ Gem::Builder.new(SPEC).build
12
+ end
13
+
14
+ desc "Installs the gem"
15
+ task :install => :gem do
16
+ sh "#{SUDO} gem install #{SPEC.name}-#{SPEC.version}.gem --no-rdoc --no-ri"
17
+ end
18
+
19
+ desc 'Build the extension'
20
+ task :build do
21
+ sh "cd ext && ruby extconf.rb && make clean && make"
22
+ end
@@ -0,0 +1,195 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = .
7
+ topdir = /usr/local/lib/ruby/1.8/i686-darwin10.0.0
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ exec_prefix = $(prefix)
11
+ prefix = $(DESTDIR)/usr/local
12
+ sharedstatedir = $(prefix)/com
13
+ mandir = $(datarootdir)/man
14
+ psdir = $(docdir)
15
+ oldincludedir = $(DESTDIR)/usr/include
16
+ localedir = $(datarootdir)/locale
17
+ bindir = $(exec_prefix)/bin
18
+ libexecdir = $(exec_prefix)/libexec
19
+ sitedir = $(libdir)/ruby/site_ruby
20
+ htmldir = $(docdir)
21
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
22
+ includedir = $(prefix)/include
23
+ infodir = $(datarootdir)/info
24
+ vendorlibdir = $(vendordir)/$(ruby_version)
25
+ sysconfdir = $(prefix)/etc
26
+ libdir = $(exec_prefix)/lib
27
+ sbindir = $(exec_prefix)/sbin
28
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
29
+ docdir = $(datarootdir)/doc/$(PACKAGE)
30
+ dvidir = $(docdir)
31
+ vendordir = $(libdir)/ruby/vendor_ruby
32
+ datarootdir = $(prefix)/share
33
+ pdfdir = $(docdir)
34
+ archdir = $(rubylibdir)/$(arch)
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ datadir = $(datarootdir)
37
+ localstatedir = $(prefix)/var
38
+ sitelibdir = $(sitedir)/$(ruby_version)
39
+
40
+ CC = gcc
41
+ LIBRUBY = $(LIBRUBY_A)
42
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
+ LIBRUBYARG_SHARED =
44
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
+
46
+ RUBY_EXTCONF_H =
47
+ CFLAGS = -fno-common -g -O2 -pipe -fno-common $(cflags)
48
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/backports
49
+ DEFS =
50
+ CPPFLAGS = -DRIPPER -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
51
+ CXXFLAGS = $(CFLAGS)
52
+ ldflags = -L.
53
+ dldflags =
54
+ archflag =
55
+ DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
+ LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
57
+ AR = ar
58
+ EXEEXT =
59
+
60
+ RUBY_INSTALL_NAME = ruby18
61
+ RUBY_SO_NAME = ruby18
62
+ arch = i686-darwin10.0.0
63
+ sitearch = i686-darwin10.0.0
64
+ ruby_version = 1.8
65
+ ruby = /usr/local/bin/ruby18
66
+ RUBY = $(ruby)
67
+ RM = rm -f
68
+ MAKEDIRS = mkdir -p
69
+ INSTALL = /usr/bin/install -c
70
+ INSTALL_PROG = $(INSTALL) -m 0755
71
+ INSTALL_DATA = $(INSTALL) -m 644
72
+ COPY = cp
73
+
74
+ #### End of system configuration section. ####
75
+
76
+ preload =
77
+
78
+ libpath = . $(libdir)
79
+ LIBPATH = -L. -L$(libdir)
80
+ DEFFILE =
81
+
82
+ CLEANFILES = mkmf.log ripper.y ripper.c ripper.E ripper.output y.output eventids1.c eventids2table.c
83
+ DISTCLEANFILES =
84
+
85
+ extout =
86
+ extout_prefix =
87
+ target_prefix =
88
+ LOCAL_LIBS =
89
+ LIBS = -ldl -lobjc
90
+ SRCS = ripper.c
91
+ OBJS = ripper.o
92
+ TARGET = ripper
93
+ DLLIB = $(TARGET).bundle
94
+ EXTSTATIC =
95
+ STATIC_LIB =
96
+
97
+ BINDIR = $(bindir)
98
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
+
102
+ TARGET_SO = $(DLLIB)
103
+ CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
104
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
+
106
+ all: $(DLLIB)
107
+ static: $(STATIC_LIB)
108
+
109
+ clean:
110
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
+
112
+ distclean: clean
113
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
+
116
+ realclean: distclean
117
+ install: install-so install-rb
118
+
119
+ install-so: $(RUBYARCHDIR)
120
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
121
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
122
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
123
+ install-rb: pre-install-rb install-rb-default
124
+ install-rb-default: pre-install-rb-default
125
+ pre-install-rb: Makefile
126
+ pre-install-rb-default: Makefile
127
+ $(RUBYARCHDIR):
128
+ $(MAKEDIRS) $@
129
+
130
+ site-install: site-install-so site-install-rb
131
+ site-install-so: install-so
132
+ site-install-rb: install-rb
133
+
134
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
135
+
136
+ .cc.o:
137
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
138
+
139
+ .cxx.o:
140
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
141
+
142
+ .cpp.o:
143
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
144
+
145
+ .C.o:
146
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
147
+
148
+ .c.o:
149
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
150
+
151
+ $(DLLIB): $(OBJS) Makefile
152
+ @-$(RM) $@
153
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
154
+
155
+
156
+
157
+ ###
158
+ .SUFFIXES: .y .c
159
+
160
+ GEN = $(srcdir)/tools/generate.rb
161
+ SRC1 = parse.y
162
+ SRC2 = $(srcdir)/eventids2.c
163
+ BISON = bison
164
+
165
+ .SUFFIXES: .y
166
+
167
+ src: ripper.c eventids1.c eventids2table.c
168
+
169
+ ripper.o: ripper.c lex.c eventids1.c eventids2.c eventids2table.c
170
+
171
+ .y.c:
172
+ $(BISON) -t -v -oy.tab.c $<
173
+ sed -f tools/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@
174
+ @$(RM) y.tab.c
175
+
176
+ all: check
177
+ static: check
178
+
179
+ ripper.y: $(srcdir)/tools/preproc.rb parse.y
180
+ $(RUBY) $(srcdir)/tools/preproc.rb parse.y --output=$@
181
+
182
+ check: $(GEN) $(SRC1) $(SRC2)
183
+ $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
184
+
185
+ eventids1.c: tools/generate.rb $(SRC1)
186
+ $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
187
+
188
+ eventids2table.c: tools/generate.rb $(SRC2)
189
+ $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
190
+
191
+ # Entries for Ripper maintainer
192
+
193
+ preproc: ripper.E
194
+ ripper.E: ripper.c
195
+ $(CC) -E $(CPPFLAGS) ripper.c | $(RUBY) $(srcdir)/tools/strip.rb > $@
@@ -0,0 +1,107 @@
1
+ #ifndef BACKPORTS_H
2
+ #define BACKPORTS_H 1
3
+
4
+ #include <stdarg.h>
5
+ #define TRUE 1
6
+ #define FALSE 0
7
+ #define SIGNED_VALUE long
8
+ #define RSTRING_NOEMBED FL_USER1
9
+ #define rb_isascii(c) 1
10
+ #define rb_isalpha(c) isalpha(c)
11
+ #define rb_islower(c) islower(c)
12
+ #define rb_isupper(c) isupper(c)
13
+ #define rb_ispunct(c) ispunct(c)
14
+ #define rb_isalnum(c) isalnum(c)
15
+ #define rb_isprint(c) isprint(c)
16
+ #define rb_isspace(c) isspace(c)
17
+ #define rb_isdigit(c) isdigit(c)
18
+ #define FL_USER8 (((VALUE)1)<<(FL_USHIFT+8))
19
+ #define DBL2NUM(dbl) rb_float_new(dbl)
20
+ #define RB_TYPE_P(obj, type) ( \
21
+ ((type) == T_FIXNUM) ? FIXNUM_P(obj) : \
22
+ ((type) == T_TRUE) ? ((obj) == Qtrue) : \
23
+ ((type) == T_FALSE) ? ((obj) == Qfalse) : \
24
+ ((type) == T_NIL) ? ((obj) == Qnil) : \
25
+ ((type) == T_UNDEF) ? ((obj) == Qundef) : \
26
+ ((type) == T_SYMBOL) ? SYMBOL_P(obj) : \
27
+ (!SPECIAL_CONST_P(obj) && BUILTIN_TYPE(obj) == (type)))
28
+
29
+ #define rb_intern3(s,l,e) rb_intern(s)
30
+ #define rb_intern2(s, l) rb_intern(s)
31
+ #define rb_intern_const(str) rb_intern(str)
32
+ #define local_cnt(x) 3
33
+
34
+ #define STRCASECMP(s1, s2) (strcasecmp(s1, s2))
35
+ #define STRNCASECMP(s1, s2, n) (strncasecmp(s1, s2, n))
36
+
37
+ unsigned long ruby_strtoul(const char *str, char **endptr, int base);
38
+ #define STRTOUL(str, endptr, base) (ruby_strtoul(str, endptr, base))
39
+
40
+ #define TypedData_Get_Struct(a,b,c,d) Data_Get_Struct(a,b,d)
41
+ #define TypedData_Wrap_Struct(klass, type, p) \
42
+ Data_Wrap_Struct(klass, (type)->dmark, (type)->dfree, p)
43
+
44
+ typedef struct rb_data_type_struct {
45
+ const char *wrap_struct_name;
46
+ void (*dmark)(void*);
47
+ void (*dfree)(void*);
48
+ size_t (*dsize)(const void *);
49
+ void *reserved[3]; /* For future extension.
50
+ This array *must* be filled with ZERO. */
51
+ void *data; /* This area can be used for any purpose
52
+ by a programmer who define the type. */
53
+ } rb_data_type_t;
54
+
55
+ #define CONST_ID_CACHE(result, str) \
56
+ { \
57
+ static ID rb_intern_id_cache; \
58
+ if (!rb_intern_id_cache) \
59
+ rb_intern_id_cache = rb_intern2(str, (long)strlen(str)); \
60
+ result rb_intern_id_cache; \
61
+ }
62
+ #define CONST_ID(var, str) \
63
+ do CONST_ID_CACHE(var =, str) while (0)
64
+
65
+ VALUE
66
+ rb_vsprintf(const char *fmt, va_list ap)
67
+ {
68
+ char buffer[1024];
69
+ int len = vsnprintf(buffer, 1023, fmt, ap);
70
+ return rb_str_new(buffer, len);
71
+ }
72
+
73
+ #define ruby_scan_oct(s, l, r) ruby_scan_oct2(s, l, r)
74
+ #define ruby_scan_hex(s, l, r) ruby_scan_hex2(s, l, r)
75
+
76
+ unsigned long
77
+ ruby_scan_oct2(const char *start, size_t len, size_t *retlen)
78
+ {
79
+ register const char *s = start;
80
+ register unsigned long retval = 0;
81
+
82
+ while (len-- && *s >= '0' && *s <= '7') {
83
+ retval <<= 3;
84
+ retval |= *s++ - '0';
85
+ }
86
+ *retlen = (int)(s - start); /* less than len */
87
+ return retval;
88
+ }
89
+
90
+ unsigned long
91
+ ruby_scan_hex2(const char *start, size_t len, size_t *retlen)
92
+ {
93
+ static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
94
+ register const char *s = start;
95
+ register unsigned long retval = 0;
96
+ const char *tmp;
97
+
98
+ while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
99
+ retval <<= 4;
100
+ retval |= (tmp - hexdigit) & 15;
101
+ s++;
102
+ }
103
+ *retlen = (int)(s - start); /* less than len */
104
+ return retval;
105
+ }
106
+
107
+ #endif
@@ -0,0 +1 @@
1
+ #include "backports.h" /* hack to include backports */
@@ -0,0 +1,68 @@
1
+ /**********************************************************************
2
+
3
+ encoding.h -
4
+
5
+ $Author: matz $
6
+ created at: Thu May 24 11:49:41 JST 2007
7
+
8
+ Copyright (C) 2007 Yukihiro Matsumoto
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_ENCODING_H
13
+ #define RUBY_ENCODING_H 1
14
+
15
+ #include <stdarg.h>
16
+
17
+ typedef struct rb_encoding_s {
18
+ int ruby_encoding_index;
19
+ int min_enc_len;
20
+ char *name;
21
+ } rb_encoding;
22
+
23
+ static rb_encoding __default_encoding_s = {1, 1, "default"};
24
+ static rb_encoding *__default_encoding = &__default_encoding_s;
25
+ int rb_char_to_option_kcode(int c, int *option, int *kcode) { return 0; }
26
+
27
+ #define ENC_CODERANGE_7BIT 0
28
+ #define ENC_CODERANGE_UNKNOWN -1
29
+ #define rb_enc_str_coderange(s) ENC_CODERANGE_7BIT
30
+ #define MBCLEN_CHARFOUND_P(x) 1
31
+ #define rb_enc_str_new(s,l,e) rb_str_new(s,l)
32
+ #define rb_enc_reg_new(s,l,e,i) rb_reg_new(s,l,i)
33
+ #define rb_external_str_new_with_enc(s,l,e) rb_str_new(s,l)
34
+ #define rb_enc_from_index(idx) __default_encoding
35
+ #define rb_enc_find(name) __default_encoding
36
+ #define rb_enc_name(enc) (enc)->name
37
+ #define rb_enc_mbminlen(enc) (enc)->min_enc_len
38
+ #define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
39
+ #define rb_enc_mbclen(p,e,enc) 1
40
+ #define rb_enc_fast_mbclen(p,e,enc) 1
41
+ #define rb_enc_isascii(c,enc) isascii(c)
42
+ #define rb_enc_isalpha(c,enc) isalpha(c)
43
+ #define rb_enc_islower(c,enc) islower(c)
44
+ #define rb_enc_isupper(c,enc) isupper(c)
45
+ #define rb_enc_ispunct(c,enc) ispunct(c)
46
+ #define rb_enc_isalnum(c,enc) isalnum(c)
47
+ #define rb_enc_isprint(c,enc) isprint(c)
48
+ #define rb_enc_isspace(c,enc) isspace(c)
49
+ #define rb_enc_isdigit(c,enc) isdigit(c)
50
+ #define rb_enc_toupper(c,e) toupper(c)
51
+ #define rb_enc_tolower(c,e) tolower(c)
52
+ #define rb_enc_str_asciicompat_p(str) 1
53
+ #define rb_enc_from_encoding(e) Qnil
54
+ #define rb_enc_precise_mbclen(s,l,e) 1
55
+ #define rb_enc_unicode_p(e) 0
56
+ #define rb_ascii8bit_encoding() __default_encoding
57
+ #define rb_utf8_encoding() __default_encoding
58
+ #define rb_usascii_encoding() __default_encoding
59
+ #define rb_locale_encoding() __default_encoding
60
+ #define rb_filesystem_encoding() __default_encoding
61
+ #define rb_default_external_encoding() __default_encoding
62
+ #define rb_default_internal_encoding() __default_encoding
63
+ #define rb_enc_associate(s,e) 0
64
+ #define rb_usascii_str_new2(s) rb_str_new2(s)
65
+ #define rb_enc_get(n) 0
66
+ #define rb_enc_asciicompat(e) 1
67
+
68
+ #endif /* RUBY_ENCODING_H */
@@ -0,0 +1,36 @@
1
+ GEN = $(srcdir)/tools/generate.rb
2
+ SRC1 = parse.y
3
+ SRC2 = $(srcdir)/eventids2.c
4
+ BISON = bison
5
+
6
+ .SUFFIXES: .y
7
+
8
+ src: ripper.c eventids1.c eventids2table.c
9
+
10
+ ripper.o: ripper.c lex.c eventids1.c eventids2.c eventids2table.c
11
+
12
+ .y.c:
13
+ $(BISON) -t -v -oy.tab.c $<
14
+ sed -f tools/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@
15
+ @$(RM) y.tab.c
16
+
17
+ all: check
18
+ static: check
19
+
20
+ ripper.y: $(srcdir)/tools/preproc.rb parse.y
21
+ $(RUBY) $(srcdir)/tools/preproc.rb parse.y --output=$@
22
+
23
+ check: $(GEN) $(SRC1) $(SRC2)
24
+ $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
25
+
26
+ eventids1.c: tools/generate.rb $(SRC1)
27
+ $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
28
+
29
+ eventids2table.c: tools/generate.rb $(SRC2)
30
+ $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
31
+
32
+ # Entries for Ripper maintainer
33
+
34
+ preproc: ripper.E
35
+ ripper.E: ripper.c
36
+ $(CC) -E $(CPPFLAGS) ripper.c | $(RUBY) $(srcdir)/tools/strip.rb > $@