Module: Rubasteme::AST

Defined in:
lib/rubasteme/ast.rb,
lib/rubasteme/ast/leaf_node.rb,
lib/rubasteme/ast/branch_node.rb

Defined Under Namespace

Classes: AndNode, AssignmentNode, BeginNode, BindSpecNode, BindingsNode, BodyNode, BooleanNode, BranchNode, CaseClauseNode, CaseNode, CaseRecipientClauseNode, CharacterNode, CondClauseNode, CondNode, CondRecipientClauseNode, ConditionalNode, DataNode, DoNode, DotNode, ElseClauseNode, ElseRecipientClauseNode, EmptyListNode, FormalsNode, HoldingSequenceBaseNode, IdentifierDefinitionNode, IdentifierNode, IllegalNode, InternalDefinitionsNode, IterationBindingsNode, IterationSpecNode, LambdaExpressionNode, LeafNode, LetBaseNode, LetNode, LetStarNode, LetrecNode, LetrecStarNode, ListNode, Node, NumberNode, OrNode, ProcedureCallNode, ProgramNode, QuotationNode, RecipientClauseBaseNode, SequenceNode, StringNode, TestAndDoResultNode, TestAndSequenceBaseNode, UnlessNode, VectorNode, WhenNode

Constant Summary collapse

AST_NODE_TYPE =

:nodoc:

[           # :nodoc:
  # leaf
  :ast_empty_list,
  :ast_boolean,
  :ast_identifier,
  :ast_character,
  :ast_string,
  :ast_number,
  :ast_dot,
  # branch
  :ast_program,
  :ast_vector,
  :ast_list,
  :ast_quotation,
  :ast_procedure_call,
  :ast_lambda_expression,
  :ast_formals,
  :ast_body,
  :ast_internal_definitions,
  :ast_sequence,
  :ast_conditional,
  :ast_assignment,
  :ast_identifier_definition,
  :ast_cond,
  :ast_cond_clause,
  :ast_cond_recipient_clause,
  :ast_else_clause,
  :ast_case,
  :ast_case_clause,
  :ast_data,
  :ast_case_recipient_clause,
  :ast_else_recipient_clause,
  :ast_and,
  :ast_or,
  :ast_when,
  :ast_unless,
  :ast_let,
  :ast_let_star,
  :ast_letrec,
  :ast_letrec_star,
  :ast_bindings,
  :ast_bind_spec,
  :ast_begin,
  :ast_do,
  :ast_iteration_bindings,
  :ast_test_and_do_result,
  :ast_iteration_spec,
  # misc.
  :ast_illegal,
]

Class Method Summary collapse

Class Method Details

.instantiate(ast_node_type, literal = nil) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/rubasteme/ast.rb', line 62

def self.instantiate(ast_node_type, literal = nil)
  type_name = Utils.camel_case(ast_node_type.to_s.delete_prefix("ast_"))
  klass = AST.const_get("#{type_name}Node")

  if klass.nil? or klass == IllegalNode
    IllegalNode.new(ast_node_type, literal)
  else
    klass.new(literal)
  end
end