Class: RSAC::PropertyParser
- Inherits:
-
GeneratedPropertyParser
- Object
- Racc::Parser
- GeneratedPropertyParser
- RSAC::PropertyParser
- Defined in:
- lib/antisamy/csspool/rsac/sac/property_parser.rb
Constant Summary
Constants inherited from GeneratedPropertyParser
GeneratedPropertyParser::Racc_arg, GeneratedPropertyParser::Racc_debug_parser, GeneratedPropertyParser::Racc_token_to_s_table
Instance Method Summary collapse
-
#initialize ⇒ PropertyParser
constructor
A new instance of PropertyParser.
- #parse_tokens(tokens) ⇒ Object
Methods inherited from GeneratedPropertyParser
Constructor Details
#initialize ⇒ PropertyParser
Returns a new instance of PropertyParser.
5 6 7 8 |
# File 'lib/antisamy/csspool/rsac/sac/property_parser.rb', line 5 def initialize @tokens = [] @token_table = Racc_arg[10] end |
Instance Method Details
#parse_tokens(tokens) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/antisamy/csspool/rsac/sac/property_parser.rb', line 10 def parse_tokens(tokens) negate = false # Nasty hack for unary minus @tokens = tokens.find_all { |x| x.name != :S }.map { |token| tok = if @token_table.has_key?(token.value) [token.value, token.value] else if token.name == :delim && !@token_table.has_key?(token.value) negate = true if token.value == '-' nil else token.to_racc_token end end if negate && tok tok[1] = "-#{tok[1]}" negate = false end tok }.compact begin return do_parse rescue ParseError => e return nil end end |