Class: Liquidscript::Scanner::Base

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Lexer
Defined in:
lib/liquidscript/scanner/base.rb,
lib/liquidscript/scanner/base/dsl.rb,
lib/liquidscript/scanner/base/lexer.rb,
lib/liquidscript/scanner/base/builder.rb,
lib/liquidscript/scanner/base/context.rb

Overview

TODO: documentation

Direct Known Subclasses

Liquidscript

Defined Under Namespace

Modules: DSL, Lexer Classes: Builder, Context

Constant Summary collapse

EXIT =
Object.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Lexer

#error, #lex, #perform_with_context

Constructor Details

#initialize(source) ⇒ Base

Returns a new instance of Base.



20
21
22
23
24
25
26
# File 'lib/liquidscript/scanner/base.rb', line 20

def initialize(source)
  @source   = source
  @scanner  = StringScanner.new(@source)
  @tokens   = []
  @_scan    = nil
   = {}
end

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata.



18
19
20
# File 'lib/liquidscript/scanner/base.rb', line 18

def 
  
end

Instance Method Details

#columnObject



55
56
57
# File 'lib/liquidscript/scanner/base.rb', line 55

def column
  "(unkown)"
end

#contextsObject



28
29
30
# File 'lib/liquidscript/scanner/base.rb', line 28

def contexts
  self.class.contexts
end

#default_contextObject



32
33
34
# File 'lib/liquidscript/scanner/base.rb', line 32

def default_context
  self.class.default
end

#eachObject



41
42
43
44
45
46
47
48
49
# File 'lib/liquidscript/scanner/base.rb', line 41

def each
  e = buffer.each

  if block_given?
    e.each(&Proc.new)
  else
    e
  end
end

#emit(token_name, body = nil) ⇒ Object



59
60
61
# File 'lib/liquidscript/scanner/base.rb', line 59

def emit(token_name, body = nil)
  @tokens << Token.new(token_name, body, line, column)
end

#inspectObject



63
64
65
# File 'lib/liquidscript/scanner/base.rb', line 63

def inspect
  "#<#{self.class}:#{'0x%08x' % object_id}>"
end

#lineObject



51
52
53
# File 'lib/liquidscript/scanner/base.rb', line 51

def line
  "(unknown)"
end

#scanObject



36
37
38
39
# File 'lib/liquidscript/scanner/base.rb', line 36

def scan
  lex default_context
  self
end