/scalate-jruby/src/main/resources/haml-3.0.25/lib/sass/scss/script_parser.rb

http://github.com/scalate/scalate · Ruby · 25 lines · 15 code · 2 blank · 8 comment · 0 complexity · 73b35560c2ef260966160dfcfcd7a8eb MD5 · raw file

  1. module Sass
  2. module SCSS
  3. # A mixin for subclasses of {Sass::Script::Parser}
  4. # that makes them usable by {SCSS::Parser} to parse SassScript.
  5. # In particular, the parser won't raise an error
  6. # when there's more content in the lexer once lexing is done.
  7. # In addition, the parser doesn't support `!` for a variable prefix.
  8. module ScriptParser
  9. private
  10. # @private
  11. def lexer_class
  12. klass = Class.new(super)
  13. klass.send(:include, ScriptLexer)
  14. klass
  15. end
  16. # Instead of raising an error when the parser is done,
  17. # rewind the StringScanner so that it hasn't consumed the final token.
  18. def assert_done
  19. @lexer.unpeek!
  20. end
  21. end
  22. end
  23. end