Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport ruby core to 1.4 stable branch #107

Merged
merged 24 commits into from May 15, 2019
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cc7fe95
Switch to Ruby license from LGPL2.
hsbt May 8, 2019
751b269
Removed the files that are GPL license.
hsbt May 8, 2019
c179feb
* ext/racc/cparse/cparse.c: suppressed warnings for shortening on
nobu Mar 11, 2010
fa7b198
* ext/**/*.[ch]: removed trailing spaces.
nobu Apr 22, 2010
037e58b
* lib/racc/parser.rb (do_parse, yyparse): using class eval to define
tenderlove Nov 15, 2010
fcc43ec
use RB_TYPE_P() instead of comparison of TYPE()
nobu May 23, 2012
37f6763
* lib/racc/parser.rb: Hide copyright notice from Racc doc
zzak Feb 5, 2013
bcc535a
fix typos. Patch by k_takata.
k-tsj May 19, 2013
58893b1
* lib/racc: Merge Racc documentation downstream, add grammar ref file
zzak Feb 5, 2013
9c7d926
* lib/racc/rdoc/grammar.en.rdoc: [DOC] fix typo by Tsuyoshi Sawada
zzak Nov 9, 2013
b292be8
ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
nobu Nov 29, 2013
3282c72
ext: use PRIsVALUE for rb_raise and rb_warn
nobu Jan 13, 2014
fa90485
* lib/racc/rdoc/grammar.en.rdoc: [DOC] Correct grammar and typos
zzak Jan 24, 2014
71f873a
racc/cparse: private class
nobu Sep 29, 2014
245ed8e
cparse.c: typed data
nobu Dec 3, 2014
964a2e2
Fix typo in racc english documentation [ci skip]
nobu Sep 14, 2015
333544f
* lib/racc/rdoc/grammar.en.rdoc: fix spell error.
hsbt Oct 14, 2015
082a55c
Grammatical fixes [ci skip]
nobu Oct 26, 2015
dfa6b8f
Add frozen_string_literal: false for all files
nurse Dec 16, 2015
0b64add
Update dependencies
nobu Jul 6, 2016
749e35f
Fix grammar errors
amatsuda Nov 8, 2016
665fb29
Fixed misspelling words.
hsbt Oct 22, 2017
1626c1a
lib/*: Prefer require_relative over require.
marcandre Nov 2, 2018
5048d42
lib/racc/parser.rb: use require for racc/cparse
stomar Nov 3, 2018
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

537 COPYING

Large diffs are not rendered by default.

@@ -56,7 +56,6 @@ sample/yyerr.y
setup.rb
tasks/doc.rb
tasks/email.rb
test/assets/bibtex.y
test/assets/cadenza.y
test/assets/cast.y
test/assets/chk.y
@@ -93,8 +92,6 @@ test/assets/opal.y
test/assets/opt.y
test/assets/percent.y
test/assets/php_serialization.y
test/assets/rdblockparser.y
test/assets/rdinlineparser.y
test/assets/recv.y
test/assets/riml.y
test/assets/rrconf.y
@@ -113,7 +110,6 @@ test/assets/yyerr.y
test/bench.y
test/helper.rb
test/infini.y
test/regress/bibtex
test/regress/cadenza
test/regress/cast
test/regress/csspool
@@ -129,8 +125,6 @@ test/regress/nasl
test/regress/nokogiri-css
test/regress/opal
test/regress/php_serialization
test/regress/rdblockparser
test/regress/rdinlineparser
test/regress/riml
test/regress/ruby18
test/regress/ruby22
@@ -76,10 +76,9 @@
== ライセンス

このパッケージに付属するファイルの著作権は青木峰郎が保持します。

This comment has been minimized.

Copy link
@shyouhei

shyouhei May 14, 2019

Member

You must get @aamine's approval before merging this. As you can see he has the copyright. You must not bend human rights of someone else.

This comment has been minimized.

Copy link
@hsbt

hsbt May 14, 2019

Author Member

I already to get approval from aamine. #105 (comment)

Is it not enough?

This comment has been minimized.

Copy link
@shyouhei

shyouhei May 14, 2019

Member

Yes, definitely. I was not aware of that comment.

ライセンスは GNU Lesser General Public License (LGPL) version 2
です。ただしユーザが書いた規則ファイルや、Racc がそこから生成し
た Ruby スクリプトはその対象外です。好きなライセンスで配布して
ください。
ライセンスは Ruby ライセンスです。ただしユーザが書いた規則
ファイルや、Racc がそこから生成した Ruby スクリプトはその対象
外です。好きなライセンスで配布してください。


== バグなど
@@ -68,10 +68,10 @@

== License

Racc is distributed under the terms of the GNU Lesser General
Public License version 2. Note that you do NOT need to follow
LGPL for your own parser (racc outputs). You can provide those
files under any licenses you want.
Racc is distributed under the same terms of ruby.
(see the file COPYING). Note that you do NOT need to follow
ruby license for your own parser (racc outputs).
You can distribute those files under any licenses you want.


== Bug Reports
@@ -5,10 +5,8 @@
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of LGPL, see the file "COPYING".
#
# You can distribute/modify this program under the same terms of ruby.
# see the file "COPYING".

require 'racc/static'
require 'optparse'
@@ -1,9 +1,9 @@
/*
cparse.c -- Racc Runtime Core
Copyright (c) 1999-2006 Minero Aoki
This library is free software.
You can distribute/modify this program under the same terms of ruby.
@@ -13,6 +13,13 @@

#include <ruby.h>

#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif

/* -----------------------------------------------------------------------
Important Constants
----------------------------------------------------------------------- */
@@ -189,14 +196,15 @@ static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
VALUE arg, VALUE sysdebug));

