Data section initialization values are now skimmed over
This commit is contained in:
parent
613ccc3fba
commit
ae0166b509
@ -28,6 +28,13 @@ func (parser *ParsingOperation) parseDataSection () (
|
||||
section.what, err = parser.parseType()
|
||||
if err != nil { return }
|
||||
|
||||
// skip the rest of the section if we are only skimming it
|
||||
if parser.skimming {
|
||||
section.external = true
|
||||
err = parser.skipIndentLevel(1)
|
||||
return
|
||||
}
|
||||
|
||||
if parser.token.Is(lexer.TokenKindNewline) {
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
@ -13,6 +13,7 @@ type ParsingOperation struct {
|
||||
token lexer.Token
|
||||
tokens []lexer.Token
|
||||
tokenIndex int
|
||||
skimming bool
|
||||
|
||||
tree SyntaxTree
|
||||
}
|
||||
@ -42,6 +43,7 @@ func Fetch (modulePath string, skim bool) (tree SyntaxTree, err error) {
|
||||
// miss, so parse the module.
|
||||
parser := ParsingOperation {
|
||||
modulePath: modulePath,
|
||||
skimming: skim,
|
||||
tree: SyntaxTree {
|
||||
sections: make(map[string] Section),
|
||||
},
|
||||
@ -155,13 +157,18 @@ func (parser *ParsingOperation) previousToken () {
|
||||
// equal to or greater than the specified indent.
|
||||
func (parser *ParsingOperation) skipIndentLevel (indent int) (err error) {
|
||||
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 {
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err = parser.nextToken()
|
||||
if err != nil { return }
|
||||
|
||||
if parser.token.Is(lexer.TokenKindIndent) &&
|
||||
parser.token.Value().(int) < indent {
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import "path/filepath"
|
||||
func checkTree (modulePath string, skim bool, correct string, test *testing.T) {
|
||||
cwd, _ := os.Getwd()
|
||||
modulePath = filepath.Join(cwd, modulePath)
|
||||
println(modulePath)
|
||||
tree, err := Fetch(modulePath, skim)
|
||||
|
||||
treeString := tree.ToString(0)
|
||||
|
Reference in New Issue
Block a user