diff options
| author | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2026-01-27 16:37:02 +0100 |
| commit | 60f6ebc8d8369721e105d826145af2b8856ac67e (patch) | |
| tree | 002073b75edc68aba95399db89f50b24ebb6935f /parser | |
| parent | aa5861917ac2543f85bf4cfefbb69cf501d4de41 (diff) | |
fix: improve multiple define
The VM Vassign instruction now takes an argument to indicates the
number of assignations to perform on the stack.
Definitions with a function returning multiple values now work.
There is still some simplifications, and also to apply the same
strategy to var declarations with assign.
Diffstat (limited to 'parser')
| -rw-r--r-- | parser/decl.go | 2 | ||||
| -rw-r--r-- | parser/parse.go | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/parser/decl.go b/parser/decl.go index 378eb56..0ba0075 100644 --- a/parser/decl.go +++ b/parser/decl.go @@ -358,7 +358,7 @@ func (p *Parser) parseVarLine(in Tokens) (out Tokens, err error) { } out = append(out, newIdent(vars[i], 0)) out = append(out, v...) - out = append(out, newToken(lang.Assign, "", 0)) + out = append(out, newToken(lang.Assign, "", 0, 1)) } return out, err } diff --git a/parser/parse.go b/parser/parse.go index 9c1fd13..68721f2 100644 --- a/parser/parse.go +++ b/parser/parse.go @@ -184,11 +184,11 @@ func (p *Parser) parseAssign(in Tokens, aindex int) (out Tokens, err error) { // Map elements cannot be assigned directly, but only through IndexAssign. out = out[:len(out)-1] out = append(out, toks...) - out = append(out, newToken(lang.IndexAssign, "", in[aindex].Pos)) + out = append(out, newToken(lang.IndexAssign, "", in[aindex].Pos, len(lhs))) } else { out = append(out, toks...) if out[len(out)-1].Tok != lang.Range { - out = append(out, newToken(in[aindex].Tok, "", in[aindex].Pos)) + out = append(out, newToken(in[aindex].Tok, "", in[aindex].Pos, len(lhs))) } } return out, err @@ -215,10 +215,10 @@ func (p *Parser) parseAssign(in Tokens, aindex int) (out Tokens, err error) { // Map elements cannot be assigned directly, but only through IndexAssign. out = out[:len(out)-1] out = append(out, toks...) - out = append(out, newToken(lang.IndexAssign, "", in[aindex].Pos)) + out = append(out, newToken(lang.IndexAssign, "", in[aindex].Pos, 1)) } else { out = append(out, toks...) - out = append(out, newToken(in[aindex].Tok, "", in[aindex].Pos)) + out = append(out, newToken(in[aindex].Tok, "", in[aindex].Pos, 1)) } } return out, err |
