Class: Deadfire::FrontEnd::Parser
- Inherits:
-
Object
- Object
- Deadfire::FrontEnd::Parser
- Defined in:
- lib/deadfire/front_end/parser.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#error_reporter ⇒ Object
readonly
Returns the value of attribute error_reporter.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
-
#initialize(tokens, error_reporter) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(tokens, error_reporter) ⇒ Parser
Returns a new instance of Parser.
8 9 10 11 12 13 |
# File 'lib/deadfire/front_end/parser.rb', line 8 def initialize(tokens, error_reporter) @error_reporter = error_reporter @tokens = tokens @current = 0 @stylesheet = StylesheetNode.new end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
6 7 8 |
# File 'lib/deadfire/front_end/parser.rb', line 6 def current @current end |
#error_reporter ⇒ Object (readonly)
Returns the value of attribute error_reporter.
6 7 8 |
# File 'lib/deadfire/front_end/parser.rb', line 6 def error_reporter @error_reporter end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/deadfire/front_end/parser.rb', line 6 def @options end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
6 7 8 |
# File 'lib/deadfire/front_end/parser.rb', line 6 def tokens @tokens end |
Instance Method Details
#parse ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/deadfire/front_end/parser.rb', line 15 def parse while !is_at_end? if check(:comment) comment = add_comment @stylesheet << comment unless Deadfire.configuration.compressed elsif check(:newline) newline = add_newline @stylesheet << newline unless Deadfire.configuration.compressed elsif matches_at_rule? @stylesheet << at_rule_declaration else @stylesheet << ruleset_declaration end end @stylesheet end |