Reduced number of tokens processed
This commit is contained in:
parent
57c9fc22d1
commit
1c27f0cad2
2 changed files with 9 additions and 15 deletions
|
@ -62,12 +62,6 @@ func (f *Function) Compile() {
|
|||
|
||||
case token.GroupEnd:
|
||||
groupLevel--
|
||||
|
||||
case token.BlockStart:
|
||||
// Add scope
|
||||
|
||||
case token.BlockEnd:
|
||||
// Remove scope
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,9 +123,8 @@ func (f *Function) CompileVariableDefinition(expr *expression.Expression) error
|
|||
}
|
||||
|
||||
name := expr.Children[0].Token.Text()
|
||||
_, exists := f.Variables[name]
|
||||
|
||||
if exists {
|
||||
if f.identifierExists(name) {
|
||||
return errors.New(&errors.VariableAlreadyExists{Name: name}, f.File, expr.Children[0].Token.Position)
|
||||
}
|
||||
|
||||
|
@ -161,11 +154,6 @@ func (f *Function) CompileVariableDefinition(expr *expression.Expression) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func (f *Function) identifierExists(name string) bool {
|
||||
_, exists := f.Variables[name]
|
||||
return exists
|
||||
}
|
||||
|
||||
// CompileFunctionCall compiles a function call.
|
||||
func (f *Function) CompileFunctionCall(expr *expression.Expression) error {
|
||||
funcName := expr.Children[0].Token.Text()
|
||||
|
@ -254,6 +242,12 @@ func (f *Function) String() string {
|
|||
return f.Name
|
||||
}
|
||||
|
||||
// identifierExists returns true if the identifier has been defined.
|
||||
func (f *Function) identifierExists(name string) bool {
|
||||
_, exists := f.Variables[name]
|
||||
return exists
|
||||
}
|
||||
|
||||
// isVariableDefinition returns true if the expression is a variable definition.
|
||||
func isVariableDefinition(expr *expression.Expression) bool {
|
||||
return expr.Token.Kind == token.Operator && expr.Token.Text() == ":="
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue