Class: Deadfire::ParserEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/deadfire/parser_engine.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, options = {}) ⇒ ParserEngine

Returns a new instance of ParserEngine.



7
8
9
10
11
12
# File 'lib/deadfire/parser_engine.rb', line 7

def initialize(content, options = {})
  @error_reporter = ErrorReporter.new
  @options = {}
  @asset_loader = AssetLoader.new(options[:filename])
  @scanner = FrontEnd::Scanner.new(content, error_reporter)
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



5
6
7
# File 'lib/deadfire/parser_engine.rb', line 5

def current
  @current
end

#error_reporterObject (readonly)

Returns the value of attribute error_reporter.



5
6
7
# File 'lib/deadfire/parser_engine.rb', line 5

def error_reporter
  @error_reporter
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/deadfire/parser_engine.rb', line 5

def options
  @options
end

Instance Method Details

#errors?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/deadfire/parser_engine.rb', line 31

def errors?
  @error_reporter.errors?
end

#load_mixinsObject



35
36
37
38
39
40
41
42
# File 'lib/deadfire/parser_engine.rb', line 35

def load_mixins
  ast = _parse
  parser = MixinParser.new
  ast.statements.each do |node|
    parser.interpret(node)
  end
  parser.mixins
end

#parseObject



14
15
16
17
18
19
20
21
# File 'lib/deadfire/parser_engine.rb', line 14

def parse
  ast = _parse
  interpreter = Interpreter.new(error_reporter, @asset_loader)
  ast.statements.each do |node|
    interpreter.interpret(node)
  end
  CssGenerator.new(ast).generate
end


23
24
25
26
27
28
29
# File 'lib/deadfire/parser_engine.rb', line 23

def print_ast
  ast = _parse
  printer = AstPrinter.new
  ast.statements.each do |node|
    printer.print(node)
  end
end