SlideShare ist ein Scribd-Unternehmen logo
1 von 16
 
Ruby Macros
 
 
“ print 'hello'” :(print 'hello')‏ proc{ print 'hello' }
RedParse.new(“print 'hello'”).parse :(print 'hello')‏ RedParse::CallNode[nil, "print", [RedParse::StringNode["hello",  {:@line=>1, :@close=>"'", :@open=>"'", :@char=>"amp;quot;"}]], nil, nil,  {:@line=>1, :@not_real_parens=>true, :@offset=>0, :@lvalue=>nil}]
str=:(“hello”)‏ :(print ^str)‏
macro simple(a,b)  :(^a+^b)  end def simple_user p simple(1,2)‏ end
if $Debug macro assert(cond)‏ if RedParse::OpNode===cond and /[=!]=/===cond.op left,op,right=*cond :(fail 'expected '+^left.unparse({})+"(==#{^left}) to be "+ ^op+" "+^right.unparse({})+"(==#{^right})" unless ^cond)  else :(fail "expected #{:(^^cond)}, but was not true" unless ^cond)‏ end end else macro assert(cond)‏ end end
def test_assert a=1  b=2 assert a  #ok assert a!=b  #ok assert(a==b) #oops, fails. msg="expected a(==1) to be == b(==2)" assert(nil) #oops, fails. msg="expected nil, but was not true" #ok, that message didn't make a lot of sense... end
Syntax trees are represented by trees of nested Nodes. All  Nodes descend from Array, and their subnodes can be  addressed by numeric index, just like normal Arrays.  However, many subnodes want to have names as well,  thus most (but not all) array slots within the various Node  classes have names. The general rule is that Node slots  may contain a Node, a VarNameToken, a plain Array, a  String, or nil. However, many cases are more specific  than that.
VarNameToken<RubyLexer::Token  #represents variables and constants (ident: String)‏ Node<Array  #abstract ancestor of all nodes (except VarNameToken)‏ +RescueNode  #a rescue clause in a def of begin statement |  (exceptions: Array[Value*], varname: VarNameToken|nil, action: Value)‏ +WhenNode  #a when clause in a case statement |  (when: Value|Array[Value+]  then: Value|nil )‏ +ElsifNode  #an elsif clause in an if statement |  (elsif: Value, then: Value|nil)‏ +ValueNode  #abstract, a node which has a value (an expression)‏ |+ListOpNode  #abstract, ancestor for nodes which are lists of |||  #things separated by some op ||+SequenceNode  #a sequence of statements |||  (Array[Value*])‏ ||+ConstantNode  #a constant expression of the form A::B::C or the like ||  #first expression can be anything ||  (Array[String|Value|nil,String+])‏ |+RawOpNode  #ancestor of all operators (but not . :: ; , ?..:)‏ |||  (left: Value, op: String, right: Value)‏ ||+OpNode  #ancestor of some operators |||+RangeNode  #a range literal node |||+KeywordOpNode #abstract, ancestor of keyword operators ||||+LogicalNode  #and or && || expressions ||||+WhileOpNode  #while as an operator ||||+UntilOpNode  #until as an operator ||||+IfOpNode  #if as an operator ||||+UnlessOpNode #unless as an operator |||+NotEqualNode  #!= expressions
|||+MatchNode  #=~ expressions |||+NotMatchNode  #!~ expressions |+LiteralNode  #literal symbols, integers ||  (val: Numeric|Symbol|StringNode)‏ |+StringNode  #literal strings |||  (Array[(String|Value)+])‏ ||+HereDocNode  #here documents |+StringCatNode  #adjacent strings are catenated (&quot;foo&quot; &quot;bar&quot; == &quot;foobar&quot;)‏ ||  (Array[StringNode+])‏ |+NopNode  #an expression with no tokens at all in it ||  (no attributes)‏ |+VarLikeNode  #nil,false,true,__FILE__,__LINE__,self ||  (name: String)‏ |+UnOpNode  #unary operators ||  (op: String, val: Value)‏ ||+UnaryStarNode  #unary star (splat)‏ |||+DanglingStarNode  #unary star with no argument |||||  (no attributes)‏ ||||+DanglingCommaNode  #comma with no rhs ||  (no attributes)‏ |+ParenedNode  #ugly, parenthesized expressions and begin..end ||  (body: Value)  -OR-  (parentheses)‏ ||  (body: Value|nil, rescues: Array[RescueNode*], ||  else: Value|nil, ensure: Value|nil)  (begin...end and rescue as operator)‏ |+AssignNode  #assignment (including eg +=)‏ ||  (left:AssigneeList|LValue, op:String ,right:Array[Value*]|Value)‏
|+AssigneeList  #abstract, comma-delimited list of assignables |||  (Array[LValue*])‏ ||+NestedAssign  #nested lhs, in parentheses ||+MultiAssign  #regular top-level lhs ||+BlockParams  #block formal parameter list |+CallSiteNode  #abstract, method calls |||  (receiver: Value|nil, name: String,  |||  params: nil|Array[Value+,UnaryStarNode?,UnAmpNode?], |||  block_params: BlockParams, block: Value)‏ ||+CallNode  #normal method calls ||+KWCallNode  #keywords that look (more or less) like methods  ||  #(BEGIN END yield return break continue next)‏ |+ArrayLiteralNode #[..] ||  (Array[Value*])‏ |+IfNode  #if..end and unless..end ||  (if: Value, then: Value|nil, elsifs: Array[ElsifNode+]|Nil, else: Value|nil)‏ |+LoopNode  #while..end and until..end ||  (while: Value, do: Value:nil)‏ |+CaseNode  #case..end ||  (case: Value|nil, whens: Array[WhenNode*], else: Value|nil)‏ |+ForNode  #for..end ||  (for: LValue, in: Value, do: Value|nil)‏ |+HashLiteralNode #{..} ||  (Array[Value*]) (size must be even)‏ |+TernaryNode  # ? .. : ||  (if: Value, then: Value, else: Value)‏
|+MethodNode  #def..end ||  (receiver:Value|nil, name:String, ||  params:Array[VarNameToken*,AssignNode*,UnaryStarNode?,UnAmpNode?]|nil, ||  body: Value|nil, rescues: Array[RescueNode+]|nil, else: Value|nil, ensure: Value|nil)‏ |+AliasNode  #alias foo bar ||  (to: String|VarNameToken|StringNode, from: String|VarNameToken|StringNode)‏ |+UndefNode  #undef foo ||  (Array[String|StringNode+])‏ |+NamespaceNode #abstract ||+ModuleNode  #module..end |||  (name: VarNameToken|ConstantNode, body: Value|nil)‏ ||+ClassNode  #class..end |||  (name: VarNameToken|ConstantNode, parent: Value|nil, body: Value|nil)‏ ||+MetaClassNode  #class<<x..end ||  (val: Value, body: Value|nil)‏ |+BracketsGetNode #a[b] |  (receiver: Value, params: Array[Value+,UnaryStarNode?]|nil)‏ | ErrorNode  #mixed in to nodes with a syntax error +MisparsedNode  #mismatched braces or begin..end or the like
Drawbacks: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (19)

