History

add set!

Sigrid Solveig Haflínudóttir committed 6 years ago

Commit 04545b31 parent 619ada82 files · +48 −37Browse files

Unified · Split

2 files
  1. README.md +1 −0
  2. aa.c +47 −37
README.md+1−0
@@ -43,6 +43,7 @@ newline · 42 unmodified lines
43not43not
44or44or
45quote45quote
46set!
46square47square
47while48while
48```49```
aa.c+47−37
@@ -45,6 +45,7 @@ · 44 unmodified lines
45enum {45enum {
46 P_LET,46 P_LET,
47 P_DEFINE,47 P_DEFINE,
48 P_SET_YAS,
48 P_IF,49 P_IF,
49 P_LAMBDA,50 P_LAMBDA,
50 P_MAC,51 P_MAC,
@@ -85,43 +86,44 @@ enum { · 34 unmodified lines
85};86};
86 87
87static const char *primnames[P_MAX] = {88static const char *primnames[P_MAX] = {
88 "let",89 [P_LET] = "let",
89 "define",90 [P_DEFINE] = "define",
90 "if",91 [P_SET_YAS] = "set!",
91 "lambda",92 [P_IF] = "if",
92 "mac",93 [P_LAMBDA] = "lambda",
93 "while",94 [P_MAC] = "mac",
94 "quote",95 [P_WHILE] = "while",
95 "eval",96 [P_QUOTE] = "quote",
96 "and",97 [P_EVAL] = "eval",
97 "or",98 [P_AND] = "and",
98 "begin",99 [P_OR] = "or",
99 "cons",100 [P_BEGIN] = "begin",
100 "car",101 [P_CONS] = "cons",
101 "cdr",102 [P_CAR] = "car",
102 "setcar",103 [P_CDR] = "cdr",
103 "setcdr",104 [P_SETCAR] = "setcar",
104 "list",105 [P_SETCDR] = "setcdr",
105 "not",106 [P_LIST] = "list",
106 "display",107 [P_NOT] = "not",
107 "eq?",108 [P_DISPLAY] = "display",
108 "equal?",109 [P_EQ_HUH] = "eq?",
109 "atom?",110 [P_EQUAL_HUH] = "equal?",
110 "number?",111 [P_ATOM_HUH] = "atom?",
111 "boolean?",112 [P_NUMBER_HUH] = "number?",
112 "port?",113 [P_BOOLEAN_HUH] = "boolean?",
113 "defined?",114 [P_PORT_HUH] = "port?",
114 "string?",115 [P_DEFINED_HUH] = "defined?",
115 "nan?",116 [P_STRING_HUH] = "string?",
116 "=",117 [P_NAN_HUH] = "nan?",
117 "<",118 [P_EQN] = "=",
118 ">",119 [P_LT] = "<",
119 "<=",120 [P_GT] = ">",
120 ">=",121 [P_LTE] = "<=",
121 "+",122 [P_GTE] = ">=",
122 "-",123 [P_ADD] = "+",
123 "*",124 [P_SUB] = "-",
124 "/",125 [P_MUL] = "*",
126 [P_DIV] = "/",
125};127};
126 128
127static const char *typenames[AA_TMAX] = {129static const char *typenames[AA_TMAX] = {
@@ -785,6 +787,14 @@ eval(aaContext *ctx, aaObject *obj, aaObject *env, aaObject **newenv) · 657 unmodified lines
785 CDR(getbound(ctx, res, env)) = evalarg();787 CDR(getbound(ctx, res, env)) = evalarg();
786 break;788 break;
787 789
790 case P_SET_YAS:
791 va = checktype(ctx, aa_nextarg(ctx, &arg, 0), AA_TSYMBOL);
792 if(ISUNBOUND(CDR(CDR(va))))
793 aa_error(ctx, "unbound variable: %ß", va);
794 else
795 aa_set(ctx, va, evalarg());
796 break;
797
788 case P_IF:798 case P_IF:
789 while(!ISNULL(arg)){799 while(!ISNULL(arg)){
790 va = evalarg();800 va = evalarg();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t