1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-13 11:23:59 +03:00

Ada: add variable length args (bind)

This commit is contained in:
Chris M Moore 2015-04-26 19:28:22 +01:00
parent 0571a45f09
commit a90ea3c742
2 changed files with 12 additions and 3 deletions

View File

@ -111,12 +111,21 @@ package body Envs is
procedure Bind (E : Env_Handle; Syms, Exprs : Types.List_Mal_Type) is
use Types;
S, Expr : List_Mal_Type;
First_Sym : Atom_Ptr;
begin
S := Syms;
Expr := Exprs;
while not Is_Null (S) and not Is_Null (Expr) loop
Set (E, Deref_Atom (Car (S)).Get_Atom, Car (Expr));
while not Is_Null (S) loop
First_Sym := Deref_Atom (Car (S));
if First_Sym.Get_Atom = "&" then
S := Deref_List (Cdr (S)).all;
First_Sym := Deref_Atom (Car (S));
Set (E, First_Sym.Get_Atom, New_List_Mal_Type (Expr));
exit;
end if;
Set (E, First_Sym.Get_Atom, Car (Expr));
S := Deref_List (Cdr (S)).all;
exit when Is_Null (Expr);
Expr := Deref_List (Cdr (Expr)).all;
end loop;
end Bind;

View File

@ -84,7 +84,7 @@ package body Reader is
(Opentoken.Recognizer.Identifier.Get (Start_Chars, Body_Chars));
Lisp_Syms : constant Ada.Strings.Maps.Character_Set :=
Ada.Strings.Maps.To_Set ("[]{}()'`~^@+-*/<>=");
Ada.Strings.Maps.To_Set ("[]{}()'`~^@&+-*/<>=");
Sym_Recognizer : constant Tokenizer.Recognizable_Token :=
Tokenizer.Get (Opentoken.Recognizer.Single_Character_Set.Get (Lisp_Syms));