Practical scalaz
Practical scalazPractical scalaz
Practical scalaz
 
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184
 
week-7x
week-7xweek-7x
week-7x
 
Scalaz
ScalazScalaz
Scalaz
 
ProgrammingwithGOLang
ProgrammingwithGOLangProgrammingwithGOLang
ProgrammingwithGOLang
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189
 
Scala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereldScala: Functioneel programmeren in een object georiënteerde wereld
Scala: Functioneel programmeren in een object georiënteerde wereld
 
Ruby Basics by Rafiq
Ruby Basics by RafiqRuby Basics by Rafiq
Ruby Basics by Rafiq
 
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185
 
The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88The Ring programming language version 1.3 book - Part 15 of 88
The Ring programming language version 1.3 book - Part 15 of 88
 
LeetCode April Coding Challenge
LeetCode April Coding ChallengeLeetCode April Coding Challenge
LeetCode April Coding Challenge
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
Oscon 2010 Specs talk
Oscon 2010 Specs talkOscon 2010 Specs talk
Oscon 2010 Specs talk
 
The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.4 book - Part 6 of 30The Ring programming language version 1.4 book - Part 6 of 30
The Ring programming language version 1.4 book - Part 6 of 30
 
Swift rocks! #1
Swift rocks! #1Swift rocks! #1
Swift rocks! #1
 
The Ring programming language version 1.7 book - Part 27 of 196
The Ring programming language version 1.7 book - Part 27 of 196The Ring programming language version 1.7 book - Part 27 of 196
The Ring programming language version 1.7 book - Part 27 of 196
 
Arrays matrix 2020 ab
Arrays matrix 2020 abArrays matrix 2020 ab
Arrays matrix 2020 ab
 
Fp intro scala
Fp intro scalaFp intro scala
Fp intro scala
 
TRICK
TRICKTRICK
TRICK
 

Ähnlich wie Rubymacros

Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
adrianoalmeida7
 
check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdf
angelfragranc
 
#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf
ANSAPPARELS
 
Nik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReactNik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReact
OdessaJS Conf
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 

Ähnlich wie Rubymacros (20)

Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
Arrays
ArraysArrays
Arrays
 
Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011Petitparser at the Deep into Smalltalk School 2011
Petitparser at the Deep into Smalltalk School 2011
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
check the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdfcheck the modifed code now you will get all operations done.termin.pdf
check the modifed code now you will get all operations done.termin.pdf
 
Perl 6 in Context
Perl 6 in ContextPerl 6 in Context
Perl 6 in Context
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Kotlin, Spek and tests
Kotlin, Spek and testsKotlin, Spek and tests
Kotlin, Spek and tests
 
#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf#include iostream using namespace std; class Array { priva.pdf
#include iostream using namespace std; class Array { priva.pdf
 
Nik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReactNik Graf - Get started with Reason and ReasonReact
Nik Graf - Get started with Reason and ReasonReact
 
Slaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in RubySlaying the Dragon: Implementing a Programming Language in Ruby
Slaying the Dragon: Implementing a Programming Language in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Analysis of algorithms
Analysis of algorithms Analysis of algorithms
Analysis of algorithms
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Array, string and pointer
Array, string and pointerArray, string and pointer
Array, string and pointer
 
Quick swift tour
Quick swift tourQuick swift tour
Quick swift tour
 
