summaryrefslogtreecommitdiff
path: root/ext/ripper/tools
AgeCommit message (Collapse)Author
12 daysripper: Move DSL line patternNobuyoshi Nakada
12 daysUse user defined parameterizing rulesydah
2024-03-17Remove no longer needed matchingNobuyoshi Nakada
2024-03-17Revert "Remove flip-flop usages from build scripts"Nobuyoshi Nakada
This reverts commit 301fa452f7a9cdea922103e9c50d85a2d5652d0d.
2024-03-14Ensure test suite is compatible with --frozen-string-literalJean Boussier
As preparation for https://bugs.ruby-lang.org/issues/20205 making sure the test suite is compatible with frozen string literals is making things easier.
2024-02-20[Feature #20257] Rearchitect Ripperyui-knk
Introduce another semantic value stack for Ripper so that Ripper can manage both Node and Ruby Object separately. This rearchitectutre of Ripper solves these issues. Therefore adding test cases for them. * [Bug 10436] https://bugs.ruby-lang.org/issues/10436 * [Bug 18988] https://bugs.ruby-lang.org/issues/18988 * [Bug 20055] https://bugs.ruby-lang.org/issues/20055 Checked the differences of `Ripper.sexp` for files under `/test/ruby` are only on test_pattern_matching.rb. The differences comes from the differences between `new_hash_pattern_tail` functions between parser and Ripper. Ripper `new_hash_pattern_tail` didn’t call `assignable` then `kw_rest_arg` wasn’t marked as local variable. This is also fixed by this commit. ``` --- a/./tmp/before/test_pattern_matching.rb +++ b/./tmp/after/test_pattern_matching.rb @@ -3607,7 +3607,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “a”, [984, 13]]]], [[:binary, - [:vcall, [:@ident, “a”, [985, 10]]], + [:var_ref, [:@ident, “a”, [985, 10]]], :==, [:hash, nil]]], nil]]], @@ -3662,7 +3662,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “a”, [993, 13]]]], [[:binary, - [:vcall, [:@ident, “a”, [994, 10]]], + [:var_ref, [:@ident, “a”, [994, 10]]], :==, [:hash, [:assoclist_from_args, @@ -3813,7 +3813,7 @@ [:command, [:@ident, “raise”, [1022, 10]], [:args_add_block, - [[:vcall, [:@ident, “b”, [1022, 16]]]], + [[:var_ref, [:@ident, “b”, [1022, 16]]]], false]]], [:else, [[:var_ref, [:@kw, “true”, [1024, 10]]]]]]]], nil, @@ -3876,7 +3876,7 @@ [:@int, “0”, [1033, 15]]], :“&&“, [:binary, - [:vcall, [:@ident, “b”, [1033, 20]]], + [:var_ref, [:@ident, “b”, [1033, 20]]], :==, [:hash, nil]]]], nil]]], @@ -3946,7 +3946,7 @@ [:@int, “0”, [1042, 15]]], :“&&“, [:binary, - [:vcall, [:@ident, “b”, [1042, 20]]], + [:var_ref, [:@ident, “b”, [1042, 20]]], :==, [:hash, [:assoclist_from_args, @@ -5206,7 +5206,7 @@ [[:assoc_new, [:@label, “c:“, [1352, 22]], [:@int, “0”, [1352, 25]]]]]], - [:vcall, [:@ident, “r”, [1352, 29]]]], + [:var_ref, [:@ident, “r”, [1352, 29]]]], false]]], [:binary, [:call, @@ -5299,7 +5299,7 @@ [:assoc_new, [:@label, “c:“, [1367, 34]], [:@int, “0”, [1367, 37]]]]]], - [:vcall, [:@ident, “r”, [1367, 41]]]], + [:var_ref, [:@ident, “r”, [1367, 41]]]], false]]], [:binary, [:call, @@ -5931,7 +5931,7 @@ [:in, [:hshptn, nil, [], [:var_field, [:@ident, “r”, [1533, 11]]]], [[:binary, - [:vcall, [:@ident, “r”, [1534, 8]]], + [:var_ref, [:@ident, “r”, [1534, 8]]], :==, [:hash, [:assoclist_from_args, ```
2024-01-30[DOC] Fix Ripper DSL input exampleyui-knk
'!' suffix is needed for event dispatch.
2023-12-28Verify that events2table.c was generated successfullyNobuyoshi Nakada
2023-10-10ripper: Support member references in the DSLNobuyoshi Nakada
2023-10-01Use rb_node_opt_arg_t and rb_node_kw_arg_t instead of NODEyui-knk
2023-09-25ripper: Support named references in the DSLNobuyoshi Nakada
2023-09-17ripper: Preprocess ripper-dispatchable types onlyNobuyoshi Nakada
Keep the other types, which not having setter macros for ripper.
2023-06-12[Feature #19719] Universal Parseryui-knk
Introduce Universal Parser mode for the parser. This commit includes these changes: * Introduce `UNIVERSAL_PARSER` macro. All of CRuby related functions are passed via `struct rb_parser_config_struct` when this macro is enabled. * Add CI task with 'cppflags=-DUNIVERSAL_PARSER' for ubuntu. Notes: Merged: https://github.com/ruby/ruby/pull/7927
2023-05-14Preprocess input parse.y from stdinNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7807
2022-11-08Set default %printer for NODE ntermsyui-knk
Before: ``` Reducing stack by rule 639 (line 5062): $1 = token "integer literal" (1.0-1.1: 1) -> $$ = nterm simple_numeric (1.0-1.1: ) ``` After: ``` Reducing stack by rule 641 (line 5078): $1 = token "integer literal" (1.0-1.1: 1) -> $$ = nterm simple_numeric (1.0-1.1: NODE_LIT) ``` `"<*>"` is supported by Bison 2.3b (2008-05-27) or later. https://git.savannah.gnu.org/cgit/bison.git/commit/?id=12e3584054c16ab255672c07af0ffc7bb220e8bc Therefore developers need to install Bison 2.3b+ to build ruby from source codes if their Bison is older. Minimum version requirement for Bison is changed to 3.0. See: https://bugs.ruby-lang.org/issues/19068 [Feature #19068] Notes: Merged: https://github.com/ruby/ruby/pull/6579
2020-05-29Allow references to $$ in Ripper DSLNobuyoshi Nakada
2020-01-20Get rid of use of special variablesJeremy Evans
Use `"\n"` and `IO#fileno` instead of `$/` and `$.` respectively. [Feature #14240]
2019-11-26Allow `$10` and more in the Ripper DSLNobuyoshi Nakada
2019-11-09Remove unneeded exec bits from some filesDavid Rodríguez
I noticed that some files in rubygems were executable, and I could think of no reason why they should be. In general, I think ruby files should never have the executable bit set unless they include a shebang, so I run the following command over the whole repo: ```bash find . -name '*.rb' -type f -executable -exec bash -c 'grep -L "^#!" $1 || chmod -x $1' _ {} \; ``` Notes: Merged: https://github.com/ruby/ruby/pull/2662
2019-11-07Suppress unused variable warningNobuyoshi Nakada
2019-10-19Extend Ripper DSL to set to pseudo variables other than `$$`Nobuyoshi Nakada
2019-04-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-15Remove flip-flop usages from build scriptsmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20ext/ripper/tools/dsl.rb: Use String#sub instead of delete_suffixmame
It fails when baseruby is old. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20parse.y: Remove double meaning of new_qcall/new_command_qcallmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20ext/ripper/tools/dsl.rb: Serialize dispatch callsmame
To avoid the unspecified behavior (the evaluation order of arguments). In `$$ = foo(bar(), baz());`, it is unspecified which `bar` or `baz` is called earlier. This commit changes the code to `v1=bar(); v2=baz(); $$ = foo();`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20parse.y: Remove unneeded var_field_1 trickmame
I thought this trick was needed because the result of var_field was passed to different arguments, as follows: ``` $1 = var_field(p, $1); $$ = backref_assign_error(p, $1, $1, &@$); ``` Currently the DSL supports that one result is passed to one argument. However, after the refactoring, I found that `backref_assign_error` uses only one `$1`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20dsl.rb: pnobu
* ext/ripper/tools/dsl.rb (DSL#initialize): define `p` for `struct parser_params *p`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20dsl.rb: ID constantsnobu
* ext/ripper/tools/dsl.rb (DSL#method_missing): expand ID constnats without parentheses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20dsl.rb: const_missingnobu
* ext/ripper/tools/dsl.rb (DSL.const_missing): define to expand Qnil and Qundef as-is. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-20dsl.rb: indentnobu
* ext/ripper/tools/dsl.rb (DSL#generate): indent after surrounding by braces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19parse.y: Remove double meaning of backref_assign_errormame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19parse.y: Remove unneeded type decls for Rippermame
I think that they are not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19parse.y: swap `foo!` and `foo` in Ripper DSLmame
`foo!(...)` means Ripper event, and `foo(...)` means C function/macro call. This is for fail-safe; if I forget `!` accidentally, it would fail to compile, instead of wrongly adding a new Ripper event. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19parse.y: Allows Ripper DSL to embed C function calls as `foo!`mame
Instead of `_foo`. This makes it useful to do word boundary search of the editor. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19ext/ripper/tools/preproc.rb: Remove `/*%c%` handlingmame
It was replaced with `/*% ripper[brace]: ... %*/` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19ext/ripper: Introduce a simple DSL for ripper.y code generationmame
Currently, parse.y actions are hard to read and write because the code has double meaning (for core parser and for ripper). I think that, if it is easy to write ripper's code shortly and simply, the double meaning trick is not needed. For the sake, this change adds a simple DSL for ripper's code. For example, in parse.y, we can write: /*% ripper: stmts_add(stmts_new, void_stmt) %*/ instead of: $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14ripper: add states of scannernobu
* parse.y (ripper_state): add states of scanner to tokens from Ripper.lex and Ripper::Filter#on_*. based on the patch by aycabta (Code Ahss) at [ruby-core:81789]. [Feature #13686] * ext/ripper/tools/preproc.rb (prelude, usercode): generate EXPR_* constants from enums. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-05{ext,test}/ripper: Specify frozen_string_literal: true.kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-25ripper: fix ripper.Enobu
* ext/ripper/depend (ripper.E): add missing $(INCFLAGS). * ext/ripper/tools/strip.rb: insert an empty line for blank or line directive lines. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16handle ext/ as r53141naruse
g -L frozen_string_literal ext/**/*.rb|xargs ruby -Ka -e'ARGV.each{|fn|puts fn;open(fn,"r+"){|f|s=f.read.sub(/\A(#!.*\n)?(#.*coding.*\n)?/,"\\&# frozen_string_literal: false\n");f.rewind;f.write s}}' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-28eventids2.c: reduce sizenobu
* ext/ripper/eventids2.c (token_assoc): reduce size. unsigned short can hold 65535 at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27ripper/tools/generate.rb: shorten generated sourcenobu
* ext/ripper/tools/generate.rb (generate_eventids1): shorten generated source. * ext/ripper/tools/generate.rb (generate_eventids2): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-25suppress warnings.naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-18* ext/ripper/eventids2.c (ripper_init_eventids2): separatenobu
initializations of IDs and objects. * ext/ripper/tools/generate.rb (generate_eventids1): ditto. * parse.y (Init_ripper, InitVM_ripper): fix inversed roles. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31* ext/ripper/eventids2.c (ripper_init_eventids2): use rb_intern_const.nobu
* ext/ripper/tools/generate.rb (generate_eventids1): ditto. * ext/ripper/tools/generate.rb (generate_eventids2_table): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-20* ext/ripper/tools/preproc.rb (prelude): do not append surplusnobu
newlines to fix line numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-23* ext/ripper: no longer generates .rb files.aamine
* parse.y (Init_ripper): ripper_init_eventids*() takes 1 argument, self (class Ripper). * ext/ripper/depend: target removed: `lib/ripper/core.rb'. * ext/ripper/depend: new target `eventids2table.c'. * ext/ripper/depend: new target `check'. * ext/ripper/eventids2.c: include eventids2table.c. * ext/ripper/eventids2.c: initialize SCANNER_EVENT_TABLE. * ext/ripper/extconf.rb: update $cleanfiles list. * ext/ripper/tools/generate.rb: no longer generate ripper/core.rb. * ext/ripper/tools/generate.rb: new mode `check'. * ext/ripper/tools/generate.rb: new mode `eventids2table'. * ext/ripper/lib/ripper/core.rb.in: removed. * ext/ripper/lib/ripper/core.rb: added. * ext/ripper/lib/ripper/filter.rb: update copyright year. * ext/ripper/lib/ripper/lexer.rb: ditto. * ext/ripper/lib/ripper/sexp.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-23* ext/ripper/tools/generate.rb, ext/ripper/tools/preproc.rb: StringIOnobu
is not available for miniruby. fixed: [ruby-dev:27307] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-22* test/ripper/depend: use --output option instead of redirect; nmake does ↵aamine
not remove a target when the target file is created by redirect. [ruby-dev:26466] * test/ripper/tools/preproc.rb: new option --output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e