Class: RSAC::Parser

Inherits:
GeneratedParser show all
Defined in:
lib/antisamy/csspool/rsac/sac/parser.rb

Constant Summary collapse

VERSION =

The version of CSSPool you’re using

'0.2.7'
TOKENIZER =
Tokenizer.new

Constants inherited from GeneratedParser

GeneratedParser::Racc_arg, GeneratedParser::Racc_debug_parser, GeneratedParser::Racc_token_to_s_table

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GeneratedParser

#_reduce_none

Constructor Details

#initialize(document_handler = StyleSheet.new(self)) ⇒ Parser

Returns a new instance of Parser.



18
19
20
21
22
23
24
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 18

def initialize(document_handler = StyleSheet.new(self))
  @error_handler = ErrorHandler.new
  @document_handler = document_handler
  @property_parser = PropertyParser.new()
  @tokenizer = TOKENIZER
  @logger = nil
end

Instance Attribute Details

#document_handlerObject

Returns the value of attribute document_handler.



16
17
18
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 16

def document_handler
  @document_handler
end

#error_handlerObject

Returns the value of attribute error_handler.



16
17
18
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 16

def error_handler
  @error_handler
end

#loggerObject

Returns the value of attribute logger.



16
17
18
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 16

def logger
  @logger
end

#property_parserObject (readonly)

Returns the value of attribute property_parser.



57
58
59
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 57

def property_parser
  @property_parser
end

#tokenizerObject (readonly)

Returns the value of attribute tokenizer.



58
59
60
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 58

def tokenizer
  @tokenizer
end

Instance Method Details

#parse_rule(rule) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 39

def parse_rule(rule)
  returner = Class.new(DocumentHandler) {
    attr_accessor :selector
    alias :start_selector :selector=
  }.new
  old_document_handler = self.document_handler
  self.document_handler = returner
  self.parse("#{rule} { }")
  self.document_handler = old_document_handler
  returner.selector
end

#parse_style_sheet(string) ⇒ Object Also known as: parse



26
27
28
29
30
31
32
33
34
35
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 26

def parse_style_sheet(string)
  @yydebug = true
  @tokens = TOKENIZER.tokenize(string)
  @position = 0

  self.document_handler.start_document(string)
  do_parse
  self.document_handler.end_document(string)
  self.document_handler
end

#parser_versionObject

Returns the parser version. We return CSS2, but its actually CSS2.1. No font-face tags. Sorry.



53
54
55
# File 'lib/antisamy/csspool/rsac/sac/parser.rb', line 53

def parser_version
  "http://www.w3.org/TR/REC-CSS2"
end