diff --git a/file/error.go b/file/error.go index 4aed323..cfdb853 100644 --- a/file/error.go +++ b/file/error.go @@ -12,7 +12,6 @@ const ( type Error struct { Location - width int message string kind ErrorKind } @@ -20,7 +19,6 @@ type Error struct { // NewError creates a new error at the specified location. func NewError ( location Location, - width int, message string, kind ErrorKind, ) ( @@ -28,7 +26,6 @@ func NewError ( ) { return &Error { Location: location, - width: width, message: message, kind: kind, } diff --git a/file/file.go b/file/file.go index 557be39..bbaaca8 100644 --- a/file/file.go +++ b/file/file.go @@ -108,5 +108,6 @@ func (file *File) Location () (location Location) { file: file, row: file.currentLine, column: file.currentColumn, + width: 1, } } diff --git a/file/location.go b/file/location.go index acc65cf..e20abb5 100644 --- a/file/location.go +++ b/file/location.go @@ -6,4 +6,5 @@ type Location struct { file *File row int column int + width int } diff --git a/lexer/lexer.go b/lexer/lexer.go index 4e75732..fac177e 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -35,7 +35,7 @@ func (lexer *LexingOperation) tokenize () (err error) { if err != nil || shebangCheck[index] != lexer.char { err = file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "not an arf file", file.ErrorKindError) return @@ -119,7 +119,7 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) { err = lexer.nextRune() file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "tab not used as indent", file.ErrorKindWarn).Print() return @@ -272,7 +272,7 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) { err = lexer.nextRune() default: err = file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "unexpected symbol character " + string(lexer.char), file.ErrorKindError) @@ -334,7 +334,7 @@ func (lexer *LexingOperation) nextRune () (err error) { lexer.char, _, err = lexer.file.ReadRune() if err != nil && err != io.EOF { return file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), err.Error(), file.ErrorKindError) } return diff --git a/lexer/numbers.go b/lexer/numbers.go index c96f1c8..4414bc3 100644 --- a/lexer/numbers.go +++ b/lexer/numbers.go @@ -23,7 +23,7 @@ func (lexer *LexingOperation) tokenizeNumberBeginning (negative bool) (err error number, fragment, isFloat, err = lexer.tokenizeNumber(8) } else { return file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "unexpected character in number literal", file.ErrorKindError) } diff --git a/lexer/text.go b/lexer/text.go index 9a2adb0..e2359e2 100644 --- a/lexer/text.go +++ b/lexer/text.go @@ -43,7 +43,7 @@ func (lexer *LexingOperation) tokenizeString (isRuneLiteral bool) (err error) { if isRuneLiteral { if len(got) > 1 { err = file.NewError ( - lexer.file.Location(), len(got) - 1, + lexer.file.Location(), "excess data in rune literal", file.ErrorKindError) return @@ -99,7 +99,7 @@ func (lexer *LexingOperation) getEscapeSequence () (result rune, err error) { if len(number) < 3 { err = file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "octal escape sequence too short", file.ErrorKindError) return @@ -133,7 +133,7 @@ func (lexer *LexingOperation) getEscapeSequence () (result rune, err error) { if len(number) < want { err = file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "hex escape sequence too short ", file.ErrorKindError) return @@ -143,7 +143,7 @@ func (lexer *LexingOperation) getEscapeSequence () (result rune, err error) { result = rune(parsedNumber) } else { err = file.NewError ( - lexer.file.Location(), 1, + lexer.file.Location(), "unknown escape character " + string(lexer.char), file.ErrorKindError) return