2010-03-27 15:52:41 -07:00
|
|
|
require 'sass/script'
|
|
|
|
require 'sass/script/css_lexer'
|
|
|
|
|
|
|
|
module Sass
|
|
|
|
module Script
|
2010-04-20 02:55:28 -07:00
|
|
|
# This is a subclass of {Parser} for use in parsing plain CSS properties.
|
|
|
|
#
|
|
|
|
# @see Sass::SCSS::CssParser
|
2010-03-27 15:52:41 -07:00
|
|
|
class CssParser < Parser
|
|
|
|
private
|
|
|
|
|
2010-03-29 22:57:18 -07:00
|
|
|
# @private
|
|
|
|
def lexer_class; CssLexer; end
|
|
|
|
|
2010-03-27 15:52:41 -07:00
|
|
|
# We need a production that only does /,
|
|
|
|
# since * and % aren't allowed in plain CSS
|
|
|
|
production :div, :unary_plus, :div
|
|
|
|
|
|
|
|
def string
|
|
|
|
return number unless tok = try_tok(:string)
|
|
|
|
return tok.value unless @lexer.peek && @lexer.peek.type == :begin_interpolation
|
|
|
|
end
|
|
|
|
|
|
|
|
# Short-circuit all the SassScript-only productions
|
|
|
|
alias_method :interpolation, :concat
|
|
|
|
alias_method :or_expr, :div
|
2010-04-17 14:56:17 -07:00
|
|
|
alias_method :unary_div, :ident
|
2010-03-27 15:52:41 -07:00
|
|
|
alias_method :paren, :string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|