Print warning when a tab is discovered where it shouldn't be
This commit is contained in:
parent
0d2d10fe04
commit
245798f33d
@ -63,6 +63,7 @@ func (err Error) Error () (formattedMessage string) {
|
|||||||
columnCountdown --
|
columnCountdown --
|
||||||
}
|
}
|
||||||
for err.width > 1 {
|
for err.width > 1 {
|
||||||
|
// TODO: for tabs, print out 8 of these instead.
|
||||||
formattedMessage += "-"
|
formattedMessage += "-"
|
||||||
}
|
}
|
||||||
formattedMessage += "-\n"
|
formattedMessage += "-\n"
|
||||||
|
@ -59,8 +59,18 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
|
|||||||
}
|
}
|
||||||
case '\t':
|
case '\t':
|
||||||
// indent level
|
// indent level
|
||||||
// TODO: throw error if tab is not at line beginning, or after
|
previousToken := lexer.tokens[len(lexer.tokens) - 1]
|
||||||
// other tab
|
|
||||||
|
if !previousToken.Is(TokenKindNewline) ||
|
||||||
|
!previousToken.Is(TokenKindNewline) {
|
||||||
|
|
||||||
|
file.NewError (
|
||||||
|
lexer.file.Location(), 1,
|
||||||
|
"tab not used as indent",
|
||||||
|
file.ErrorKindWarn)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
for lexer.char == '\t' {
|
for lexer.char == '\t' {
|
||||||
lexer.addToken (Token {
|
lexer.addToken (Token {
|
||||||
kind: TokenKindIndent,
|
kind: TokenKindIndent,
|
||||||
|
@ -62,6 +62,11 @@ func (token Token) Kind () (kind TokenKind) {
|
|||||||
return token.kind
|
return token.kind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is returns whether or not the token is of kind kind.
|
||||||
|
func (token Token) Is (kind TokenKind) (match bool) {
|
||||||
|
return token.kind == kind
|
||||||
|
}
|
||||||
|
|
||||||
// Value returns the value of the token. Depending on what kind of token it is,
|
// Value returns the value of the token. Depending on what kind of token it is,
|
||||||
// this value may be nil.
|
// this value may be nil.
|
||||||
func (token Token) Value () (value any) {
|
func (token Token) Value () (value any) {
|
||||||
|
Reference in New Issue
Block a user