class Savi::Compiler::Reparse

Overview

The purpose of the Reparse pass is to clean up the work of the parser, such as rebalancing ASTs or converting them to more specific forms.

For example, this pass converts dot-relations into function calls, a more specific AST form that is useful to handle as a single unit later.

This pass also converts each dot-relation for a known nested type name into single identifier that represents the full type name, so that later passes do not need to deal with nested type names as if they were calls.

This pass uses copy-on-mutate patterns to "mutate" the Program topology. This pass uses copy-on-mutate patterns to "mutate" the AST. This pass may raise compilation errors. This pass keeps temporary state at the per-function level. This pass produces no output state.

Defined in:

savi/compiler/reparse.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Savi::AST::CopyOnMutateVisitor

visit(ctx : Compiler::Context, node : Node) visit, visit_any?(ctx : Compiler::Context, node : Node) visit_any?, visit_children?(ctx : Compiler::Context, node : Node) visit_children?, visit_pre(ctx : Compiler::Context, node : Node) visit_pre

Constructor Detail

def self.new(namespace : Namespace::Analysis) #

[View source]

Class Method Detail

def self.cached_or_run(ctx, l, t, f : Program::Function, deps, &) : Program::Function #

[View source]
def self.run(ctx, package) #

[View source]
def self.t_cached_or_run(ctx, l, t : Program::Type, deps, &) : Program::Type #

[View source]
def self.ta_cached_or_run(ctx, l, t : Program::TypeAlias, deps, &) : Program::TypeAlias #

[View source]

Instance Method Detail

def maybe_dot_relation_to_nested_type_ident(ctx, node : AST::Relate) : AST::Identifier | Nil #

[View source]
def maybe_nested_ident_value(node : AST::Node) : String | Nil #

[View source]
def run(ctx, f) #

[View source]
def run_for_type_alias_target(ctx, t) #

[View source]
def run_for_type_params(ctx, t) #

[View source]
def visit(ctx, node : AST::Identifier) #

[View source]
def visit(ctx, node : AST::Qualify) #

[View source]
def visit(ctx, node : AST::Relate) #

[View source]
def visit_local_or_param_defn(ctx, node) #

[View source]