Class: Liquidscript::Compiler::ICR

Inherits:
Base
  • Object
show all
Includes:
Classes, 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/expressions.rb

Defined Under Namespace

Modules: Classes, 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, #code, #ref, #set, #value_expect

Methods included from Classes

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

Methods included from Literals

#_compile_for_in, #_compile_for_seg, #compile_action, #compile_array, #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_regex, #compile_sstring, #compile_while

Methods included from Functions

#compile_access, #compile_call, #compile_function_with_parameters, #compile_property

Methods included from Expressions

#_compile_lparen_expression, #_compile_lparen_method, #_compile_lparen_method_final, #compile_assignment, #compile_binop, #compile_expression, #compile_lparen, #compile_minus, #compile_plus, #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.



21
22
23
24
25
# File 'lib/liquidscript/compiler/icr.rb', line 21

def initialize(*)
  super

  handle_directives
end

Instance Method Details

#compile_startICR::Code

Sets the starting point for compiliation.

Returns:



43
44
45
# File 'lib/liquidscript/compiler/icr.rb', line 43

def compile_start
  compile_expression
end

#reset!void

This method returns an undefined value.

Resets the state of the compiler.



28
29
30
31
32
33
# File 'lib/liquidscript/compiler/icr.rb', line 28

def reset!
  @top         = Liquidscript::ICR::Set.new
  @top.context = Liquidscript::ICR::Context.new
  @set         = [@top]
  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:



36
37
38
# File 'lib/liquidscript/compiler/icr.rb', line 36

def top
  @set.last
end