mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
31 lines
812 B
Ruby
31 lines
812 B
Ruby
![]() |
require 'sass/script'
|
||
|
require 'sass/script/css_lexer'
|
||
|
|
||
|
module Sass
|
||
|
module Script
|
||
|
class CssParser < Parser
|
||
|
def initialize(str, line, offset, options = {})
|
||
|
@options = options
|
||
|
@lexer = CssLexer.new(str, line, offset, options)
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
# 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
|
||
|
alias_method :unary_div, :funcall
|
||
|
alias_method :paren, :string
|
||
|
end
|
||
|
end
|
||
|
end
|