Pass skim test

This commit is contained in:
Sasha Koshka 2022-09-29 11:15:58 -04:00
parent 8b88e1d440
commit 51428e3755
3 changed files with 27 additions and 6 deletions

View File

@ -150,16 +150,35 @@ func (parser *ParsingOperation) previousToken () {
// 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) {
braceLevel := 0
parenLevel := 0
bracketLevel := 0
for {
if parser.token.Is(lexer.TokenKindNewline) {
err = parser.nextToken()
if err != nil { return }
if !parser.token.Is(lexer.TokenKindIndent) ||
parser.token.Value().(int) < indent {
shouldBreak :=
!parser.token.Is(lexer.TokenKindIndent) ||
parser.token.Value().(int) < indent
shouldBreak =
shouldBreak &&
braceLevel < 1 &&
parenLevel < 1 &&
bracketLevel < 1
return
}
if shouldBreak { return }
}
switch parser.token.Kind() {
case lexer.TokenKindLBrace: braceLevel ++
case lexer.TokenKindRBrace: braceLevel --
case lexer.TokenKindLParen: parenLevel ++
case lexer.TokenKindRParen: parenLevel --
case lexer.TokenKindLBracket: bracketLevel ++
case lexer.TokenKindRBracket: bracketLevel --
}
err = parser.nextToken()

View File

@ -21,7 +21,7 @@ func ro fComplexFunction
external
func ro gExternalFunction
> x:Int
< arr:Int
< arr:Int 5
---
external
`, test)

View File

@ -20,7 +20,9 @@ data ro eIntegerArrayInitialized:Int:16:mut
func ro fComplexFunction
---
= x:Int 3
= y:{Int} [loc x]
= y:{Int
} [loc x
]
= z:Int:8 (
398 9 2309 983 -2387
478 555 123)