D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
RubyVM
/
AbstractSyntaxTree
/
Filename :
parse-c.ri
back
Copy
U:RDoc::AnyMethod[iI" parse:ETI"&RubyVM::AbstractSyntaxTree::parse;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"=Parses the given _string_ into an abstract syntax tree, ;TI"*returning the root node of that tree.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"3RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") ;TI"<# => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9> ;T:@format0o; ; [I"TIf <tt>keep_script_lines: true</tt> option is provided, the text of the parsed ;TI"Lsource is associated with nodes and is available via Node#script_lines.;T@o; ; [I"QIf <tt>keep_tokens: true</tt> option is provided, Node#tokens are populated.;T@o; ; [ I"VSyntaxError is raised if the given _string_ is invalid syntax. To overwrite this ;TI"Wbehavior, <tt>error_tolerant: true</tt> can be provided. In this case, the parser ;TI"Vwill produce a tree where expressions with syntax errors would be represented by ;TI"$Node with <tt>type=:ERROR</tt>.;T@o;; [I"@root = RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2") ;TI"_# <internal:ast>:33:in `parse': syntax error, unexpected ';', expecting ')' (SyntaxError) ;TI"# x = 1; p(x; y=2 ;TI"# ^ ;TI" ;TI"Vroot = RubyVM::AbstractSyntaxTree.parse("x = 1; p(x; y=2", error_tolerant: true) ;TI"# (SCOPE@1:0-1:15 ;TI"# tbl: [:x, :y] ;TI"# args: nil ;TI"{# body: (BLOCK@1:0-1:15 (LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)) (ERROR@1:7-1:11) (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2)))) ;TI"!root.children.last.children ;TI",# [(LASGN@1:0-1:5 :x (LIT@1:4-1:5 1)), ;TI"# (ERROR@1:7-1:11), ;TI"0# (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))] ;T; 0o; ; [I"CNote that parsing continues even after the errored expression.;T: @fileI"ast.rb;T:0@omit_headings_from_table_of_contents_below0I"�RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node ;T0[ I"e(string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false);T@4FI"AbstractSyntaxTree;TcRDoc::NormalModule00