Add skipIndentLevel function

This commit is contained in:
Sasha Koshka 2022-09-05 14:56:35 -04:00
parent cc1eaa2c11
commit 613ccc3fba
1 changed files with 15 additions and 0 deletions

View File

@ -150,3 +150,18 @@ func (parser *ParsingOperation) previousToken () {
parser.token = parser.tokens[parser.tokenIndex]
return
}
// skipIndentLevel advances the parser, ignoring every line with an indentation
// equal to or greater than the specified indent.
func (parser *ParsingOperation) skipIndentLevel (indent int) (err error) {
for {
err = parser.nextToken()
if err != nil { return }
if parser.token.Is(lexer.TokenKindIndent) &&
parser.token.Value().(int) < indent {
return
}
}
}