1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

fix line break code (fix to LF)

This commit is contained in:
Koichi Sasada 2019-11-08 09:30:11 +09:00
parent 46b9ca6c54
commit 08ff9edb53

268
ast.rb
View file

@ -1,134 +1,134 @@
# for ast.c # for ast.c
class RubyVM class RubyVM
# AbstractSyntaxTree provides methods to parse Ruby code into # AbstractSyntaxTree provides methods to parse Ruby code into
# abstract syntax trees. The nodes in the tree # abstract syntax trees. The nodes in the tree
# are instances of RubyVM::AbstractSyntaxTree::Node. # are instances of RubyVM::AbstractSyntaxTree::Node.
# #
# This class is MRI specific as it exposes implementation details # This class is MRI specific as it exposes implementation details
# of the MRI abstract syntax tree. # of the MRI abstract syntax tree.
# #
module AbstractSyntaxTree module AbstractSyntaxTree
# call-seq: # call-seq:
# RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node # RubyVM::AbstractSyntaxTree.parse(string) -> RubyVM::AbstractSyntaxTree::Node
# #
# Parses the given _string_ into an abstract syntax tree, # Parses the given _string_ into an abstract syntax tree,
# returning the root node of that tree. # returning the root node of that tree.
# #
# SyntaxError is raised if the given _string_ is invalid syntax. # SyntaxError is raised if the given _string_ is invalid syntax.
# #
# RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") # RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9> # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9>
def self.parse string def self.parse string
__builtin_ast_s_parse string __builtin_ast_s_parse string
end end
# call-seq: # call-seq:
# RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node # RubyVM::AbstractSyntaxTree.parse_file(pathname) -> RubyVM::AbstractSyntaxTree::Node
# #
# Reads the file from _pathname_, then parses it like ::parse, # Reads the file from _pathname_, then parses it like ::parse,
# returning the root node of the abstract syntax tree. # returning the root node of the abstract syntax tree.
# #
# SyntaxError is raised if _pathname_'s contents are not # SyntaxError is raised if _pathname_'s contents are not
# valid Ruby syntax. # valid Ruby syntax.
# #
# RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb") # RubyVM::AbstractSyntaxTree.parse_file("my-app/app.rb")
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3> # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
def self.parse_file pathname def self.parse_file pathname
__builtin_ast_s_parse_file pathname __builtin_ast_s_parse_file pathname
end end
# call-seq: # call-seq:
# RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node # RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node
# RubyVM::AbstractSyntaxTree.of(method) -> RubyVM::AbstractSyntaxTree::Node # RubyVM::AbstractSyntaxTree.of(method) -> RubyVM::AbstractSyntaxTree::Node
# #
# Returns AST nodes of the given _proc_ or _method_. # Returns AST nodes of the given _proc_ or _method_.
# #
# RubyVM::AbstractSyntaxTree.of(proc {1 + 2}) # RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:35-1:42> # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:35-1:42>
# #
# def hello # def hello
# puts "hello, world" # puts "hello, world"
# end # end
# #
# RubyVM::AbstractSyntaxTree.of(method(:hello)) # RubyVM::AbstractSyntaxTree.of(method(:hello))
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3> # # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
def self.of body def self.of body
__builtin_ast_s_of body __builtin_ast_s_of body
end end
# RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in # RubyVM::AbstractSyntaxTree::Node instances are created by parse methods in
# RubyVM::AbstractSyntaxTree. # RubyVM::AbstractSyntaxTree.
# #
# This class is MRI specific. # This class is MRI specific.
# #
class Node class Node
# call-seq: # call-seq:
# node.type -> symbol # node.type -> symbol
# #
# Returns the type of this node as a symbol. # Returns the type of this node as a symbol.
# #
# root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") # root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2")
# root.type # => :SCOPE # root.type # => :SCOPE
# call = root.children[2] # call = root.children[2]
# call.type # => :OPCALL # call.type # => :OPCALL
def type def type
__builtin_ast_node_type __builtin_ast_node_type
end end
# call-seq: # call-seq:
# node.first_lineno -> integer # node.first_lineno -> integer
# #
# The line number in the source code where this AST's text began. # The line number in the source code where this AST's text began.
def first_lineno def first_lineno
__builtin_ast_node_first_lineno __builtin_ast_node_first_lineno
end end
# call-seq: # call-seq:
# node.first_column -> integer # node.first_column -> integer
# #
# The column number in the source code where this AST's text began. # The column number in the source code where this AST's text began.
def first_column def first_column
__builtin_ast_node_first_column __builtin_ast_node_first_column
end end
# call-seq: # call-seq:
# node.last_lineno -> integer # node.last_lineno -> integer
# #
# The line number in the source code where this AST's text ended. # The line number in the source code where this AST's text ended.
def last_lineno def last_lineno
__builtin_ast_node_last_lineno __builtin_ast_node_last_lineno
end end
# call-seq: # call-seq:
# node.last_column -> integer # node.last_column -> integer
# #
# The column number in the source code where this AST's text ended. # The column number in the source code where this AST's text ended.
def last_column def last_column
__builtin_ast_node_last_column __builtin_ast_node_last_column
end end
# call-seq: # call-seq:
# node.children -> array # node.children -> array
# #
# Returns AST nodes under this one. Each kind of node # Returns AST nodes under this one. Each kind of node
# has different children, depending on what kind of node it is. # has different children, depending on what kind of node it is.
# #
# The returned array may contain other nodes or <code>nil</code>. # The returned array may contain other nodes or <code>nil</code>.
def children def children
__builtin_ast_node_children __builtin_ast_node_children
end end
# call-seq: # call-seq:
# node.inspect -> string # node.inspect -> string
# #
# Returns debugging information about this node as a string. # Returns debugging information about this node as a string.
def inspect def inspect
__builtin_ast_node_inspect __builtin_ast_node_inspect
end end
end end
end end
end end