@appthreat/atom 2.0.25 → 2.1.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.
- package/package.json +5 -4
- package/plugins/bin/atom +1 -1
- package/plugins/bin/atom.bat +1 -1
- package/plugins/bin/bundler +14 -0
- package/plugins/bin/ruby_ast_gen +14 -0
- package/plugins/composer/InstalledVersions.php +7 -4
- package/plugins/composer/installed.php +6 -6
- package/plugins/lib/{com.github.javaparser.javaparser-core-3.26.2.jar → com.github.javaparser.javaparser-core-3.26.3.jar} +0 -0
- package/plugins/lib/{com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar → com.github.javaparser.javaparser-symbol-solver-core-3.26.3.jar} +0 -0
- package/plugins/lib/{com.google.guava.guava-33.3.0-jre.jar → com.google.guava.guava-33.3.1-jre.jar} +0 -0
- package/plugins/lib/{commons-io.commons-io-2.17.0.jar → commons-io.commons-io-2.18.0.jar} +0 -0
- package/plugins/lib/io.appthreat.atom-2.1.0-classpath.jar +0 -0
- package/plugins/lib/io.appthreat.atom-2.1.0.jar +0 -0
- package/plugins/lib/io.appthreat.c2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.dataflowengineoss_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.javasrc2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.jimple2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.jssrc2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/{io.appthreat.php2atom_3-2.2.3.jar → io.appthreat.php2atom_3-2.3.0.jar} +0 -0
- package/plugins/lib/io.appthreat.pysrc2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.ruby2atom_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.semanticcpg_3-2.3.0.jar +0 -0
- package/plugins/lib/io.appthreat.x2cpg_3-2.3.0.jar +0 -0
- package/plugins/lib/net.java.dev.jna.jna-5.15.0.jar +0 -0
- package/plugins/lib/net.java.dev.jna.jna-platform-5.15.0.jar +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.core.contenttype-3.9.600.jar +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.core.filesystem-1.11.0.jar → org.eclipse.platform.org.eclipse.core.filesystem-1.11.100.jar} +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.core.jobs-3.15.300.jar → org.eclipse.platform.org.eclipse.core.jobs-3.15.400.jar} +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.core.resources-3.21.0.jar → org.eclipse.platform.org.eclipse.core.resources-3.22.0.jar} +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.core.runtime-3.31.100.jar → org.eclipse.platform.org.eclipse.core.runtime-3.32.0.jar} +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.equinox.app-1.7.200.jar +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.equinox.common-3.19.100.jar → org.eclipse.platform.org.eclipse.equinox.common-3.19.200.jar} +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.equinox.preferences-3.11.200.jar +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.equinox.registry-3.12.100.jar → org.eclipse.platform.org.eclipse.equinox.registry-3.12.200.jar} +0 -0
- package/plugins/lib/{org.eclipse.platform.org.eclipse.osgi-3.21.0.jar → org.eclipse.platform.org.eclipse.osgi-3.22.0.jar} +0 -0
- package/plugins/lib/{org.scala-lang.modules.scala-asm-9.7.0-scala-2.jar → org.scala-lang.modules.scala-asm-9.7.1-scala-1.jar} +0 -0
- package/plugins/lib/org.scala-lang.modules.scala-parallel-collections_3-1.1.0.jar +0 -0
- package/plugins/lib/{org.scala-lang.scala-library-2.13.14.jar → org.scala-lang.scala-library-2.13.15.jar} +0 -0
- package/plugins/lib/org.scala-lang.scala3-library_3-3.6.2.jar +0 -0
- package/plugins/rubyastgen/.bundle/config +5 -0
- package/plugins/rubyastgen/Gemfile +11 -0
- package/plugins/rubyastgen/Gemfile.lock +31 -0
- package/plugins/rubyastgen/bundle/bundler/setup.rb +42 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/racc +29 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-parse +29 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-rewrite +29 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby_ast_gen +29 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/.rspec +3 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/Gemfile +13 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/LICENSE.txt +213 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/README.md +46 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/Rakefile +8 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/bin/console +11 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/bin/setup +6 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/exe/ruby_ast_gen +59 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/lib/ruby_ast_gen/node_handling.rb +236 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/lib/ruby_ast_gen/version.rb +5 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/lib/ruby_ast_gen.rb +139 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/ruby_ast_gen.gemspec +25 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/sig/ruby_ast_gen.rbs +3 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/spec/ruby_ast_gen_spec.rb +93 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/spec/spec_helper.rb +15 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-1c6e88faec50/update_version.rb +36 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem.build_complete +0 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem_make.out +18 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/racc/cparse.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/LICENSE.MIT +20 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/README.YARD.md +12 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/lib/ast/node.rb +268 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/lib/ast/processor/mixin.rb +288 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/lib/ast/processor.rb +12 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/lib/ast/sexp.rb +30 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.2/lib/ast.rb +17 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/BSDL +22 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/COPYING +56 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Gemfile +10 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/README.md +69 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Rakefile +18 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/console +14 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/setup +8 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/lib/ostruct.rb +489 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/ostruct.gemspec +24 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/LICENSE.txt +26 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/bin/ruby-parse +7 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/bin/ruby-rewrite +7 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/gauntlet_parser.rb +123 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/all.rb +17 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ast/node.rb +40 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ast/processor.rb +293 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/base.rb +291 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/builders/default.rb +2338 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/clobbering_error.rb +13 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/color.rb +32 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/context.rb +49 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/current.rb +137 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/current_arg_stack.rb +46 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/deprecation.rb +13 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/diagnostic/engine.rb +104 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/diagnostic.rb +163 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer/dedenter.rb +88 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer/explanation.rb +55 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer/literal.rb +284 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer/stack_state.rb +49 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer-F0.rb +12922 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer-F1.rb +14875 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/lexer-strings.rb +5424 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/macruby.rb +9634 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/max_numparam_stack.rb +56 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/messages.rb +125 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/meta.rb +40 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/rewriter.rb +105 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby18.rb +9272 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby19.rb +9558 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby20.rb +10229 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby21.rb +10203 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby22.rb +10302 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby23.rb +10322 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby24.rb +10454 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby25.rb +10374 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby26.rb +10352 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby27.rb +11947 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby28.rb +8047 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby30.rb +12243 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby31.rb +12716 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby32.rb +12704 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby33.rb +12589 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/ruby34.rb +12589 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/rubymotion.rb +9515 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/runner/ruby_parse.rb +157 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/runner/ruby_rewrite.rb +101 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/runner.rb +294 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/buffer.rb +369 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/comment/associator.rb +233 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/comment.rb +134 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/collection.rb +18 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/condition.rb +21 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/constant.rb +32 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/definition.rb +23 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/for.rb +19 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/heredoc.rb +19 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/index.rb +33 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/keyword.rb +20 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/method_definition.rb +25 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/objc_kwarg.rb +19 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/operator.rb +17 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/rescue_body.rb +21 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/send.rb +36 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/ternary.rb +18 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map/variable.rb +31 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/map.rb +186 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/range.rb +326 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/rewriter/action.rb +44 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/rewriter.rb +513 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/tree_rewriter/action.rb +243 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/source/tree_rewriter.rb +431 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/static_environment.rb +134 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/syntax_error.rb +21 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/tree_rewriter.rb +133 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/unknown_encoding_in_magic_comment_error.rb +15 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/variables_stack.rb +36 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser/version.rb +5 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/lib/parser.rb +91 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.6.0/parser.gemspec +43 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/BSDL +22 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/COPYING +56 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ChangeLog +846 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +58 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +60 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/TODO +5 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/bin/racc +320 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar.en.rdoc +218 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar2.en.rdoc +219 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/command.ja.html +99 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/debug.ja.rdoc +36 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/grammar.ja.rdoc +348 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/index.ja.html +10 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/parser.ja.rdoc +125 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/usage.ja.html +414 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/Makefile +273 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/cparse.c +840 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/extconf.rb +8 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/compat.rb +33 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/cparse.so +0 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/debugflags.rb +60 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/exception.rb +16 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammar.rb +1191 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammarfileparser.rb +667 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/info.rb +18 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/iset.rb +92 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/logfilegenerator.rb +212 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser-text.rb +644 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser.rb +630 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parserfilegenerator.rb +473 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/sourcetext.rb +35 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/state.rb +976 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/statetransitiontable.rb +311 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/static.rb +5 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc.rb +6 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ast-2.4.2.gemspec +30 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ostruct-0.6.1.gemspec +21 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/parser-3.3.6.0.gemspec +37 -0
- package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +28 -0
- package/plugins/rubyastgen/setup.sh +6 -0
- package/rbastgen.js +37 -0
- package/utils.mjs +11 -1
- package/plugins/lib/io.appthreat.atom-2.0.25-classpath.jar +0 -0
- package/plugins/lib/io.appthreat.atom-2.0.25.jar +0 -0
- package/plugins/lib/io.appthreat.c2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.dataflowengineoss_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.javasrc2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.jimple2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.jssrc2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.pysrc2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.semanticcpg_3-2.2.3.jar +0 -0
- package/plugins/lib/io.appthreat.x2cpg_3-2.2.3.jar +0 -0
- package/plugins/lib/net.java.dev.jna.jna-5.14.0.jar +0 -0
- package/plugins/lib/net.java.dev.jna.jna-platform-5.14.0.jar +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.core.contenttype-3.9.400.jar +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.equinox.app-1.7.100.jar +0 -0
- package/plugins/lib/org.eclipse.platform.org.eclipse.equinox.preferences-3.11.100.jar +0 -0
- package/plugins/lib/org.scala-lang.modules.scala-parallel-collections_3-1.0.4.jar +0 -0
- package/plugins/lib/org.scala-lang.scala3-library_3-3.5.2.jar +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
require 'parser/current'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'thread'
|
|
5
|
+
|
|
6
|
+
require_relative 'ruby_ast_gen/version'
|
|
7
|
+
require_relative 'ruby_ast_gen/node_handling'
|
|
8
|
+
|
|
9
|
+
module RubyAstGen
|
|
10
|
+
|
|
11
|
+
module Logger
|
|
12
|
+
|
|
13
|
+
def self.debug(message)
|
|
14
|
+
puts "[DEBUG] #{message}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.info(message)
|
|
18
|
+
puts "[INFO] #{message}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.warn(message)
|
|
22
|
+
puts "[WARN] #{message}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.error(message)
|
|
26
|
+
puts "[ERR] #{message}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Main method to parse the input and generate the AST output
|
|
31
|
+
def self.parse(opts)
|
|
32
|
+
if opts[:debug]
|
|
33
|
+
RubyAstGen::Logger::debug "CLI Arguments received: #{opts}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
input_path = opts[:input]
|
|
37
|
+
output_dir = opts[:output]
|
|
38
|
+
exclude_regex = Regexp.new(opts[:exclude])
|
|
39
|
+
|
|
40
|
+
if opts[:debug]
|
|
41
|
+
RubyAstGen::Logger::debug "Exclude Regex Received: #{exclude_regex}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
FileUtils.mkdir_p(output_dir)
|
|
45
|
+
|
|
46
|
+
if File.file?(input_path)
|
|
47
|
+
process_file(input_path, output_dir, exclude_regex, input_path)
|
|
48
|
+
elsif File.directory?(input_path)
|
|
49
|
+
process_directory(input_path, output_dir, exclude_regex)
|
|
50
|
+
else
|
|
51
|
+
RubyAstGen::Logger::error "#{input_path} is neither a file nor a directory."
|
|
52
|
+
exit 1
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
# Process a single file and generate its AST
|
|
59
|
+
def self.process_file(file_path, output_dir, exclude_regex, base_dir)
|
|
60
|
+
# Get the relative path of the file to apply exclusion rules
|
|
61
|
+
relative_path = file_path.sub(%r{^.*\/}, '')
|
|
62
|
+
relative_input_path = file_path.sub("#{base_dir}/", '')
|
|
63
|
+
# Skip if the file matches the exclusion regex
|
|
64
|
+
if exclude_regex && exclude_regex.match?(relative_input_path)
|
|
65
|
+
RubyAstGen::Logger::info "Excluding: #{relative_input_path}"
|
|
66
|
+
return
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
return unless ruby_file?(file_path) # Skip if it's not a Ruby-related file
|
|
70
|
+
|
|
71
|
+
begin
|
|
72
|
+
ast = parse_file(file_path, relative_input_path)
|
|
73
|
+
return unless ast
|
|
74
|
+
|
|
75
|
+
output_path = File.join(output_dir, "#{relative_path}.json")
|
|
76
|
+
|
|
77
|
+
File.write(output_path, JSON.pretty_generate(ast))
|
|
78
|
+
RubyAstGen::Logger::info "Processed: #{relative_input_path} -> #{output_path}"
|
|
79
|
+
rescue StandardError => e
|
|
80
|
+
RubyAstGen::Logger::error "'#{relative_input_path}' - #{e.message}"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def self.process_directory(dir_path, output_dir, exclude_regex, max_threads = 10)
|
|
85
|
+
threads = []
|
|
86
|
+
queue = Queue.new
|
|
87
|
+
|
|
88
|
+
Dir.glob("#{dir_path}/**/*").each do |path|
|
|
89
|
+
next unless File.file?(path) && ruby_file?(path)
|
|
90
|
+
relative_dir = path.sub("#{dir_path}/", '')
|
|
91
|
+
next if exclude_regex.match?(relative_dir)
|
|
92
|
+
|
|
93
|
+
queue << path
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
max_threads.times do
|
|
97
|
+
threads << Thread.new do
|
|
98
|
+
until queue.empty?
|
|
99
|
+
begin
|
|
100
|
+
path = queue.pop(true) rescue nil # Non-blocking pop
|
|
101
|
+
next unless path
|
|
102
|
+
|
|
103
|
+
relative_path = path.sub(dir_path, '')
|
|
104
|
+
output_subdir = File.join(output_dir, File.dirname(relative_path))
|
|
105
|
+
FileUtils.mkdir_p(output_subdir)
|
|
106
|
+
|
|
107
|
+
process_file(path, output_subdir, exclude_regex, dir_path)
|
|
108
|
+
rescue => e
|
|
109
|
+
RubyAstGen::Logger::error "Error processing #{path}: #{e.message}"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
threads.each(&:join)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.parse_file(file_path, relative_input_path)
|
|
119
|
+
code = File.read(file_path)
|
|
120
|
+
buffer = Parser::Source::Buffer.new(file_path)
|
|
121
|
+
buffer.source = code
|
|
122
|
+
parser = Parser::CurrentRuby.new
|
|
123
|
+
ast = parser.parse(buffer)
|
|
124
|
+
return unless ast
|
|
125
|
+
json_ast = NodeHandling::ast_to_json(ast, code, file_path: relative_input_path)
|
|
126
|
+
json_ast[:file_path] = file_path
|
|
127
|
+
json_ast[:rel_file_path] = relative_input_path
|
|
128
|
+
json_ast
|
|
129
|
+
rescue Parser::SyntaxError => e
|
|
130
|
+
RubyAstGen::Logger::error "Failed to parse #{file_path}: #{e.message}"
|
|
131
|
+
nil
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def self.ruby_file?(file_path)
|
|
135
|
+
ext = File.extname(file_path)
|
|
136
|
+
['.rb', '.gemspec', 'Rakefile'].include?(ext) || file_path.end_with?('.rb')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
# stub: ruby_ast_gen 0.34.0 ruby lib
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "ruby_ast_gen".freeze
|
|
6
|
+
s.version = "0.34.0".freeze
|
|
7
|
+
|
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
|
+
s.metadata = { "homepage_uri" => "https://github.com/whirlylabs/ruby_ast_gen" } if s.respond_to? :metadata=
|
|
10
|
+
s.require_paths = ["lib".freeze]
|
|
11
|
+
s.authors = ["David Baker Effendi".freeze, "Andrei Dreyer".freeze]
|
|
12
|
+
s.bindir = "exe".freeze
|
|
13
|
+
s.date = "2025-01-10"
|
|
14
|
+
s.description = "A Ruby parser than dumps the AST as JSON output for Joern's `rubysrc2cpg` frontend".freeze
|
|
15
|
+
s.email = ["dave@whirlylabs.com".freeze, "andrei@whirlylabs.com".freeze]
|
|
16
|
+
s.executables = ["ruby_ast_gen".freeze]
|
|
17
|
+
s.files = ["Gemfile".freeze, "exe/ruby_ast_gen".freeze, "lib/ruby_ast_gen".freeze, "lib/ruby_ast_gen.rb".freeze, "lib/ruby_ast_gen/node_handling.rb".freeze, "lib/ruby_ast_gen/version.rb".freeze, "ruby_ast_gen.gemspec".freeze, "sig/ruby_ast_gen.rbs".freeze]
|
|
18
|
+
s.homepage = "https://github.com/whirlylabs/ruby_ast_gen".freeze
|
|
19
|
+
s.licenses = ["MIT".freeze]
|
|
20
|
+
s.required_ruby_version = Gem::Requirement.new(">= 3.0.7".freeze)
|
|
21
|
+
s.rubygems_version = "3.6.2".freeze
|
|
22
|
+
s.summary = "A Ruby parser than dumps the AST as JSON output".freeze
|
|
23
|
+
|
|
24
|
+
s.installed_by_version = "3.6.2".freeze
|
|
25
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
|
|
5
|
+
RSpec.describe RubyAstGen do
|
|
6
|
+
temp_name = ""
|
|
7
|
+
let(:temp_file) {
|
|
8
|
+
file = Tempfile.new('test_ruby_code')
|
|
9
|
+
temp_name = File.basename(file.path)
|
|
10
|
+
file
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
after(:each) do
|
|
14
|
+
temp_file.close
|
|
15
|
+
temp_file.unlink
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def code(s)
|
|
19
|
+
temp_file.write(s)
|
|
20
|
+
temp_file.rewind
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should parse a class successfully" do
|
|
24
|
+
code(<<-CODE)
|
|
25
|
+
class Foo
|
|
26
|
+
CONST = 1
|
|
27
|
+
end
|
|
28
|
+
CODE
|
|
29
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
30
|
+
expect(ast).not_to be_nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should parse assignment to HEREDOCs successfully" do
|
|
34
|
+
code(<<-CODE)
|
|
35
|
+
multi_line_string = <<-TEXT
|
|
36
|
+
This is a multi-line string.
|
|
37
|
+
You can freely write across
|
|
38
|
+
multiple lines using heredoc.
|
|
39
|
+
TEXT
|
|
40
|
+
CODE
|
|
41
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
42
|
+
expect(ast).not_to be_nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
it "should parse call with HEREDOC args successfully" do
|
|
47
|
+
code(<<-CODE)
|
|
48
|
+
puts(<<-ARG1, <<-ARG2)
|
|
49
|
+
This is the first HEREDOC.
|
|
50
|
+
It spans multiple lines.
|
|
51
|
+
ARG1
|
|
52
|
+
This is the second HEREDOC.
|
|
53
|
+
It also spans multiple lines.
|
|
54
|
+
ARG2
|
|
55
|
+
CODE
|
|
56
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
57
|
+
expect(ast).not_to be_nil
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should create a singleton object body successfully" do
|
|
61
|
+
code(<<-CODE)
|
|
62
|
+
class C
|
|
63
|
+
class << self
|
|
64
|
+
def f(x)
|
|
65
|
+
x + 1
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
CODE
|
|
70
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
71
|
+
expect(ast).not_to be_nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "should create an operator assignment successfully" do
|
|
75
|
+
code(<<-CODE)
|
|
76
|
+
def foo(x)
|
|
77
|
+
x += 1
|
|
78
|
+
end
|
|
79
|
+
CODE
|
|
80
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
81
|
+
expect(ast).not_to be_nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should create a function with a keyword option argument sucessfully" do
|
|
85
|
+
code(<<-CODE)
|
|
86
|
+
def foo(a, bar: "default")
|
|
87
|
+
puts(bar)
|
|
88
|
+
end
|
|
89
|
+
CODE
|
|
90
|
+
ast = RubyAstGen::parse_file(temp_file.path, temp_name)
|
|
91
|
+
expect(ast).not_to be_nil
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ruby_ast_gen"
|
|
4
|
+
|
|
5
|
+
RSpec.configure do |config|
|
|
6
|
+
# Enable flags like --only-failures and --next-failure
|
|
7
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
|
8
|
+
|
|
9
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
10
|
+
config.disable_monkey_patching!
|
|
11
|
+
|
|
12
|
+
config.expect_with :rspec do |c|
|
|
13
|
+
c.syntax = :expect
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Script to update the version in `lib/ruby_ast_gen/version.rb`
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
VERSION_FILE_PATH = 'lib/ruby_ast_gen/version.rb'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
if ARGV.empty?
|
|
10
|
+
puts "Usage: update_version.rb <new_version>"
|
|
11
|
+
exit 1
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
new_version = ARGV[0]
|
|
15
|
+
unless new_version.match?(/^v\d+\.\d+\.\d+$/)
|
|
16
|
+
puts "Invalid version format. Please provide a version in the format 'vX.X.X' (e.g., v1.0.0)."
|
|
17
|
+
exit 1
|
|
18
|
+
end
|
|
19
|
+
stripped_version = new_version.gsub(/^v/, '')
|
|
20
|
+
|
|
21
|
+
begin
|
|
22
|
+
contents = File.read(VERSION_FILE_PATH)
|
|
23
|
+
rescue Errno::ENOENT
|
|
24
|
+
puts "Error: Couldn't find the version file at #{VERSION_FILE_PATH}"
|
|
25
|
+
exit 1
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
new_contents = contents.gsub(/VERSION\s*=\s*["']\d+\.\d+\.\d+["']/, "VERSION = \"#{stripped_version}\"")
|
|
29
|
+
|
|
30
|
+
begin
|
|
31
|
+
File.write(VERSION_FILE_PATH, new_contents)
|
|
32
|
+
puts "Successfully updated version to #{stripped_version} in #{VERSION_FILE_PATH}"
|
|
33
|
+
rescue Errno::EACCES
|
|
34
|
+
puts "Error: Insufficient permissions to update #{VERSION_FILE_PATH}"
|
|
35
|
+
exit 1
|
|
36
|
+
end
|
|
File without changes
|
package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem_make.out
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
current directory: /home/runner/work/atom/atom/wrapper/nodejs/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse
|
|
2
|
+
/opt/hostedtoolcache/Ruby/3.4.1/x64/bin/ruby extconf.rb
|
|
3
|
+
creating Makefile
|
|
4
|
+
|
|
5
|
+
current directory: /home/runner/work/atom/atom/wrapper/nodejs/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse
|
|
6
|
+
make DESTDIR\= sitearchdir\=./.gem.20250110-2738-8nl9so sitelibdir\=./.gem.20250110-2738-8nl9so clean
|
|
7
|
+
|
|
8
|
+
current directory: /home/runner/work/atom/atom/wrapper/nodejs/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse
|
|
9
|
+
make DESTDIR\= sitearchdir\=./.gem.20250110-2738-8nl9so sitelibdir\=./.gem.20250110-2738-8nl9so
|
|
10
|
+
compiling cparse.c
|
|
11
|
+
linking shared-object racc/cparse.so
|
|
12
|
+
|
|
13
|
+
current directory: /home/runner/work/atom/atom/wrapper/nodejs/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse
|
|
14
|
+
make DESTDIR\= sitearchdir\=./.gem.20250110-2738-8nl9so sitelibdir\=./.gem.20250110-2738-8nl9so install
|
|
15
|
+
/usr/bin/install -c -m 0755 cparse.so ./.gem.20250110-2738-8nl9so/racc
|
|
16
|
+
|
|
17
|
+
current directory: /home/runner/work/atom/atom/wrapper/nodejs/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse
|
|
18
|
+
make DESTDIR\= sitearchdir\=./.gem.20250110-2738-8nl9so sitelibdir\=./.gem.20250110-2738-8nl9so clean
|
package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/racc/cparse.so
ADDED
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011-2013 Peter Zotov <whitequark@whitequark.org>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
+
copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included
|
|
12
|
+
in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{AST} is a library for manipulating abstract syntax trees.
|
|
2
|
+
|
|
3
|
+
It embraces immutability; each AST node is inherently frozen at
|
|
4
|
+
creation, and updating a child node requires recreating that node
|
|
5
|
+
and its every parent, recursively.
|
|
6
|
+
|
|
7
|
+
This is a design choice. It does create some pressure on
|
|
8
|
+
garbage collector, but completely eliminates all concurrency
|
|
9
|
+
and aliasing problems.
|
|
10
|
+
|
|
11
|
+
See also {AST::Node}, {AST::Processor::Mixin} and {AST::Sexp} for
|
|
12
|
+
additional recommendations and design patterns.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AST
|
|
4
|
+
# Node is an immutable class, instances of which represent abstract
|
|
5
|
+
# syntax tree nodes. It combines semantic information (i.e. anything
|
|
6
|
+
# that affects the algorithmic properties of a program) with
|
|
7
|
+
# meta-information (line numbers or compiler intermediates).
|
|
8
|
+
#
|
|
9
|
+
# Notes on inheritance
|
|
10
|
+
# ====================
|
|
11
|
+
#
|
|
12
|
+
# The distinction between semantics and metadata is important. Complete
|
|
13
|
+
# semantic information should be contained within just the {#type} and
|
|
14
|
+
# {#children} of a Node instance; in other words, if an AST was to be
|
|
15
|
+
# stripped of all meta-information, it should remain a valid AST which
|
|
16
|
+
# could be successfully processed to yield a result with the same
|
|
17
|
+
# algorithmic properties.
|
|
18
|
+
#
|
|
19
|
+
# Thus, Node should never be inherited in order to define methods which
|
|
20
|
+
# affect or return semantic information, such as getters for `class_name`,
|
|
21
|
+
# `superclass` and `body` in the case of a hypothetical `ClassNode`. The
|
|
22
|
+
# correct solution is to use a generic Node with a {#type} of `:class`
|
|
23
|
+
# and three children. See also {Processor} for tips on working with such
|
|
24
|
+
# ASTs.
|
|
25
|
+
#
|
|
26
|
+
# On the other hand, Node can and should be inherited to define
|
|
27
|
+
# application-specific metadata (see also {#initialize}) or customize the
|
|
28
|
+
# printing format. It is expected that an application would have one or two
|
|
29
|
+
# such classes and use them across the entire codebase.
|
|
30
|
+
#
|
|
31
|
+
# The rationale for this pattern is extensibility and maintainability.
|
|
32
|
+
# Unlike static ones, dynamic languages do not require the presence of a
|
|
33
|
+
# predefined, rigid structure, nor does it improve dispatch efficiency,
|
|
34
|
+
# and while such a structure can certainly be defined, it does not add
|
|
35
|
+
# any value but incurs a maintaining cost.
|
|
36
|
+
# For example, extending the AST even with a transformation-local
|
|
37
|
+
# temporary node type requires making globally visible changes to
|
|
38
|
+
# the codebase.
|
|
39
|
+
#
|
|
40
|
+
class Node
|
|
41
|
+
# Returns the type of this node.
|
|
42
|
+
# @return [Symbol]
|
|
43
|
+
attr_reader :type
|
|
44
|
+
|
|
45
|
+
# Returns the children of this node.
|
|
46
|
+
# The returned value is frozen.
|
|
47
|
+
# The to_a alias is useful for decomposing nodes concisely.
|
|
48
|
+
# For example:
|
|
49
|
+
#
|
|
50
|
+
# node = s(:gasgn, :$foo, s(:integer, 1))
|
|
51
|
+
# var_name, value = *node
|
|
52
|
+
# p var_name # => :$foo
|
|
53
|
+
# p value # => (integer 1)
|
|
54
|
+
#
|
|
55
|
+
# @return [Array]
|
|
56
|
+
attr_reader :children
|
|
57
|
+
alias to_a children
|
|
58
|
+
|
|
59
|
+
# Returns the precomputed hash value for this node
|
|
60
|
+
# @return [Fixnum]
|
|
61
|
+
attr_reader :hash
|
|
62
|
+
|
|
63
|
+
# Constructs a new instance of Node.
|
|
64
|
+
#
|
|
65
|
+
# The arguments `type` and `children` are converted with `to_sym` and
|
|
66
|
+
# `to_a` respectively. Additionally, the result of converting `children`
|
|
67
|
+
# is frozen. While mutating the arguments is generally considered harmful,
|
|
68
|
+
# the most common case is to pass an array literal to the constructor. If
|
|
69
|
+
# your code does not expect the argument to be frozen, use `#dup`.
|
|
70
|
+
#
|
|
71
|
+
# The `properties` hash is passed to {#assign_properties}.
|
|
72
|
+
def initialize(type, children=[], properties={})
|
|
73
|
+
@type, @children = type.to_sym, children.to_a.freeze
|
|
74
|
+
|
|
75
|
+
assign_properties(properties)
|
|
76
|
+
|
|
77
|
+
@hash = [@type, @children, self.class].hash
|
|
78
|
+
|
|
79
|
+
freeze
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Test if other object is equal to
|
|
83
|
+
# @param [Object] other
|
|
84
|
+
# @return [Boolean]
|
|
85
|
+
def eql?(other)
|
|
86
|
+
self.class.eql?(other.class) &&
|
|
87
|
+
@type.eql?(other.type) &&
|
|
88
|
+
@children.eql?(other.children)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# By default, each entry in the `properties` hash is assigned to
|
|
92
|
+
# an instance variable in this instance of Node. A subclass should define
|
|
93
|
+
# attribute readers for such variables. The values passed in the hash
|
|
94
|
+
# are not frozen or whitelisted; such behavior can also be implemented
|
|
95
|
+
# by subclassing Node and overriding this method.
|
|
96
|
+
#
|
|
97
|
+
# @return [nil]
|
|
98
|
+
def assign_properties(properties)
|
|
99
|
+
properties.each do |name, value|
|
|
100
|
+
instance_variable_set :"@#{name}", value
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
nil
|
|
104
|
+
end
|
|
105
|
+
protected :assign_properties
|
|
106
|
+
|
|
107
|
+
alias :original_dup :dup
|
|
108
|
+
private :original_dup
|
|
109
|
+
|
|
110
|
+
# Nodes are already frozen, so there is no harm in returning the
|
|
111
|
+
# current node as opposed to initializing from scratch and freezing
|
|
112
|
+
# another one.
|
|
113
|
+
#
|
|
114
|
+
# @return self
|
|
115
|
+
def dup
|
|
116
|
+
self
|
|
117
|
+
end
|
|
118
|
+
alias :clone :dup
|
|
119
|
+
|
|
120
|
+
# Returns a new instance of Node where non-nil arguments replace the
|
|
121
|
+
# corresponding fields of `self`.
|
|
122
|
+
#
|
|
123
|
+
# For example, `Node.new(:foo, [ 1, 2 ]).updated(:bar)` would yield
|
|
124
|
+
# `(bar 1 2)`, and `Node.new(:foo, [ 1, 2 ]).updated(nil, [])` would
|
|
125
|
+
# yield `(foo)`.
|
|
126
|
+
#
|
|
127
|
+
# If the resulting node would be identical to `self`, does nothing.
|
|
128
|
+
#
|
|
129
|
+
# @param [Symbol, nil] type
|
|
130
|
+
# @param [Array, nil] children
|
|
131
|
+
# @param [Hash, nil] properties
|
|
132
|
+
# @return [AST::Node]
|
|
133
|
+
def updated(type=nil, children=nil, properties=nil)
|
|
134
|
+
new_type = type || @type
|
|
135
|
+
new_children = children || @children
|
|
136
|
+
new_properties = properties || {}
|
|
137
|
+
|
|
138
|
+
if @type == new_type &&
|
|
139
|
+
@children == new_children &&
|
|
140
|
+
properties.nil?
|
|
141
|
+
self
|
|
142
|
+
else
|
|
143
|
+
copy = original_dup
|
|
144
|
+
copy.send :initialize, new_type, new_children, new_properties
|
|
145
|
+
copy
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Compares `self` to `other`, possibly converting with `to_ast`. Only
|
|
150
|
+
# `type` and `children` are compared; metadata is deliberately ignored.
|
|
151
|
+
#
|
|
152
|
+
# @return [Boolean]
|
|
153
|
+
def ==(other)
|
|
154
|
+
if equal?(other)
|
|
155
|
+
true
|
|
156
|
+
elsif other.respond_to? :to_ast
|
|
157
|
+
other = other.to_ast
|
|
158
|
+
other.type == self.type &&
|
|
159
|
+
other.children == self.children
|
|
160
|
+
else
|
|
161
|
+
false
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Concatenates `array` with `children` and returns the resulting node.
|
|
166
|
+
#
|
|
167
|
+
# @return [AST::Node]
|
|
168
|
+
def concat(array)
|
|
169
|
+
updated(nil, @children + array.to_a)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
alias + concat
|
|
173
|
+
|
|
174
|
+
# Appends `element` to `children` and returns the resulting node.
|
|
175
|
+
#
|
|
176
|
+
# @return [AST::Node]
|
|
177
|
+
def append(element)
|
|
178
|
+
updated(nil, @children + [element])
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
alias << append
|
|
182
|
+
|
|
183
|
+
# Converts `self` to a pretty-printed s-expression.
|
|
184
|
+
#
|
|
185
|
+
# @param [Integer] indent Base indentation level.
|
|
186
|
+
# @return [String]
|
|
187
|
+
def to_sexp(indent=0)
|
|
188
|
+
indented = " " * indent
|
|
189
|
+
sexp = "#{indented}(#{fancy_type}"
|
|
190
|
+
|
|
191
|
+
children.each do |child|
|
|
192
|
+
if child.is_a?(Node)
|
|
193
|
+
sexp += "\n#{child.to_sexp(indent + 1)}"
|
|
194
|
+
else
|
|
195
|
+
sexp += " #{child.inspect}"
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
sexp += ")"
|
|
200
|
+
|
|
201
|
+
sexp
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
alias to_s to_sexp
|
|
205
|
+
|
|
206
|
+
# Converts `self` to a s-expression ruby string.
|
|
207
|
+
# The code return will recreate the node, using the sexp module s()
|
|
208
|
+
#
|
|
209
|
+
# @param [Integer] indent Base indentation level.
|
|
210
|
+
# @return [String]
|
|
211
|
+
def inspect(indent=0)
|
|
212
|
+
indented = " " * indent
|
|
213
|
+
sexp = "#{indented}s(:#{@type}"
|
|
214
|
+
|
|
215
|
+
children.each do |child|
|
|
216
|
+
if child.is_a?(Node)
|
|
217
|
+
sexp += ",\n#{child.inspect(indent + 1)}"
|
|
218
|
+
else
|
|
219
|
+
sexp += ", #{child.inspect}"
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
sexp += ")"
|
|
224
|
+
|
|
225
|
+
sexp
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# @return [AST::Node] self
|
|
229
|
+
def to_ast
|
|
230
|
+
self
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Converts `self` to an Array where the first element is the type as a Symbol,
|
|
234
|
+
# and subsequent elements are the same representation of its children.
|
|
235
|
+
#
|
|
236
|
+
# @return [Array<Symbol, [...Array]>]
|
|
237
|
+
def to_sexp_array
|
|
238
|
+
children_sexp_arrs = children.map do |child|
|
|
239
|
+
if child.is_a?(Node)
|
|
240
|
+
child.to_sexp_array
|
|
241
|
+
else
|
|
242
|
+
child
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
[type, *children_sexp_arrs]
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Enables matching for Node, where type is the first element
|
|
250
|
+
# and the children are remaining items.
|
|
251
|
+
#
|
|
252
|
+
# @return [Array]
|
|
253
|
+
def deconstruct
|
|
254
|
+
[type, *children]
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
protected
|
|
258
|
+
|
|
259
|
+
# Returns `@type` with all underscores replaced by dashes. This allows
|
|
260
|
+
# to write symbol literals without quotes in Ruby sources and yet have
|
|
261
|
+
# nicely looking s-expressions.
|
|
262
|
+
#
|
|
263
|
+
# @return [String]
|
|
264
|
+
def fancy_type
|
|
265
|
+
@type.to_s.gsub('_', '-')
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|