Skip to content

Commit

Permalink
added a check to remove function parameters from the dependancies
Browse files Browse the repository at this point in the history
  • Loading branch information
mkarten committed Oct 3, 2024
1 parent bed1b47 commit 2e8598d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parser/Parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Parser struct {
}

var selectorDepth int
var inFunction bool

// Step moves the parser to the next token
func (p *Parser) Step() {
Expand Down Expand Up @@ -1068,6 +1069,12 @@ func (p *Parser) ParseAnonymousFunctionExpr() Expr {
tempAnonymousFunctionDecl.Prototype = p.ParsePrototype()
p.Step()
tempAnonymousFunctionDecl.Body = p.ParseBody()
// check the parsed prototype parameters and remove them from the list of dependencies if they are inside
for _, param := range tempAnonymousFunctionDecl.Prototype.Parameters {
if contains(param.Name, p.CurrentFile.Dependencies) {
p.CurrentFile.RemoveDependency(param.Name)
}
}
p.Step()
//check if it is a call
if p.CurrentToken.TokenType == lexer.LPAREN {
Expand Down Expand Up @@ -1122,12 +1129,20 @@ func (p *Parser) ParseFunctionDecl() Node {
p.HandleFatal("Expected '(' after function name")
return nil
}
inFunction = true
tempFunctionDecl.Prototype = p.ParsePrototype()
p.Step()
tempFunctionDecl.Body = p.ParseBody()
// check the parsed prototype parameters and remove them from the list of dependencies if they are inside
for _, param := range tempFunctionDecl.Prototype.Parameters {
if contains(param.Name, p.CurrentFile.Dependencies) {
p.CurrentFile.RemoveDependency(param.Name)
}
}
p.Step()
p.CurrentFile.FunctionDecl = append(p.CurrentFile.FunctionDecl, tempFunctionDecl.Name)
p.DisableEOLChecking()
inFunction = false
return tempFunctionDecl
}

Expand Down

0 comments on commit 2e8598d

Please sign in to comment.