static void call_lexer _((struct cparse_params *v));
static VALUE lexer_i _((VALUE block_args, VALUE data, VALUE self));
static VALUE lexer_i _((RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data)));

static VALUE assert_array _((VALUE a));
static long assert_integer _((VALUE n));
static VALUE assert_hash _((VALUE h));
static VALUE initialize_params _((VALUE vparams, VALUE parser, VALUE arg,
VALUE lexer, VALUE lexmid));
static void cparse_params_mark _((void *ptr));
static size_t cparse_params_memsize _((const void *ptr));

static void parse_main _((struct cparse_params *v,
VALUE tok, VALUE val, int resume));
@@ -214,35 +222,52 @@ static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
# define D_printf(fmt,arg)
#endif

#undef RUBY_UNTYPED_DATA_WARNING
#define RUBY_UNTYPED_DATA_WARNING 1

static const rb_data_type_t cparse_params_type = {
"racc/cparse",
{
cparse_params_mark,
RUBY_TYPED_DEFAULT_FREE,
cparse_params_memsize,
},
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
0, 0,
RUBY_TYPED_FREE_IMMEDIATELY,
#endif
};

static VALUE
racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug)
{
volatile VALUE vparams;
VALUE vparams;
struct cparse_params *v;

vparams = Data_Make_Struct(CparseParams, struct cparse_params,
cparse_params_mark, -1, v);
vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
&cparse_params_type, v);
D_puts("starting cparse");
v->sys_debug = RTEST(sysdebug);
vparams = initialize_params(vparams, parser, arg, Qnil, Qnil);
v->lex_is_iterator = Qfalse;
v->lex_is_iterator = FALSE;
parse_main(v, Qnil, Qnil, 0);

RB_GC_GUARD(vparams);
return v->retval;
}

static VALUE
racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
{
volatile VALUE vparams;
VALUE vparams;
struct cparse_params *v;

vparams = Data_Make_Struct(CparseParams, struct cparse_params,
cparse_params_mark, -1, v);
vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
&cparse_params_type, v);
v->sys_debug = RTEST(sysdebug);
D_puts("start C yyparse");
vparams = initialize_params(vparams, parser, arg, lexer, lexmid);
v->lex_is_iterator = Qtrue;
v->lex_is_iterator = TRUE;
D_puts("params initialized");
parse_main(v, Qnil, Qnil, 0);
call_lexer(v);
@@ -251,6 +276,7 @@ racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
rb_id2name(v->lexmid));
}

RB_GC_GUARD(vparams);
return v->retval;
}

@@ -264,9 +290,8 @@ call_lexer(struct cparse_params *v)
static VALUE
lexer_iter(VALUE data)
{
struct cparse_params *v;
struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);

Data_Get_Struct(data, struct cparse_params, v);
rb_funcall(v->lexer, v->lexmid, 0);
return Qnil;
}
@@ -279,18 +304,17 @@ call_lexer(struct cparse_params *v)
#endif

static VALUE
lexer_i(VALUE block_args, VALUE data, VALUE self)
lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
{
struct cparse_params *v;
struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
VALUE tok, val;

Data_Get_Struct(data, struct cparse_params, v);
if (v->fin)
rb_raise(rb_eArgError, "extra token after EndOfToken");
extract_user_token(v, block_args, &tok, &val);
parse_main(v, tok, val, 1);
if (v->fin && v->fin != CP_FIN_ACCEPT)
rb_iter_break();
rb_iter_break();
return Qnil;
}

@@ -317,9 +341,8 @@ assert_integer(VALUE n)
static VALUE
initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
{
struct cparse_params *v;
struct cparse_params *v = rb_check_typeddata(vparams, &cparse_params_type);

Data_Get_Struct(vparams, struct cparse_params, v);
v->value_v = vparams;
v->parser = parser;
v->lexer = lexer;
@@ -348,7 +371,7 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
v->use_result_var = RTEST(rb_ary_entry(arg, 13));
}
else {
v->use_result_var = Qtrue;
v->use_result_var = TRUE;
}

