@appthreat/atom 2.1.19 → 2.2.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 (462) hide show
  1. package/{plugins/composer/LICENSE → LICENSE} +6 -6
  2. package/README.md +2 -2
  3. package/index.js +4 -8
  4. package/package.json +20 -13
  5. package/packages/atom-parsetools/LICENSE +21 -0
  6. package/{astgen.js → packages/atom-parsetools/astgen.js} +1 -1
  7. package/packages/atom-parsetools/index.js +1 -0
  8. package/{phpastgen.js → packages/atom-parsetools/phpastgen.js} +1 -1
  9. package/{rbastgen.js → packages/atom-parsetools/rbastgen.js} +1 -1
  10. package/{scalasem.js → packages/atom-parsetools/scalasem.js} +1 -1
  11. package/plugins/bin/atom +1 -1
  12. package/plugins/bin/atom.bat +1 -1
  13. package/plugins/lib/io.appthreat.atom-2.2.0-classpath.jar +0 -0
  14. package/plugins/lib/{io.appthreat.atom-2.1.19.jar → io.appthreat.atom-2.2.0.jar} +0 -0
  15. package/plugins/lib/{io.appthreat.c2cpg_3-2.3.10.jar → io.appthreat.c2cpg_3-2.4.1.jar} +0 -0
  16. package/plugins/lib/{io.appthreat.dataflowengineoss_3-2.3.10.jar → io.appthreat.dataflowengineoss_3-2.4.1.jar} +0 -0
  17. package/plugins/lib/{io.appthreat.javasrc2cpg_3-2.3.10.jar → io.appthreat.javasrc2cpg_3-2.4.1.jar} +0 -0
  18. package/plugins/lib/{io.appthreat.jimple2cpg_3-2.3.10.jar → io.appthreat.jimple2cpg_3-2.4.1.jar} +0 -0
  19. package/plugins/lib/{io.appthreat.jssrc2cpg_3-2.3.10.jar → io.appthreat.jssrc2cpg_3-2.4.1.jar} +0 -0
  20. package/plugins/lib/{io.appthreat.php2atom_3-2.3.10.jar → io.appthreat.php2atom_3-2.4.1.jar} +0 -0
  21. package/plugins/lib/{io.appthreat.pysrc2cpg_3-2.3.10.jar → io.appthreat.pysrc2cpg_3-2.4.1.jar} +0 -0
  22. package/plugins/lib/{io.appthreat.ruby2atom_3-2.3.10.jar → io.appthreat.ruby2atom_3-2.4.1.jar} +0 -0
  23. package/plugins/lib/{io.appthreat.semanticcpg_3-2.3.10.jar → io.appthreat.semanticcpg_3-2.4.1.jar} +0 -0
  24. package/plugins/lib/{io.appthreat.x2cpg_3-2.3.10.jar → io.appthreat.x2cpg_3-2.4.1.jar} +0 -0
  25. package/plugins/lib/{io.circe.circe-core_3-0.14.12.jar → io.circe.circe-core_3-0.14.13.jar} +0 -0
  26. package/plugins/lib/{io.circe.circe-generic_3-0.14.12.jar → io.circe.circe-generic_3-0.14.13.jar} +0 -0
  27. package/plugins/lib/{io.circe.circe-jawn_3-0.14.12.jar → io.circe.circe-jawn_3-0.14.13.jar} +0 -0
  28. package/plugins/lib/{io.circe.circe-numbers_3-0.14.12.jar → io.circe.circe-numbers_3-0.14.13.jar} +0 -0
  29. package/plugins/lib/{io.circe.circe-parser_3-0.14.12.jar → io.circe.circe-parser_3-0.14.13.jar} +0 -0
  30. package/plugins/lib/{org.scala-lang.scala3-library_3-3.6.2.jar → org.scala-lang.scala3-library_3-3.6.4.jar} +0 -0
  31. package/plugins/autoload.php +0 -22
  32. package/plugins/bin/bundler +0 -14
  33. package/plugins/bin/php-parse +0 -119
  34. package/plugins/bin/ruby_ast_gen +0 -14
  35. package/plugins/composer/ClassLoader.php +0 -579
  36. package/plugins/composer/InstalledVersions.php +0 -396
  37. package/plugins/composer/autoload_classmap.php +0 -260
  38. package/plugins/composer/autoload_namespaces.php +0 -9
  39. package/plugins/composer/autoload_psr4.php +0 -10
  40. package/plugins/composer/autoload_real.php +0 -36
  41. package/plugins/composer/autoload_static.php +0 -286
  42. package/plugins/composer/installed.json +0 -65
  43. package/plugins/composer/installed.php +0 -32
  44. package/plugins/lib/io.appthreat.atom-2.1.19-classpath.jar +0 -0
  45. package/plugins/nikic/php-parser/LICENSE +0 -29
  46. package/plugins/nikic/php-parser/README.md +0 -225
  47. package/plugins/nikic/php-parser/bin/php-parse +0 -205
  48. package/plugins/nikic/php-parser/composer.json +0 -41
  49. package/plugins/nikic/php-parser/lib/PhpParser/Builder/ClassConst.php +0 -148
  50. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Class_.php +0 -146
  51. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Declaration.php +0 -43
  52. package/plugins/nikic/php-parser/lib/PhpParser/Builder/EnumCase.php +0 -85
  53. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Enum_.php +0 -117
  54. package/plugins/nikic/php-parser/lib/PhpParser/Builder/FunctionLike.php +0 -73
  55. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Function_.php +0 -67
  56. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Interface_.php +0 -93
  57. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Method.php +0 -146
  58. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Namespace_.php +0 -45
  59. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Param.php +0 -168
  60. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Property.php +0 -161
  61. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUse.php +0 -64
  62. package/plugins/nikic/php-parser/lib/PhpParser/Builder/TraitUseAdaptation.php +0 -148
  63. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Trait_.php +0 -78
  64. package/plugins/nikic/php-parser/lib/PhpParser/Builder/Use_.php +0 -49
  65. package/plugins/nikic/php-parser/lib/PhpParser/Builder.php +0 -13
  66. package/plugins/nikic/php-parser/lib/PhpParser/BuilderFactory.php +0 -399
  67. package/plugins/nikic/php-parser/lib/PhpParser/BuilderHelpers.php +0 -335
  68. package/plugins/nikic/php-parser/lib/PhpParser/Comment/Doc.php +0 -7
  69. package/plugins/nikic/php-parser/lib/PhpParser/Comment.php +0 -239
  70. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluationException.php +0 -6
  71. package/plugins/nikic/php-parser/lib/PhpParser/ConstExprEvaluator.php +0 -229
  72. package/plugins/nikic/php-parser/lib/PhpParser/Error.php +0 -180
  73. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Collecting.php +0 -46
  74. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler/Throwing.php +0 -18
  75. package/plugins/nikic/php-parser/lib/PhpParser/ErrorHandler.php +0 -13
  76. package/plugins/nikic/php-parser/lib/PhpParser/Internal/DiffElem.php +0 -27
  77. package/plugins/nikic/php-parser/lib/PhpParser/Internal/Differ.php +0 -164
  78. package/plugins/nikic/php-parser/lib/PhpParser/Internal/PrintableNewAnonClassNode.php +0 -64
  79. package/plugins/nikic/php-parser/lib/PhpParser/Internal/TokenStream.php +0 -286
  80. package/plugins/nikic/php-parser/lib/PhpParser/JsonDecoder.php +0 -103
  81. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php +0 -251
  82. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php +0 -56
  83. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/CoaleseEqualTokenEmulator.php +0 -47
  84. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/EnumTokenEmulator.php +0 -31
  85. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php +0 -44
  86. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FlexibleDocStringEmulator.php +0 -76
  87. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/FnTokenEmulator.php +0 -23
  88. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php +0 -62
  89. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/MatchTokenEmulator.php +0 -23
  90. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php +0 -67
  91. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/NumericLiteralSeparatorEmulator.php +0 -105
  92. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyFunctionTokenEmulator.php +0 -31
  93. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReadonlyTokenEmulator.php +0 -36
  94. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/ReverseEmulator.php +0 -36
  95. package/plugins/nikic/php-parser/lib/PhpParser/Lexer/TokenEmulator/TokenEmulator.php +0 -25
  96. package/plugins/nikic/php-parser/lib/PhpParser/Lexer.php +0 -560
  97. package/plugins/nikic/php-parser/lib/PhpParser/NameContext.php +0 -285
  98. package/plugins/nikic/php-parser/lib/PhpParser/Node/Arg.php +0 -46
  99. package/plugins/nikic/php-parser/lib/PhpParser/Node/Attribute.php +0 -34
  100. package/plugins/nikic/php-parser/lib/PhpParser/Node/AttributeGroup.php +0 -29
  101. package/plugins/nikic/php-parser/lib/PhpParser/Node/ComplexType.php +0 -14
  102. package/plugins/nikic/php-parser/lib/PhpParser/Node/Const_.php +0 -37
  103. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayDimFetch.php +0 -34
  104. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrayItem.php +0 -41
  105. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Array_.php +0 -34
  106. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ArrowFunction.php +0 -79
  107. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Assign.php +0 -34
  108. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseAnd.php +0 -12
  109. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseOr.php +0 -12
  110. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/BitwiseXor.php +0 -12
  111. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Coalesce.php +0 -12
  112. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Concat.php +0 -12
  113. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Div.php +0 -12
  114. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Minus.php +0 -12
  115. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mod.php +0 -12
  116. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Mul.php +0 -12
  117. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Plus.php +0 -12
  118. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/Pow.php +0 -12
  119. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftLeft.php +0 -12
  120. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp/ShiftRight.php +0 -12
  121. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignOp.php +0 -30
  122. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/AssignRef.php +0 -34
  123. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseAnd.php +0 -16
  124. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseOr.php +0 -16
  125. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BitwiseXor.php +0 -16
  126. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanAnd.php +0 -16
  127. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/BooleanOr.php +0 -16
  128. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Coalesce.php +0 -16
  129. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Concat.php +0 -16
  130. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Div.php +0 -16
  131. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Equal.php +0 -16
  132. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Greater.php +0 -16
  133. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/GreaterOrEqual.php +0 -16
  134. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Identical.php +0 -16
  135. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalAnd.php +0 -16
  136. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalOr.php +0 -16
  137. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/LogicalXor.php +0 -16
  138. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Minus.php +0 -16
  139. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mod.php +0 -16
  140. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Mul.php +0 -16
  141. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotEqual.php +0 -16
  142. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/NotIdentical.php +0 -16
  143. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Plus.php +0 -16
  144. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Pow.php +0 -16
  145. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftLeft.php +0 -16
  146. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/ShiftRight.php +0 -16
  147. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Smaller.php +0 -16
  148. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/SmallerOrEqual.php +0 -16
  149. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp/Spaceship.php +0 -16
  150. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BinaryOp.php +0 -40
  151. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BitwiseNot.php +0 -30
  152. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/BooleanNot.php +0 -30
  153. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/CallLike.php +0 -39
  154. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Array_.php +0 -12
  155. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Bool_.php +0 -12
  156. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Double.php +0 -17
  157. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Int_.php +0 -12
  158. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Object_.php +0 -12
  159. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/String_.php +0 -12
  160. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast/Unset_.php +0 -12
  161. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Cast.php +0 -26
  162. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClassConstFetch.php +0 -36
  163. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Clone_.php +0 -30
  164. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Closure.php +0 -79
  165. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ClosureUse.php +0 -34
  166. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ConstFetch.php +0 -31
  167. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Empty_.php +0 -30
  168. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Error.php +0 -31
  169. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ErrorSuppress.php +0 -30
  170. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Eval_.php +0 -30
  171. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Exit_.php +0 -34
  172. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/FuncCall.php +0 -39
  173. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Include_.php +0 -39
  174. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Instanceof_.php +0 -35
  175. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Isset_.php +0 -30
  176. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/List_.php +0 -30
  177. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Match_.php +0 -31
  178. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/MethodCall.php +0 -45
  179. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/New_.php +0 -41
  180. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafeMethodCall.php +0 -45
  181. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/NullsafePropertyFetch.php +0 -35
  182. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostDec.php +0 -30
  183. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PostInc.php +0 -30
  184. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreDec.php +0 -30
  185. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PreInc.php +0 -30
  186. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Print_.php +0 -30
  187. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/PropertyFetch.php +0 -35
  188. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/ShellExec.php +0 -30
  189. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticCall.php +0 -46
  190. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/StaticPropertyFetch.php +0 -36
  191. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Ternary.php +0 -38
  192. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Throw_.php +0 -30
  193. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryMinus.php +0 -30
  194. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/UnaryPlus.php +0 -30
  195. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Variable.php +0 -30
  196. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/YieldFrom.php +0 -30
  197. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr/Yield_.php +0 -34
  198. package/plugins/nikic/php-parser/lib/PhpParser/Node/Expr.php +0 -9
  199. package/plugins/nikic/php-parser/lib/PhpParser/Node/FunctionLike.php +0 -43
  200. package/plugins/nikic/php-parser/lib/PhpParser/Node/Identifier.php +0 -75
  201. package/plugins/nikic/php-parser/lib/PhpParser/Node/IntersectionType.php +0 -30
  202. package/plugins/nikic/php-parser/lib/PhpParser/Node/MatchArm.php +0 -31
  203. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/FullyQualified.php +0 -50
  204. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name/Relative.php +0 -50
  205. package/plugins/nikic/php-parser/lib/PhpParser/Node/Name.php +0 -254
  206. package/plugins/nikic/php-parser/lib/PhpParser/Node/NullableType.php +0 -28
  207. package/plugins/nikic/php-parser/lib/PhpParser/Node/Param.php +0 -60
  208. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/DNumber.php +0 -77
  209. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/Encapsed.php +0 -31
  210. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/EncapsedStringPart.php +0 -30
  211. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php +0 -80
  212. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Class_.php +0 -16
  213. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Dir.php +0 -16
  214. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/File.php +0 -16
  215. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Function_.php +0 -16
  216. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Line.php +0 -16
  217. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Method.php +0 -16
  218. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Namespace_.php +0 -16
  219. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst/Trait_.php +0 -16
  220. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/MagicConst.php +0 -28
  221. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php +0 -157
  222. package/plugins/nikic/php-parser/lib/PhpParser/Node/Scalar.php +0 -7
  223. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Break_.php +0 -30
  224. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Case_.php +0 -34
  225. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Catch_.php +0 -41
  226. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php +0 -85
  227. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php +0 -109
  228. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassMethod.php +0 -161
  229. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Class_.php +0 -137
  230. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Const_.php +0 -30
  231. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Continue_.php +0 -30
  232. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/DeclareDeclare.php +0 -34
  233. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Declare_.php +0 -34
  234. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Do_.php +0 -34
  235. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Echo_.php +0 -30
  236. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/ElseIf_.php +0 -34
  237. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Else_.php +0 -30
  238. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/EnumCase.php +0 -37
  239. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Enum_.php +0 -40
  240. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php +0 -33
  241. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Finally_.php +0 -30
  242. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/For_.php +0 -43
  243. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Foreach_.php +0 -47
  244. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Function_.php +0 -77
  245. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Global_.php +0 -30
  246. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Goto_.php +0 -31
  247. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/GroupUse.php +0 -39
  248. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/HaltCompiler.php +0 -30
  249. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/If_.php +0 -43
  250. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php +0 -30
  251. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Interface_.php +0 -37
  252. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Label.php +0 -31
  253. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Namespace_.php +0 -38
  254. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Nop.php +0 -17
  255. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Property.php +0 -91
  256. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/PropertyProperty.php +0 -34
  257. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Return_.php +0 -30
  258. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/StaticVar.php +0 -37
  259. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Static_.php +0 -30
  260. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Switch_.php +0 -34
  261. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Throw_.php +0 -30
  262. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUse.php +0 -34
  263. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Alias.php +0 -38
  264. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation/Precedence.php +0 -34
  265. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TraitUseAdaptation.php +0 -13
  266. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Trait_.php +0 -32
  267. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/TryCatch.php +0 -38
  268. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Unset_.php +0 -30
  269. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/UseUse.php +0 -52
  270. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/Use_.php +0 -47
  271. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt/While_.php +0 -34
  272. package/plugins/nikic/php-parser/lib/PhpParser/Node/Stmt.php +0 -9
  273. package/plugins/nikic/php-parser/lib/PhpParser/Node/UnionType.php +0 -28
  274. package/plugins/nikic/php-parser/lib/PhpParser/Node/VarLikeIdentifier.php +0 -17
  275. package/plugins/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php +0 -27
  276. package/plugins/nikic/php-parser/lib/PhpParser/Node.php +0 -151
  277. package/plugins/nikic/php-parser/lib/PhpParser/NodeAbstract.php +0 -178
  278. package/plugins/nikic/php-parser/lib/PhpParser/NodeDumper.php +0 -206
  279. package/plugins/nikic/php-parser/lib/PhpParser/NodeFinder.php +0 -81
  280. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverser.php +0 -291
  281. package/plugins/nikic/php-parser/lib/PhpParser/NodeTraverserInterface.php +0 -29
  282. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php +0 -20
  283. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php +0 -48
  284. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/FirstFindingVisitor.php +0 -50
  285. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php +0 -260
  286. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php +0 -52
  287. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php +0 -41
  288. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitor.php +0 -72
  289. package/plugins/nikic/php-parser/lib/PhpParser/NodeVisitorAbstract.php +0 -25
  290. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Multiple.php +0 -55
  291. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php5.php +0 -2682
  292. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Php7.php +0 -2898
  293. package/plugins/nikic/php-parser/lib/PhpParser/Parser/Tokens.php +0 -148
  294. package/plugins/nikic/php-parser/lib/PhpParser/Parser.php +0 -18
  295. package/plugins/nikic/php-parser/lib/PhpParser/ParserAbstract.php +0 -1060
  296. package/plugins/nikic/php-parser/lib/PhpParser/ParserFactory.php +0 -76
  297. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php +0 -1126
  298. package/plugins/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php +0 -1576
  299. package/plugins/rubyastgen/.bundle/config +0 -5
  300. package/plugins/rubyastgen/Gemfile +0 -12
  301. package/plugins/rubyastgen/Gemfile.lock +0 -34
  302. package/plugins/rubyastgen/bundle/bundler/setup.rb +0 -42
  303. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/racc +0 -29
  304. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-parse +0 -29
  305. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby-rewrite +0 -29
  306. package/plugins/rubyastgen/bundle/ruby/3.4.0/bin/ruby_ast_gen +0 -29
  307. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/.rspec +0 -3
  308. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/Gemfile +0 -10
  309. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/LICENSE.txt +0 -213
  310. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/README.md +0 -46
  311. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/Rakefile +0 -8
  312. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/bin/console +0 -11
  313. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/bin/setup +0 -6
  314. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/exe/ruby_ast_gen +0 -59
  315. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen/node_handling.rb +0 -232
  316. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen/version.rb +0 -5
  317. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/lib/ruby_ast_gen.rb +0 -140
  318. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/ruby_ast_gen.gemspec +0 -25
  319. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/spec/ruby_ast_gen_spec.rb +0 -175
  320. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/spec/spec_helper.rb +0 -15
  321. package/plugins/rubyastgen/bundle/ruby/3.4.0/bundler/gems/ruby_ast_gen-d8b5c5740b5a/update_version.rb +0 -36
  322. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem.build_complete +0 -0
  323. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/gem_make.out +0 -18
  324. package/plugins/rubyastgen/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/racc-1.8.1/racc/cparse.so +0 -0
  325. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/LICENSE.MIT +0 -20
  326. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/README.YARD.md +0 -12
  327. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/node.rb +0 -268
  328. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/processor/mixin.rb +0 -288
  329. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/processor.rb +0 -12
  330. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast/sexp.rb +0 -30
  331. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ast-2.4.3/lib/ast.rb +0 -17
  332. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/BSDL +0 -22
  333. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/COPYING +0 -56
  334. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Gemfile +0 -10
  335. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/README.md +0 -69
  336. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/Rakefile +0 -18
  337. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/console +0 -14
  338. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/bin/setup +0 -8
  339. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/lib/ostruct.rb +0 -489
  340. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/ostruct-0.6.1/ostruct.gemspec +0 -24
  341. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/LICENSE.txt +0 -26
  342. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/bin/ruby-parse +0 -7
  343. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/bin/ruby-rewrite +0 -7
  344. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/gauntlet_parser.rb +0 -123
  345. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/all.rb +0 -17
  346. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ast/node.rb +0 -40
  347. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ast/processor.rb +0 -293
  348. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/base.rb +0 -294
  349. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/builders/default.rb +0 -2351
  350. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/clobbering_error.rb +0 -13
  351. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/color.rb +0 -32
  352. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/context.rb +0 -51
  353. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/current.rb +0 -146
  354. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/current_arg_stack.rb +0 -46
  355. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/deprecation.rb +0 -13
  356. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/diagnostic/engine.rb +0 -104
  357. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/diagnostic.rb +0 -163
  358. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/dedenter.rb +0 -88
  359. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/explanation.rb +0 -55
  360. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/literal.rb +0 -284
  361. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer/stack_state.rb +0 -49
  362. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-F0.rb +0 -12931
  363. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-F1.rb +0 -14884
  364. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/lexer-strings.rb +0 -5433
  365. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/macruby.rb +0 -9634
  366. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/max_numparam_stack.rb +0 -56
  367. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/messages.rb +0 -125
  368. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/meta.rb +0 -48
  369. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/rewriter.rb +0 -105
  370. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby18.rb +0 -9272
  371. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby19.rb +0 -9558
  372. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby20.rb +0 -10229
  373. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby21.rb +0 -10203
  374. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby22.rb +0 -10302
  375. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby23.rb +0 -10322
  376. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby24.rb +0 -10454
  377. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby25.rb +0 -10374
  378. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby26.rb +0 -10352
  379. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby27.rb +0 -11948
  380. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby30.rb +0 -12244
  381. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby31.rb +0 -12717
  382. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby32.rb +0 -12705
  383. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby33.rb +0 -12590
  384. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/ruby34.rb +0 -12597
  385. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/rubymotion.rb +0 -9515
  386. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner/ruby_parse.rb +0 -157
  387. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner/ruby_rewrite.rb +0 -101
  388. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/runner.rb +0 -299
  389. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/buffer.rb +0 -369
  390. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/comment/associator.rb +0 -233
  391. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/comment.rb +0 -134
  392. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/collection.rb +0 -18
  393. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/condition.rb +0 -21
  394. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/constant.rb +0 -32
  395. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/definition.rb +0 -23
  396. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/for.rb +0 -19
  397. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/heredoc.rb +0 -19
  398. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/index.rb +0 -33
  399. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/keyword.rb +0 -20
  400. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/method_definition.rb +0 -25
  401. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/objc_kwarg.rb +0 -19
  402. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/operator.rb +0 -17
  403. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/rescue_body.rb +0 -21
  404. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/send.rb +0 -36
  405. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/ternary.rb +0 -18
  406. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map/variable.rb +0 -31
  407. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/map.rb +0 -186
  408. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/range.rb +0 -326
  409. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/rewriter/action.rb +0 -44
  410. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/rewriter.rb +0 -513
  411. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/tree_rewriter/action.rb +0 -243
  412. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/source/tree_rewriter.rb +0 -431
  413. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/static_environment.rb +0 -134
  414. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/syntax_error.rb +0 -21
  415. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/tree_rewriter.rb +0 -133
  416. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/unknown_encoding_in_magic_comment_error.rb +0 -15
  417. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/variables_stack.rb +0 -36
  418. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser/version.rb +0 -5
  419. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/lib/parser.rb +0 -91
  420. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/parser-3.3.8.0/parser.gemspec +0 -43
  421. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/BSDL +0 -22
  422. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/COPYING +0 -56
  423. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ChangeLog +0 -846
  424. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.ja.rdoc +0 -58
  425. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/README.rdoc +0 -60
  426. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/TODO +0 -5
  427. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/bin/racc +0 -320
  428. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar.en.rdoc +0 -218
  429. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/en/grammar2.en.rdoc +0 -219
  430. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/command.ja.html +0 -99
  431. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/debug.ja.rdoc +0 -36
  432. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/grammar.ja.rdoc +0 -348
  433. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/index.ja.html +0 -10
  434. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/parser.ja.rdoc +0 -125
  435. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/doc/ja/usage.ja.html +0 -414
  436. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/Makefile +0 -273
  437. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/cparse.c +0 -840
  438. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/ext/racc/cparse/extconf.rb +0 -8
  439. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/compat.rb +0 -33
  440. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/cparse.so +0 -0
  441. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/debugflags.rb +0 -60
  442. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/exception.rb +0 -16
  443. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammar.rb +0 -1191
  444. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/grammarfileparser.rb +0 -667
  445. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/info.rb +0 -18
  446. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/iset.rb +0 -92
  447. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/logfilegenerator.rb +0 -212
  448. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser-text.rb +0 -644
  449. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parser.rb +0 -630
  450. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/parserfilegenerator.rb +0 -473
  451. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/sourcetext.rb +0 -35
  452. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/state.rb +0 -976
  453. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/statetransitiontable.rb +0 -311
  454. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc/static.rb +0 -5
  455. package/plugins/rubyastgen/bundle/ruby/3.4.0/gems/racc-1.8.1/lib/racc.rb +0 -6
  456. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ast-2.4.3.gemspec +0 -29
  457. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/ostruct-0.6.1.gemspec +0 -21
  458. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/parser-3.3.8.0.gemspec +0 -37
  459. package/plugins/rubyastgen/bundle/ruby/3.4.0/specifications/racc-1.8.1.gemspec +0 -28
  460. package/plugins/rubyastgen/setup.ps1 +0 -4
  461. package/plugins/rubyastgen/setup.sh +0 -6
  462. package/utils.mjs +0 -139
