Pass skim test
This commit is contained in:
parent
8b88e1d440
commit
51428e3755
@ -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()
|
||||
|
@ -21,7 +21,7 @@ func ro fComplexFunction
|
||||
external
|
||||
func ro gExternalFunction
|
||||
> x:Int
|
||||
< arr:Int
|
||||
< arr:Int 5
|
||||
---
|
||||
external
|
||||
`, test)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user