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()
 | 
						section.what, err = parser.parseType()
 | 
				
			||||||
	if err != nil { return }
 | 
						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) {
 | 
						if parser.token.Is(lexer.TokenKindNewline) {
 | 
				
			||||||
		err = parser.nextToken()
 | 
							err = parser.nextToken()
 | 
				
			||||||
		if err != nil { return }
 | 
							if err != nil { return }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,7 @@ type ParsingOperation struct {
 | 
				
			|||||||
	token      lexer.Token
 | 
						token      lexer.Token
 | 
				
			||||||
	tokens     []lexer.Token
 | 
						tokens     []lexer.Token
 | 
				
			||||||
	tokenIndex int
 | 
						tokenIndex int
 | 
				
			||||||
 | 
						skimming   bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tree SyntaxTree
 | 
						tree SyntaxTree
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -42,6 +43,7 @@ func Fetch (modulePath string, skim bool) (tree SyntaxTree, err error) {
 | 
				
			|||||||
	// miss, so parse the module.
 | 
						// miss, so parse the module.
 | 
				
			||||||
	parser := ParsingOperation {
 | 
						parser := ParsingOperation {
 | 
				
			||||||
		modulePath: modulePath,
 | 
							modulePath: modulePath,
 | 
				
			||||||
 | 
							skimming:   skim,
 | 
				
			||||||
		tree: SyntaxTree {
 | 
							tree: SyntaxTree {
 | 
				
			||||||
			sections: make(map[string] Section),			
 | 
								sections: make(map[string] Section),			
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@ -155,13 +157,18 @@ func (parser *ParsingOperation) previousToken () {
 | 
				
			|||||||
// 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) {
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
 | 
							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) &&
 | 
								if !parser.token.Is(lexer.TokenKindIndent) ||
 | 
				
			||||||
				parser.token.Value().(int) < indent {
 | 
									parser.token.Value().(int) < indent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							err = parser.nextToken()
 | 
				
			||||||
 | 
							if err != nil { return }
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,6 @@ import "path/filepath"
 | 
				
			|||||||
func checkTree (modulePath string, skim bool, correct string, test *testing.T) {
 | 
					func checkTree (modulePath string, skim bool, correct string, test *testing.T) {
 | 
				
			||||||
	cwd, _ := os.Getwd()
 | 
						cwd, _ := os.Getwd()
 | 
				
			||||||
	modulePath = filepath.Join(cwd, modulePath)
 | 
						modulePath = filepath.Join(cwd, modulePath)
 | 
				
			||||||
	println(modulePath)
 | 
					 | 
				
			||||||
	tree, err := Fetch(modulePath, skim)
 | 
						tree, err := Fetch(modulePath, skim)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	treeString := tree.ToString(0)
 | 
						treeString := tree.ToString(0)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user