Skip to content

Commit

Permalink
Add ECR::Lexer::SyntaxException with location info (#15222)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodywasishere authored Dec 17, 2024
1 parent a576c9d commit 25086b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ecr/lexer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class ECR::Lexer
end
end

class SyntaxException < Exception
getter line_number : Int32
getter column_number : Int32

def initialize(message, @line_number, @column_number)
super(message)
end
end

def initialize(string)
@reader = Char::Reader.new(string)
@token = Token.new
Expand Down Expand Up @@ -198,4 +207,8 @@ class ECR::Lexer
private def string_range(start_pos, end_pos)
@reader.string.byte_slice(start_pos, end_pos - start_pos)
end

private def raise(message : String)
raise SyntaxException.new(message, @line_number, @column_number)
end
end

0 comments on commit 25086b9

Please sign in to comment.