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
|
// skipIndentLevel advances the parser, ignoring every line with an indentation
|
||||||
// equal to or greater than the specified indent.
|
// equal to or greater than the specified indent.
|
||||||
func (parser *ParsingOperation) skipIndentLevel (indent int) (err error) {
|
func (parser *ParsingOperation) skipIndentLevel (indent int) (err error) {
|
||||||
|
braceLevel := 0
|
||||||
|
parenLevel := 0
|
||||||
|
bracketLevel := 0
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if parser.token.Is(lexer.TokenKindNewline) {
|
if parser.token.Is(lexer.TokenKindNewline) {
|
||||||
err = parser.nextToken()
|
err = parser.nextToken()
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
|
|
||||||
if !parser.token.Is(lexer.TokenKindIndent) ||
|
shouldBreak :=
|
||||||
parser.token.Value().(int) < indent {
|
!parser.token.Is(lexer.TokenKindIndent) ||
|
||||||
|
parser.token.Value().(int) < indent
|
||||||
|
|
||||||
return
|
shouldBreak =
|
||||||
|
shouldBreak &&
|
||||||
|
braceLevel < 1 &&
|
||||||
|
parenLevel < 1 &&
|
||||||
|
bracketLevel < 1
|
||||||
|
|
||||||
|
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()
|
err = parser.nextToken()
|
||||||
|
@ -21,7 +21,7 @@ func ro fComplexFunction
|
|||||||
external
|
external
|
||||||
func ro gExternalFunction
|
func ro gExternalFunction
|
||||||
> x:Int
|
> x:Int
|
||||||
< arr:Int
|
< arr:Int 5
|
||||||
---
|
---
|
||||||
external
|
external
|
||||||
`, test)
|
`, test)
|
||||||
|
@ -20,7 +20,9 @@ data ro eIntegerArrayInitialized:Int:16:mut
|
|||||||
func ro fComplexFunction
|
func ro fComplexFunction
|
||||||
---
|
---
|
||||||
= x:Int 3
|
= x:Int 3
|
||||||
= y:{Int} [loc x]
|
= y:{Int
|
||||||
|
} [loc x
|
||||||
|
]
|
||||||
= z:Int:8 (
|
= z:Int:8 (
|
||||||
398 9 2309 983 -2387
|
398 9 2309 983 -2387
|
||||||
478 555 123)
|
478 555 123)
|
||||||
|
Reference in New Issue
Block a user