kanayago 0.2.0 → 0.4.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +261 -0
  3. data/README.md +1 -1
  4. data/Rakefile +5 -48
  5. data/ext/kanayago/extconf.rb +8 -0
  6. data/ext/kanayago/kanayago.c +30 -185
  7. data/ext/kanayago/scope_node.c +2 -16
  8. data/ext/kanayago/variable_node.c +2 -1
  9. data/lib/kanayago/call_node.rb +19 -0
  10. data/lib/kanayago/constant_node.rb +15 -0
  11. data/lib/kanayago/literal_node.rb +4 -0
  12. data/lib/kanayago/scope_node.rb +14 -0
  13. data/lib/kanayago/statement_node.rb +16 -0
  14. data/lib/kanayago/variable_node.rb +4 -0
  15. data/lib/kanayago/version.rb +1 -1
  16. data/lib/kanayago.rb +3 -16
  17. data/script/setup_parser.rb +136 -0
  18. metadata +6 -64
  19. data/ext/kanayago/ccan/check_type/check_type.h +0 -63
  20. data/ext/kanayago/ccan/container_of/container_of.h +0 -142
  21. data/ext/kanayago/ccan/list/list.h +0 -791
  22. data/ext/kanayago/ccan/str/str.h +0 -17
  23. data/ext/kanayago/constant.h +0 -53
  24. data/ext/kanayago/id.h +0 -354
  25. data/ext/kanayago/id_table.h +0 -54
  26. data/ext/kanayago/include/ruby/st.h +0 -199
  27. data/ext/kanayago/internal/array.h +0 -154
  28. data/ext/kanayago/internal/basic_operators.h +0 -65
  29. data/ext/kanayago/internal/bignum.h +0 -245
  30. data/ext/kanayago/internal/bits.h +0 -650
  31. data/ext/kanayago/internal/compile.h +0 -34
  32. data/ext/kanayago/internal/compilers.h +0 -107
  33. data/ext/kanayago/internal/complex.h +0 -29
  34. data/ext/kanayago/internal/encoding.h +0 -39
  35. data/ext/kanayago/internal/error.h +0 -251
  36. data/ext/kanayago/internal/fixnum.h +0 -185
  37. data/ext/kanayago/internal/gc.h +0 -358
  38. data/ext/kanayago/internal/hash.h +0 -194
  39. data/ext/kanayago/internal/imemo.h +0 -322
  40. data/ext/kanayago/internal/io.h +0 -163
  41. data/ext/kanayago/internal/namespace.h +0 -81
  42. data/ext/kanayago/internal/numeric.h +0 -275
  43. data/ext/kanayago/internal/parse.h +0 -131
  44. data/ext/kanayago/internal/rational.h +0 -71
  45. data/ext/kanayago/internal/re.h +0 -33
  46. data/ext/kanayago/internal/ruby_parser.h +0 -125
  47. data/ext/kanayago/internal/sanitizers.h +0 -346
  48. data/ext/kanayago/internal/serial.h +0 -23
  49. data/ext/kanayago/internal/set_table.h +0 -70
  50. data/ext/kanayago/internal/static_assert.h +0 -16
  51. data/ext/kanayago/internal/string.h +0 -203
  52. data/ext/kanayago/internal/symbol.h +0 -46
  53. data/ext/kanayago/internal/thread.h +0 -112
  54. data/ext/kanayago/internal/variable.h +0 -74
  55. data/ext/kanayago/internal/vm.h +0 -136
  56. data/ext/kanayago/internal/warnings.h +0 -16
  57. data/ext/kanayago/internal.h +0 -105
  58. data/ext/kanayago/lex.c +0 -302
  59. data/ext/kanayago/method.h +0 -271
  60. data/ext/kanayago/node.c +0 -446
  61. data/ext/kanayago/node.h +0 -122
  62. data/ext/kanayago/node_name.inc +0 -224
  63. data/ext/kanayago/parse.c +0 -27377
  64. data/ext/kanayago/parse.h +0 -244
  65. data/ext/kanayago/parser_bits.h +0 -564
  66. data/ext/kanayago/parser_node.h +0 -32
  67. data/ext/kanayago/parser_st.c +0 -165
  68. data/ext/kanayago/parser_st.h +0 -162
  69. data/ext/kanayago/parser_value.h +0 -106
  70. data/ext/kanayago/probes.h +0 -4
  71. data/ext/kanayago/ruby_assert.h +0 -14
  72. data/ext/kanayago/ruby_atomic.h +0 -66
  73. data/ext/kanayago/ruby_parser.c +0 -1137
  74. data/ext/kanayago/rubyparser.h +0 -1394
  75. data/ext/kanayago/shape.h +0 -444
  76. data/ext/kanayago/st.c +0 -3223
  77. data/ext/kanayago/symbol.h +0 -116
  78. data/ext/kanayago/thread_pthread.h +0 -175
  79. data/ext/kanayago/universal_parser.c +0 -211
  80. data/ext/kanayago/vm_core.h +0 -2349
  81. data/ext/kanayago/vm_opts.h +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b8dcde5a49288a284edf3323cc0279740a923e0ea85d895571dcfa1be774970
