Variable nodes now have the variable name in .Value.

This commit is contained in:
Qi Xiao 2016-02-07 02:31:11 +01:00
parent 77df994361
commit 64401af225
2 changed files with 2 additions and 2 deletions

View File

@ -503,7 +503,7 @@ func (cp *compiler) primary(n *parse.Primary) valuesOp {
case parse.Bareword, parse.SingleQuoted, parse.DoubleQuoted:
return literalStr(n.Value)
case parse.Variable:
qname := n.Value[1:]
qname := n.Value
if !cp.registerVariableGet(qname) {
cp.errorf(n.Begin(), "variable %s not found", n.Value)
}

View File

@ -557,7 +557,7 @@ func hexToDigit(r rune) (rune, bool) {
func (pn *Primary) variable(ps *parser) {
pn.Type = Variable
defer func() { pn.Value = ps.src[pn.begin:ps.pos] }()
defer func() { pn.Value = ps.src[pn.begin+1 : ps.pos] }()
ps.next()
// The character of the variable name can be anything.
if ps.next() == EOF {