Implemented variable scopes
This commit is contained in:
parent
96078f40d8
commit
1bf288b8fd
13 changed files with 81 additions and 26 deletions
|
@ -16,9 +16,9 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error {
|
|||
switch t.Kind {
|
||||
case token.Identifier:
|
||||
name := t.Text()
|
||||
variable, exists := f.variables[name]
|
||||
variable := f.Variable(name)
|
||||
|
||||
if !exists {
|
||||
if variable == nil {
|
||||
return errors.New(&errors.UnknownIdentifier{Name: name}, f.File, t.Position)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue