Comments (2)
make a new function:
void compileSymbolList(char* var, Cell* symbolList)
{
Cell tmp = malloc(sizeof(struct cell));
size_t len = strlen(var) + 1;
char* sym = malloc(len);
strcpy(sym, var);
car(tmp) = (Cell)sym;
cdr(tmp) = *symbolList;
*symbolList = tmp;
}
to use here:
while ((c = fgetc(fp)) != ')')
{
ungetc(c, fp);
char buf[LINESIZE];
char* var = readToken(buf, sizeof(buf), fp);
if (strcmp(var, ".") == 0)
{
var = readToken(buf, sizeof(buf), fp);
compileSymbolList(var, &symbolList);
if (strcmp(var, ")") != 0)
{
AQ_PRINTF("Too much elements are given to dot list.\n");
return;
}
index++;
var = readToken(buf, sizeof(buf), fp);
break;
}
else
{
var = readToken(buf, sizeof(buf), fp);
compileSymbolList(var, &symbolList);
index++;
}
}
from aquario.
In execute(),
case FUNCSM:
{
Cell l = popArg();
int argNum = ivalue(stack[stack_top - 1]);
int paramNum = ivalue(lambdaParamNum(l));
if (paramNum > argNum)
{
AQ_PRINTF("param num is wrong: %d, %d\n", paramNum, argNum);
++pc;
break;
}
popArg();
int num = argNum - paramNum + 1;
Cell lst = (Cell)AQ_NIL;
for (i = 0; i < num; i++)
{
lst = pairCell(stack[stack_top - 1], lst);
popArg();
}
pushArg(lst);
pushArg(makeInteger(paramNum));
int retAddr = pc + 1;
pushArg(makeInteger(retAddr));
updateOffsetReg();
// jump
int funcAddr = ivalue(lambdaAddr(l));
pc = funcAddr;
}
from aquario.
Related Issues (20)
- Error handling HOT 1
- eval allows procedure call even it is not actually procedure HOT 2
- Confusing names: GET_OBJECT_SIZE and get_obj_size HOT 1
- Dot form HOT 1
- Allocate heap memory at gc/base.c instead of at each GC algorithms.
- New options
- Mark-Sweep exhausts heap HOT 1
- Lambda without arguments causes SEGV HOT 1
- Integer should be immediate number HOT 1
- tak.lsp causes SEGV
- Tail Call Optimization
- Directly call closure
- Main flow improvement
- Travis-CI fails
- Restore GC HOT 1
- Integer should be made by makeInteger() HOT 1
- Script needs an empty line at the end HOT 1
- Remove unnecessary cast to Cell HOT 1
- Problems with aquari0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aquario.