4
- data.tar.gz: 5c7bf5ef11155f14e6b8f2049bd344228c10089cb430b4d4c453a7b02e94bdb5
3
+ metadata.gz: 5c6e26071a97395c4f35c029908d78bba8a927f75129aa361367dc9cf549c3ca
4
+ data.tar.gz: be48eae66a3bc69256ff3a9dba5afa842b8b8876f7be66eb72d79774fb94d878
5
5
  SHA512:
6
- metadata.gz: ce3d04f88db918e619f94195b2ca33cae122466b502a56df3e399acfadc7e4ed193ff045b0d12e326ff2fbeb4435587ce75507a02c7a1185c4f3a0290f7d3935
7
- data.tar.gz: 0a3981c9eae87d6fd12ff320a3f3d8759c78830b2936569c604e7c1c82ca614f2ba07c2d1e97b2c765c81ed4eb0b7e63424af75e8342320c8bc0134fb69aa3b5
6
+ metadata.gz: 5073effb4706b23b912a61f79a3bb40d2565e59f4d9805c6ba6f3006c613d8029340d2e164e67f94eb0341cc7b14d340ca5a9f862ee8c4fb84a2b8a86f1622b9
7
+ data.tar.gz: 5731b6e8463b384cbd3dfe7bd3bf67835ea0a4a8f51ac0ee84259f8fd04d414fd5b2e1ea38e79f6f3dfab83787207c86757dfa5bce0180bfbf6fbac1102665ef
data/CHANGELOG.md ADDED
@@ -0,0 +1,261 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.4.0]
11
+
12
+ ### Added
13
+ - Add Ruby class definitions for previously C-only AST nodes:
14
+ - `ScopeNode` - Scope representation with args and body
15
+ - `ClassNode` - Class definition with cpath, super, and body
16
+ - `ModuleNode` - Module definition with cpath, super, and body
17
+ - `DefinitionNode` - Method definition with mid and defn
18
+ - `BeginNode` - Begin statement with body
19
+ - `SelfNode` - Self reference with state
20
+ - `ConstantNode` - Constant reference with vid
21
+ - `OperatorCallNode` - Operator method call with recv, mid, and args
22
+ - `CallNode` - Method call with recv, mid, and args
23
+ - `FunctionCallNode` - Function call with mid and args
24
+ - `VariableCallNode` - Variable call with mid
25
+ - `ArgumentsNode` - Arguments information with ainfo hash
26
+ - `BlockNode` - Block representation (inherits from Array)
27
+ - `ConstantDeclarationNode` - Constant declaration with vid, else, and value
28
+ - `Colon2Node` - Scoped constant resolution (::) with mid and head
29
+ - `Colon3Node` - Top-level constant resolution (::) with mid
30
+
31
+ ### Changed
32
+ - Use `rb_intern("@...")` instead of `symbol()` macro for instance variable access in C layer
33
+ - Remove redundant getter methods from C layer (scope_node.c and kanayago.c)
34
+ - Rely on Ruby's `attr_reader` for attribute access instead of C-defined methods
35
+
36
+ ### Fixed
37
+ - Fix SEGV in args_ainfo_tohash function
38
+
39
+ ## [0.3.0] - 2025-10-25
40
+
41
+ ### Fixed
42
+ - Fix gem install kanayago
43
+
44
+ ## [0.2.0] - 2025-10-25
45
+
46
+ ### Added
47
+ - Add sample for Kanayago usecase
48
+ - Support NODE_FOR_MASGN, NODE_MASGN, NODE_DASGN, NODE_ONCE, NODE_ERRINFO, NODE_POSTEXE, and NODE_ERROR
49
+ - Support NODE_ARGS_AUX, NODE_OPT_ARG, NODE_KW_ARG, NODE_POSTARG, NODE_ARGSCAT, and NODE_ARGSPUSH
50
+ - Support NODE_SPLAT and NODE_BLOCK_PASS
51
+ - Support NODE_YIELD and NODE_LAMBDA
52
+ - Support NODE_OP_ASGN1, NODE_OP_ASGN2, NODE_OP_ASGN_AND, NODE_OP_ASGN_OR and NODE_OP_CDECL
53
+ - Support NODE_NTH_REF and NODE_BACK_REF
54
+ - Support NODE_DVAR
55
+ - Support NODE_DSYM
56
+ - Support NODE_BREAK and NODE_NEXT
57
+ - Support NODE_REDO
58
+ - Support NODE_DEFINED
59
+ - Support NODE_ITER, NODE_RETRY, NODE_RESCUE, NODE_RESBODY and NODE_ENSURE
60
+ - Support NODE_HASH, NODE_IN, NODE_ARYPTN, NODE_HSHPTN and NODE_FNDPTN
61
+ - Support NODE_MATCH, NODE_MATCH2 and NODE_MATCH3
62
+ - Support NODE_REGX and NODE_DREGX
63
+ - Support NODE_XSTR and NODE_DXSTR
64
+ - Support NODE_FLIP2 and NODE_FLIP3
65
+ - Support NODE_DOT2 and NODE_DOT3
66
+ - Support NODE_CASE, NODE_CASE2, NODE_CASE3 and NODE_WHEN
67
+ - Support NODE_QCALL, NODE_SUPER and NODE_ZSUPER
68
+ - Support NODE_DEFS, NODE_SCLASS and NODE_ATTRASGN
69
+ - Support NODE_COLON3
70
+ - Support NODE_VCALL
71
+ - Support NODE_CVASGN
72
+ - Support NODE_IASGN
73
+ - Support NODE_DSTR and NODE_EVSTR
74
+ - Support NODE_GASGN
75
+ - Support NODE_RETURN
76
+ - Support NODE_UNDEF
77
+ - Support NODE_VALIAS
78
+ - Support NODE_ALIAS
79
+ - Support NODE_FOR
80
+ - Support NODE_UNTIL
81
+ - Add NODE_WHILE test
82
+ - Support NODE_WHILE
83
+ - Support NODE_CVAR
84
+ - Introduce debug.gem
85
+ - Support NODE_MODULE
86
+ - Support NODE_SELF
87
+ - Support NODE_GVAR
88
+ - Support NODE_AND
89
+ - Support NODE_OR
90
+ - Support NODE_FALSE
91
+ - Support NODE_TRUE
92
+ - Support NODE_NIL
93
+ - Support NODE_ENCODING
94
+ - Add typeprof.conf.json
95
+ - Support NODE_ZLIST
96
+ - Introduce TypeProf for development
97
+ - Support __LINE__ literal node
98
+ - Support __FILE__ literal node
99
+ - Support Ruby 3.4
100
+ - Introduce Kanayago gem build and install CI
101
+
102
+ ### Changed
103
+ - Update RuboCop
104
+ - Split kanayago.patch file to more easier maintain multi Ruby Parser
105
+ - Update bin/setup
106
+ - Use Node class attr_reader to access Node values
107
+ - Split Literal Node code
108
+ - Split Kanayago::ScopeNode code
109
+ - Update README.md
110
+ - Update test CI
111
+ - Update kanayago.patch
112
+ - Improve import Ruby Parser file's
113
+ - Update RuboCop setting
114
+ - Migrate to Kanayago parsed AST hash to Instance
115
+ - Update kanayago.patch for Ruby head build
116
+ - Update CI flow
117
+ - Update Kanayago build flow
118
+ - Update Ruby Parser's file
119
+ - Update lrama
120
+ - Split file for Variable Node's
121
+ - Move Statement Node class definition
122
+ - Rename LeftAssignNode to LocalAssignmentNode
123
+
124
+ ### Fixed
125
+ - Fix RuboCop Lint error
126
+ - Fix NODE_IF attributes access
127
+ - Fix Kanayago::ListNode holds data
128
+ - Fix NODE_FOR loop
129
+ - Fix Ruby head build failure
130
+ - Add internal/namespace.h for Ruby head Parser dependency
131
+ - Fix RuboCop SEGV in Ruby head
132
+ - Apply auto correct
133
+ - Update json
134
+ - Update zlib
135
+ - Fix CI failures
136
+ - Add ext/kanayago/probes.h
137
+ - Fix Ruby 3.4 dependency
138
+ - Fix Ruby 3.4 build
139
+ - Fix file copy error handling
140
+ - Fix build gem
141
+ - Add dependency for Universal Parser
142
+ - Fix code lint
143
+
144
+ ### Removed
145
+ - Remove unneeded comment
146
+ - Remove Lrama that unneeded any more
147
+
148
+ ### CI
149
+ - Add fail-fast: false
150
+ - Suppress already initialized constant warning
151
+
152
+ ## [0.1.1] - 2024-09-06
153
+
154
+ ### Changed
155
+ - Bump up v0.1.1
156
+
157
+ ## [0.1.0] - 2024-09-06
158
+
159
+ ### Added
160
+ - Support NODE_UNLESS
161
+ - Add class description
162
+ - Add rubocop check in CI
163
+ - Add rubocop-on-rbs
164
+ - Add rubocop-rake
165
+ - Add rubocop and rubocop-minitest for development
166
+ - Add refine_tree_parse module function
167
+ - Support NODE_IVAR
168
+ - Add Referenced implementations link
169
+ - Support NODE_SYM
170
+ - Support method definition
171
+ - Add NODE_CONST test
172
+ - Support NODE_CDECL
173
+ - Support NODE_CONST
174
+ - Support NODE_IF
175
+ - Support NODE_LVAR
176
+ - Add gdb rake task
177
+ - Support NODE_FCALL
178
+ - Introduce literal_node_to_hash function for get literal node value
179
+ - Support NODE_LASGN
180
+ - Add NODE_STR parse test
181
+ - Add NODE_IMAGINARY parse test
182
+ - Add NODE_RATIONAL parse test
183
+ - Add NODE_FLOAT parse test
184
+ - Add parse NODE_INTEGER test
185
+ - Add GitHub Actions for test
186
+ - Add Ruby's Parser files
187
+ - Add run task for running test.rb
188
+ - Add test for NODE_INTEGER
189
+ - Support NODE_CALL
190
+ - Support NODE_STR
191
+ - Support NODE_IMAGINARY
192
+ - Support NODE_BLOCK
193
+ - Support NODE_RATIONAL
194
+ - Support NODE_FLOAT
195
+ - Support NODE_OPCALL and NODE_LIST
196
+ - Parse Ruby code and return Hash
197
+ - Build Mjollnir with Ruby Parser
198
+ - Build ruby-parser for Mjollnir
199
+ - Add ruby_parser:build task
200
+ - Add lex.c generation for ruby_parser:import task
201
+ - Add ruby_parser:clean task
202
+ - Add Mjollnir.parse method
203
+ - Import ruby parser
204
+ - Add lrama
205
+ - Add 金屋子 for README.md
206
+
207
+ ### Changed
208
+ - Rename parse to kanayago_parse
209
+ - Using test-queue
210
+ - Auto correct to Gemfile
211
+ - Auto correct Hash
212
+ - Fix required_ruby_version to > 3.3.0
213
+ - Rename to Kanayago
214
+ - Ignore refine_tree.gemspec in Metrics/BlockLength
215
+ - Format Rakefile
216
+ - Rename sig/refine_tree.rb to sig/refine_tree.rbs
217
+ - require rubocop-minitest and rubocop-rake
218
+ - Generate .rubocop.yml and .rubocop_todo.yml
219
+ - Move minitest to test group in Gemfile
220
+ - Change to key type from String to Symbol
221
+ - Fix require path for test
222
+ - Fix install gem name
223
+ - Rename to RefineTree
224
+ - Fix GitHub Actions
225
+ - Add PATH for GitHub Actions
226
+ - Add install check for GitHub Actions
227
+ - Add depend task for rake build and rake install
228
+ - Fix Mjollnir.parse sample in README.md
229
+ - Fix username in README.md
230
+ - Merge Ruby's Parser struct and enum definition for Mjollnir
231
+ - Fix Mjollnir gem summary and description
232
+ - Fix gem's description
233
+ - Fix README.md
234
+ - Fix Mjollnir gem build and install
235
+ - Apply RuboCop auto correct to Gemfile
236
+ - Apply RuboCop auto correct for test helper
237
+ - Apply RuboCop auto correct
238
+ - Fix Mjollnir build
239
+ - Update TODO's
240
+
241
+ ### Fixed
242
+ - Fix SEGV
243
+ - Fix NODE_BLOCK support
244
+ - Remove allowed_push_host
245
+ - Remove parse.c and parse.h
246
+ - Ignore parse.c and parse.h
247
+ - Fix gem name in GitHub Action
248
+
249
+ ### Removed
250
+ - Remove uneeded file
251
+ - Remove unnecessary include header
252
+ - Remove unnecessary code in Rakefile
253
+ - Remove ext/mjollnir/ruby-parser directory
254
+ - Remove uneeded headers
255
+ - Remove gem build for CI
256
+
257
+ ### Internal
258
+ - Suppress warning
259
+ - Add newline
260
+ - Some refactor for mjollnir.c
261
+ - Using rb_ruby_ast_data_get function
data/README.md CHANGED
@@ -31,7 +31,7 @@ Finally, build `Kanayago` gem and install it.
31
31
 
32
32
  ```console
33
33
  bundle exec rake build
34
- gem install pkg/kanayago-0.2.0.gem
34
+ gem install pkg/kanayago-0.4.0.gem
35
35
  ```
36
36
 
37
37
  ## Usage
data/Rakefile CHANGED
@@ -14,52 +14,9 @@ else
14
14
  end
15
15
 
16
16
  namespace :ruby_parser do
17
- desc 'import ruby parser files'
18
- task :import do
19
- tar_name = if RUBY_DESCRIPTION.include?('dev')
20
- 'snapshot/snapshot-master.tar.gz'
21
- else
22
- "#{RUBY_VERSION[0..2]}/ruby-#{RUBY_VERSION}.tar.gz"
23
- end
24
-
25
- `mkdir -p tmp/ruby`
26
- `curl -L https://cache.ruby-lang.org/pub/ruby/#{tar_name} -o tmp/ruby.tar.gz`
27
- `tar -zxvf tmp/ruby.tar.gz -C tmp/ruby --strip-components 1`
28
-
29
- dist = File.expand_path('ext/kanayago', __dir__)
30
- ruby_dir = File.expand_path('tmp/ruby', __dir__)
31
-
32
- MAKE_DIRECTORIES.each do |dir|
33
- Dir.mkdir File.join(dist, dir) unless Dir.exist? dir
34
- end
35
-
36
- RUBY_PARSER_COPY_TARGETS.each do |target|
37
- FileUtils.cp File.join(ruby_dir, target), File.join(dist, target)
38
- end
39
-
40
- # "probes.h"
41
- probes_h_path = File.join(dist, 'probes.h')
42
- File.open(probes_h_path, 'w+') do |f|
43
- f << <<~SRC
44
- #define RUBY_DTRACE_PARSE_BEGIN_ENABLED() (0)
45
- #define RUBY_DTRACE_PARSE_BEGIN(arg0, arg1) (void)(arg0), (void)(arg1);
46
- #define RUBY_DTRACE_PARSE_END_ENABLED() (0)
47
- #define RUBY_DTRACE_PARSE_END(arg0, arg1) (void)(arg0), (void)(arg1);
48
- SRC
49
- end
50
-
51
- `rm -rf tmp/ruby tmp/ruby.tar.gz`
52
- end
53
-
54
- desc 'patched ro ruby parse that build for Kanayago'
55
- task :patch do
56
- running_ruby_version = if RUBY_DESCRIPTION.include?('dev')
57
- 'head'
58
- else
59
- RUBY_VERSION[..2]
60
- end
61
-
62
- sh "patch -p1 < patch/#{running_ruby_version}/kanayago.patch"
17
+ desc 'import ruby parser files and apply patch'
18
+ task :setup do
19
+ sh 'ruby script/setup_parser.rb'
63
20
  end
64
21
 
65
22
  desc 'clean to ruby parser file'
@@ -82,8 +39,8 @@ namespace :ruby_parser do
82
39
  end
83
40
  end
84
41
 
85
- task build: ['ruby_parser:import', 'ruby_parser:patch', 'compile']
86
- task install: ['ruby_parser:import', 'ruby_parser:patch', 'compile']
42
+ task :build # rubocop:disable Rake/Desc
43
+ task install: ['ruby_parser:clean', 'ruby_parser:setup', 'compile']
87
44
 
88
45
  GEMSPEC = Gem::Specification.load('kanayago.gemspec')
89
46
 
@@ -2,6 +2,14 @@
2
2
 
3
3
  require 'mkmf'
4
4
 
5
+ # Run setup script to prepare Ruby parser files before building
6
+ setup_script = File.expand_path('../../script/setup_parser.rb', __dir__)
7
+ puts 'Running parser setup script...'
8
+ unless system("ruby #{setup_script}")
9
+ warn 'Failed to setup parser files. Please check the error messages above.'
10
+ exit 1
11
+ end
12
+
5
13
  $objs = %w[
6
14
  node
7
15
  parse