Get started with Reason
Get started with ReasonGet started with Reason
Get started with Reason
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Rubymacros

  • 1.  
  • 3.  
  • 4.  
  • 5. “ print 'hello'” :(print 'hello')‏ proc{ print 'hello' }
  • 6. RedParse.new(“print 'hello'”).parse :(print 'hello')‏ RedParse::CallNode[nil, &quot;print&quot;, [RedParse::StringNode[&quot;hello&quot;, {:@line=>1, :@close=>&quot;'&quot;, :@open=>&quot;'&quot;, :@char=>&quot;amp;quot;&quot;}]], nil, nil, {:@line=>1, :@not_real_parens=>true, :@offset=>0, :@lvalue=>nil}]
  • 8. macro simple(a,b) :(^a+^b) end def simple_user p simple(1,2)‏ end
  • 9. if $Debug macro assert(cond)‏ if RedParse::OpNode===cond and /[=!]=/===cond.op left,op,right=*cond :(fail 'expected '+^left.unparse({})+&quot;(==#{^left}) to be &quot;+ ^op+&quot; &quot;+^right.unparse({})+&quot;(==#{^right})&quot; unless ^cond) else :(fail &quot;expected #{:(^^cond)}, but was not true&quot; unless ^cond)‏ end end else macro assert(cond)‏ end end
  • 10. def test_assert a=1 b=2 assert a #ok assert a!=b #ok assert(a==b) #oops, fails. msg=&quot;expected a(==1) to be == b(==2)&quot; assert(nil) #oops, fails. msg=&quot;expected nil, but was not true&quot; #ok, that message didn't make a lot of sense... end
  • 11. Syntax trees are represented by trees of nested Nodes. All Nodes descend from Array, and their subnodes can be addressed by numeric index, just like normal Arrays. However, many subnodes want to have names as well, thus most (but not all) array slots within the various Node classes have names. The general rule is that Node slots may contain a Node, a VarNameToken, a plain Array, a String, or nil. However, many cases are more specific than that.
  • 12. VarNameToken<RubyLexer::Token #represents variables and constants (ident: String)‏ Node<Array #abstract ancestor of all nodes (except VarNameToken)‏ +RescueNode #a rescue clause in a def of begin statement | (exceptions: Array[Value*], varname: VarNameToken|nil, action: Value)‏ +WhenNode #a when clause in a case statement | (when: Value|Array[Value+] then: Value|nil )‏ +ElsifNode #an elsif clause in an if statement | (elsif: Value, then: Value|nil)‏ +ValueNode #abstract, a node which has a value (an expression)‏ |+ListOpNode #abstract, ancestor for nodes which are lists of ||| #things separated by some op ||+SequenceNode #a sequence of statements ||| (Array[Value*])‏ ||+ConstantNode #a constant expression of the form A::B::C or the like || #first expression can be anything || (Array[String|Value|nil,String+])‏ |+RawOpNode #ancestor of all operators (but not . :: ; , ?..:)‏ ||| (left: Value, op: String, right: Value)‏ ||+OpNode #ancestor of some operators |||+RangeNode #a range literal node |||+KeywordOpNode #abstract, ancestor of keyword operators ||||+LogicalNode #and or && || expressions ||||+WhileOpNode #while as an operator ||||+UntilOpNode #until as an operator ||||+IfOpNode #if as an operator ||||+UnlessOpNode #unless as an operator |||+NotEqualNode #!= expressions
  • 13. |||+MatchNode #=~ expressions |||+NotMatchNode #!~ expressions |+LiteralNode #literal symbols, integers || (val: Numeric|Symbol|StringNode)‏ |+StringNode #literal strings ||| (Array[(String|Value)+])‏ ||+HereDocNode #here documents |+StringCatNode #adjacent strings are catenated (&quot;foo&quot; &quot;bar&quot; == &quot;foobar&quot;)‏ || (Array[StringNode+])‏ |+NopNode #an expression with no tokens at all in it || (no attributes)‏ |+VarLikeNode #nil,false,true,__FILE__,__LINE__,self || (name: String)‏ |+UnOpNode #unary operators || (op: String, val: Value)‏ ||+UnaryStarNode #unary star (splat)‏ |||+DanglingStarNode #unary star with no argument ||||| (no attributes)‏ ||||+DanglingCommaNode #comma with no rhs || (no attributes)‏ |+ParenedNode #ugly, parenthesized expressions and begin..end || (body: Value) -OR- (parentheses)‏ || (body: Value|nil, rescues: Array[RescueNode*], || else: Value|nil, ensure: Value|nil) (begin...end and rescue as operator)‏ |+AssignNode #assignment (including eg +=)‏ || (left:AssigneeList|LValue, op:String ,right:Array[Value*]|Value)‏
  • 14. |+AssigneeList #abstract, comma-delimited list of assignables ||| (Array[LValue*])‏ ||+NestedAssign #nested lhs, in parentheses ||+MultiAssign #regular top-level lhs ||+BlockParams #block formal parameter list |+CallSiteNode #abstract, method calls ||| (receiver: Value|nil, name: String, ||| params: nil|Array[Value+,UnaryStarNode?,UnAmpNode?], ||| block_params: BlockParams, block: Value)‏ ||+CallNode #normal method calls ||+KWCallNode #keywords that look (more or less) like methods || #(BEGIN END yield return break continue next)‏ |+ArrayLiteralNode #[..] || (Array[Value*])‏ |+IfNode #if..end and unless..end || (if: Value, then: Value|nil, elsifs: Array[ElsifNode+]|Nil, else: Value|nil)‏ |+LoopNode #while..end and until..end || (while: Value, do: Value:nil)‏ |+CaseNode #case..end || (case: Value|nil, whens: Array[WhenNode*], else: Value|nil)‏ |+ForNode #for..end || (for: LValue, in: Value, do: Value|nil)‏ |+HashLiteralNode #{..} || (Array[Value*]) (size must be even)‏ |+TernaryNode # ? .. : || (if: Value, then: Value, else: Value)‏
  • 15. |+MethodNode #def..end || (receiver:Value|nil, name:String, || params:Array[VarNameToken*,AssignNode*,UnaryStarNode?,UnAmpNode?]|nil, || body: Value|nil, rescues: Array[RescueNode+]|nil, else: Value|nil, ensure: Value|nil)‏ |+AliasNode #alias foo bar || (to: String|VarNameToken|StringNode, from: String|VarNameToken|StringNode)‏ |+UndefNode #undef foo || (Array[String|StringNode+])‏ |+NamespaceNode #abstract ||+ModuleNode #module..end ||| (name: VarNameToken|ConstantNode, body: Value|nil)‏ ||+ClassNode #class..end ||| (name: VarNameToken|ConstantNode, parent: Value|nil, body: Value|nil)‏ ||+MetaClassNode #class<<x..end || (val: Value, body: Value|nil)‏ |+BracketsGetNode #a[b] | (receiver: Value, params: Array[Value+,UnaryStarNode?]|nil)‏ | ErrorNode #mixed in to nodes with a syntax error +MisparsedNode #mismatched braces or begin..end or the like
  • 16.