This commit is contained in:
silva guimaraes 2025-08-23 20:02:18 -03:00
parent 0cd6040a1f
commit c1f75bb980
6 changed files with 140 additions and 67 deletions

View file

@ -96,6 +96,35 @@ func parseValue(in *Input) (Expression, error) {
}
}
func parseParamList(in *Input) (Expression, error) {
list, err := in.TakeParens(Lparen, Rparen)
if err != nil {
return nil, err
}
var params []*Symbol
for list.Len() > 0 {
p, err := list.TakeParens(LsquareBracket, RsquareBracket)
if err != nil {
return nil, err
}
if p.Len() != 2 {
return nil, fmt.Errorf("expected parameter in the following form: [identifier type]")
}
id, ok := p.Peek(0).(*Identifier)
if !ok {
return nil, noMatch
}
typ, ok := p.Peek(1).(*Identifier)
if !ok {
return nil, noMatch
}
params = append(params, &Symbol{
id: ,
})
}
return args, nil
}
func parseList(in *Input) (Expression, error) {
openingParens, ok := in.Pop()
if !ok {
@ -192,11 +221,7 @@ func parseLambda(in *Input) (Expression, error) {
return nil, fmt.Errorf("unmatched parenthesis starting at %s", openingParens.Position())
}
decl := in.Take(idx)
tok, ok := decl.Pop()
if !ok {
return nil, noMatch
}
if !tok.Equals(LambdaTok) {
if tok, ok := decl.Pop(); !ok || !tok.Equals(LambdaTok) {
return nil, noMatch
}
l, err := parseList(decl)