Class: Liquidscript::Compiler::ICR

Inherits:
Base
  • Object
show all
Includes:
Classes, Directives, Expressions, Functions, Groups, Helpers, Literals
Defined in:
lib/liquidscript/compiler/icr.rb,
lib/liquidscript/compiler/icr/groups.rb,
lib/liquidscript/compiler/icr/classes.rb,
lib/liquidscript/compiler/icr/helpers.rb,
lib/liquidscript/compiler/icr/heredoc.rb,
lib/liquidscript/compiler/icr/literals.rb,
lib/liquidscript/compiler/icr/functions.rb,
lib/liquidscript/compiler/icr/directives.rb,
lib/liquidscript/compiler/icr/expressions.rb

Overview

A list of codes:

  • :class

  • :module

  • :neg

  • :pos

  • :binop

  • :unop

  • :set

  • :expression

  • :property

  • :access

  • :call

  • :function

  • :if

  • :elsif

  • :unless

  • :else

  • :try

  • :catch

  • :finally

  • :nrange

  • :number

  • :action

  • :range

  • :while

  • :for_in

  • :for_seg

  • :regex

  • :href

  • :interop

  • :istring

  • :sstring

  • :operator

  • :keyword

  • :object

  • :array

  • :newline (depricated)

Defined Under Namespace

Modules: Classes, Directives, Expressions, Functions, Groups, Helpers, Literals Classes: Heredoc

Instance Method Summary collapse

Methods included from Groups

#compile_catch, #compile_else, #compile_elsif, #compile_finally, #compile_if, #compile_try, #compile_unless

Methods included from Helpers

#_compile_block, #check, #code, #ref, #set, #value_expect

Methods included from Classes

#_compile_class_body, #_compile_class_body_key, #_new_token, #compile_class, #compile_module, #delegate_if_class

Methods included from Literals

#_compile_for_in, #_compile_for_seg, #compile_action, #compile_array, #compile_erange, #compile_for, #compile_function, #compile_heredoc, #compile_href, #compile_identifier, #compile_iheredoc_begin, #compile_istring, #compile_istring_begin, #compile_keyword, #compile_newline, #compile_number, #compile_object, #compile_object_key, #compile_operator, #compile_range, #compile_regex, #compile_sstring, #compile_while

Methods included from Functions

#compile_access, #compile_call, #compile_function_with_parameters, #compile_property

Methods included from Directives

included

Methods included from Expressions

#_compile_lparen_argument, #_compile_lparen_expression, #_compile_lparen_method, #_compile_lparen_method_final, #compile_assignment, #compile_binop, #compile_directive, #compile_expression, #compile_lparen, #compile_minus, #compile_plus, #compile_return, #compile_unop, #compile_vexpression

Methods inherited from Base

#compile, #compile?, #peek, #pop, #scanner_nil

Methods included from Base::Helpers

#action, #collect_compiles, #expect, #loop, #maybe, #peek?, #shift

Constructor Details

#initializeObject

Initializes the compiler.

Parameters:

  • scanner (Scanner, #each)

    the scanner. Used to manage the tokens. This could be stubbed out, if the #each function returns an Enumerator, which yields Scanner::Tokens.



62
63
64
# File 'lib/liquidscript/compiler/icr.rb', line 62

def initialize(*)
  super
end

Instance Method Details

#compile_startICR::Code

Sets the starting point for compiliation.

Returns:



83
84
85
# File 'lib/liquidscript/compiler/icr.rb', line 83

def compile_start
  compile_expression
end

#normalize(s) ⇒ Object



87
88
89
# File 'lib/liquidscript/compiler/icr.rb', line 87

def normalize(s)
  s.map { |x| x.gsub(/\-[a-z]/) { |p| p[1].upcase } }
end

#reset!void

This method returns an undefined value.

Resets the state of the compiler.



67
68
69
70
71
72
73
# File 'lib/liquidscript/compiler/icr.rb', line 67

def reset!
  @top         = Liquidscript::ICR::Set.new
  @top.context = Liquidscript::ICR::Context.new
  @set         = [@top]
  @classes     = {}
  super
end

#topArray, #push

Returns the top set. If the variable @top isn’t set by the inheriting class, then it defaults to the value of an array.

Returns:



76
77
78
# File 'lib/liquidscript/compiler/icr.rb', line 76

def top
  @set.last
end