@@ -1,2351 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Parser
4
-
5
- ##
6
- # Default AST builder. Uses {AST::Node}s.
7
- #
8
- class Builders::Default
9
- class << self
10
- ##
11
- # AST compatibility attribute; since `-> {}` is not semantically
12
- # equivalent to `lambda {}`, all new code should set this attribute
13
- # to true.
14
- #
15
- # If set to false (the default), `-> {}` is emitted as
16
- # `s(:block, s(:send, nil, :lambda), s(:args), nil)`.
17
- #
18
- # If set to true, `-> {}` is emitted as
19
- # `s(:block, s(:lambda), s(:args), nil)`.
20
- #
21
- # @return [Boolean]
22
- attr_accessor :emit_lambda
23
- end
24
-
25
- @emit_lambda = false
26
-
27
- class << self
28
- ##
29
- # AST compatibility attribute; block arguments of `m { |a| }` are
30
- # not semantically equivalent to block arguments of `m { |a,| }` or `m { |a, b| }`,
31
- # all new code should set this attribute to true.
32
- #
33
- # If set to false (the default), arguments of `m { |a| }` are emitted as
34
- # `s(:args, s(:arg, :a))`.
35
- #
36
- # If set to true, arguments of `m { |a| }` are emitted as
37
- # `s(:args, s(:procarg0, :a)).
38
- #
39
- # @return [Boolean]
40
- attr_accessor :emit_procarg0
41
- end
42
-
43
- @emit_procarg0 = false
44
-
45
- class << self
46
- ##
47
- # AST compatibility attribute; locations of `__ENCODING__` are not the same
48
- # as locations of `Encoding::UTF_8` causing problems during rewriting,
49
- # all new code should set this attribute to true.
50
- #
51
- # If set to false (the default), `__ENCODING__` is emitted as
52
- # ` s(:const, s(:const, nil, :Encoding), :UTF_8)`.
53
- #
54
- # If set to true, `__ENCODING__` is emitted as
55
- # `s(:__ENCODING__)`.
56
- #
57
- # @return [Boolean]
58
- attr_accessor :emit_encoding
59
- end
60
-
61
- @emit_encoding = false
62
-
63
- class << self
64
- ##
65
- # AST compatibility attribute; indexed assignment, `x[] = 1`, is not
66
- # semantically equivalent to calling the method directly, `x.[]=(1)`.
67
- # Specifically, in the former case, the expression's value is always 1,
68
- # and in the latter case, the expression's value is the return value
69
- # of the `[]=` method.
70
- #
71
- # If set to false (the default), `self[1]` is emitted as
72
- # `s(:send, s(:self), :[], s(:int, 1))`, and `self[1] = 2` is
73
- # emitted as `s(:send, s(:self), :[]=, s(:int, 1), s(:int, 2))`.
74
- #
75
- # If set to true, `self[1]` is emitted as
76
- # `s(:index, s(:self), s(:int, 1))`, and `self[1] = 2` is
77
- # emitted as `s(:indexasgn, s(:self), s(:int, 1), s(:int, 2))`.
78
- #
79
- # @return [Boolean]
80
- attr_accessor :emit_index
81
- end
82
-
83
- @emit_index = false
84
-
85
- class << self
86
- ##
87
- # AST compatibility attribute; causes a single non-mlhs
88
- # block argument to be wrapped in s(:procarg0).
89
- #
90
- # If set to false (the default), block arguments `|a|` are emitted as
91
- # `s(:args, s(:procarg0, :a))`
92
- #
93
- # If set to true, block arguments `|a|` are emitted as
94
- # `s(:args, s(:procarg0, s(:arg, :a))`
95
- #
96
- # @return [Boolean]
97
- attr_accessor :emit_arg_inside_procarg0
98
- end
99
-
100
- @emit_arg_inside_procarg0 = false
101
-
102
- class << self
103
- ##
104
- # AST compatibility attribute; arguments forwarding initially
105
- # didn't have support for leading arguments
106
- # (i.e. `def m(a, ...); end` was a syntax error). However, Ruby 3.0
107
- # added support for any number of arguments in front of the `...`.
108
- #
109
- # If set to false (the default):
110
- # 1. `def m(...) end` is emitted as
111
- # s(:def, :m, s(:forward_args), nil)
112
- # 2. `def m(a, b, ...) end` is emitted as
113
- # s(:def, :m,
114
- # s(:args, s(:arg, :a), s(:arg, :b), s(:forward_arg)))
115
- #
116
- # If set to true it uses a single format:
117
- # 1. `def m(...) end` is emitted as
118
- # s(:def, :m, s(:args, s(:forward_arg)))
119
- # 2. `def m(a, b, ...) end` is emitted as
120
- # s(:def, :m, s(:args, s(:arg, :a), s(:arg, :b), s(:forward_arg)))
121
- #
122
- # It does't matter that much on 2.7 (because there can't be any leading arguments),
123
- # but on 3.0 it should be better enabled to use a single AST format.
124
- #
125
- # @return [Boolean]
126
- attr_accessor :emit_forward_arg
127
- end
128
-
129
- @emit_forward_arg = false
130
-
131
- class << self
132
- ##
133
- # AST compatibility attribute; Starting from Ruby 2.7 keyword arguments
134
- # of method calls that are passed explicitly as a hash (i.e. with curly braces)
135
- # are treated as positional arguments and Ruby 2.7 emits a warning on such method
136
- # call. Ruby 3.0 given an ArgumentError.
137
- #
138
- # If set to false (the default) the last hash argument is emitted as `hash`:
139
- #
140
- # ```
141
- # (send nil :foo
142
- # (hash
143
- # (pair
144
- # (sym :bar)
145
- # (int 42))))
146
- # ```
147
- #
148
- # If set to true it is emitted as `kwargs`:
149
- #
150
- # ```
151
- # (send nil :foo
152
- # (kwargs
153
- # (pair
154
- # (sym :bar)
155
- # (int 42))))
156
- # ```
157
- #
158
- # Note that `kwargs` node is just a replacement for `hash` argument,
159
- # so if there's are multiple arguments (or a `kwsplat`) all of them
160
- # are wrapped into `kwargs` instead of `hash`:
161
- #
162
- # ```
163
- # (send nil :foo
164
- # (kwargs
165
- # (pair
166
- # (sym :a)
167
- # (int 42))
168
- # (kwsplat
169
- # (send nil :b))
170
- # (pair
171
- # (sym :c)
172
- # (int 10))))
173
- # ```
174
- attr_accessor :emit_kwargs
175
- end
176
-
177
- @emit_kwargs = false
178
-
179
- class << self
180
- ##
181
- # AST compatibility attribute; Starting from 3.0 Ruby returns
182
- # true/false from single-line pattern matching with `in` keyword.
183
- #
184
- # Before 3.0 there was an exception if given value doesn't match pattern.
185
- #
186
- # NOTE: This attribute affects only Ruby 2.7 grammar.
187
- # 3.0 grammar always emits `match_pattern`/`match_pattern_p`
188
- #
189
- # If compatibility attribute set to false `foo in bar` is emitted as `in_match`:
190
- #
191
- # ```
192
- # (in-match
193
- # (send nil :foo)
194
- # (match-var :bar))
195
- # ```
196
- #
197
- # If set to true it's emitted as `match_pattern_p`:
198
- # ```
199
- # (match-pattern-p
200
- # (send nil :foo)
201
- # (match-var :bar))
202
- # ```
203
- attr_accessor :emit_match_pattern
204
- end
205
-
206
- @emit_match_pattern = false
207
-
208
- class << self
209
- ##
210
- # @api private
211
- def modernize
212
- @emit_lambda = true
213
- @emit_procarg0 = true
214
- @emit_encoding = true
215
- @emit_index = true
216
- @emit_arg_inside_procarg0 = true
217
- @emit_forward_arg = true
218
- @emit_kwargs = true
219
- @emit_match_pattern = true
220
- end
221
- end
222
-
223
- ##
224
- # @api private
225
- attr_accessor :parser
226
-
227
- ##
228
- # If set to true (the default), `__FILE__` and `__LINE__` are transformed to
229
- # literal nodes. For example, `s(:str, "lib/foo.rb")` and `s(:int, 10)`.
230
- #
231
- # If set to false, `__FILE__` and `__LINE__` are emitted as-is,
232
- # i.e. as `s(:__FILE__)` and `s(:__LINE__)` nodes.
233
- #
234
- # Source maps are identical in both cases.
235
- #
236
- # @return [Boolean]
237
- attr_accessor :emit_file_line_as_literals
238
-
239
- ##
240
- # Initializes attributes:
241
- #
242
- # * `emit_file_line_as_literals`: `true`
243
- def initialize
244
- @emit_file_line_as_literals = true
245
- end
246
-
247
- # @!parse private
248
-
249
- #
250
- # Literals
251
- #
252
-
253
- # Singletons
254
-
255
- def nil(nil_t)
256
- n0(:nil,
257
- token_map(nil_t))
258
- end
259
-
260
- def true(true_t)
261
- n0(:true,
262
- token_map(true_t))
263
- end
264
-
265
- def false(false_t)
266
- n0(:false,
267
- token_map(false_t))
268
- end
269
-
270
- # Numerics
271
-
272
- def integer(integer_t)
273
- numeric(:int, integer_t)
274
- end
275
-
276
- def float(float_t)
277
- numeric(:float, float_t)
278
- end
279
-
280
- def rational(rational_t)
281
- numeric(:rational, rational_t)
282
- end
283
-
284
- def complex(complex_t)
285
- numeric(:complex, complex_t)
286
- end
287
-
288
- def numeric(kind, token)
289
- n(kind, [ value(token) ],
290
- Source::Map::Operator.new(nil, loc(token)))
291
- end
292
- private :numeric
293
-
294
- def unary_num(unary_t, numeric)
295
- value, = *numeric
296
- operator_loc = loc(unary_t)
297
-
298
- case value(unary_t)
299
- when '+'
300
- value = +value
301
- when '-'
302
- value = -value
303
- end
304
-
305
- numeric.updated(nil, [ value ],
306
- :location =>
307
- Source::Map::Operator.new(
308
- operator_loc,
309
- operator_loc.join(numeric.loc.expression)))
310
- end
311
-
312
- def __LINE__(__LINE__t)
313
- n0(:__LINE__,
314
- token_map(__LINE__t))
315
- end
316
-
317
- # Strings
318
-
319
- def string(string_t)
320
- n(:str, [ string_value(string_t) ],
321
- delimited_string_map(string_t))
322
- end
323
-
324
- def string_internal(string_t)
325
- n(:str, [ string_value(string_t) ],
326
- unquoted_map(string_t))
327
- end
328
-
329
- def string_compose(begin_t, parts, end_t)
330
- if collapse_string_parts?(parts)
331
- if begin_t.nil? && end_t.nil?
332
- parts.first
333
- else
334
- n(:str, parts.first.children,
335
- string_map(begin_t, parts, end_t))
336
- end
337
- else
338
- n(:dstr, [ *parts ],
339
- string_map(begin_t, parts, end_t))
340
- end
341
- end
342
-
343
- def character(char_t)
344
- n(:str, [ string_value(char_t) ],
345
- prefix_string_map(char_t))
346
- end
347
-
348
- def __FILE__(__FILE__t)
349
- n0(:__FILE__,
350
- token_map(__FILE__t))
351
- end
352
-
353
- # Symbols
354
-
355
- def symbol(symbol_t)
356
- n(:sym, [ string_value(symbol_t).to_sym ],
357
- prefix_string_map(symbol_t))
358
- end
359
-
360
- def symbol_internal(symbol_t)
361
- n(:sym, [ string_value(symbol_t).to_sym ],
362
- unquoted_map(symbol_t))
363
- end
364
-
365
- def symbol_compose(begin_t, parts, end_t)
366
- if collapse_string_parts?(parts)
367
- str = parts.first
368
-
369
- n(:sym, [ str.children.first.to_sym ],
370
- collection_map(begin_t, str.loc.expression, end_t))
371
- elsif @parser.version == 18 && parts.empty?
372
- diagnostic :error, :empty_symbol, nil, loc(begin_t).join(loc(end_t))
373
- else
374
- n(:dsym, [ *parts ],
375
- collection_map(begin_t, parts, end_t))
376
- end
377
- end
378
-
379
- # Executable strings
380
-
381
- def xstring_compose(begin_t, parts, end_t)
382
- n(:xstr, [ *parts ],
383
- string_map(begin_t, parts, end_t))
384
- end
385
-
386
- # Indented (interpolated, noninterpolated, executable) strings
387
-
388
- def dedent_string(node, dedent_level)
389
- if !dedent_level.nil?
390
- dedenter = Lexer::Dedenter.new(dedent_level)
391
-
392
- case node.type
393
- when :str
394
- str = node.children.first
395
- dedenter.dedent(str)
396
- when :dstr, :xstr
397
- children = node.children.map do |str_node|
398
- if str_node.type == :str
399
- str = str_node.children.first
400
- dedenter.dedent(str)
401
- next nil if str.empty?
402
- else
403
- dedenter.interrupt
404
- end
405
- str_node
406
- end
407
-
408
- node = node.updated(nil, children.compact)
409
- end
410
- end
411
-
412
- node
413
- end
414
-
415
- # Regular expressions
416
-
417
- def regexp_options(regopt_t)
418
- options = value(regopt_t).
419
- each_char.sort.uniq.
420
- map(&:to_sym)
421
-
422
- n(:regopt, options,
423
- token_map(regopt_t))
424
- end
425
-
426
- def regexp_compose(begin_t, parts, end_t, options)
427
- begin
428
- static_regexp(parts, options)
429
- rescue RegexpError, Encoding::UndefinedConversionError => e
430
- diagnostic :error, :invalid_regexp, { :message => e.message },
431
- loc(begin_t).join(loc(end_t))
432
- end
433
-
434
- n(:regexp, (parts << options),
435
- regexp_map(begin_t, end_t, options))
436
- end
437
-
438
- # Arrays
439
-
440
- def array(begin_t, elements, end_t)
441
- n(:array, elements,
442
- collection_map(begin_t, elements, end_t))
443
- end
444
-
445
- def splat(star_t, arg=nil)
446
- if arg.nil?
447
- n0(:splat,
448
- unary_op_map(star_t))
449
- else
450
- n(:splat, [ arg ],
451
- unary_op_map(star_t, arg))
452
- end
453
- end
454
-
455
- def word(parts)
456
- if collapse_string_parts?(parts)
457
- parts.first
458
- else
459
- n(:dstr, [ *parts ],
460
- collection_map(nil, parts, nil))
461
- end
462
- end
463
-
464
- def words_compose(begin_t, parts, end_t)
465
- n(:array, [ *parts ],
466
- collection_map(begin_t, parts, end_t))
467
- end
468
-
469
- def symbols_compose(begin_t, parts, end_t)
470
- parts = parts.map do |part|
471
- case part.type
472
- when :str
473
- value, = *part
474
- part.updated(:sym, [ value.to_sym ])
475
- when :dstr
476
- part.updated(:dsym)
477
- else
478
- part
479
- end
480
- end
481
-
482
- n(:array, [ *parts ],
483
- collection_map(begin_t, parts, end_t))
484
- end
485
-
486
- # Hashes
487
-
488
- def pair(key, assoc_t, value)
489
- n(:pair, [ key, value ],
490
- binary_op_map(key, assoc_t, value))
491
- end
492
-
493
- def pair_list_18(list)
494
- if list.size % 2 != 0
495
- diagnostic :error, :odd_hash, nil, list.last.loc.expression
496
- else
497
- list.
498
- each_slice(2).map do |key, value|
499
- n(:pair, [ key, value ],
500
- binary_op_map(key, nil, value))
501
- end
502
- end
503
- end
504
-
505
- def pair_keyword(key_t, value)
506
- key_map, pair_map = pair_keyword_map(key_t, value)
507
-
508
- key = n(:sym, [ value(key_t).to_sym ], key_map)
509
-
510
- n(:pair, [ key, value ], pair_map)
511
- end
512
-
513
- def pair_quoted(begin_t, parts, end_t, value)
514
- end_t, pair_map = pair_quoted_map(begin_t, end_t, value)
515
-
516
- key = symbol_compose(begin_t, parts, end_t)
517
-
518
- n(:pair, [ key, value ], pair_map)
519
- end
520
-
521
- def pair_label(key_t)
522
- key_l = loc(key_t)
523
- value_l = key_l.adjust(end_pos: -1)
524
-
525
- label = value(key_t)
526
- value =
527
- if label =~ /\A[[:upper:]]/
528
- n(:const, [ nil, label.to_sym ], Source::Map::Constant.new(nil, value_l, value_l))
529
- else
530
- n(:ident, [ label.to_sym ], Source::Map::Variable.new(value_l))
531
- end
532
- pair_keyword(key_t, accessible(value))
533
- end
534
-
535
- def kwsplat(dstar_t, arg)
536
- n(:kwsplat, [ arg ],
537
- unary_op_map(dstar_t, arg))
538
- end
539
-
540
- def associate(begin_t, pairs, end_t)
541
- key_set = Set.new
542
-
543
- pairs.each do |pair|
544
- next unless pair.type.eql?(:pair)
545
-
546
- key, = *pair
547
-
548
- case key.type
549
- when :sym, :str, :int, :float
550
- when :rational, :complex, :regexp
551
- next unless @parser.version >= 31
552
- else
553
- next
554
- end
555
-
556
- unless key_set.add?(key)
557
- diagnostic :warning, :duplicate_hash_key, nil, key.loc.expression
558
- end
559
- end
560
-
561
- n(:hash, [ *pairs ],
562
- collection_map(begin_t, pairs, end_t))
563
- end
564
-
565
- # Ranges
566
-
567
- def range_inclusive(lhs, dot2_t, rhs)
568
- n(:irange, [ lhs, rhs ],
569
- range_map(lhs, dot2_t, rhs))
570
- end
571
-
572
- def range_exclusive(lhs, dot3_t, rhs)
573
- n(:erange, [ lhs, rhs ],
574
- range_map(lhs, dot3_t, rhs))
575
- end
576
-
577
- #
578
- # Access
579
- #
580
-
581
- def self(token)
582
- n0(:self,
583
- token_map(token))
584
- end
585
-
586
- def ident(token)
587
- n(:ident, [ value(token).to_sym ],
588
- variable_map(token))
589
- end
590
-
591
- def ivar(token)
592
- n(:ivar, [ value(token).to_sym ],
593
- variable_map(token))
594
- end
595
-
596
- def gvar(token)
597
- gvar_name = value(token)
598
-
599
- if gvar_name.start_with?('$0') && gvar_name.length > 2
600
- diagnostic :error, :gvar_name, { :name => gvar_name }, loc(token)
601
- end
602
-
603
- n(:gvar, [ gvar_name.to_sym ],
604
- variable_map(token))
605
- end
606
-
607
- def cvar(token)
608
- n(:cvar, [ value(token).to_sym ],
609
- variable_map(token))
610
- end
611
-
612
- def back_ref(token)
613
- n(:back_ref, [ value(token).to_sym ],
614
- token_map(token))
615
- end
616
-
617
- def nth_ref(token)
618
- n(:nth_ref, [ value(token) ],
619
- token_map(token))
620
- end
621
-
622
- def accessible(node)
623
- case node.type
624
- when :__FILE__
625
- if @emit_file_line_as_literals
626
- n(:str, [ node.loc.expression.source_buffer.name ],
627
- node.loc.dup)
628
- else
629
- node
630
- end
631
-
632
- when :__LINE__
633
- if @emit_file_line_as_literals
634
- n(:int, [ node.loc.expression.line ],
635
- node.loc.dup)
636
- else
637
- node
638
- end
639
-
640
- when :__ENCODING__
641
- if !self.class.emit_encoding
642
- n(:const, [ n(:const, [ nil, :Encoding], nil), :UTF_8 ],
643
- node.loc.dup)
644
- else
645
- node
646
- end
647
-
648
- when :ident
649
- name, = *node
650
-
651
- if %w[? !].any? { |c| name.to_s.end_with?(c) }
652
- diagnostic :error, :invalid_id_to_get,
653
- { :identifier => name.to_s }, node.loc.expression
654
- end
655
-
656
- # Numbered parameters are not declared anywhere,
657
- # so they take precedence over method calls in numblock contexts
658
- if @parser.version >= 27 && @parser.try_declare_numparam(node)
659
- return node.updated(:lvar)
660
- end
661
-
662
- unless @parser.static_env.declared?(name)
663
- if @parser.version == 33 &&
664
- name == :it &&
665
- @parser.context.in_block &&
666
- !@parser.max_numparam_stack.has_ordinary_params?
667
- diagnostic :warning, :ambiguous_it_call, nil, node.loc.expression
668
- end
669
-
670
- return n(:send, [ nil, name ],
671
- var_send_map(node))
672
- end
673
-
674
- if name.to_s == parser.current_arg_stack.top
675
- diagnostic :error, :circular_argument_reference,
676
- { :var_name => name.to_s }, node.loc.expression
677
- end
678
-
679
- node.updated(:lvar)
680
-
681
- else
682
- node
683
- end
684
- end
685
-
686
- def const(name_t)
687
- n(:const, [ nil, value(name_t).to_sym ],
688
- constant_map(nil, nil, name_t))
689
- end
690
-
691
- def const_global(t_colon3, name_t)
692
- cbase = n0(:cbase, token_map(t_colon3))
693
-
694
- n(:const, [ cbase, value(name_t).to_sym ],
695
- constant_map(cbase, t_colon3, name_t))
696
- end
697
-
698
- def const_fetch(scope, t_colon2, name_t)
699
- n(:const, [ scope, value(name_t).to_sym ],
700
- constant_map(scope, t_colon2, name_t))
701
- end
702
-
703
- def __ENCODING__(__ENCODING__t)
704
- n0(:__ENCODING__,
705
- token_map(__ENCODING__t))
706
- end
707
-
708
- #
709
- # Assignment
710
- #
711
-
712
- def assignable(node)
713
- case node.type
714
- when :cvar
715
- node.updated(:cvasgn)
716
-
717
- when :ivar
718
- node.updated(:ivasgn)
719
-
720
- when :gvar
721
- node.updated(:gvasgn)
722
-
723
- when :const
724
- if @parser.context.in_def
725
- diagnostic :error, :dynamic_const, nil, node.loc.expression
726
- end
727
-
728
- node.updated(:casgn)
729
-
730
- when :ident
731
- name, = *node
732
-
733
- var_name = node.children[0].to_s
734
- name_loc = node.loc.expression
735
-
736
- check_assignment_to_numparam(var_name, name_loc)
737
- check_reserved_for_numparam(var_name, name_loc)
738
-
739
- @parser.static_env.declare(name)
740
-
741
- node.updated(:lvasgn)
742
-
743
- when :match_var
744
- name, = *node
745
-
746
- var_name = node.children[0].to_s
747
- name_loc = node.loc.expression
748
-
749
- check_assignment_to_numparam(var_name, name_loc)
750
- check_reserved_for_numparam(var_name, name_loc)
751
-
752
- node
753
-
754
- when :nil, :self, :true, :false,
755
- :__FILE__, :__LINE__, :__ENCODING__
756
- diagnostic :error, :invalid_assignment, nil, node.loc.expression
757
-
758
- when :back_ref, :nth_ref
759
- diagnostic :error, :backref_assignment, nil, node.loc.expression
760
- end
761
- end
762
-
763
- def const_op_assignable(node)
764
- node.updated(:casgn)
765
- end
766
-
767
- def assign(lhs, eql_t, rhs)
768
- (lhs << rhs).updated(nil, nil,
769
- :location => lhs.loc.
770
- with_operator(loc(eql_t)).
771
- with_expression(join_exprs(lhs, rhs)))
772
- end
773
-
774
- def op_assign(lhs, op_t, rhs)
775
- case lhs.type
776
- when :gvasgn, :ivasgn, :lvasgn, :cvasgn, :casgn, :send, :csend, :index
777
- operator = value(op_t)[0..-1].to_sym
778
- source_map = lhs.loc.
779
- with_operator(loc(op_t)).
780
- with_expression(join_exprs(lhs, rhs))
781
-
782
- if lhs.type == :index
783
- lhs = lhs.updated(:indexasgn)
784
- end
785
-
786
- case operator
787
- when :'&&'
788
- n(:and_asgn, [ lhs, rhs ], source_map)
789
- when :'||'
790
- n(:or_asgn, [ lhs, rhs ], source_map)
791
- else
792
- n(:op_asgn, [ lhs, operator, rhs ], source_map)
793
- end
794
-
795
- when :back_ref, :nth_ref
796
- diagnostic :error, :backref_assignment, nil, lhs.loc.expression
797
- end
798
- end
799
-
800
- def multi_lhs(begin_t, items, end_t)
801
- n(:mlhs, [ *items ],
802
- collection_map(begin_t, items, end_t))
803
- end
804
-
805
- def multi_assign(lhs, eql_t, rhs)
806
- n(:masgn, [ lhs, rhs ],
807
- binary_op_map(lhs, eql_t, rhs))
808
- end
809
-
810
- #
811
- # Class and module definition
812
- #
813
-
814
- def def_class(class_t, name,
815
- lt_t, superclass,
816
- body, end_t)
817
- n(:class, [ name, superclass, body ],
818
- module_definition_map(class_t, name, lt_t, end_t))
819
- end
820
-
821
- def def_sclass(class_t, lshft_t, expr,
822
- body, end_t)
823
- n(:sclass, [ expr, body ],
824
- module_definition_map(class_t, nil, lshft_t, end_t))
825
- end
826
-
827
- def def_module(module_t, name,
828
- body, end_t)
829
- n(:module, [ name, body ],
830
- module_definition_map(module_t, name, nil, end_t))
831
- end
832
-
833
- #
834
- # Method (un)definition
835
- #
836
-
837
- def def_method(def_t, name_t, args,
838
- body, end_t)
839
- check_reserved_for_numparam(value(name_t), loc(name_t))
840
-
841
- n(:def, [ value(name_t).to_sym, args, body ],
842
- definition_map(def_t, nil, name_t, end_t))
843
- end
844
-
845
- def def_endless_method(def_t, name_t, args,
846
- assignment_t, body)
847
- check_reserved_for_numparam(value(name_t), loc(name_t))
848
-
849
- n(:def, [ value(name_t).to_sym, args, body ],
850
- endless_definition_map(def_t, nil, name_t, assignment_t, body))
851
- end
852
-
853
- def def_singleton(def_t, definee, dot_t,
854
- name_t, args,
855
- body, end_t)
856
- validate_definee(definee)
857
- check_reserved_for_numparam(value(name_t), loc(name_t))
858
-
859
- n(:defs, [ definee, value(name_t).to_sym, args, body ],
860
- definition_map(def_t, dot_t, name_t, end_t))
861
- end
862
-
863
- def def_endless_singleton(def_t, definee, dot_t,
864
- name_t, args,
865
- assignment_t, body)
866
- validate_definee(definee)
867
- check_reserved_for_numparam(value(name_t), loc(name_t))
868
-
869
- n(:defs, [ definee, value(name_t).to_sym, args, body ],
870
- endless_definition_map(def_t, dot_t, name_t, assignment_t, body))
871
- end
872
-
873
- def undef_method(undef_t, names)
874
- n(:undef, [ *names ],
875
- keyword_map(undef_t, nil, names, nil))
876
- end
877
-
878
- def alias(alias_t, to, from)
879
- n(:alias, [ to, from ],
880
- keyword_map(alias_t, nil, [to, from], nil))
881
- end
882
-
883
- #
884
- # Formal arguments
885
- #
886
-
887
- def args(begin_t, args, end_t, check_args=true)
888
- args = check_duplicate_args(args) if check_args
889
- validate_no_forward_arg_after_restarg(args)
890
-
891
- map = collection_map(begin_t, args, end_t)
892
- if !self.class.emit_forward_arg && args.length == 1 && args[0].type == :forward_arg
893
- n(:forward_args, [], map)
894
- else
895
- n(:args, args, map)
896
- end
897
- end
898
-
899
- def numargs(max_numparam)
900
- n(:numargs, [ max_numparam ], nil)
901
- end
902
-
903
- def forward_only_args(begin_t, dots_t, end_t)
904
- if self.class.emit_forward_arg
905
- arg = forward_arg(dots_t)
906
- n(:args, [ arg ],
907
- collection_map(begin_t, [ arg ], end_t))
908
- else
909
- n(:forward_args, [], collection_map(begin_t, token_map(dots_t), end_t))
910
- end
911
- end
912
-
913
- def forward_arg(dots_t)
914
- n(:forward_arg, [], token_map(dots_t))
915
- end
916
-
917
- def arg(name_t)
918
- check_reserved_for_numparam(value(name_t), loc(name_t))
919
-
920
- n(:arg, [ value(name_t).to_sym ],
921
- variable_map(name_t))
922
- end
923
-
924
- def optarg(name_t, eql_t, value)
925
- check_reserved_for_numparam(value(name_t), loc(name_t))
926
-
927
- n(:optarg, [ value(name_t).to_sym, value ],
928
- variable_map(name_t).
929
- with_operator(loc(eql_t)).
930
- with_expression(loc(name_t).join(value.loc.expression)))
931
- end
932
-
933
- def restarg(star_t, name_t=nil)
934
- if name_t
935
- check_reserved_for_numparam(value(name_t), loc(name_t))
936
- n(:restarg, [ value(name_t).to_sym ],
937
- arg_prefix_map(star_t, name_t))
938
- else
939
- n0(:restarg,
940
- arg_prefix_map(star_t))
941
- end
942
- end
943
-
944
- def kwarg(name_t)
945
- check_reserved_for_numparam(value(name_t), loc(name_t))
946
-
947
- n(:kwarg, [ value(name_t).to_sym ],
948
- kwarg_map(name_t))
949
- end
950
-
951
- def kwoptarg(name_t, value)
952
- check_reserved_for_numparam(value(name_t), loc(name_t))
953
-
954
- n(:kwoptarg, [ value(name_t).to_sym, value ],
955
- kwarg_map(name_t, value))
956
- end
957
-
958
- def kwrestarg(dstar_t, name_t=nil)
959
- if name_t
960
- check_reserved_for_numparam(value(name_t), loc(name_t))
961
-
962
- n(:kwrestarg, [ value(name_t).to_sym ],
963
- arg_prefix_map(dstar_t, name_t))
964
- else
965
- n0(:kwrestarg,
966
- arg_prefix_map(dstar_t))
967
- end
968
- end
969
-
970
- def kwnilarg(dstar_t, nil_t)
971
- n0(:kwnilarg,
972
- arg_prefix_map(dstar_t, nil_t))
973
- end
974
-
975
- def shadowarg(name_t)
976
- check_reserved_for_numparam(value(name_t), loc(name_t))
977
-
978
- n(:shadowarg, [ value(name_t).to_sym ],
979
- variable_map(name_t))
980
- end
981
-
982
- def blockarg(amper_t, name_t)
983
- if !name_t.nil?
984
- check_reserved_for_numparam(value(name_t), loc(name_t))
985
- end
986
-
987
- arg_name = name_t ? value(name_t).to_sym : nil
988
- n(:blockarg, [ arg_name ],
989
- arg_prefix_map(amper_t, name_t))
990
- end
991
-
992
- def procarg0(arg)
993
- if self.class.emit_procarg0
994
- if arg.type == :arg && self.class.emit_arg_inside_procarg0
995
- n(:procarg0, [ arg ],
996
- Source::Map::Collection.new(nil, nil, arg.location.expression))
997
- else
998
- arg.updated(:procarg0)
999
- end
1000
- else
1001
- arg
1002
- end
1003
- end
1004
-
1005
- # Ruby 1.8 block arguments
1006
-
1007
- def arg_expr(expr)
1008
- if expr.type == :lvasgn
1009
- expr.updated(:arg)
1010
- else
1011
- n(:arg_expr, [ expr ],
1012
- expr.loc.dup)
1013
- end
1014
- end
1015
-
1016
- def restarg_expr(star_t, expr=nil)
1017
- if expr.nil?
1018
- n0(:restarg, token_map(star_t))
1019
- elsif expr.type == :lvasgn
1020
- expr.updated(:restarg)
1021
- else
1022
- n(:restarg_expr, [ expr ],
1023
- expr.loc.dup)
1024
- end
1025
- end
1026
-
1027
- def blockarg_expr(amper_t, expr)
1028
- if expr.type == :lvasgn
1029
- expr.updated(:blockarg)
1030
- else
1031
- n(:blockarg_expr, [ expr ],
1032
- expr.loc.dup)
1033
- end
1034
- end
1035
-
1036
- # MacRuby Objective-C arguments
1037
-
1038
- def objc_kwarg(kwname_t, assoc_t, name_t)
1039
- kwname_l = loc(kwname_t)
1040
- if assoc_t.nil? # a: b, not a => b
1041
- kwname_l = kwname_l.resize(kwname_l.size - 1)
1042
- operator_l = kwname_l.end.resize(1)
1043
- else
1044
- operator_l = loc(assoc_t)
1045
- end
1046
-
1047
- n(:objc_kwarg, [ value(kwname_t).to_sym, value(name_t).to_sym ],
1048
- Source::Map::ObjcKwarg.new(kwname_l, operator_l, loc(name_t),
1049
- kwname_l.join(loc(name_t))))
1050
- end
1051
-
1052
- def objc_restarg(star_t, name=nil)
1053
- if name.nil?
1054
- n0(:restarg, arg_prefix_map(star_t))
1055
- elsif name.type == :arg # regular restarg
1056
- name.updated(:restarg, nil,
1057
- { :location => name.loc.with_operator(loc(star_t)) })
1058
- else # restarg with objc_kwarg inside
1059
- n(:objc_restarg, [ name ],
1060
- unary_op_map(star_t, name))
1061
- end
1062
- end
1063
-
1064
- #
1065
- # Method calls
1066
- #
1067
-
1068
- def call_type_for_dot(dot_t)
1069
- if !dot_t.nil? && value(dot_t) == :anddot
1070
- :csend
1071
- else
1072
- # This case is a bit tricky. ruby23.y returns the token tDOT with
1073
- # the value :dot, and the token :tANDDOT with the value :anddot.
1074
- #
1075
- # But, ruby{18..22}.y (which unconditionally expect tDOT) just
1076
- # return "." there, since they are to be kept close to the corresponding
1077
- # Ruby MRI grammars.
1078
- #
1079
- # Thankfully, we don't have to care.
1080
- :send
1081
- end
1082
- end
1083
-
1084
- def forwarded_args(dots_t)
1085
- n(:forwarded_args, [], token_map(dots_t))
1086
- end
1087
-
1088
- def forwarded_restarg(star_t)
1089
- n(:forwarded_restarg, [], token_map(star_t))
1090
- end
1091
-
1092
- def forwarded_kwrestarg(dstar_t)
1093
- n(:forwarded_kwrestarg, [], token_map(dstar_t))
1094
- end
1095
-
1096
- def call_method(receiver, dot_t, selector_t,
1097
- lparen_t=nil, args=[], rparen_t=nil)
1098
- type = call_type_for_dot(dot_t)
1099
-
1100
- if self.class.emit_kwargs
1101
- rewrite_hash_args_to_kwargs(args)
1102
- end
1103
-
1104
- if selector_t.nil?
1105
- n(type, [ receiver, :call, *args ],
1106
- send_map(receiver, dot_t, nil, lparen_t, args, rparen_t))
1107
- else
1108
- n(type, [ receiver, value(selector_t).to_sym, *args ],
1109
- send_map(receiver, dot_t, selector_t, lparen_t, args, rparen_t))
1110
- end
1111
- end
1112
-
1113
- def call_lambda(lambda_t)
1114
- if self.class.emit_lambda
1115
- n0(:lambda, expr_map(loc(lambda_t)))
1116
- else
1117
- n(:send, [ nil, :lambda ],
1118
- send_map(nil, nil, lambda_t))
1119
- end
1120
- end
1121
-
1122
- def block(method_call, begin_t, args, body, end_t)
1123
- if method_call.type == :yield
1124
- diagnostic :error, :block_given_to_yield, nil, method_call.loc.keyword, [loc(begin_t)]
1125
- end
1126
-
1127
- if method_call.type == :super
1128
- *_args, last_arg = *method_call
1129
- else
1130
- _receiver, _selector, *_args, last_arg = *method_call
1131
- end
1132
- if last_arg && (last_arg.type == :block_pass || last_arg.type == :forwarded_args)
1133
- if (@parser.version == 33 && method_call.type != :super) || @parser.version != 33
1134
- diagnostic :error, :block_and_blockarg, nil, last_arg.loc.expression, [loc(begin_t)]
1135
- end
1136
- end
1137
-
1138
- if args.type == :numargs
1139
- block_type = :numblock
1140
- args = args.children[0]
1141
- else
1142
- block_type = :block
1143
- end
1144
-
1145
- if [:send, :csend, :index, :super, :zsuper, :lambda].include?(method_call.type)
1146
- n(block_type, [ method_call, args, body ],
1147
- block_map(method_call.loc.expression, begin_t, end_t))
1148
- else
1149
- # Code like "return foo 1 do end" is reduced in a weird sequence.
1150
- # Here, method_call is actually (return).
1151
- actual_send, = *method_call
1152
- block =
1153
- n(block_type, [ actual_send, args, body ],
1154
- block_map(actual_send.loc.expression, begin_t, end_t))
1155
-
1156
- n(method_call.type, [ block ],
1157
- method_call.loc.with_expression(join_exprs(method_call, block)))
1158
- end
1159
- end
1160
-
1161
- def block_pass(amper_t, arg)
1162
- n(:block_pass, [ arg ],
1163
- unary_op_map(amper_t, arg))
1164
- end
1165
-
1166
- def objc_varargs(pair, rest_of_varargs)
1167
- value, first_vararg = *pair
1168
- vararg_array = array(nil, [ first_vararg, *rest_of_varargs ], nil).
1169
- updated(:objc_varargs)
1170
- pair.updated(nil, [ value, vararg_array ],
1171
- { :location => pair.loc.with_expression(
1172
- pair.loc.expression.join(vararg_array.loc.expression)) })
1173
- end
1174
-
1175
- def attr_asgn(receiver, dot_t, selector_t)
1176
- method_name = (value(selector_t) + '=').to_sym
1177
- type = call_type_for_dot(dot_t)
1178
-
1179
- # Incomplete method call.
1180
- n(type, [ receiver, method_name ],
1181
- send_map(receiver, dot_t, selector_t))
1182
- end
1183
-
1184
- def index(receiver, lbrack_t, indexes, rbrack_t)
1185
- if self.class.emit_kwargs
1186
- rewrite_hash_args_to_kwargs(indexes)
1187
- end
1188
-
1189
- if self.class.emit_index
1190
- n(:index, [ receiver, *indexes ],
1191
- index_map(receiver, lbrack_t, rbrack_t))
1192
- else
1193
- n(:send, [ receiver, :[], *indexes ],
1194
- send_index_map(receiver, lbrack_t, rbrack_t))
1195
- end
1196
- end
1197
-
1198
- def index_asgn(receiver, lbrack_t, indexes, rbrack_t)
1199
- if self.class.emit_kwargs
1200
- rewrite_hash_args_to_kwargs(indexes)
1201
- end
1202
-
1203
- if self.class.emit_index
1204
- n(:indexasgn, [ receiver, *indexes ],
1205
- index_map(receiver, lbrack_t, rbrack_t))
1206
- else
1207
- # Incomplete method call.
1208
- n(:send, [ receiver, :[]=, *indexes ],
1209
- send_index_map(receiver, lbrack_t, rbrack_t))
1210
- end
1211
- end
1212
-
1213
- def binary_op(receiver, operator_t, arg)
1214
- source_map = send_binary_op_map(receiver, operator_t, arg)
1215
-
1216
- if @parser.version == 18
1217
- operator = value(operator_t)
1218
-
1219
- if operator == '!='
1220
- method_call = n(:send, [ receiver, :==, arg ], source_map)
1221
- elsif operator == '!~'
1222
- method_call = n(:send, [ receiver, :=~, arg ], source_map)
1223
- end
1224
-
1225
- if %w(!= !~).include?(operator)
1226
- return n(:not, [ method_call ],
1227
- expr_map(source_map.expression))
1228
- end
1229
- end
1230
-
1231
- n(:send, [ receiver, value(operator_t).to_sym, arg ],
1232
- source_map)
1233
- end
1234
-
1235
- def match_op(receiver, match_t, arg)
1236
- source_map = send_binary_op_map(receiver, match_t, arg)
1237
-
1238
- if (regexp = static_regexp_node(receiver))
1239
- regexp.names.each do |name|
1240
- @parser.static_env.declare(name)
1241
- end
1242
-
1243
- n(:match_with_lvasgn, [ receiver, arg ],
1244
- source_map)
1245
- else
1246
- n(:send, [ receiver, :=~, arg ],
1247
- source_map)
1248
- end
1249
- end
1250
-
1251
- def unary_op(op_t, receiver)
1252
- case value(op_t)
1253
- when '+', '-'
1254
- method = value(op_t) + '@'
1255
- else
1256
- method = value(op_t)
1257
- end
1258
-
1259
- n(:send, [ receiver, method.to_sym ],
1260
- send_unary_op_map(op_t, receiver))
1261
- end
1262
-
1263
- def not_op(not_t, begin_t=nil, receiver=nil, end_t=nil)
1264
- if @parser.version == 18
1265
- n(:not, [ check_condition(receiver) ],
1266
- unary_op_map(not_t, receiver))
1267
- else
1268
- if receiver.nil?
1269
- nil_node = n0(:begin, collection_map(begin_t, nil, end_t))
1270
-
1271
- n(:send, [
1272
- nil_node, :'!'
1273
- ], send_unary_op_map(not_t, nil_node))
1274
- else
1275
- n(:send, [ check_condition(receiver), :'!' ],
1276
- send_map(nil, nil, not_t, begin_t, [receiver], end_t))
1277
- end
1278
- end
1279
- end
1280
-
1281
- #
1282
- # Control flow
1283
- #
1284
-
1285
- # Logical operations: and, or
1286
-
1287
- def logical_op(type, lhs, op_t, rhs)
1288
- n(type, [ lhs, rhs ],
1289
- binary_op_map(lhs, op_t, rhs))
1290
- end
1291
-
1292
- # Conditionals
1293
-
1294
- def condition(cond_t, cond, then_t,
1295
- if_true, else_t, if_false, end_t)
1296
- n(:if, [ check_condition(cond), if_true, if_false ],
1297
- condition_map(cond_t, cond, then_t, if_true, else_t, if_false, end_t))
1298
- end
1299
-
1300
- def condition_mod(if_true, if_false, cond_t, cond)
1301
- n(:if, [ check_condition(cond), if_true, if_false ],
1302
- keyword_mod_map(if_true || if_false, cond_t, cond))
1303
- end
1304
-
1305
- def ternary(cond, question_t, if_true, colon_t, if_false)
1306
- n(:if, [ check_condition(cond), if_true, if_false ],
1307
- ternary_map(cond, question_t, if_true, colon_t, if_false))
1308
- end
1309
-
1310
- # Case matching
1311
-
1312
- def when(when_t, patterns, then_t, body)
1313
- children = patterns << body
1314
- n(:when, children,
1315
- keyword_map(when_t, then_t, children, nil))
1316
- end
1317
-
1318
- def case(case_t, expr, when_bodies, else_t, else_body, end_t)
1319
- n(:case, [ expr, *(when_bodies << else_body)],
1320
- condition_map(case_t, expr, nil, nil, else_t, else_body, end_t))
1321
- end
1322
-
1323
- # Loops
1324
-
1325
- def loop(type, keyword_t, cond, do_t, body, end_t)
1326
- n(type, [ check_condition(cond), body ],
1327
- keyword_map(keyword_t, do_t, nil, end_t))
1328
- end
1329
-
1330
- def loop_mod(type, body, keyword_t, cond)
1331
- if body.type == :kwbegin
1332
- type = :"#{type}_post"
1333
- end
1334
-
1335
- n(type, [ check_condition(cond), body ],
1336
- keyword_mod_map(body, keyword_t, cond))
1337
- end
1338
-
1339
- def for(for_t, iterator, in_t, iteratee,
1340
- do_t, body, end_t)
1341
- n(:for, [ iterator, iteratee, body ],
1342
- for_map(for_t, in_t, do_t, end_t))
1343
- end
1344
-
1345
- # Keywords
1346
-
1347
- def keyword_cmd(type, keyword_t, lparen_t=nil, args=[], rparen_t=nil)
1348
- if type == :yield && args.count > 0
1349
- last_arg = args.last
1350
- if last_arg.type == :block_pass
1351
- diagnostic :error, :block_given_to_yield, nil, loc(keyword_t), [last_arg.loc.expression]
1352
- end
1353
- end
1354
-
1355
- if %i[yield super].include?(type) && self.class.emit_kwargs
1356
- rewrite_hash_args_to_kwargs(args)
1357
- end
1358
-
1359
- n(type, args,
1360
- keyword_map(keyword_t, lparen_t, args, rparen_t))
1361
- end
1362
-
1363
- # BEGIN, END
1364
-
1365
- def preexe(preexe_t, lbrace_t, compstmt, rbrace_t)
1366
- n(:preexe, [ compstmt ],
1367
- keyword_map(preexe_t, lbrace_t, [], rbrace_t))
1368
- end
1369
-
1370
- def postexe(postexe_t, lbrace_t, compstmt, rbrace_t)
1371
- n(:postexe, [ compstmt ],
1372
- keyword_map(postexe_t, lbrace_t, [], rbrace_t))
1373
- end
1374
-
1375
- # Exception handling
1376
-
1377
- def rescue_body(rescue_t,
1378
- exc_list, assoc_t, exc_var,
1379
- then_t, compound_stmt)
1380
- n(:resbody, [ exc_list, exc_var, compound_stmt ],
1381
- rescue_body_map(rescue_t, exc_list, assoc_t,
1382
- exc_var, then_t, compound_stmt))
1383
- end
1384
-
1385
- def begin_body(compound_stmt, rescue_bodies=[],
1386
- else_t=nil, else_=nil,
1387
- ensure_t=nil, ensure_=nil)
1388
- if rescue_bodies.any?
1389
- if else_t
1390
- compound_stmt =
1391
- n(:rescue,
1392
- [ compound_stmt, *(rescue_bodies + [ else_ ]) ],
1393
- eh_keyword_map(compound_stmt, nil, rescue_bodies, else_t, else_))
1394
- else
1395
- compound_stmt =
1396
- n(:rescue,
1397
- [ compound_stmt, *(rescue_bodies + [ nil ]) ],
1398
- eh_keyword_map(compound_stmt, nil, rescue_bodies, nil, nil))
1399
- end
1400
- elsif else_t
1401
- statements = []
1402
- if !compound_stmt.nil?
1403
- if compound_stmt.type == :begin
1404
- statements += compound_stmt.children
1405
- else
1406
- statements.push(compound_stmt)
1407
- end
1408
- end
1409
- statements.push(
1410
- n(:begin, [ else_ ],
1411
- collection_map(else_t, [ else_ ], nil)))
1412
- compound_stmt =
1413
- n(:begin, statements,
1414
- collection_map(nil, statements, nil))
1415
- end
1416
-
1417
- if ensure_t
1418
- compound_stmt =
1419
- n(:ensure,
1420
- [ compound_stmt, ensure_ ],
1421
- eh_keyword_map(compound_stmt, ensure_t, [ ensure_ ], nil, nil))
1422
- end
1423
-
1424
- compound_stmt
1425
- end
1426
-
1427
- #
1428
- # Expression grouping
1429
- #
1430
-
1431
- def compstmt(statements)
1432
- case
1433
- when statements.none?
1434
- nil
1435
- when statements.one?
1436
- statements.first
1437
- else
1438
- n(:begin, statements,
1439
- collection_map(nil, statements, nil))
1440
- end
1441
- end
1442
-
1443
- def begin(begin_t, body, end_t)
1444
- if body.nil?
1445
- # A nil expression: `()'.
1446
- n0(:begin,
1447
- collection_map(begin_t, nil, end_t))
1448
- elsif body.type == :mlhs ||
1449
- (body.type == :begin &&
1450
- body.loc.begin.nil? && body.loc.end.nil?)
1451
- # Synthesized (begin) from compstmt "a; b" or (mlhs)
1452
- # from multi_lhs "(a, b) = *foo".
1453
- n(body.type, body.children,
1454
- collection_map(begin_t, body.children, end_t))
1455
- else
1456
- n(:begin, [ body ],
1457
- collection_map(begin_t, [ body ], end_t))
1458
- end
1459
- end
1460
-
1461
- def begin_keyword(begin_t, body, end_t)
1462
- if body.nil?
1463
- # A nil expression: `begin end'.
1464
- n0(:kwbegin,
1465
- collection_map(begin_t, nil, end_t))
1466
- elsif (body.type == :begin &&
1467
- body.loc.begin.nil? && body.loc.end.nil?)
1468
- # Synthesized (begin) from compstmt "a; b".
1469
- n(:kwbegin, body.children,
1470
- collection_map(begin_t, body.children, end_t))
1471
- else
1472
- n(:kwbegin, [ body ],
1473
- collection_map(begin_t, [ body ], end_t))
1474
- end
1475
- end
1476
-
1477
- #
1478
- # PATTERN MATCHING
1479
- #
1480
-
1481
- def case_match(case_t, expr, in_bodies, else_t, else_body, end_t)
1482
- else_body = n(:empty_else, nil, token_map(else_t)) if else_t && !else_body
1483
- n(:case_match, [ expr, *(in_bodies << else_body)],
1484
- condition_map(case_t, expr, nil, nil, else_t, else_body, end_t))
1485
- end
1486
-
1487
- def in_match(lhs, in_t, rhs)
1488
- n(:in_match, [lhs, rhs],
1489
- binary_op_map(lhs, in_t, rhs))
1490
- end
1491
-
1492
- def match_pattern(lhs, match_t, rhs)
1493
- n(:match_pattern, [lhs, rhs],
1494
- binary_op_map(lhs, match_t, rhs))
1495
- end
1496
-
1497
- def match_pattern_p(lhs, match_t, rhs)
1498
- n(:match_pattern_p, [lhs, rhs],
1499
- binary_op_map(lhs, match_t, rhs))
1500
- end
1501
-
1502
- def in_pattern(in_t, pattern, guard, then_t, body)
1503
- children = [pattern, guard, body]
1504
- n(:in_pattern, children,
1505
- keyword_map(in_t, then_t, children.compact, nil))
1506
- end
1507
-
1508
- def if_guard(if_t, if_body)
1509
- n(:if_guard, [if_body], guard_map(if_t, if_body))
1510
- end
1511
-
1512
- def unless_guard(unless_t, unless_body)
1513
- n(:unless_guard, [unless_body], guard_map(unless_t, unless_body))
1514
- end
1515
-
1516
- def match_var(name_t)
1517
- name = value(name_t).to_sym
1518
- name_l = loc(name_t)
1519
-
1520
- check_lvar_name(name, name_l)
1521
- check_duplicate_pattern_variable(name, name_l)
1522
- @parser.static_env.declare(name)
1523
-
1524
- n(:match_var, [ name ],
1525
- variable_map(name_t))
1526
- end
1527
-
1528
- def match_hash_var(name_t)
1529
- name = value(name_t).to_sym
1530
-
1531
- expr_l = loc(name_t)
1532
- name_l = expr_l.adjust(end_pos: -1)
1533
-
1534
- check_lvar_name(name, name_l)
1535
- check_duplicate_pattern_variable(name, name_l)
1536
- @parser.static_env.declare(name)
1537
-
1538
- n(:match_var, [ name ],
1539
- Source::Map::Variable.new(name_l, expr_l))
1540
- end
1541
-
1542
- def match_hash_var_from_str(begin_t, strings, end_t)
1543
- if strings.length > 1
1544
- diagnostic :error, :pm_interp_in_var_name, nil, loc(begin_t).join(loc(end_t))
1545
- end
1546
-
1547
- string = strings[0]
1548
-
1549
- case string.type
1550
- when :str
1551
- # MRI supports plain strings in hash pattern matching
1552
- name, = *string
1553
- name_l = string.loc.expression
1554
-
1555
- check_lvar_name(name, name_l)
1556
- check_duplicate_pattern_variable(name, name_l)
1557
-
1558
- @parser.static_env.declare(name)
1559
-
1560
- if (begin_l = string.loc.begin)
1561
- # exclude beginning of the string from the location of the variable
1562
- name_l = name_l.adjust(begin_pos: begin_l.length)
1563
- end
1564
-
1565
- if (end_l = string.loc.end)
1566
- # exclude end of the string from the location of the variable
1567
- name_l = name_l.adjust(end_pos: -end_l.length)
1568
- end
1569
-
1570
- expr_l = loc(begin_t).join(string.loc.expression).join(loc(end_t))
1571
- n(:match_var, [ name.to_sym ],
1572
- Source::Map::Variable.new(name_l, expr_l))
1573
- when :begin
1574
- match_hash_var_from_str(begin_t, string.children, end_t)
1575
- else
1576
- # we only can get here if there is an interpolation, e.g., ``in "#{ a }":`
1577
- diagnostic :error, :pm_interp_in_var_name, nil, loc(begin_t).join(loc(end_t))
1578
- end
1579
- end
1580
-
1581
- def match_rest(star_t, name_t = nil)
1582
- if name_t.nil?
1583
- n0(:match_rest,
1584
- unary_op_map(star_t))
1585
- else
1586
- name = match_var(name_t)
1587
- n(:match_rest, [ name ],
1588
- unary_op_map(star_t, name))
1589
- end
1590
- end
1591
-
1592
- def hash_pattern(lbrace_t, kwargs, rbrace_t)
1593
- args = check_duplicate_args(kwargs)
1594
- n(:hash_pattern, args,
1595
- collection_map(lbrace_t, args, rbrace_t))
1596
- end
1597
-
1598
- def array_pattern(lbrack_t, elements, rbrack_t)
1599
- return n(:array_pattern, nil, collection_map(lbrack_t, [], rbrack_t)) if elements.nil?
1600
-
1601
- trailing_comma = false
1602
-
1603
- node_elements = elements.map do |element|
1604
- if element.type == :match_with_trailing_comma
1605
- trailing_comma = true
1606
- element.children.first
1607
- else
1608
- trailing_comma = false
1609
- element
1610
- end
1611
- end
1612
-
1613
- node_type = trailing_comma ? :array_pattern_with_tail : :array_pattern
1614
-
1615
- n(node_type, node_elements,
1616
- collection_map(lbrack_t, elements, rbrack_t))
1617
- end
1618
-
1619
- def find_pattern(lbrack_t, elements, rbrack_t)
1620
- n(:find_pattern, elements,
1621
- collection_map(lbrack_t, elements, rbrack_t))
1622
- end
1623
-
1624
- def match_with_trailing_comma(match, comma_t)
1625
- n(:match_with_trailing_comma, [ match ], expr_map(match.loc.expression.join(loc(comma_t))))
1626
- end
1627
-
1628
- def const_pattern(const, ldelim_t, pattern, rdelim_t)
1629
- n(:const_pattern, [const, pattern],
1630
- Source::Map::Collection.new(
1631
- loc(ldelim_t), loc(rdelim_t),
1632
- const.loc.expression.join(loc(rdelim_t))
1633
- )
1634
- )
1635
- end
1636
-
1637
- def pin(pin_t, var)
1638
- n(:pin, [ var ],
1639
- send_unary_op_map(pin_t, var))
1640
- end
1641
-
1642
- def match_alt(left, pipe_t, right)
1643
- source_map = binary_op_map(left, pipe_t, right)
1644
-
1645
- n(:match_alt, [ left, right ],
1646
- source_map)
1647
- end
1648
-
1649
- def match_as(value, assoc_t, as)
1650
- source_map = binary_op_map(value, assoc_t, as)
1651
-
1652
- n(:match_as, [ value, as ],
1653
- source_map)
1654
- end
1655
-
1656
- def match_nil_pattern(dstar_t, nil_t)
1657
- n0(:match_nil_pattern,
1658
- arg_prefix_map(dstar_t, nil_t))
1659
- end
1660
-
1661
- def match_pair(label_type, label, value)
1662
- if label_type == :label
1663
- check_duplicate_pattern_key(label[0], label[1])
1664
- pair_keyword(label, value)
1665
- else
1666
- begin_t, parts, end_t = label
1667
- label_loc = loc(begin_t).join(loc(end_t))
1668
-
1669
- # quoted label like "label": value
1670
- if (var_name = static_string(parts))
1671
- check_duplicate_pattern_key(var_name, label_loc)
1672
- else
1673
- diagnostic :error, :pm_interp_in_var_name, nil, label_loc
1674
- end
1675
-
1676
- pair_quoted(begin_t, parts, end_t, value)
1677
- end
1678
- end
1679
-
1680
- def match_label(label_type, label)
1681
- if label_type == :label
1682
- match_hash_var(label)
1683
- else
1684
- # quoted label like "label": value
1685
- begin_t, strings, end_t = label
1686
- match_hash_var_from_str(begin_t, strings, end_t)
1687
- end
1688
- end
1689
-
1690
- private
1691
-
1692
- #
1693
- # VERIFICATION
1694
- #
1695
-
1696
- def check_condition(cond)
1697
- case cond.type
1698
- when :masgn
1699
- if @parser.version <= 23
1700
- diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
1701
- else
1702
- cond
1703
- end
1704
-
1705
- when :begin
1706
- if cond.children.count == 1
1707
- cond.updated(nil, [
1708
- check_condition(cond.children.last)
1709
- ])
1710
- else
1711
- cond
1712
- end
1713
-
1714
- when :and, :or
1715
- lhs, rhs = *cond
1716
-
1717
- if @parser.version == 18
1718
- cond
1719
- else
1720
- cond.updated(cond.type, [
1721
- check_condition(lhs),
1722
- check_condition(rhs)
1723
- ])
1724
- end
1725
-
1726
- when :irange, :erange
1727
- lhs, rhs = *cond
1728
-
1729
- type = case cond.type
1730
- when :irange then :iflipflop
1731
- when :erange then :eflipflop
1732
- end
1733
-
1734
- lhs_condition = check_condition(lhs) unless lhs.nil?
1735
- rhs_condition = check_condition(rhs) unless rhs.nil?
1736
-
1737
- return cond.updated(type, [
1738
- lhs_condition,
1739
- rhs_condition
1740
- ])
1741
-
1742
- when :regexp
1743
- n(:match_current_line, [ cond ], expr_map(cond.loc.expression))
1744
-
1745
- else
1746
- cond
1747
- end
1748
- end
1749
-
1750
- def check_duplicate_args(args, map={})
1751
- args.each do |this_arg|
1752
- case this_arg.type
1753
- when :arg, :optarg, :restarg, :blockarg,
1754
- :kwarg, :kwoptarg, :kwrestarg,
1755
- :shadowarg
1756
-
1757
- check_duplicate_arg(this_arg, map)
1758
-
1759
- when :procarg0
1760
-
1761
- if this_arg.children[0].is_a?(Symbol)
1762
- # s(:procarg0, :a)
1763
- check_duplicate_arg(this_arg, map)
1764
- else
1765
- # s(:procarg0, s(:arg, :a), ...)
1766
- check_duplicate_args(this_arg.children, map)
1767
- end
1768
-
1769
- when :mlhs
1770
- check_duplicate_args(this_arg.children, map)
1771
- end
1772
- end
1773
- end
1774
-
1775
- def check_duplicate_arg(this_arg, map={})
1776
- this_name, = *this_arg
1777
-
1778
- that_arg = map[this_name]
1779
- that_name, = *that_arg
1780
-
1781
- if that_arg.nil?
1782
- map[this_name] = this_arg
1783
- elsif arg_name_collides?(this_name, that_name)
1784
- diagnostic :error, :duplicate_argument, nil,
1785
- this_arg.loc.name, [ that_arg.loc.name ]
1786
- end
1787
- end
1788
-
1789
- def validate_no_forward_arg_after_restarg(args)
1790
- restarg = nil
1791
- forward_arg = nil
1792
- args.each do |arg|
1793
- case arg.type
1794
- when :restarg then restarg = arg
1795
- when :forward_arg then forward_arg = arg
1796
- end
1797
- end
1798
-
1799
- if !forward_arg.nil? && !restarg.nil?
1800
- diagnostic :error, :forward_arg_after_restarg, nil, forward_arg.loc.expression, [restarg.loc.expression]
1801
- end
1802
- end
1803
-
1804
- def check_assignment_to_numparam(name, loc)
1805
- # MRI < 2.7 treats numbered parameters as regular variables
1806
- # and so it's allowed to perform assignments like `_1 = 42`.
1807
- return if @parser.version < 27
1808
-
1809
- assigning_to_numparam =
1810
- @parser.context.in_dynamic_block? &&
1811
- name =~ /\A_([1-9])\z/ &&
1812
- @parser.max_numparam_stack.has_numparams?
1813
-
1814
- if assigning_to_numparam
1815
- diagnostic :error, :cant_assign_to_numparam, { :name => name }, loc
1816
- end
1817
- end
1818
-
1819
- def check_reserved_for_numparam(name, loc)
1820
- # MRI < 3.0 accepts assignemnt to variables like _1
1821
- # if it's not a numbered parameter. MRI 3.0 and newer throws an error.
1822
- return if @parser.version < 30
1823
-
1824
- if name =~ /\A_([1-9])\z/
1825
- diagnostic :error, :reserved_for_numparam, { :name => name }, loc
1826
- end
1827
- end
1828
-
1829
- def arg_name_collides?(this_name, that_name)
1830
- case @parser.version
1831
- when 18
1832
- this_name == that_name
1833
- when 19
1834
- # Ignore underscore.
1835
- this_name != :_ &&
1836
- this_name == that_name
1837
- else
1838
- # Ignore everything beginning with underscore.
1839
- this_name && this_name[0] != '_' &&
1840
- this_name == that_name
1841
- end
1842
- end
1843
-
1844
- def check_lvar_name(name, loc)
1845
- if name =~ /\A[[[:lower:]]_][[[:alnum:]]_]*\z/
1846
- # OK
1847
- else
1848
- diagnostic :error, :lvar_name, { name: name }, loc
1849
- end
1850
- end
1851
-
1852
- def check_duplicate_pattern_variable(name, loc)
1853
- return if name.to_s.start_with?('_')
1854
-
1855
- if @parser.pattern_variables.declared?(name)
1856
- diagnostic :error, :duplicate_variable_name, { name: name.to_s }, loc
1857
- end
1858
-
1859
- @parser.pattern_variables.declare(name)
1860
- end
1861
-
1862
- def check_duplicate_pattern_key(name, loc)
1863
- if @parser.pattern_hash_keys.declared?(name)
1864
- diagnostic :error, :duplicate_pattern_key, { name: name.to_s }, loc
1865
- end
1866
-
1867
- @parser.pattern_hash_keys.declare(name)
1868
- end
1869
-
1870
- #
1871
- # SOURCE MAPS
1872
- #
1873
-
1874
- def n(type, children, source_map)
1875
- AST::Node.new(type, children, :location => source_map)
1876
- end
1877
-
1878
- def n0(type, source_map)
1879
- n(type, [], source_map)
1880
- end
1881
-
1882
- def join_exprs(left_expr, right_expr)
1883
- left_expr.loc.expression.
1884
- join(right_expr.loc.expression)
1885
- end
1886
-
1887
- def token_map(token)
1888
- Source::Map.new(loc(token))
1889
- end
1890
-
1891
- def delimited_string_map(string_t)
1892
- str_range = loc(string_t)
1893
-
1894
- begin_l = str_range.with(end_pos: str_range.begin_pos + 1)
1895
-
1896
- end_l = str_range.with(begin_pos: str_range.end_pos - 1)
1897
-
1898
- Source::Map::Collection.new(begin_l, end_l,
1899
- loc(string_t))
1900
- end
1901
-
1902
- def prefix_string_map(symbol)
1903
- str_range = loc(symbol)
1904
-
1905
- begin_l = str_range.with(end_pos: str_range.begin_pos + 1)
1906
-
1907
- Source::Map::Collection.new(begin_l, nil,
1908
- loc(symbol))
1909
- end
1910
-
1911
- def unquoted_map(token)
1912
- Source::Map::Collection.new(nil, nil,
1913
- loc(token))
1914
- end
1915
-
1916
- def pair_keyword_map(key_t, value_e)
1917
- key_range = loc(key_t)
1918
-
1919
- key_l = key_range.adjust(end_pos: -1)
1920
-
1921
- colon_l = key_range.with(begin_pos: key_range.end_pos - 1)
1922
-
1923
- [ # key map
1924
- Source::Map::Collection.new(nil, nil,
1925
- key_l),
1926
- # pair map
1927
- Source::Map::Operator.new(colon_l,
1928
- key_range.join(value_e.loc.expression)) ]
1929
- end
1930
-
1931
- def pair_quoted_map(begin_t, end_t, value_e)
1932
- end_l = loc(end_t)
1933
-
1934
- quote_l = end_l.with(begin_pos: end_l.end_pos - 2,
1935
- end_pos: end_l.end_pos - 1)
1936
-
1937
- colon_l = end_l.with(begin_pos: end_l.end_pos - 1)
1938
-
1939
- [ # modified end token
1940
- [ value(end_t), quote_l ],
1941
- # pair map
1942
- Source::Map::Operator.new(colon_l,
1943
- loc(begin_t).join(value_e.loc.expression)) ]
1944
- end
1945
-
1946
- def expr_map(loc)
1947
- Source::Map.new(loc)
1948
- end
1949
-
1950
- def collection_map(begin_t, parts, end_t)
1951
- if begin_t.nil? || end_t.nil?
1952
- if parts.any?
1953
- expr_l = join_exprs(parts.first, parts.last)
1954
- elsif !begin_t.nil?
1955
- expr_l = loc(begin_t)
1956
- elsif !end_t.nil?
1957
- expr_l = loc(end_t)
1958
- end
1959
- else
1960
- expr_l = loc(begin_t).join(loc(end_t))
1961
- end
1962
-
1963
- Source::Map::Collection.new(loc(begin_t), loc(end_t), expr_l)
1964
- end
1965
-
1966
- def string_map(begin_t, parts, end_t)
1967
- if begin_t && value(begin_t).start_with?('<<')
1968
- if parts.any?
1969
- expr_l = join_exprs(parts.first, parts.last)
1970
- else
1971
- expr_l = loc(end_t).begin
1972
- end
1973
-
1974
- Source::Map::Heredoc.new(loc(begin_t), expr_l, loc(end_t))
1975
- else
1976
- collection_map(begin_t, parts, end_t)
1977
- end
1978
- end
1979
-
1980
- def regexp_map(begin_t, end_t, options_e)
1981
- Source::Map::Collection.new(loc(begin_t), loc(end_t),
1982
- loc(begin_t).join(options_e.loc.expression))
1983
- end
1984
-
1985
- def constant_map(scope, colon2_t, name_t)
1986
- if scope.nil?
1987
- expr_l = loc(name_t)
1988
- else
1989
- expr_l = scope.loc.expression.join(loc(name_t))
1990
- end
1991
-
1992
- Source::Map::Constant.new(loc(colon2_t), loc(name_t), expr_l)
1993
- end
1994
-
1995
- def variable_map(name_t)
1996
- Source::Map::Variable.new(loc(name_t))
1997
- end
1998
-
1999
- def binary_op_map(left_e, op_t, right_e)
2000
- Source::Map::Operator.new(loc(op_t), join_exprs(left_e, right_e))
2001
- end
2002
-
2003
- def unary_op_map(op_t, arg_e=nil)
2004
- if arg_e.nil?
2005
- expr_l = loc(op_t)
2006
- else
2007
- expr_l = loc(op_t).join(arg_e.loc.expression)
2008
- end
2009
-
2010
- Source::Map::Operator.new(loc(op_t), expr_l)
2011
- end
2012
-
2013
- def range_map(start_e, op_t, end_e)
2014
- if start_e && end_e
2015
- expr_l = join_exprs(start_e, end_e)
2016
- elsif start_e
2017
- expr_l = start_e.loc.expression.join(loc(op_t))
2018
- elsif end_e
2019
- expr_l = loc(op_t).join(end_e.loc.expression)
2020
- end
2021
-
2022
- Source::Map::Operator.new(loc(op_t), expr_l)
2023
- end
2024
-
2025
- def arg_prefix_map(op_t, name_t=nil)
2026
- if name_t.nil?
2027
- expr_l = loc(op_t)
2028
- else
2029
- expr_l = loc(op_t).join(loc(name_t))
2030
- end
2031
-
2032
- Source::Map::Variable.new(loc(name_t), expr_l)
2033
- end
2034
-
2035
- def kwarg_map(name_t, value_e=nil)
2036
- label_range = loc(name_t)
2037
- name_range = label_range.adjust(end_pos: -1)
2038
-
2039
- if value_e
2040
- expr_l = loc(name_t).join(value_e.loc.expression)
2041
- else
2042
- expr_l = loc(name_t)
2043
- end
2044
-
2045
- Source::Map::Variable.new(name_range, expr_l)
2046
- end
2047
-
2048
- def module_definition_map(keyword_t, name_e, operator_t, end_t)
2049
- if name_e
2050
- name_l = name_e.loc.expression
2051
- end
2052
-
2053
- Source::Map::Definition.new(loc(keyword_t),
2054
- loc(operator_t), name_l,
2055
- loc(end_t))
2056
- end
2057
-
2058
- def definition_map(keyword_t, operator_t, name_t, end_t)
2059
- Source::Map::MethodDefinition.new(loc(keyword_t),
2060
- loc(operator_t), loc(name_t),
2061
- loc(end_t), nil, nil)
2062
- end
2063
-
2064
- def endless_definition_map(keyword_t, operator_t, name_t, assignment_t, body_e)
2065
- body_l = body_e.loc.expression
2066
-
2067
- Source::Map::MethodDefinition.new(loc(keyword_t),
2068
- loc(operator_t), loc(name_t), nil,
2069
- loc(assignment_t), body_l)
2070
- end
2071
-
2072
- def send_map(receiver_e, dot_t, selector_t, begin_t=nil, args=[], end_t=nil)
2073
- if receiver_e
2074
- begin_l = receiver_e.loc.expression
2075
- elsif selector_t
2076
- begin_l = loc(selector_t)
2077
- end
2078
-
2079
- if end_t
2080
- end_l = loc(end_t)
2081
- elsif args.any?
2082
- end_l = args.last.loc.expression
2083
- elsif selector_t
2084
- end_l = loc(selector_t)
2085
- end
2086
-
2087
- Source::Map::Send.new(loc(dot_t), loc(selector_t),
2088
- loc(begin_t), loc(end_t),
2089
- begin_l.join(end_l))
2090
- end
2091
-
2092
- def var_send_map(variable_e)
2093
- Source::Map::Send.new(nil, variable_e.loc.expression,
2094
- nil, nil,
2095
- variable_e.loc.expression)
2096
- end
2097
-
2098
- def send_binary_op_map(lhs_e, selector_t, rhs_e)
2099
- Source::Map::Send.new(nil, loc(selector_t),
2100
- nil, nil,
2101
- join_exprs(lhs_e, rhs_e))
2102
- end
2103
-
2104
- def send_unary_op_map(selector_t, arg_e)
2105
- if arg_e.nil?
2106
- expr_l = loc(selector_t)
2107
- else
2108
- expr_l = loc(selector_t).join(arg_e.loc.expression)
2109
- end
2110
-
2111
- Source::Map::Send.new(nil, loc(selector_t),
2112
- nil, nil,
2113
- expr_l)
2114
- end
2115
-
2116
- def index_map(receiver_e, lbrack_t, rbrack_t)
2117
- Source::Map::Index.new(loc(lbrack_t), loc(rbrack_t),
2118
- receiver_e.loc.expression.join(loc(rbrack_t)))
2119
- end
2120
-
2121
- def send_index_map(receiver_e, lbrack_t, rbrack_t)
2122
- Source::Map::Send.new(nil, loc(lbrack_t).join(loc(rbrack_t)),
2123
- nil, nil,
2124
- receiver_e.loc.expression.join(loc(rbrack_t)))
2125
- end
2126
-
2127
- def block_map(receiver_l, begin_t, end_t)
2128
- Source::Map::Collection.new(loc(begin_t), loc(end_t),
2129
- receiver_l.join(loc(end_t)))
2130
- end
2131
-
2132
- def keyword_map(keyword_t, begin_t, args, end_t)
2133
- args ||= []
2134
-
2135
- if end_t
2136
- end_l = loc(end_t)
2137
- elsif args.any? && !args.last.nil?
2138
- end_l = args.last.loc.expression
2139
- elsif args.any? && args.count > 1
2140
- end_l = args[-2].loc.expression
2141
- else
2142
- end_l = loc(keyword_t)
2143
- end
2144
-
2145
- Source::Map::Keyword.new(loc(keyword_t), loc(begin_t), loc(end_t),
2146
- loc(keyword_t).join(end_l))
2147
- end
2148
-
2149
- def keyword_mod_map(pre_e, keyword_t, post_e)
2150
- Source::Map::Keyword.new(loc(keyword_t), nil, nil,
2151
- join_exprs(pre_e, post_e))
2152
- end
2153
-
2154
- def condition_map(keyword_t, cond_e, begin_t, body_e, else_t, else_e, end_t)
2155
- if end_t
2156
- end_l = loc(end_t)
2157
- elsif else_e && else_e.loc.expression
2158
- end_l = else_e.loc.expression
2159
- elsif loc(else_t)
2160
- end_l = loc(else_t)
2161
- elsif body_e && body_e.loc.expression
2162
- end_l = body_e.loc.expression
2163
- elsif loc(begin_t)
2164
- end_l = loc(begin_t)
2165
- else
2166
- end_l = cond_e.loc.expression
2167
- end
2168
-
2169
- Source::Map::Condition.new(loc(keyword_t),
2170
- loc(begin_t), loc(else_t), loc(end_t),
2171
- loc(keyword_t).join(end_l))
2172
- end
2173
-
2174
- def ternary_map(begin_e, question_t, mid_e, colon_t, end_e)
2175
- Source::Map::Ternary.new(loc(question_t), loc(colon_t),
2176
- join_exprs(begin_e, end_e))
2177
- end
2178
-
2179
- def for_map(keyword_t, in_t, begin_t, end_t)
2180
- Source::Map::For.new(loc(keyword_t), loc(in_t),
2181
- loc(begin_t), loc(end_t),
2182
- loc(keyword_t).join(loc(end_t)))
2183
- end
2184
-
2185
- def rescue_body_map(keyword_t, exc_list_e, assoc_t,
2186
- exc_var_e, then_t,
2187
- compstmt_e)
2188
- end_l = compstmt_e.loc.expression if compstmt_e
2189
- end_l = loc(then_t) if end_l.nil? && then_t
2190
- end_l = exc_var_e.loc.expression if end_l.nil? && exc_var_e
2191
- end_l = exc_list_e.loc.expression if end_l.nil? && exc_list_e
2192
- end_l = loc(keyword_t) if end_l.nil?
2193
-
2194
- Source::Map::RescueBody.new(loc(keyword_t), loc(assoc_t), loc(then_t),
2195
- loc(keyword_t).join(end_l))
2196
- end
2197
-
2198
- def eh_keyword_map(compstmt_e, keyword_t, body_es,
2199
- else_t, else_e)
2200
- if compstmt_e.nil?
2201
- if keyword_t.nil?
2202
- begin_l = body_es.first.loc.expression
2203
- else
2204
- begin_l = loc(keyword_t)
2205
- end
2206
- else
2207
- begin_l = compstmt_e.loc.expression
2208
- end
2209
-
2210
- if else_t
2211
- if else_e.nil?
2212
- end_l = loc(else_t)
2213
- else
2214
- end_l = else_e.loc.expression
2215
- end
2216
- elsif !body_es.last.nil?
2217
- end_l = body_es.last.loc.expression
2218
- else
2219
- end_l = loc(keyword_t)
2220
- end
2221
-
2222
- Source::Map::Condition.new(loc(keyword_t), nil, loc(else_t), nil,
2223
- begin_l.join(end_l))
2224
- end
2225
-
2226
- def guard_map(keyword_t, guard_body_e)
2227
- keyword_l = loc(keyword_t)
2228
- guard_body_l = guard_body_e.loc.expression
2229
-
2230
- Source::Map::Keyword.new(keyword_l, nil, nil, keyword_l.join(guard_body_l))
2231
- end
2232
-
2233
- #
2234
- # HELPERS
2235
- #
2236
-
2237
- # Extract a static string from e.g. a regular expression,
2238
- # honoring the fact that MRI expands interpolations like #{""}
2239
- # at parse time.
2240
- def static_string(nodes)
2241
- nodes.map do |node|
2242
- case node.type
2243
- when :str
2244
- node.children[0]
2245
- when :begin
2246
- if (string = static_string(node.children))
2247
- string
2248
- else
2249
- return nil
2250
- end
2251
- else
2252
- return nil
2253
- end
2254
- end.join
2255
- end
2256
-
2257
- def static_regexp(parts, options)
2258
- source = static_string(parts)
2259
- return nil if source.nil?
2260
-
2261
- source = case
2262
- when options.children.include?(:u)
2263
- source.encode(Encoding::UTF_8)
2264
- when options.children.include?(:e)
2265
- source.encode(Encoding::EUC_JP)
2266
- when options.children.include?(:s)
2267
- source.encode(Encoding::WINDOWS_31J)
2268
- when options.children.include?(:n)
2269
- source.encode(Encoding::BINARY)
2270
- else
2271
- source
2272
- end
2273
-
2274
- begin
2275
- old_verbose, $VERBOSE = $VERBOSE, nil
2276
- Regexp.new(source, (Regexp::EXTENDED if options.children.include?(:x)))
2277
- ensure
2278
- $VERBOSE = old_verbose
2279
- end
2280
- end
2281
-
2282
- def static_regexp_node(node)
2283
- if node.type == :regexp
2284
- if @parser.version >= 33 && node.children[0..-2].any? { |child| child.type != :str }
2285
- return nil
2286
- end
2287
-
2288
- parts, options = node.children[0..-2], node.children[-1]
2289
- static_regexp(parts, options)
2290
- end
2291
- end
2292
-
2293
- def collapse_string_parts?(parts)
2294
- parts.one? &&
2295
- [:str, :dstr].include?(parts.first.type)
2296
- end
2297
-
2298
- def value(token)
2299
- token[0]
2300
- end
2301
-
2302
- def string_value(token)
2303
- unless token[0].valid_encoding?
2304
- diagnostic(:error, :invalid_encoding, nil, token[1])
2305
- end
2306
-
2307
- token[0]
2308
- end
2309
-
2310
- def loc(token)
2311
- # Pass through `nil`s and return nil for tNL.
2312
- token[1] if token && token[0]
2313
- end
2314
-
2315
- def diagnostic(type, reason, arguments, location, highlights=[])
2316
- @parser.diagnostics.process(
2317
- Diagnostic.new(type, reason, arguments, location, highlights))
2318
-
2319
- if type == :error
2320
- @parser.send :yyerror
2321
- end
2322
- end
2323
-
2324
- def validate_definee(definee)
2325
- case definee.type
2326
- when :int, :str, :dstr, :sym, :dsym,
2327
- :regexp, :array, :hash
2328
-
2329
- diagnostic :error, :singleton_literal, nil, definee.loc.expression
2330
- false
2331
- else
2332
- true
2333
- end
2334
- end
2335
-
2336
- def rewrite_hash_args_to_kwargs(args)
2337
- if args.any? && kwargs?(args.last)
2338
- # foo(..., bar: baz)
2339
- args[args.length - 1] = args[args.length - 1].updated(:kwargs)
2340
- elsif args.length > 1 && args.last.type == :block_pass && kwargs?(args[args.length - 2])
2341
- # foo(..., bar: baz, &blk)
2342
- args[args.length - 2] = args[args.length - 2].updated(:kwargs)
2343
- end
2344
- end
2345
-
2346
- def kwargs?(node)
2347
- node.type == :hash && node.loc.begin.nil? && node.loc.end.nil?
2348
- end
2349
- end
2350
-
2351
- end