More accurate line number and character offset reporting.
This commit is contained in:
parent
b5d098b3c8
commit
5cb9e83d18
|
@ -303,7 +303,7 @@ END
|
|||
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath variable declarations.", @line + 1) unless line.children.empty?
|
||||
raise SyntaxError.new("Invalid variable: \"#{line.text}\".", @line) unless name && value
|
||||
|
||||
Tree::VariableNode.new(name, parse_script(value), op == '||=', @options)
|
||||
Tree::VariableNode.new(name, parse_script(value, :offset => line.offset + line.text.index(value)), op == '||=', @options)
|
||||
end
|
||||
|
||||
def parse_comment(line)
|
||||
|
|
|
@ -6,7 +6,9 @@ module Sass
|
|||
def run
|
||||
environment = Environment.new
|
||||
environment.set_var('important', Script::String.new('!important'))
|
||||
@line = 0
|
||||
loop do
|
||||
@line += 1
|
||||
unless text = Readline.readline('>> ')
|
||||
puts
|
||||
return
|
||||
|
@ -32,7 +34,7 @@ module Sass
|
|||
|
||||
p environment.var(name)
|
||||
else
|
||||
p Script::Parser.parse(text).perform(environment)
|
||||
p Script::Parser.parse(text, @line, 0).perform(environment)
|
||||
end
|
||||
rescue Sass::SyntaxError => e
|
||||
puts "SyntaxError: #{e.message}"
|
||||
|
|
|
@ -125,7 +125,7 @@ module Sass
|
|||
protected
|
||||
|
||||
def current_position
|
||||
@offset + @scanner.pos
|
||||
@offset + @scanner.pos + 1
|
||||
end
|
||||
def last_match_position
|
||||
current_position - @scanner.matchedsize
|
||||
|
|
|
@ -50,7 +50,7 @@ class SassEngineTest < Test::Unit::TestCase
|
|||
"@import foo.sass" => "File to import not found or unreadable: foo.sass.",
|
||||
"@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
|
||||
"foo\n @import templates/basic" => "Import directives may only be used at the root of a document.",
|
||||
"!foo = bar baz !" => "Syntax error in 'bar baz !' at character 8.",
|
||||
"!foo = bar baz !" => "Syntax error in 'bar baz !' at character 20.",
|
||||
"=foo\n :color red\n.bar\n +bang" => "Undefined mixin 'bang'.",
|
||||
".bar\n =foo\n :color red\n" => ["Mixins may only be defined at the root of a document.", 2],
|
||||
"=foo\n :color red\n.bar\n +foo\n :color red" => "Illegal nesting: Nothing may be nested beneath mixin directives.",
|
||||
|
|
Loading…
Reference in New Issue