v->tstack = v->debug ? NEW_STACK() : Qnil;
@@ -364,7 +387,7 @@ initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lex
v->retval = Qnil;
v->fin = 0;

v->lex_is_iterator = Qfalse;
v->lex_is_iterator = FALSE;

rb_iv_set(parser, "@vstack", v->vstack);
if (v->debug) {
@@ -402,6 +425,12 @@ cparse_params_mark(void *ptr)
rb_gc_mark(v->retval);
}

static size_t
cparse_params_memsize(const void *ptr)
{
return sizeof(struct cparse_params);
}

static void
extract_user_token(struct cparse_params *v, VALUE block_args,
VALUE *tok, VALUE *val)
@@ -413,12 +442,12 @@ extract_user_token(struct cparse_params *v, VALUE block_args,
return;
}

if (TYPE(block_args) != T_ARRAY) {
if (!RB_TYPE_P(block_args, T_ARRAY)) {
rb_raise(rb_eTypeError,
"%s() %s %s (must be Array[2])",
"%s() %s %"PRIsVALUE" (must be Array[2])",
v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
v->lex_is_iterator ? "yielded" : "returned",
rb_class2name(CLASS_OF(block_args)));
rb_obj_class(block_args));
}
if (RARRAY_LEN(block_args) != 2) {
rb_raise(rb_eArgError,
@@ -457,7 +486,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)

if (resume)
goto resume;

while (1) {
D_puts("");
D_puts("---- enter new loop ----");
@@ -516,7 +545,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
act_fixed:
D_printf("act=%ld\n", act);
goto handle_act;

notfound:
D_puts("(act) not found: use default");
act_value = AREF(v->action_default, v->curstate);
@@ -617,7 +646,7 @@ parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)

D_puts("(err) found: can handle error token");
break;

error_pop:
D_puts("(err) act not found: can't handle error token; pop");

@@ -681,15 +710,14 @@ reduce(struct cparse_params *v, long act)
static VALUE
reduce0(VALUE val, VALUE data, VALUE self)
{
struct cparse_params *v;
struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
VALUE reduce_to, reduce_len, method_id;
long len;
ID mid;
VALUE tmp, tmp_t = Qundef, tmp_v = Qundef;
long i, k1, k2;
VALUE goto_state;

Data_Get_Struct(data, struct cparse_params, v);
reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
@@ -791,6 +819,8 @@ reduce0(VALUE val, VALUE data, VALUE self)
void
Init_cparse(void)
{
#undef rb_intern
#define rb_intern(str) rb_intern_const(str)
VALUE Racc, Parser;
ID id_racc = rb_intern("Racc");

@@ -810,6 +840,9 @@ Init_cparse(void)
rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));

CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
rb_undef_alloc_func(CparseParams);
rb_undef_method(CparseParams, "initialize");
rb_undef_method(CparseParams, "initialize_copy");

RaccBug = rb_eRuntimeError;

@@ -1 +1,12 @@
cparse.o: cparse.c $(hdrdir)/ruby/ruby.h $(topdir)/config.h $(hdrdir)/ruby/defines.h
# AUTOGENERATED DEPENDENCIES START
cparse.o: $(RUBY_EXTCONF_H)
cparse.o: $(arch_hdrdir)/ruby/config.h
cparse.o: $(hdrdir)/ruby/backward.h
cparse.o: $(hdrdir)/ruby/defines.h
cparse.o: $(hdrdir)/ruby/intern.h
cparse.o: $(hdrdir)/ruby/missing.h
cparse.o: $(hdrdir)/ruby/ruby.h
cparse.o: $(hdrdir)/ruby/st.h
cparse.o: $(hdrdir)/ruby/subst.h
cparse.o: cparse.c
# AUTOGENERATED DEPENDENCIES END
@@ -4,10 +4,8 @@
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
# You can distribute/modify this program under the same terms of ruby.
# see the file "COPYING".

module Racc
class Error < StandardError; end
@@ -4,10 +4,8 @@
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
# You can distribute/modify this program under the same terms of ruby.
# see the file "COPYING".

require 'racc/compat'
require 'racc/iset'
@@ -4,10 +4,8 @@
# Copyright (c) 1999-2006 Minero Aoki
#
# This program is free software.
# You can distribute/modify this program under the terms of
# the GNU LGPL, Lesser General Public License version 2.1.
# For details of the GNU LGPL, see the file "COPYING".
#
# You can distribute/modify this program under the same terms of ruby.
# see the file "COPYING".

module Racc
VERSION = '1.4.15'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.