Variable references belonging to the parent scope added ('@')
This commit is contained in:
+12
-1
@@ -7,6 +7,7 @@ package expr
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -190,7 +191,17 @@ func (self *scanner) fetchNextToken() (tk *Token) {
|
||||
case '#':
|
||||
tk = self.makeToken(SymHash, ch)
|
||||
case '@':
|
||||
tk = self.makeToken(SymAt, ch)
|
||||
if next, _ := self.peek(); (next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z') {
|
||||
self.readChar()
|
||||
if tk = self.fetchIdentifier(next); tk.Sym == SymIdentifier {
|
||||
//tk.Sym = SymIdRef
|
||||
tk.source = "@" + tk.source
|
||||
} else {
|
||||
tk = self.makeErrorToken(fmt.Errorf("invalid variable reference %q", tk.source))
|
||||
}
|
||||
} else {
|
||||
tk = self.makeToken(SymAt, ch)
|
||||
}
|
||||
case '_':
|
||||
tk = self.makeToken(SymUndescore, ch)
|
||||
case '=':
|
||||
|
||||
Reference in New Issue
Block a user