Removed erroneous indentation from indent test file
Need to find a more controlled and accurate way to test erroneous indentation. Possibly by analyzing the returned error object.
This commit is contained in:
parent
2a7111e700
commit
31a2d84483
@ -101,16 +101,17 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
|
|||||||
// indent level
|
// indent level
|
||||||
previousToken := lexer.tokens[len(lexer.tokens) - 1]
|
previousToken := lexer.tokens[len(lexer.tokens) - 1]
|
||||||
|
|
||||||
if !previousToken.Is(TokenKindNewline) ||
|
if !previousToken.Is(TokenKindNewline) {
|
||||||
!previousToken.Is(TokenKindNewline) {
|
err = lexer.nextRune()
|
||||||
|
|
||||||
file.NewError (
|
file.NewError (
|
||||||
lexer.file.Location(), 1,
|
lexer.file.Location(), 1,
|
||||||
"tab not used as indent",
|
"tab not used as indent",
|
||||||
file.ErrorKindWarn)
|
file.ErrorKindWarn).Print()
|
||||||
break
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eat up tabs while increasing the indent level
|
||||||
indentLevel := 0
|
indentLevel := 0
|
||||||
for lexer.char == '\t' {
|
for lexer.char == '\t' {
|
||||||
indentLevel ++
|
indentLevel ++
|
||||||
@ -124,11 +125,12 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
|
|||||||
})
|
})
|
||||||
case '\n':
|
case '\n':
|
||||||
// line break
|
// line break
|
||||||
|
|
||||||
|
// if the last line is empty, discard it
|
||||||
lastLineEmpty := true
|
lastLineEmpty := true
|
||||||
tokenIndex := len(lexer.tokens) - 1
|
tokenIndex := len(lexer.tokens) - 1
|
||||||
for lexer.tokens[tokenIndex].kind != TokenKindNewline {
|
for lexer.tokens[tokenIndex].kind != TokenKindNewline {
|
||||||
if lexer.tokens[tokenIndex].kind != TokenKindIndent {
|
if lexer.tokens[tokenIndex].kind != TokenKindIndent {
|
||||||
|
|
||||||
lastLineEmpty = false
|
lastLineEmpty = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -139,7 +141,6 @@ func (lexer *LexingOperation) tokenizeSymbolBeginning () (err error) {
|
|||||||
lexer.tokens = lexer.tokens[:tokenIndex]
|
lexer.tokens = lexer.tokens[:tokenIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if last line was blank, (ony whitespace) discard.
|
|
||||||
lexer.addToken (Token {
|
lexer.addToken (Token {
|
||||||
kind: TokenKindNewline,
|
kind: TokenKindNewline,
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user