Enable using dollar symbol when defining a param variable

This commit is contained in:
Tobie Morgan Hitchcock 2019-01-08 15:51:53 +00:00
parent b901c78bd1
commit 33ba4d5de3
2 changed files with 14 additions and 1 deletions

View file

@ -149,6 +149,19 @@ func (p *parser) parseIdioms() (mul Idents, err error) {
}
func (p *parser) parseParam() (*Ident, error) {
_, lit, err := p.shouldBe(IDENT, PARAM)
if err != nil {
return nil, &ParseError{Found: lit, Expected: []string{"name"}}
}
val, err := p.declare(IDENT, lit)
return val.(*Ident), err
}
// --------------------------------------------------
//
// --------------------------------------------------

View file

@ -26,7 +26,7 @@ func (p *parser) parseLetStatement() (stmt *LetStatement, err error) {
// always be an identifier, specifying a
// variable name to set.
stmt.Name, err = p.parseIdent()
stmt.Name, err = p.parseParam()
if err != nil {
return nil, err
}