Class: Liquidscript::Scanner::Base
- Inherits:
-
Object
- Object
- Liquidscript::Scanner::Base
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
Defined Under Namespace
Modules: DSL, Lexer
Classes: Builder, Context
Constant Summary
collapse
- EXIT =
Object.new.freeze
Class Attribute Summary collapse
Class Method 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.
28
29
30
31
32
33
|
# File 'lib/liquidscript/scanner/base.rb', line 28
def initialize(source)
@source = source
@scanner = StringScanner.new(@source)
@tokens = []
@_scan = nil
end
|
Class Attribute Details
.default ⇒ Object
Returns the value of attribute default.
24
25
26
|
# File 'lib/liquidscript/scanner/base.rb', line 24
def default
@default
end
|
Class Method Details
.contexts ⇒ Object
20
21
22
|
# File 'lib/liquidscript/scanner/base.rb', line 20
def contexts
@_contexts ||= Set.new
end
|
Instance Method Details
#column ⇒ Object
62
63
64
|
# File 'lib/liquidscript/scanner/base.rb', line 62
def column
"(unkown)"
end
|
#contexts ⇒ Object
35
36
37
|
# File 'lib/liquidscript/scanner/base.rb', line 35
def contexts
self.class.contexts
end
|
#default_context ⇒ Object
39
40
41
|
# File 'lib/liquidscript/scanner/base.rb', line 39
def default_context
self.class.default
end
|
#each ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/liquidscript/scanner/base.rb', line 48
def each
e = buffer.each
if block_given?
e.each(&Proc.new)
else
e
end
end
|
#emit(token_name, body = nil) ⇒ Object
66
67
68
|
# File 'lib/liquidscript/scanner/base.rb', line 66
def emit(token_name, body = nil)
@tokens << Token.new(token_name, body, line, column)
end
|
#inspect ⇒ Object
70
71
72
|
# File 'lib/liquidscript/scanner/base.rb', line 70
def inspect
"#<#{self.class}:#{'0x%08x' % object_id}>"
end
|
#line ⇒ Object
58
59
60
|
# File 'lib/liquidscript/scanner/base.rb', line 58
def line
"(unknown)"
end
|
#scan ⇒ Object
43
44
45
46
|
# File 'lib/liquidscript/scanner/base.rb', line 43
def scan
lex default_context
self
end
|