Skip to content

Commit

Permalink
carrets->carets
Browse files Browse the repository at this point in the history
  • Loading branch information
ydah committed Dec 25, 2023
1 parent f5b8a5f commit 6562bdc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/lrama/lexer/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def to_s
def generate_error_message(error_message)
<<~ERROR.chomp
#{path}:#{first_line}:#{first_column}: #{error_message}
#{line_with_carrets}
#{line_with_carets}
ERROR
end

def line_with_carrets
def line_with_carets
<<~TEXT
#{text}
#{carrets}
#{carets}
TEXT
end

Expand All @@ -78,7 +78,7 @@ def blanks
(text[0...first_column] or raise "#{first_column} is invalid").gsub(/[^\t]/, ' ')
end

def carrets
def carets
blanks + '^' * (last_column - first_column)
end

Expand Down
4 changes: 2 additions & 2 deletions sig/lrama/lexer/location.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ module Lrama
def ==: (Location other) -> bool
def partial_location: (Integer, Integer) -> Location
def generate_error_message: (String) -> String
def line_with_carrets: () -> String
def line_with_carets: () -> String

private

def path: () -> String
def blanks: () -> String
def carrets: () -> String
def carets: () -> String
def text: () -> String
def _text: () -> Array[String]
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lrama/lexer/location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
end
end

describe "#line_with_carrets" do
it "returns line text with carrets" do
describe "#line_with_carets" do
it "returns line text with carets" do
path = fixture_path("lexer/location.y")
grammar_file = Lrama::Lexer::GrammarFile.new(path, File.read(path))
location = Lrama::Lexer::Location.new(grammar_file: grammar_file, first_line: 33, first_column: 12, last_line: 33, last_column: 15)
Expand All @@ -42,7 +42,7 @@
^^^
TEXT

expect(location.line_with_carrets).to eq expected
expect(location.line_with_carets).to eq expected
end
end
end

0 comments on commit 6562bdc

Please sign in to comment.