We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I test the interpreter
` poolsize = 1 * 1024; line = 1;
// allocate memory for virtual machine if (!(text = old_text = malloc(poolsize))) return -1; if (!(data = malloc(poolsize))) return -1; if (!(stack = malloc(poolsize))) return -1; if (!(symbols = malloc(poolsize))) return -1; memset(text, 0, poolsize); memset(data, 0, poolsize); memset(stack, 0, poolsize); memset(symbols, 0, poolsize); bp = sp = (int *)((int)stack + poolsize); ax = 0; src = "char else enum if int return sizeof while " "open read close printf malloc memset memcmp exit void main"; // add keywords to symbol table i = Char; while (i <= While) { next(); current_id[Token] = i++; } // add library to symbol table i = OPEN; while (i <= EXIT) { next(); current_id[Class] = Sys; current_id[Type] = INT; current_id[Value] = i++; } next(); current_id[Token] = Char; next(); idmain = current_id;
src = "int vara; int varb; while (1) { vara=2; varb=3; int varc = vara + varb; if (varc >= 5) return varc; }";
program();
` It stuck at program() after while at (1). What do I do wrong?
The text was updated successfully, but these errors were encountered:
@jenya7 All variables should be declared before using. In your code, varc is not declared first. Checkout the example below:
varc
#include <stdio.h> int main() { int vara; int varb; int varc; while (1) { vara=2; varb=3; varc = vara + varb; if (varc >= 5) return varc; }; }
Sorry, something went wrong.
Still it stops at (1). May be it's mandatory to include all code in void main() { } ?
void main() { }
I see. Thank you, it works.
May I port it to an embedded system (a micro controller) as is?
No branches or pull requests
I test the interpreter
`
poolsize = 1 * 1024;
line = 1;
src = "int vara;
int varb;
while (1)
{
vara=2;
varb=3;
int varc = vara + varb;
if (varc >= 5)
return varc;
}";
`
It stuck at program() after while at (1). What do I do wrong?
The text was updated successfully, but these errors were encountered: