Merge pull request #44 from UB-CSE443/Sprint3-Symbol_Table_Restructure-FE-t#NoTask
Sprint3 symbol table restructure fe t#no task
This commit is contained in:
6
.clang-format
Normal file
6
.clang-format
Normal file
@ -0,0 +1,6 @@
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
ColumnLimit: 0
|
||||
AllowShortStringsOnSingleLine: true
|
||||
BreakStringLiterals: false
|
||||
ReflowComments: false
|
2
Makefile
2
Makefile
@ -29,7 +29,7 @@ tmp/symbol_table.o: src/symbol_table.c src/symbol_table.h
|
||||
$(CC) $(CFLAGS) -o tmp/symbol_table.o -c src/symbol_table.c
|
||||
|
||||
runner: tmp/lex.yy.c tmp/runner.o tmp/symbol_table.o
|
||||
$(CC) $(CFLAGS) -o $(EXE) tmp/runner.o tmp/grammar.tab.c tmp/lex.yy.c
|
||||
$(CC) $(CFLAGS) -o $(EXE) -g -ggdb tmp/runner.o tmp/grammar.tab.c tmp/lex.yy.c
|
||||
|
||||
debug: CFLAGS += -DDEBUG=1
|
||||
debug: clean compiler
|
||||
|
2
check.sh
2
check.sh
@ -33,6 +33,8 @@ compare_files() {
|
||||
diff -q "$file" "$exp" > /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo -e "${GREEN}[✔] ${PURPLE}$filename ${WHITE}passed.${NOCOLOR}"
|
||||
elif [[ ! -s "$file" ]]; then
|
||||
echo -e "${RED}[✘] ${PURPLE}$filename ${WHITE}failed with an empty file. (did it segfault?)${NOCOLOR}"
|
||||
else
|
||||
echo -e "\n${RED}[✘] ${PURPLE}$file ${WHITE}failed with an unexpected value...${NOCOLOR}"
|
||||
diff --color=always "$file" "$exp"
|
||||
|
745
src/grammar.y
745
src/grammar.y
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,16 @@
|
||||
#endif
|
||||
extern SymbolTable * cur;
|
||||
extern FILE* tok_flag;
|
||||
extern TableNode *funprime;
|
||||
extern TableNode *funtypeprime;
|
||||
extern TableNode *arrayprim;
|
||||
extern TableNode *recprime;
|
||||
extern TableNode *integ;
|
||||
extern TableNode *addr;
|
||||
extern TableNode *chara;
|
||||
extern TableNode *stri;
|
||||
extern TableNode *boo;
|
||||
extern TableNode *undefined;
|
||||
extern void incr(int lnum,int cnum, int tok);
|
||||
extern void print_tok(int tok);
|
||||
|
||||
@ -36,10 +46,10 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
|
||||
%%
|
||||
|
||||
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {if(tok_flag != NULL){print_tok(T_INTEGER);}incr(line_number,column_number,T_INTEGER);yylval.words = strdup(yytext);return T_INTEGER;}}
|
||||
"address" {if(DEBUG) {printf( "T_ADDRESS: %s (%d)\n", yytext, T_ADDRESS);} else {if(tok_flag != NULL){print_tok(T_ADDRESS);}incr(line_number,column_number,T_ADDRESS);yylval.words = strdup(yytext);return T_ADDRESS;}}
|
||||
"Boolean" {if(DEBUG) {printf( "T_BOOLEAN: %s (%d)\n", yytext, T_BOOLEAN);} else {if(tok_flag != NULL){print_tok(T_INTEGER);}incr(line_number,column_number,T_INTEGER);yylval.words = strdup(yytext);return T_BOOLEAN;}}
|
||||
"character" {if(DEBUG) {printf( "T_CHARACTER: %s (%d)\n", yytext, T_CHARACTER);} else {if(tok_flag != NULL){print_tok(T_CHARACTER);}incr(line_number,column_number,T_CHARACTER);yylval.words = strdup(yytext);return T_CHARACTER;}}
|
||||
"integer" {if(DEBUG) {printf( "T_INTEGER: %s (%d)\n", yytext, T_INTEGER);} else {if(tok_flag != NULL){print_tok(T_INTEGER);}incr(line_number,column_number,T_INTEGER);yylval.tn = integ;return T_INTEGER;}}
|
||||
"address" {if(DEBUG) {printf( "T_ADDRESS: %s (%d)\n", yytext, T_ADDRESS);} else {if(tok_flag != NULL){print_tok(T_ADDRESS);}incr(line_number,column_number,T_ADDRESS);yylval.tn = addr;return T_ADDRESS;}}
|
||||
"Boolean" {if(DEBUG) {printf( "T_BOOLEAN: %s (%d)\n", yytext, T_BOOLEAN);} else {if(tok_flag != NULL){print_tok(T_INTEGER);}incr(line_number,column_number,T_INTEGER);yylval.tn = boo;return T_BOOLEAN;}}
|
||||
"character" {if(DEBUG) {printf( "T_CHARACTER: %s (%d)\n", yytext, T_CHARACTER);} else {if(tok_flag != NULL){print_tok(T_CHARACTER);}incr(line_number,column_number,T_CHARACTER);yylval.tn = chara;return T_CHARACTER;}}
|
||||
|
||||
"while" {if(DEBUG) {printf( "WHILE: %s (%d)\n", yytext, WHILE);} else {if(tok_flag != NULL){print_tok(WHILE);}incr(line_number,column_number,WHILE);return WHILE;}}
|
||||
"if" {if(DEBUG) {printf( "IF: %s (%d)\n", yytext, IF);} else {if(tok_flag != NULL){print_tok(IF);}incr(line_number,column_number,IF);return IF;}}
|
||||
@ -73,8 +83,8 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
"->" {if(DEBUG) {printf( "ARROW: %s (%d)\n", yytext, ARROW);} else {if(tok_flag != NULL){print_tok(ARROW);}incr(line_number,column_number,ARROW);return ARROW;}}
|
||||
|
||||
{DIGIT}+ {if(DEBUG) {printf( "C_INTEGER: %s (%d)\n", yytext, C_INTEGER);} else {if(tok_flag != NULL){print_tok(C_INTEGER);}incr(line_number,column_number,C_INTEGER);yylval.integ = atoi(yytext)/*words = strdup("integer")*/;return C_INTEGER;}}
|
||||
'{CHAR}' {if(DEBUG) {printf( "C_CHARACTER: %s (%d)\n", yytext, C_CHARACTER);} else {if(tok_flag != NULL){print_tok(C_CHARACTER);}incr(line_number,column_number,C_CHARACTER);yylval.words = strdup("character");return C_CHARACTER;}}
|
||||
\"{SCHAR}*\" {if(DEBUG) {printf( "C_STRING: %s (%d)\n", yytext, C_STRING);} else {if(tok_flag != NULL){print_tok(C_STRING);}incr(line_number,column_number,C_STRING);yylval.words = strdup("string");return C_STRING;}}
|
||||
'{CHAR}' {if(DEBUG) {printf( "C_CHARACTER: %s (%d)\n", yytext, C_CHARACTER);} else {if(tok_flag != NULL){print_tok(C_CHARACTER);}incr(line_number,column_number,C_CHARACTER);yylval.tn = chara;return C_CHARACTER;}}
|
||||
\"{SCHAR}*\" {if(DEBUG) {printf( "C_STRING: %s (%d)\n", yytext, C_STRING);} else {if(tok_flag != NULL){print_tok(C_STRING);}incr(line_number,column_number,C_STRING);yylval.tn = stri;return C_STRING;}}
|
||||
{COMMENT} {if(DEBUG) {printf( "COMMENT: %s (%d)\n", yytext, COMMENT);} else {if(tok_flag != NULL){print_tok(COMMENT);}incr(line_number,column_number,COMMENT);/*return COMMENT;*/}}
|
||||
|
||||
"(" {if(DEBUG) {printf( "L_PAREN: %s (%d)\n", yytext, L_PAREN);} else {if(tok_flag != NULL){print_tok(L_PAREN);}incr(line_number,column_number,L_PAREN);return L_PAREN;}}
|
||||
@ -84,9 +94,9 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\]
|
||||
"{" {if(DEBUG) {printf( "L_BRACE: %s (%d)\n", yytext, L_BRACE);} else {if(tok_flag != NULL){print_tok(L_BRACE);}incr(line_number,column_number,L_BRACE);return L_BRACE;}}
|
||||
"}" {if(DEBUG) {printf( "R_BRACE: %s (%d)\n", yytext, R_BRACE);} else {if(tok_flag != NULL){print_tok(R_BRACE);}incr(line_number,column_number,R_BRACE);return R_BRACE;}}
|
||||
|
||||
"true" {if(DEBUG) {printf( "C_TRUE: %s (%d)\n", yytext, C_TRUE);} else {if(tok_flag != NULL){print_tok(C_TRUE);}incr(line_number,column_number,C_TRUE);yylval.words = strdup("Boolean");return C_TRUE;}}
|
||||
"false" {if(DEBUG) {printf( "C_FALSE: %s (%d)\n", yytext, C_FALSE);} else {if(tok_flag != NULL){print_tok(C_FALSE);}incr(line_number,column_number,C_FALSE);yylval.words = strdup("Boolean");return C_FALSE;}}
|
||||
"null" {if(DEBUG) {printf( "C_NULL: %s (%d)\n", yytext, C_NULL);} else {if(tok_flag != NULL){print_tok(C_NULL);}incr(line_number,column_number,C_NULL);yylval.words = strdup("address");return C_NULL;}}
|
||||
"true" {if(DEBUG) {printf( "C_TRUE: %s (%d)\n", yytext, C_TRUE);} else {if(tok_flag != NULL){print_tok(C_TRUE);}incr(line_number,column_number,C_TRUE);yylval.tn = boo;return C_TRUE;}}
|
||||
"false" {if(DEBUG) {printf( "C_FALSE: %s (%d)\n", yytext, C_FALSE);} else {if(tok_flag != NULL){print_tok(C_FALSE);}incr(line_number,column_number,C_FALSE);yylval.tn = boo;return C_FALSE;}}
|
||||
"null" {if(DEBUG) {printf( "C_NULL: %s (%d)\n", yytext, C_NULL);} else {if(tok_flag != NULL){print_tok(C_NULL);}incr(line_number,column_number,C_NULL);yylval.tn = addr;return C_NULL;}}
|
||||
|
||||
{ID} {if(DEBUG) {printf( "ID: %s (%d)\n", yytext, ID);} else {if(tok_flag != NULL){print_tok(ID);}incr(line_number,column_number,ID);yylval.words = strdup(yytext); return ID;}}
|
||||
|
||||
|
362
src/runner.c
362
src/runner.c
@ -4,241 +4,219 @@
|
||||
#include "runner.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// if last argument is debug then set to true and ignore it for the rest
|
||||
// of this file
|
||||
//if (argc > 1 && strcmp(argv[argc - 1], "-debug") == 0) {
|
||||
// DEBUG = true;
|
||||
// argc--;
|
||||
// }
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
else if (argc == 2) {
|
||||
if (is_help(argv[1])) {
|
||||
return 0;
|
||||
} else if (is_alpha_file(argv[1], strlen(argv[1])) == 0) {
|
||||
no_flag = SET_FLAG;
|
||||
alpha_file = fopen(argv[1], "r");
|
||||
} else {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (argc == 2) {
|
||||
if (is_help(argv[1])) {
|
||||
return 0;
|
||||
} else if (is_alpha_file(argv[1], strlen(argv[1])) == 0) {
|
||||
no_flag = SET_FLAG;
|
||||
alpha_file = fopen(argv[1], "r");
|
||||
} else {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
else {
|
||||
if (is_alpha_file(argv[argc - 1], strlen(argv[argc - 1])) !=
|
||||
0) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
} else {
|
||||
for (int i = 1; i < argc - 1; i++) {
|
||||
if (check_flag(argv[i], argv[argc - 1]) != 0) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
alpha_file = fopen(argv[argc - 1], "r");
|
||||
}
|
||||
|
||||
else {
|
||||
if (is_alpha_file(argv[argc - 1], strlen(argv[argc - 1])) !=
|
||||
0) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
} else {
|
||||
for (int i = 1; i < argc - 1; i++) {
|
||||
if (check_flag(argv[i], argv[argc - 1]) != 0) {
|
||||
fprintf(stderr,
|
||||
"INVALID FLAG(S): Use -help to "
|
||||
"view valid inputs \n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
alpha_file = fopen(argv[argc - 1], "r");
|
||||
}
|
||||
}
|
||||
return run(alpha_file);
|
||||
}
|
||||
return run(alpha_file);
|
||||
}
|
||||
|
||||
int check_flag(char *arg, char *alpha) {
|
||||
if (strcmp("-tok", arg) == 0) {
|
||||
if (tok_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-st", arg) == 0) {
|
||||
if (st_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
|
||||
} else if (strcmp("-tc", arg) == 0) {
|
||||
if (tc_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
} else if (strcmp("-debug", arg) == 0) {
|
||||
DEBUG = true;
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr, "INVALID FLAG: Use -help for valid inputs\n");
|
||||
return -1;
|
||||
if (strcmp("-tok", arg) == 0) {
|
||||
if (tok_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-st", arg) == 0) {
|
||||
if (st_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-asc", arg) == 0) {
|
||||
if (asc_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-tc", arg) == 0) {
|
||||
if (tc_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-ir", arg) == 0) {
|
||||
if (ir_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-cg", arg) == 0) {
|
||||
if (cg_flag == NULL) {
|
||||
return new_file(arg, alpha);
|
||||
}
|
||||
fprintf(stderr, "FLAGS REPEAT\n");
|
||||
return -1;
|
||||
} else if (strcmp("-debug", arg) == 0) {
|
||||
DEBUG = true;
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr, "INVALID FLAG: Use -help for valid inputs\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void incr(int lnum, int cnum, int tok) {
|
||||
// if (tok == COMMENT) {
|
||||
for (int i = 0; i < yyleng; i++) {
|
||||
if (yytext[i] == '\n') {
|
||||
line_number++;
|
||||
column_number = 0;
|
||||
}
|
||||
column_number++;
|
||||
for (int i = 0; i < yyleng; i++) {
|
||||
if (yytext[i] == '\n') {
|
||||
line_number++;
|
||||
column_number = 0;
|
||||
}
|
||||
// }else{
|
||||
// column_number += yyleng;
|
||||
// }
|
||||
column_number++;
|
||||
}
|
||||
}
|
||||
|
||||
void print_tok(int tok) {
|
||||
fprintf(tok_flag, "%d %d %3d \"%s\"\n", line_number, column_number, tok,
|
||||
yytext);
|
||||
fprintf(tok_flag, "%d %d %3d \"%s\"\n", line_number, column_number, tok, yytext);
|
||||
}
|
||||
|
||||
int run(FILE *alpha) {
|
||||
int token;
|
||||
top = cur = init(CreateScope(NULL, 1, 1));
|
||||
int token;
|
||||
top = cur = init(CreateScope(NULL, 1, 1));
|
||||
|
||||
// If file is not found
|
||||
if (alpha == NULL) {
|
||||
fprintf(stderr, "INPUT FILE NOT FOUND\n");
|
||||
return -1;
|
||||
// If file is not found
|
||||
if (alpha == NULL) {
|
||||
fprintf(stderr, "INPUT FILE NOT FOUND\n");
|
||||
return -1;
|
||||
}
|
||||
yyin = alpha;
|
||||
yyparse();
|
||||
|
||||
if (tok_flag != NULL) {
|
||||
while (0 != (token = yylex())) {
|
||||
// Don't delete me 🥺
|
||||
}
|
||||
yyin = alpha;
|
||||
fclose(tok_flag);
|
||||
}
|
||||
|
||||
// TOK FLAG
|
||||
if (tok_flag != NULL) {
|
||||
while (0 != (token = yylex())) {
|
||||
// if (tok_flag != NULL) {
|
||||
// fprintf(tok_flag, "%d %d %3d \"%s\"\n",
|
||||
// line_number, column_number,
|
||||
// token, yytext);
|
||||
// }
|
||||
/*if (token == COMMENT) {
|
||||
for (int i = 0; i < yyleng; i++) {
|
||||
if (yytext[i] == '\n') {
|
||||
line_number++;
|
||||
column_number = 0;
|
||||
}
|
||||
column_number++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (token == 1999) {
|
||||
printf(
|
||||
"On line number %d and column
|
||||
number %d we have an invalid " "character:%s\n",
|
||||
line_number, column_number,
|
||||
yytext);
|
||||
}
|
||||
column_number += yyleng; */
|
||||
}
|
||||
fclose(tok_flag);
|
||||
if (st_flag != NULL) {
|
||||
print_symbol_table(top, st_flag);
|
||||
fclose(st_flag);
|
||||
}
|
||||
|
||||
if (yyin != NULL) {
|
||||
fclose(yyin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (asc_flag != NULL) {
|
||||
printf("Flag -asc is not implemented yet\n");
|
||||
fclose(asc_flag);
|
||||
}
|
||||
|
||||
if (st_flag != NULL) {
|
||||
yyparse();
|
||||
if (tc_flag != NULL) {
|
||||
printf("Flag -tc is not implemented yet\n");
|
||||
fclose(tc_flag);
|
||||
}
|
||||
|
||||
if (cur == NULL) {
|
||||
printdebug("%s[FATAL] cur is null", COLOR_LIGHTRED);
|
||||
}
|
||||
if (ir_flag != NULL) {
|
||||
printf("Flag -ir is not implemented yet\n");
|
||||
fclose(ir_flag);
|
||||
}
|
||||
|
||||
if (top == NULL) {
|
||||
printdebug("%s[FATAL] top is null", COLOR_LIGHTRED);
|
||||
}
|
||||
if (cg_flag != NULL) {
|
||||
printf("Flag -cg is not implemented yet\n");
|
||||
fclose(cg_flag);
|
||||
}
|
||||
|
||||
print_symbol_table(top, st_flag);
|
||||
fclose(st_flag);
|
||||
if (yyin != NULL) {
|
||||
fclose(yyin);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (yyin != NULL) {
|
||||
fclose(yyin);
|
||||
}
|
||||
|
||||
if (tc_flag != NULL) {
|
||||
//SCARLETT NEEDS TO ADD THIS FUNCTIONALITY
|
||||
}
|
||||
|
||||
yyparse();
|
||||
FILE *f = fdopen(1, "w");
|
||||
|
||||
print_symbol_table(top, f);
|
||||
fclose(f);
|
||||
|
||||
if (yyin != NULL) {
|
||||
fclose(yyin);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_help(char *input) {
|
||||
if (strcmp(input, "-help") == 0) {
|
||||
printf("%s", HELP);
|
||||
return true;
|
||||
}
|
||||
if (strcmp(input, "-help") == 0) {
|
||||
printf("%s", HELP);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
int new_file(char *arg, char *alpha) {
|
||||
int type_len;
|
||||
const char *basename = alpha;
|
||||
const char *slash = strchr(alpha, '/');
|
||||
int type_len;
|
||||
const char *basename = alpha;
|
||||
const char *slash = strchr(alpha, '/');
|
||||
|
||||
while (slash != NULL) {
|
||||
basename = slash + 1;
|
||||
slash = strchr(basename, '/');
|
||||
}
|
||||
while (slash != NULL) {
|
||||
basename = slash + 1;
|
||||
slash = strchr(basename, '/');
|
||||
}
|
||||
|
||||
mkdir("./out", 0777);
|
||||
mkdir("./out", 0777);
|
||||
|
||||
char *new_basename = calloc(strlen(basename) + 5, sizeof(char));
|
||||
strcpy(new_basename, "./out/");
|
||||
strcat(new_basename, basename);
|
||||
basename = new_basename;
|
||||
char *new_basename = calloc(strlen(basename) + 5, sizeof(char));
|
||||
strcpy(new_basename, "./out/");
|
||||
strcat(new_basename, basename);
|
||||
basename = new_basename;
|
||||
|
||||
if (strcmp(arg, "-tok") == 0) {
|
||||
type_len = TOK_LEN;
|
||||
} else if (strcmp(arg, "-st") == 0) {
|
||||
type_len = ST_LEN;
|
||||
} else if (strcmp(arg, "-tc") == 0){
|
||||
type_len = TC_LEN;
|
||||
}else {
|
||||
fprintf(stderr,
|
||||
"INVALID FLAG: Use -help to view valid inputs\n");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(arg, "-tok") == 0) {
|
||||
type_len = TOK_LEN;
|
||||
} else if (strcmp(arg, "-st") == 0) {
|
||||
type_len = ST_LEN;
|
||||
} else if (strcmp(arg, "-tc") == 0) {
|
||||
type_len = TC_LEN;
|
||||
} else {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// calculate lengths
|
||||
int basename_len = strlen(basename);
|
||||
char *file_name =
|
||||
calloc(basename_len - ALPHA_OFFSET + type_len + 2, sizeof(char));
|
||||
// calculate lengths
|
||||
int basename_len = strlen(basename);
|
||||
char *file_name =
|
||||
calloc(basename_len - ALPHA_OFFSET + type_len + 2, sizeof(char));
|
||||
|
||||
// coy filename and add extension
|
||||
strncpy(file_name, basename, basename_len - ALPHA_OFFSET);
|
||||
strcat(file_name, ".");
|
||||
strcat(file_name, arg + 1);
|
||||
// coy filename and add extension
|
||||
strncpy(file_name, basename, basename_len - ALPHA_OFFSET);
|
||||
strcat(file_name, ".");
|
||||
strcat(file_name, arg + 1);
|
||||
|
||||
if (strcmp(arg, "-tok") == 0) {
|
||||
tok_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-st") == 0) {
|
||||
st_flag = fopen(file_name, "w");
|
||||
|
||||
} else if (strcmp(arg, "-tc") == 0) {
|
||||
tc_flag = fopen(file_name, "w");
|
||||
}
|
||||
return 0;
|
||||
if (strcmp(arg, "-tok") == 0) {
|
||||
tok_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-st") == 0) {
|
||||
st_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-asc") == 0) {
|
||||
asc_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-tc") == 0) {
|
||||
tc_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-ir") == 0) {
|
||||
ir_flag = fopen(file_name, "w");
|
||||
} else if (strcmp(arg, "-cg") == 0) {
|
||||
cg_flag = fopen(file_name, "w");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_alpha_file(char *alpha, int file_len) {
|
||||
if (strcmp(".alpha",
|
||||
alpha + sizeof(char) * (file_len - ALPHA_OFFSET)) != 0) {
|
||||
return -1; // not alpha file
|
||||
}
|
||||
return 0; // is alpha file
|
||||
if (strcmp(".alpha",
|
||||
alpha + sizeof(char) * (file_len - ALPHA_OFFSET)) != 0) {
|
||||
return -1; // not alpha file
|
||||
}
|
||||
return 0; // is alpha file
|
||||
}
|
||||
|
32
src/runner.h
32
src/runner.h
@ -5,20 +5,23 @@
|
||||
#define TOK_LEN 3
|
||||
#define ST_LEN 2
|
||||
#define TC_LEN 2
|
||||
#define HELP \
|
||||
"HELP:\nHow to run the alpha compiler:\n./alpha [options] " \
|
||||
"program\nValid " \
|
||||
"options:\n-tok output the token number, token, line number, and " \
|
||||
"column " \
|
||||
"number for each of the tokens to the .tok file\n-st output the " \
|
||||
"symbol " \
|
||||
"table for the program to the .st file\n-help print this message " \
|
||||
"and exit " \
|
||||
"the alpha compiler\n-debug print debugging messages in grammar rules \n"
|
||||
#define HELP \
|
||||
"HELP:\n" \
|
||||
" How to run the alpha compiler:\n" \
|
||||
" ./alpha [options] program\n" \
|
||||
"Valid options:\n" \
|
||||
" -tok output the token number, token, line number, and column number for each of the tokens to the .tok file\n" \
|
||||
" -st output the symbol table for the program to the .st file\n" \
|
||||
" -asc output the annotated source code for the program to the .asc file, including syntax errors\n" \
|
||||
" -tc run the type checker and report type errors to the .asc file\n" \
|
||||
" -ir run the intermediate representation generator, writing output to the .ir file\n" \
|
||||
" -cg run the (x86 assembly) code generator, writing output to the .s file\n" \
|
||||
" -debug produce debugging messages to stderr\n" \
|
||||
" -help print this message and exit the alpha compiler\n"
|
||||
|
||||
#define SET_FLAG 1 // Used to set flags for arg types
|
||||
#define INVALID \
|
||||
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n"
|
||||
#define SET_FLAG 1 // Used to set flags for arg types
|
||||
#define INVALID \
|
||||
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -42,6 +45,9 @@ FILE *alpha_file;
|
||||
FILE *tok_flag = NULL;
|
||||
FILE *st_flag = NULL;
|
||||
FILE *tc_flag = NULL;
|
||||
FILE *ir_flag = NULL;
|
||||
FILE *cg_flag = NULL;
|
||||
FILE *asc_flag = NULL;
|
||||
bool DEBUG = false;
|
||||
int no_flag = 0;
|
||||
int arg;
|
||||
|
2039
src/symbol_table.c
2039
src/symbol_table.c
File diff suppressed because it is too large
Load Diff
@ -4,71 +4,82 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SIZE_INT 4
|
||||
#define SIZE_ADDR 8
|
||||
#define SIZE_CHAR 1
|
||||
#define SIZE_BOOL 4 //TODO: Ask Carl what this size should be
|
||||
|
||||
struct TableNode;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int size;
|
||||
} primitive_info;
|
||||
|
||||
typedef struct {
|
||||
int numofdimensions;
|
||||
struct TableNode *typeofarray;
|
||||
int numofdimensions;
|
||||
struct TableNode *typeofarray;
|
||||
} array_info;
|
||||
|
||||
typedef struct {
|
||||
int numofelements;
|
||||
struct SymbolTable *recordScope;
|
||||
int numofelements;
|
||||
struct SymbolTable *recordScope;
|
||||
int total_size;
|
||||
int *offsets;
|
||||
} record_info;
|
||||
|
||||
typedef struct {
|
||||
int startlinenumber;
|
||||
bool regularoras;
|
||||
int startlinenumber;
|
||||
bool regularoras;
|
||||
} function_declaration_info;
|
||||
|
||||
typedef struct {
|
||||
struct TableNode *parameter;
|
||||
struct TableNode *returntype;
|
||||
struct TableNode *parameter;
|
||||
struct TableNode *returntype;
|
||||
} function_type_info;
|
||||
|
||||
typedef union {
|
||||
primitive_info *PrimAdInfo;
|
||||
array_info *ArrayAdInfo;
|
||||
record_info *RecAdInfo;
|
||||
function_declaration_info *FunDecAdInfo;
|
||||
function_type_info *FunTypeAdInfo;
|
||||
primitive_info *PrimAdInfo;
|
||||
array_info *ArrayAdInfo;
|
||||
record_info *RecAdInfo;
|
||||
function_declaration_info *FunDecAdInfo;
|
||||
function_type_info *FunTypeAdInfo;
|
||||
} AdInfo;
|
||||
|
||||
typedef struct ListOfTable {
|
||||
struct SymbolTable *table;
|
||||
struct ListOfTable *next;
|
||||
struct SymbolTable *table;
|
||||
struct ListOfTable *next;
|
||||
} ListOfTable;
|
||||
|
||||
//Table node to store
|
||||
typedef struct TableNode {
|
||||
struct TableNode *theType;
|
||||
char *theName;
|
||||
AdInfo *additionalinfo;
|
||||
struct TableNode *next;
|
||||
struct TableNode *theType;
|
||||
int tag;
|
||||
char *theName;
|
||||
AdInfo *additionalinfo;
|
||||
struct TableNode *next;
|
||||
} TableNode;
|
||||
|
||||
typedef struct SymbolTable {
|
||||
TableNode *entries;
|
||||
struct SymbolTable *Parent_Scope;
|
||||
struct ListOfTable *Children_Scope;
|
||||
int Line_Number;
|
||||
int Column_Number;
|
||||
TableNode *entries;
|
||||
struct SymbolTable *Parent_Scope;
|
||||
struct ListOfTable *Children_Scope;
|
||||
int Line_Number;
|
||||
int Column_Number;
|
||||
} SymbolTable;
|
||||
|
||||
typedef enum {
|
||||
TYPE_STRING = 1,
|
||||
TYPE_ARRAY_TYPE = 2,
|
||||
TYPE_RECORD_TYPE = 3,
|
||||
TYPE_FUNCTION_DECLARATION = 4,
|
||||
TYPE_FUNCTION_TYPE = 5,
|
||||
TYPE_PRIMITIVE = 6,
|
||||
TYPE_ALL_ELSE = 7,
|
||||
TYPE_UNDEFINED = 8,
|
||||
TYPE_RECORD = 9,
|
||||
TYPE_ARRAY = 10
|
||||
TYPE_STRING = 1,
|
||||
TYPE_ARRAY_TYPE = 2,
|
||||
TYPE_RECORD_TYPE = 3,
|
||||
TYPE_FUNCTION_DECLARATION = 4,
|
||||
TYPE_FUNCTION_TYPE = 5,
|
||||
TYPE_PRIMITIVE = 6,
|
||||
TYPE_ALL_ELSE = 7,
|
||||
TYPE_UNDEFINED = 8,
|
||||
TYPE_RECORD = 9,
|
||||
TYPE_ARRAY = 10,
|
||||
TYPE_SYSTEM_DEFINED = 11,
|
||||
TYPE_PRIMITIVE_TYPE = 12
|
||||
} types;
|
||||
|
||||
AdInfo *CreatePrimitiveInfo(int size);
|
||||
@ -93,12 +104,13 @@ SymbolTable *CreateScope(SymbolTable *ParentScope, int Line, int Column);
|
||||
SymbolTable *init(SymbolTable *start);
|
||||
TableNode *populateTypeAndInfo(TableNode *tn, TableNode *type, AdInfo *info);
|
||||
int getAdInfoType(TableNode *tn);
|
||||
TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id,
|
||||
TableNode *CreateEntry(SymbolTable *table, int tag, TableNode *typeOf, char *id,
|
||||
AdInfo *ad);
|
||||
char *getType(TableNode *tn);
|
||||
char *getName(TableNode *tn);
|
||||
int getLine(SymbolTable *st);
|
||||
int getColumn(SymbolTable *st);
|
||||
TableNode *getTypeEntry(TableNode *tn);
|
||||
TableNode *addName(TableNode *tn, char *str);
|
||||
SymbolTable *setLineNumber(SymbolTable *st, int line);
|
||||
SymbolTable *setColumnNumber(SymbolTable *st, int column);
|
||||
@ -115,9 +127,10 @@ ListOfTable *getRestOfChildren(ListOfTable *lt);
|
||||
TableNode *getFirstEntry(SymbolTable *st);
|
||||
TableNode *getNextEntry(TableNode *tn);
|
||||
|
||||
TableNode *printTableNode(TableNode *tn);
|
||||
void printdebug_impl(char *file, int line, const char *format, ...);
|
||||
#define printdebug(format, ...) \
|
||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
#define printdebug(format, ...) \
|
||||
printdebug_impl(__FILE__, __LINE__, format, ##__VA_ARGS__)
|
||||
|
||||
extern int yylex(void);
|
||||
extern char *yytext;
|
||||
@ -154,4 +167,4 @@ extern char *COLOR_YELLOW;
|
||||
extern char *COLOR_LIGHTBLUE;
|
||||
extern char *COLOR_LIGHTPURPLE;
|
||||
extern char *COLOR_LIGHTCYAN;
|
||||
extern char *COLOR_WHITE;
|
||||
extern char *COLOR_WHITE;
|
||||
|
10
tests/carl/Errors/entry.undeclaredType.alpha
Normal file
10
tests/carl/Errors/entry.undeclaredType.alpha
Normal file
@ -0,0 +1,10 @@
|
||||
type M : string -> integer
|
||||
|
||||
function foo : M
|
||||
|
||||
foo (s) := {
|
||||
[
|
||||
int: x
|
||||
]
|
||||
return 0;
|
||||
}
|
16
tests/carl/Errors/entry.undeclaredType.alpha.asc
Normal file
16
tests/carl/Errors/entry.undeclaredType.alpha.asc
Normal file
@ -0,0 +1,16 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.undeclaredType.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function foo : M
|
||||
004:
|
||||
005: foo (s) := {
|
||||
006: [
|
||||
007: int: x
|
||||
^0 ^1
|
||||
LINE 7:9 ** ERROR #0: the name 'int', used here as a type, has not been declared at this point in the program.
|
||||
LINE 7:14 ** ERROR #1: the name 'x' is being declared with an unknown type.
|
||||
|
||||
008: ]
|
||||
009: return 0;
|
||||
010: }
|
||||
011:
|
7
tests/carl/Errors/entry.undeclaredVar.alpha
Normal file
7
tests/carl/Errors/entry.undeclaredVar.alpha
Normal file
@ -0,0 +1,7 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
return x;
|
||||
}
|
12
tests/carl/Errors/entry.undeclaredVar.alpha.asc
Normal file
12
tests/carl/Errors/entry.undeclaredVar.alpha.asc
Normal file
@ -0,0 +1,12 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.undeclaredVar.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: return x;
|
||||
^0
|
||||
LINE 6:12 ** ERROR #0: the name 'x', used here as a variable name, has not been declared at this point in the program.
|
||||
|
||||
007: }
|
||||
008:
|
14
tests/carl/Errors/error.operator.alpha
Normal file
14
tests/carl/Errors/error.operator.alpha
Normal file
@ -0,0 +1,14 @@
|
||||
type string2int: string -> integer
|
||||
|
||||
function entry : string2int
|
||||
|
||||
entry(arg) := {
|
||||
[ integer: i; integer: sum ]
|
||||
sum := 0;
|
||||
i := 0;
|
||||
while (i < 10) {
|
||||
sum = sum + i;
|
||||
i := i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
19
tests/carl/Errors/error.operator.alpha.asc
Normal file
19
tests/carl/Errors/error.operator.alpha.asc
Normal file
@ -0,0 +1,19 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file error.operator.alpha
|
||||
001: type string2int: string -> integer
|
||||
002:
|
||||
003: function entry : string2int
|
||||
004:
|
||||
005: entry(arg) := {
|
||||
006: [ integer: i; integer: sum ]
|
||||
007: sum := 0;
|
||||
008: i := 0;
|
||||
009: while (i < 10) {
|
||||
010: sum = sum + i;
|
||||
^0
|
||||
LINE 10:13 ** ERROR #0: assignment operator (:=) expected but equality operator (=) found.
|
||||
|
||||
011: i := i + 1;
|
||||
012: }
|
||||
013: return 0;
|
||||
014: }
|
||||
015:
|
8
tests/carl/NoErrors/entry.definition.alpha
Normal file
8
tests/carl/NoErrors/entry.definition.alpha
Normal file
@ -0,0 +1,8 @@
|
||||
(* type string : 1 -> character *)
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
return 0;
|
||||
}
|
10
tests/carl/NoErrors/entry.definition.alpha.asc
Normal file
10
tests/carl/NoErrors/entry.definition.alpha.asc
Normal file
@ -0,0 +1,10 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.definition.alpha
|
||||
001: (* type string : 1 -> character *)
|
||||
002: type M : string -> integer
|
||||
003:
|
||||
004: function entry : M
|
||||
005:
|
||||
006: entry(s) := {
|
||||
007: return 0;
|
||||
008: }
|
||||
009:
|
11
tests/carl/NoErrors/entry.duplicateDifferent.alpha
Normal file
11
tests/carl/NoErrors/entry.duplicateDifferent.alpha
Normal file
@ -0,0 +1,11 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x;
|
||||
character: x
|
||||
]
|
||||
return x;
|
||||
}
|
13
tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc
Normal file
13
tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc
Normal file
@ -0,0 +1,13 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.duplicateDifferent.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: [
|
||||
007: integer: x;
|
||||
008: character: x
|
||||
009: ]
|
||||
010: return x;
|
||||
011: }
|
||||
012:
|
9
tests/carl/NoErrors/entry.duplicateSame.alpha
Normal file
9
tests/carl/NoErrors/entry.duplicateSame.alpha
Normal file
@ -0,0 +1,9 @@
|
||||
type M : string -> integer
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x; integer: x
|
||||
]
|
||||
return x;
|
||||
}
|
11
tests/carl/NoErrors/entry.duplicateSame.alpha.asc
Normal file
11
tests/carl/NoErrors/entry.duplicateSame.alpha.asc
Normal file
@ -0,0 +1,11 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.duplicateSame.alpha
|
||||
001: type M : string -> integer
|
||||
002: function entry : M
|
||||
003:
|
||||
004: entry(s) := {
|
||||
005: [
|
||||
006: integer: x; integer: x
|
||||
007: ]
|
||||
008: return x;
|
||||
009: }
|
||||
010:
|
11
tests/carl/NoErrors/entry.local.alpha
Normal file
11
tests/carl/NoErrors/entry.local.alpha
Normal file
@ -0,0 +1,11 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x
|
||||
]
|
||||
x := 0;
|
||||
return x;
|
||||
}
|
13
tests/carl/NoErrors/entry.local.alpha.asc
Normal file
13
tests/carl/NoErrors/entry.local.alpha.asc
Normal file
@ -0,0 +1,13 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.local.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: [
|
||||
007: integer: x
|
||||
008: ]
|
||||
009: x := 0;
|
||||
010: return x;
|
||||
011: }
|
||||
012:
|
14
tests/carl/NoErrors/error.none.alpha
Normal file
14
tests/carl/NoErrors/error.none.alpha
Normal file
@ -0,0 +1,14 @@
|
||||
type string2int: string -> integer
|
||||
|
||||
function entry : string2int
|
||||
|
||||
entry(arg) := {
|
||||
[ integer: i ; integer: sum ]
|
||||
sum := 0;
|
||||
i := 0 ;
|
||||
while (i < 10) {
|
||||
sum := sum + i;
|
||||
i := i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
16
tests/carl/NoErrors/error.none.alpha.asc
Normal file
16
tests/carl/NoErrors/error.none.alpha.asc
Normal file
@ -0,0 +1,16 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file error.none.alpha
|
||||
001: type string2int: string -> integer
|
||||
002:
|
||||
003: function entry : string2int
|
||||
004:
|
||||
005: entry(arg) := {
|
||||
006: [ integer: i ; integer: sum ]
|
||||
007: sum := 0;
|
||||
008: i := 0 ;
|
||||
009: while (i < 10) {
|
||||
010: sum := sum + i;
|
||||
011: i := i + 1;
|
||||
012: }
|
||||
013: return 0;
|
||||
014: }
|
||||
015:
|
3
tests/carl/NoErrors/function.declaration.alpha
Normal file
3
tests/carl/NoErrors/function.declaration.alpha
Normal file
@ -0,0 +1,3 @@
|
||||
type M : integer -> integer
|
||||
|
||||
function f : M
|
5
tests/carl/NoErrors/function.declaration.alpha.asc
Normal file
5
tests/carl/NoErrors/function.declaration.alpha.asc
Normal file
@ -0,0 +1,5 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file function.declaration.alpha
|
||||
001: type M : integer -> integer
|
||||
002:
|
||||
003: function f : M
|
||||
004:
|
7
tests/carl/NoErrors/function.definition.alpha
Normal file
7
tests/carl/NoErrors/function.definition.alpha
Normal file
@ -0,0 +1,7 @@
|
||||
type M : integer -> integer
|
||||
|
||||
function f : M
|
||||
|
||||
f(x) := {
|
||||
return x;
|
||||
}
|
9
tests/carl/NoErrors/function.definition.alpha.asc
Normal file
9
tests/carl/NoErrors/function.definition.alpha.asc
Normal file
@ -0,0 +1,9 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file function.definition.alpha
|
||||
001: type M : integer -> integer
|
||||
002:
|
||||
003: function f : M
|
||||
004:
|
||||
005: f(x) := {
|
||||
006: return x;
|
||||
007: }
|
||||
008:
|
73
tests/carl/NoErrors/functionValue.alpha
Normal file
73
tests/carl/NoErrors/functionValue.alpha
Normal file
@ -0,0 +1,73 @@
|
||||
(* Type definitions *)
|
||||
|
||||
(* mapping type *)
|
||||
type string2int: string -> integer
|
||||
|
||||
(* array of functions *)
|
||||
type funArray: 1 -> string2int
|
||||
|
||||
(* record of functions *)
|
||||
type funRec: [ string2int: f; string2int: g ]
|
||||
|
||||
(* function returning function *)
|
||||
type integer_2_string2int: integer -> string2int
|
||||
|
||||
(* function returning function *)
|
||||
type string2int_2_integer: string2int -> integer
|
||||
|
||||
|
||||
type iXiXc: [integer: a; integer: b; character: c]
|
||||
|
||||
type iic2b: iXiXc -> Boolean
|
||||
|
||||
(* Function declarations using the above type definitions *)
|
||||
function a: string2int
|
||||
function b: integer_2_string2int
|
||||
function c: string2int_2_integer
|
||||
|
||||
function d: iic2b
|
||||
|
||||
d(x,y,z) := {
|
||||
return (x < y & z < 'm');
|
||||
}
|
||||
|
||||
function entry: string2int
|
||||
|
||||
a(x) := {
|
||||
[string : s]
|
||||
s := x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
b(x) := {
|
||||
[integer: i]
|
||||
i := x;
|
||||
return a;
|
||||
}
|
||||
|
||||
c(x) := {
|
||||
[string: s]
|
||||
s := "Hi!";
|
||||
return x(s);
|
||||
}
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[integer: result; string2int: f; integer: temp]
|
||||
temp := a("Hello");
|
||||
f := b(temp);
|
||||
result := c(f);
|
||||
if (d(1,2,'c'))
|
||||
then {
|
||||
result := 0;
|
||||
}
|
||||
else {
|
||||
[ Boolean : b]
|
||||
result := entry("hello");
|
||||
}
|
||||
result := c(f);
|
||||
return result;
|
||||
}
|
75
tests/carl/NoErrors/functionValue.alpha.asc
Normal file
75
tests/carl/NoErrors/functionValue.alpha.asc
Normal file
@ -0,0 +1,75 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file functionValue.alpha
|
||||
001: (* Type definitions *)
|
||||
002:
|
||||
003: (* mapping type *)
|
||||
004: type string2int: string -> integer
|
||||
005:
|
||||
006: (* array of functions *)
|
||||
007: type funArray: 1 -> string2int
|
||||
008:
|
||||
009: (* record of functions *)
|
||||
010: type funRec: [ string2int: f; string2int: g ]
|
||||
011:
|
||||
012: (* function returning function *)
|
||||
013: type integer_2_string2int: integer -> string2int
|
||||
014:
|
||||
015: (* function returning function *)
|
||||
016: type string2int_2_integer: string2int -> integer
|
||||
017:
|
||||
018:
|
||||
019: type iXiXc: [integer: a; integer: b; character: c]
|
||||
020:
|
||||
021: type iic2b: iXiXc -> Boolean
|
||||
022:
|
||||
023: (* Function declarations using the above type definitions *)
|
||||
024: function a: string2int
|
||||
025: function b: integer_2_string2int
|
||||
026: function c: string2int_2_integer
|
||||
027:
|
||||
028: function d: iic2b
|
||||
029:
|
||||
030: d(x,y,z) := {
|
||||
031: return (x < y & z < 'm');
|
||||
032: }
|
||||
033:
|
||||
034: function entry: string2int
|
||||
035:
|
||||
036: a(x) := {
|
||||
037: [string : s]
|
||||
038: s := x;
|
||||
039: return 0;
|
||||
040: }
|
||||
041:
|
||||
042: b(x) := {
|
||||
043: [integer: i]
|
||||
044: i := x;
|
||||
045: return a;
|
||||
046: }
|
||||
047:
|
||||
048: c(x) := {
|
||||
049: [string: s]
|
||||
050: s := "Hi!";
|
||||
051: return x(s);
|
||||
052: }
|
||||
053:
|
||||
054:
|
||||
055: (* Function definition
|
||||
056: entry is the first function called
|
||||
057: *)
|
||||
058: entry(arg) := {
|
||||
059: [integer: result; string2int: f; integer: temp]
|
||||
060: temp := a("Hello");
|
||||
061: f := b(temp);
|
||||
062: result := c(f);
|
||||
063: if (d(1,2,'c'))
|
||||
064: then {
|
||||
065: result := 0;
|
||||
066: }
|
||||
067: else {
|
||||
068: [ Boolean : b]
|
||||
069: result := entry("hello");
|
||||
070: }
|
||||
071: result := c(f);
|
||||
072: return result;
|
||||
073: }
|
||||
074:
|
29
tests/carl/NoErrors/sample.good.alpha
Normal file
29
tests/carl/NoErrors/sample.good.alpha
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
(* Type definitions *)
|
||||
type int2int: integer -> integer
|
||||
type string2int: string -> integer
|
||||
|
||||
(* Function declarations
|
||||
They use the above type definitions
|
||||
*)
|
||||
function square : int2int
|
||||
function entry : string2int
|
||||
|
||||
(* Function definition
|
||||
Functions must be declared before they are defined
|
||||
*)
|
||||
square(x) := {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[ integer: input ; integer: expected ; integer: actual ; Boolean: result ]
|
||||
input := 7;
|
||||
expected := 49;
|
||||
actual := square(input);
|
||||
result := expected = actual;
|
||||
return 0;
|
||||
}
|
31
tests/carl/NoErrors/sample.good.alpha.asc
Normal file
31
tests/carl/NoErrors/sample.good.alpha.asc
Normal file
@ -0,0 +1,31 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file sample.good.alpha
|
||||
001:
|
||||
001: (* Type definitions *)
|
||||
003: type int2int: integer -> integer
|
||||
004: type string2int: string -> integer
|
||||
005:
|
||||
006: (* Function declarations
|
||||
007: They use the above type definitions
|
||||
008: *)
|
||||
009: function square : int2int
|
||||
010: function entry : string2int
|
||||
011:
|
||||
012: (* Function definition
|
||||
013: Functions must be declared before they are defined
|
||||
014: *)
|
||||
015: square(x) := {
|
||||
016: return x * x;
|
||||
017: }
|
||||
018:
|
||||
019: (* Function definition
|
||||
020: entry is the first function called
|
||||
021: *)
|
||||
022: entry(arg) := {
|
||||
023: [ integer: input ; integer: expected ; integer: actual ; Boolean: result ]
|
||||
024: input := 7;
|
||||
025: expected := 49;
|
||||
026: actual := square(input);
|
||||
027: result := expected = actual;
|
||||
028: return 0;
|
||||
029: }
|
||||
030:
|
68
tests/carl/NoErrors/selectionSort.alpha
Normal file
68
tests/carl/NoErrors/selectionSort.alpha
Normal file
@ -0,0 +1,68 @@
|
||||
(* Type definitions *)
|
||||
|
||||
type string2int: string -> integer
|
||||
type intArray: 1 -> integer
|
||||
type intArrayXinteger: [ intArray: data; integer: index ]
|
||||
type intArrayXinteger2integer: intArrayXinteger -> integer
|
||||
type intArray2Boolean: intArray -> Boolean
|
||||
|
||||
|
||||
(* Function declarations
|
||||
They use the above type definitions
|
||||
*)
|
||||
function indexOfSmallest: intArrayXinteger2integer
|
||||
function selectionSort: intArray2Boolean
|
||||
function entry : string2int
|
||||
|
||||
(* indexOfSmallest *)
|
||||
indexOfSmallest (* as *) (data, startingIndex) := {
|
||||
[ integer: indexOfSmallestSoFar; integer: i ]
|
||||
indexOfSmallestSoFar := startingIndex;
|
||||
i := 0 ;
|
||||
while (i < data._1 ) {
|
||||
if ( data(i) < data(indexOfSmallestSoFar) )
|
||||
then {
|
||||
indexOfSmallestSoFar := i;
|
||||
}
|
||||
else {
|
||||
i := i;
|
||||
}
|
||||
i := i + 1;
|
||||
}
|
||||
return indexOfSmallestSoFar;
|
||||
}
|
||||
|
||||
|
||||
(* selectionSort *)
|
||||
selectionSort(data) := {
|
||||
[ integer: i ]
|
||||
i := 0 ;
|
||||
while (i < data._1 ) {
|
||||
[ integer: index; integer: temp ]
|
||||
index := indexOfSmallest(data,i);
|
||||
temp := data(index);
|
||||
data(index) := data(i);
|
||||
data(i) := temp;
|
||||
i := i + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[ intArray: data; Boolean: _ ]
|
||||
data := reserve data(8);
|
||||
data(0) := 60;
|
||||
data(1) := 80;
|
||||
data(2) := 10;
|
||||
data(3) := 50;
|
||||
data(4) := 30;
|
||||
data(5) := 40;
|
||||
data(6) := 20;
|
||||
data(7) := 70;
|
||||
_ := selectionSort(data);
|
||||
return 0;
|
||||
}
|
70
tests/carl/NoErrors/selectionSort.alpha.asc
Normal file
70
tests/carl/NoErrors/selectionSort.alpha.asc
Normal file
@ -0,0 +1,70 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file selectionSort.alpha
|
||||
001: (* Type definitions *)
|
||||
002:
|
||||
003: type string2int: string -> integer
|
||||
004: type intArray: 1 -> integer
|
||||
005: type intArrayXinteger: [ intArray: data; integer: index ]
|
||||
006: type intArrayXinteger2integer: intArrayXinteger -> integer
|
||||
007: type intArray2Boolean: intArray -> Boolean
|
||||
008:
|
||||
009:
|
||||
010: (* Function declarations
|
||||
011: They use the above type definitions
|
||||
012: *)
|
||||
013: function indexOfSmallest: intArrayXinteger2integer
|
||||
014: function selectionSort: intArray2Boolean
|
||||
015: function entry : string2int
|
||||
016:
|
||||
017: (* indexOfSmallest *)
|
||||
018: indexOfSmallest (* as *) (data, startingIndex) := {
|
||||
019: [ integer: indexOfSmallestSoFar; integer: i ]
|
||||
020: indexOfSmallestSoFar := startingIndex;
|
||||
021: i := 0 ;
|
||||
022: while (i < data._1 ) {
|
||||
023: if ( data(i) < data(indexOfSmallestSoFar) )
|
||||
024: then {
|
||||
025: indexOfSmallestSoFar := i;
|
||||
026: }
|
||||
027: else {
|
||||
028: i := i;
|
||||
029: }
|
||||
030: i := i + 1;
|
||||
031: }
|
||||
032: return indexOfSmallestSoFar;
|
||||
033: }
|
||||
034:
|
||||
035:
|
||||
036: (* selectionSort *)
|
||||
037: selectionSort(data) := {
|
||||
038: [ integer: i ]
|
||||
039: i := 0 ;
|
||||
040: while (i < data._1 ) {
|
||||
041: [ integer: index; integer: temp ]
|
||||
042: index := indexOfSmallest(data,i);
|
||||
043: temp := data(index);
|
||||
044: data(index) := data(i);
|
||||
045: data(i) := temp;
|
||||
046: i := i + 1;
|
||||
047: }
|
||||
048: return true;
|
||||
049: }
|
||||
050:
|
||||
051:
|
||||
052: (* Function definition
|
||||
053: entry is the first function called
|
||||
054: *)
|
||||
055: entry(arg) := {
|
||||
056: [ intArray: data; Boolean: _ ]
|
||||
057: data := reserve data(8);
|
||||
058: data(0) := 60;
|
||||
059: data(1) := 80;
|
||||
060: data(2) := 10;
|
||||
061: data(3) := 50;
|
||||
062: data(4) := 30;
|
||||
063: data(5) := 40;
|
||||
064: data(6) := 20;
|
||||
065: data(7) := 70;
|
||||
066: _ := selectionSort(data);
|
||||
067: return 0;
|
||||
068: }
|
||||
069:
|
1
tests/carl/NoErrors/type.array.alpha
Normal file
1
tests/carl/NoErrors/type.array.alpha
Normal file
@ -0,0 +1 @@
|
||||
type A : 1 -> integer
|
3
tests/carl/NoErrors/type.array.alpha.asc
Normal file
3
tests/carl/NoErrors/type.array.alpha.asc
Normal file
@ -0,0 +1,3 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.array.alpha
|
||||
001: type A : 1 -> integer
|
||||
002:
|
2
tests/carl/NoErrors/type.mapping.alpha
Normal file
2
tests/carl/NoErrors/type.mapping.alpha
Normal file
@ -0,0 +1,2 @@
|
||||
type M : integer -> character
|
||||
|
4
tests/carl/NoErrors/type.mapping.alpha.asc
Normal file
4
tests/carl/NoErrors/type.mapping.alpha.asc
Normal file
@ -0,0 +1,4 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.mapping.alpha
|
||||
001: type M : integer -> character
|
||||
002:
|
||||
003:
|
1
tests/carl/NoErrors/type.record.alpha
Normal file
1
tests/carl/NoErrors/type.record.alpha
Normal file
@ -0,0 +1 @@
|
||||
type R : [ integer : i ; character : c ]
|
3
tests/carl/NoErrors/type.record.alpha.asc
Normal file
3
tests/carl/NoErrors/type.record.alpha.asc
Normal file
@ -0,0 +1,3 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.record.alpha
|
||||
001: type R : [ integer : i ; character : c ]
|
||||
002:
|
75
tests/carl/NoErrors/types.alpha
Normal file
75
tests/carl/NoErrors/types.alpha
Normal file
@ -0,0 +1,75 @@
|
||||
(*
|
||||
|
||||
At compiler start-up your program should
|
||||
create symbol table entries for the following
|
||||
built-in types:
|
||||
|
||||
Boolean (1 byte)
|
||||
character (1 byte)
|
||||
integer (4 bytes)
|
||||
address (8 bytes)
|
||||
|
||||
and the following privileged type (it has literals):
|
||||
|
||||
type string: 1 -> character
|
||||
|
||||
Your compiler can define other types during
|
||||
its start-up routine as well, if it is helpful
|
||||
to do so.
|
||||
|
||||
*)
|
||||
|
||||
|
||||
|
||||
type BooleanXBoolean: [Boolean: x; Boolean: y]
|
||||
type characterXcharacter: [character: x; character: y]
|
||||
type integerXinteger: [integer: x; integer: y]
|
||||
|
||||
type Boolean2Boolean: Boolean -> Boolean
|
||||
type integer2integer: integer -> integer
|
||||
|
||||
type character2integer: character -> integer
|
||||
type Boolean2integer: Boolean -> integer
|
||||
type string2integer: string -> integer
|
||||
|
||||
type integerXinteger2integer: integerXinteger -> integer
|
||||
|
||||
type integerXinteger2Boolean: integerXinteger -> Boolean
|
||||
type characterXcharacter2Boolean: characterXcharacter -> Boolean
|
||||
type BooleanXBoolean2Boolean: BooleanXBoolean -> Boolean
|
||||
|
||||
|
||||
type integer2address: integer -> address
|
||||
type address2integer: address -> integer
|
||||
|
||||
|
||||
(* The alpha library functions
|
||||
You will be provided with x86-64 assembly
|
||||
code implementations of these.
|
||||
*)
|
||||
|
||||
external function printInteger: integer2integer
|
||||
external function printCharacter: character2integer
|
||||
external function printBoolean: Boolean2integer
|
||||
|
||||
(*
|
||||
A declaration of the entry point function for your program
|
||||
|
||||
You may assume that when starting this function will behave as if
|
||||
it had been called from the C language main function like this:
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc == 1) {
|
||||
return entry(NULL);
|
||||
}
|
||||
else {
|
||||
return entry(makeAlphaString(argv[1]));
|
||||
}
|
||||
}
|
||||
|
||||
for some suitable definition of makeAlphaString which creates
|
||||
an alpha string representation of its argument C string in memory
|
||||
and returns a pointer to that alpha string.
|
||||
*)
|
||||
|
||||
function entry: string2integer
|
77
tests/carl/NoErrors/types.alpha.asc
Normal file
77
tests/carl/NoErrors/types.alpha.asc
Normal file
@ -0,0 +1,77 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file types.alpha
|
||||
001: (*
|
||||
001:
|
||||
002: At compiler start-up your program should
|
||||
003: create symbol table entries for the following
|
||||
004: built-in types:
|
||||
005:
|
||||
006: Boolean (1 byte)
|
||||
007: character (1 byte)
|
||||
008: integer (4 bytes)
|
||||
009: address (8 bytes)
|
||||
010:
|
||||
011: and the following privileged type (it has literals):
|
||||
012:
|
||||
013: type string: 1 -> character
|
||||
014:
|
||||
015: Your compiler can define other types during
|
||||
016: its start-up routine as well, if it is helpful
|
||||
017: to do so.
|
||||
018:
|
||||
019: *)
|
||||
021:
|
||||
022:
|
||||
023:
|
||||
024: type BooleanXBoolean: [Boolean: x; Boolean: y]
|
||||
025: type characterXcharacter: [character: x; character: y]
|
||||
026: type integerXinteger: [integer: x; integer: y]
|
||||
027:
|
||||
028: type Boolean2Boolean: Boolean -> Boolean
|
||||
029: type integer2integer: integer -> integer
|
||||
030:
|
||||
031: type character2integer: character -> integer
|
||||
032: type Boolean2integer: Boolean -> integer
|
||||
033: type string2integer: string -> integer
|
||||
034:
|
||||
035: type integerXinteger2integer: integerXinteger -> integer
|
||||
036:
|
||||
037: type integerXinteger2Boolean: integerXinteger -> Boolean
|
||||
038: type characterXcharacter2Boolean: characterXcharacter -> Boolean
|
||||
039: type BooleanXBoolean2Boolean: BooleanXBoolean -> Boolean
|
||||
040:
|
||||
041:
|
||||
042: type integer2address: integer -> address
|
||||
043: type address2integer: address -> integer
|
||||
044:
|
||||
045:
|
||||
046: (* The alpha library functions
|
||||
047: You will be provided with x86-64 assembly
|
||||
048: code implementations of these.
|
||||
049: *)
|
||||
050:
|
||||
051: external function printInteger: integer2integer
|
||||
052: external function printCharacter: character2integer
|
||||
053: external function printBoolean: Boolean2integer
|
||||
054:
|
||||
055: (*
|
||||
056: A declaration of the entry point function for your program
|
||||
057:
|
||||
058: You may assume that when starting this function will behave as if
|
||||
059: it had been called from the C language main function like this:
|
||||
060:
|
||||
061: int main(int argc, char * argv[]) {
|
||||
062: if (argc == 1) {
|
||||
063: return entry(NULL);
|
||||
064: }
|
||||
065: else {
|
||||
066: return entry(makeAlphaString(argv[1]));
|
||||
067: }
|
||||
068: }
|
||||
069:
|
||||
070: for some suitable definition of makeAlphaString which creates
|
||||
071: an alpha string representation of its argument C string in memory
|
||||
072: and returns a pointer to that alpha string.
|
||||
073: *)
|
||||
074:
|
||||
075: function entry: string2integer
|
||||
076:
|
@ -1,31 +1,35 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
bar2 : 001001 : : T2 : User Defined
|
||||
bar1 : 001001 : : T2 : User Defined
|
||||
foo : 001001 : : T1 : User Defined
|
||||
arr : 001001 : : 1 -> integer : Type of Array
|
||||
T2 : 001001 : : primitive function type : User Defined
|
||||
T1 : 001001 : : primitive function type : User Defined
|
||||
rec : 001001 : : record : elements-2
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
w : 026000 : 001001 : rec : User Defined
|
||||
result : 026000 : 001001 : integer : User Defined
|
||||
arg : 026000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
r : 021000 : 001001 : integer : User Defined
|
||||
s : 021000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
a : 017000 : 001001 : rec : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
x : 013000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 004000 : 001001 : integer : User Defined
|
||||
x : 004000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
bar2 : 001001 : : undefined : Function Definition
|
||||
bar1 : 001001 : : undefined : Function Definition
|
||||
foo : 001001 : : undefined : Function Definition
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
arr : 001001 : : 1 -> integer : Type of Array
|
||||
T2 : 001001 : : rec -> integer : Type of Function
|
||||
T1 : 001001 : : integer -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
w : 025000 : 001001 : rec : Record Instance
|
||||
result : 025000 : 001001 : integer : Primitive Instance
|
||||
arg : 025000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
r : 021000 : 001001 : integer : Primitive Instance
|
||||
s : 021000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 017000 : 001001 : integer : Primitive Instance
|
||||
y : 017000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 013000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,26 +1,29 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : string2integer : User Defined
|
||||
integer2integer2integerFunc: 001001 : : integer2integer2integer : User Defined
|
||||
released : 001001 : : address2integer : User Defined
|
||||
reserved : 001001 : : integer2address : User Defined
|
||||
printBoolean : 001001 : : Boolean2integer : User Defined
|
||||
printCharacter : 001001 : : character2integer : User Defined
|
||||
printInteger : 001001 : : integer2integer : User Defined
|
||||
integer2integer2integer : 001001 : : primitive function type : User Defined
|
||||
address2integer : 001001 : : primitive function type : User Defined
|
||||
integer2address : 001001 : : primitive function type : User Defined
|
||||
Boolean2Boolean2Boolean : 001001 : : primitive function type : User Defined
|
||||
character2character2Boolean: 001001 : : primitive function type : User Defined
|
||||
integer2integer2Boolean : 001001 : : primitive function type : User Defined
|
||||
string2integer : 001001 : : primitive function type : User Defined
|
||||
Boolean2integer : 001001 : : primitive function type : User Defined
|
||||
character2integer : 001001 : : primitive function type : User Defined
|
||||
integer2integer : 001001 : : primitive function type : User Defined
|
||||
Boolean2Boolean : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
integer2integer2integerFunc : 001001 : : undefined : Function Definition
|
||||
released : 001001 : : undefined : Function Definition
|
||||
reserved : 001001 : : undefined : Function Definition
|
||||
printBoolean : 001001 : : undefined : Function Definition
|
||||
printCharacter : 001001 : : undefined : Function Definition
|
||||
printInteger : 001001 : : undefined : Function Definition
|
||||
integer2integer2integer : 001001 : : integer2integer -> integer : Type of Function
|
||||
address2integer : 001001 : : address -> integer : Type of Function
|
||||
integer2address : 001001 : : integer -> address : Type of Function
|
||||
Boolean2Boolean2Boolean : 001001 : : Boolean2Boolean -> Boolean : Type of Function
|
||||
character2character2Boolean : 001001 : : undefined -> undefined : Type of Function
|
||||
integer2integer2Boolean : 001001 : : integer2integer -> Boolean : Type of Function
|
||||
string2integer : 001001 : : string -> integer : Type of Function
|
||||
Boolean2integer : 001001 : : Boolean -> integer : Type of Function
|
||||
character2integer : 001001 : : character -> integer : Type of Function
|
||||
integer2integer : 001001 : : integer -> integer : Type of Function
|
||||
Boolean2Boolean : 001001 : : Boolean -> Boolean : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
|
@ -1,17 +1,21 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
b1 : 005000 : 001001 : Boolean : User Defined
|
||||
b2 : 005000 : 001001 : Boolean : User Defined
|
||||
arr2 : 005000 : 001001 : address : User Defined
|
||||
arr : 005000 : 001001 : address : User Defined
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
testarr : 001001 : : 1 -> integer : Type of Array
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
b1 : 005000 : 001001 : Boolean : Primitive Instance
|
||||
b2 : 005000 : 001001 : Boolean : Primitive Instance
|
||||
arr2 : 005000 : 001001 : testarr : Array Instance
|
||||
arr : 005000 : 001001 : testarr : Array Instance
|
||||
x : 005000 : 001001 : integer : Primitive Instance
|
||||
arg : 005000 : 001001 : string : Array Instance
|
||||
|
@ -0,0 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
test : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : rec -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
arg : 005000 : 001001 : integer : Primitive Instance
|
||||
arg2 : 005000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
@ -1,17 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
rec : 001001 : : record : elements-2
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
w : 007000 : 001001 : rec : User Defined
|
||||
arg : 007000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 004000 : 001001 : integer : User Defined
|
||||
x : 004000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
w : 006000 : 001001 : rec : Record Instance
|
||||
arg : 006000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 004000 : 001001 : integer : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,14 +1,17 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
rec : 001001 : : record : elements-2
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
w : 004000 : 001001 : rec : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 001000 : 001001 : integer : User Defined
|
||||
x : 001000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
w : 003000 : 001001 : rec : Record Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,36 +1,39 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : string2integer : User Defined
|
||||
printBoolean : 001001 : : Boolean2integer : User Defined
|
||||
printCharacter : 001001 : : character2integer : User Defined
|
||||
printInteger : 001001 : : integer2integer : User Defined
|
||||
address2integer : 001001 : : primitive function type : User Defined
|
||||
integer2address : 001001 : : primitive function type : User Defined
|
||||
BooleanXBoolean2Boolean : 001001 : : primitive function type : User Defined
|
||||
characterXcharacter2Boolean: 001001 : : primitive function type : User Defined
|
||||
integerXinteger2Boolean : 001001 : : primitive function type : User Defined
|
||||
integerXinteger2integer : 001001 : : primitive function type : User Defined
|
||||
string2integer : 001001 : : primitive function type : User Defined
|
||||
Boolean2integer : 001001 : : primitive function type : User Defined
|
||||
character2integer : 001001 : : primitive function type : User Defined
|
||||
integer2integer : 001001 : : primitive function type : User Defined
|
||||
Boolean2Boolean : 001001 : : primitive function type : User Defined
|
||||
integerXinteger : 001001 : : record : elements-2
|
||||
characterXcharacter : 001001 : : record : elements-2
|
||||
BooleanXBoolean : 001001 : : record : elements-2
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 015000 : 001001 : integer : User Defined
|
||||
x : 015000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 014000 : 001001 : character : User Defined
|
||||
x : 014000 : 001001 : character : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 013000 : 001001 : Boolean : User Defined
|
||||
x : 013000 : 001001 : Boolean : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
printBoolean : 001001 : : undefined : Function Definition
|
||||
printCharacter : 001001 : : undefined : Function Definition
|
||||
printInteger : 001001 : : undefined : Function Definition
|
||||
address2integer : 001001 : : address -> integer : Type of Function
|
||||
integer2address : 001001 : : integer -> address : Type of Function
|
||||
BooleanXBoolean2Boolean : 001001 : : BooleanXBoolean -> Boolean : Type of Function
|
||||
characterXcharacter2Boolean : 001001 : : characterXcharacter -> Boolean : Type of Function
|
||||
integerXinteger2Boolean : 001001 : : integerXinteger -> Boolean : Type of Function
|
||||
integerXinteger2integer : 001001 : : integerXinteger -> integer : Type of Function
|
||||
string2integer : 001001 : : string -> integer : Type of Function
|
||||
Boolean2integer : 001001 : : Boolean -> integer : Type of Function
|
||||
character2integer : 001001 : : character -> integer : Type of Function
|
||||
integer2integer : 001001 : : integer -> integer : Type of Function
|
||||
Boolean2Boolean : 001001 : : Boolean -> Boolean : Type of Function
|
||||
integerXinteger : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
characterXcharacter : 001001 : : Record Type : elements-2 size-2 bytes
|
||||
BooleanXBoolean : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 015000 : 001001 : integer : Primitive Instance
|
||||
x : 015000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 014000 : 001001 : character : Primitive Instance
|
||||
x : 014000 : 001001 : character : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 013000 : 001001 : Boolean : Primitive Instance
|
||||
x : 013000 : 001001 : Boolean : Primitive Instance
|
||||
|
@ -1,62 +1,66 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
make_list : 001001 : : list : User Defined
|
||||
bar2 : 001001 : : T2 : User Defined
|
||||
bar1 : 001001 : : T2 : User Defined
|
||||
foo : 001001 : : T1 : User Defined
|
||||
list : 001001 : : primitive function type : User Defined
|
||||
llnode : 001001 : : record : elements-3
|
||||
T2 : 001001 : : primitive function type : User Defined
|
||||
T1 : 001001 : : primitive function type : User Defined
|
||||
rec : 001001 : : record : elements-2
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
li : 070000 : 001001 : llnode : User Defined
|
||||
w : 070000 : 001001 : rec : User Defined
|
||||
result : 070000 : 001001 : integer : User Defined
|
||||
arg : 070000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
r : 054000 : 001001 : integer : User Defined
|
||||
s : 054000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
x : 060009 : 054000 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 062028 : 060009 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 055021 : 054000 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 056026 : 055021 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
a : 050000 : 001001 : rec : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
x : 046000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
temp : 017000 : 001001 : address : User Defined
|
||||
curr : 017000 : 001001 : address : User Defined
|
||||
ret : 017000 : 001001 : address : User Defined
|
||||
orig_a : 017000 : 001001 : integer : User Defined
|
||||
a : 017000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 021012 : 017000 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 026023 : 021012 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 035020 : 026023 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 031034 : 026023 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
: 019029 : 017000 : : Empty Scope
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
next : 008000 : 001001 : llnode : User Defined
|
||||
val : 008000 : 001001 : integer : User Defined
|
||||
prev : 008000 : 001001 : llnode : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 004000 : 001001 : integer : User Defined
|
||||
x : 004000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
make_list : 001001 : : undefined : Function Definition
|
||||
bar2 : 001001 : : undefined : Function Definition
|
||||
bar1 : 001001 : : undefined : Function Definition
|
||||
foo : 001001 : : undefined : Function Definition
|
||||
list : 001001 : : integer -> llnode : Type of Function
|
||||
llnode : 001001 : : Record Type : elements-3 size-24 bytes
|
||||
T2 : 001001 : : rec -> integer : Type of Function
|
||||
T1 : 001001 : : integer -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
li : 069000 : 001001 : llnode : Record Instance
|
||||
w : 069000 : 001001 : rec : Record Instance
|
||||
result : 069000 : 001001 : integer : Primitive Instance
|
||||
arg : 069000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
r : 054000 : 001001 : integer : Primitive Instance
|
||||
s : 054000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 059012 : 054000 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 062028 : 059012 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 055021 : 054000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 056026 : 055021 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
a : 050000 : 001001 : integer : Primitive Instance
|
||||
b : 050000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 046000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
temp : 016000 : 001001 : address : Primitive Instance
|
||||
curr : 016000 : 001001 : address : Primitive Instance
|
||||
ret : 016000 : 001001 : address : Primitive Instance
|
||||
orig_a : 016000 : 001001 : integer : Primitive Instance
|
||||
a : 016000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 021012 : 016000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 026023 : 021012 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 035020 : 026023 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 031034 : 026023 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 019029 : 016000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
next : 008000 : 001001 : llnode : Record Instance
|
||||
val : 008000 : 001001 : integer : Primitive Instance
|
||||
prev : 008000 : 001001 : llnode : Record Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 004000 : 001001 : integer : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,30 +1,29 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
bar2 : 001001 : : T2 : User Defined
|
||||
bar1 : 001001 : : T2 : User Defined
|
||||
foo : 001001 : : T1 : User Defined
|
||||
T2 : 001001 : : primitive function type : User Defined
|
||||
T1 : 001001 : : primitive function type : User Defined
|
||||
rec : 001001 : : record : elements-2
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
w : 001000 : 001001 : rec : User Defined
|
||||
result : 001000 : 001001 : integer : User Defined
|
||||
arg : 001000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
r : 001000 : 001001 : integer : User Defined
|
||||
s : 001000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
a : 001000 : 001001 : rec : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
x : 001000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 001000 : 001001 : integer : User Defined
|
||||
x : 001000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
bar2 : 001001 : : undefined : Function Definition
|
||||
bar1 : 001001 : : undefined : Function Definition
|
||||
foo : 001001 : : undefined : Function Definition
|
||||
T2 : 001001 : : rec -> integer : Type of Function
|
||||
T1 : 001001 : : integer -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 000000 : 001001 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
a : 001000 : 001001 : integer : Primitive Instance
|
||||
undefined : 001000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,13 +1,23 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
arg_bool : 006000 : 001001 : Boolean : Primitive Instance
|
||||
arg_record : 006000 : 001001 : rec : Record Instance
|
||||
arg_y : 006000 : 001001 : integer : Primitive Instance
|
||||
arg_x : 006000 : 001001 : integer : Primitive Instance
|
||||
arg : 006000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
rec_y : 002000 : 001001 : integer : Primitive Instance
|
||||
rec_x : 002000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,12 +1,16 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
arg : 004000 : 001001 : string : Array Instance
|
||||
|
17
tests/sprint2/expected/sp2_sp2_arrayargs.expected
Normal file
17
tests/sprint2/expected/sp2_sp2_arrayargs.expected
Normal file
@ -0,0 +1,17 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
a_of_s : 001001 : : 1 -> string : Type of Array
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
many_names : 006000 : 001001 : a_of_s : Array Instance
|
||||
another_name : 006000 : 001001 : string : Array Instance
|
||||
one_name : 006000 : 001001 : string : Array Instance
|
@ -1,18 +1,21 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
T2 : 001001 : : primitive function type : User Defined
|
||||
rec : 001001 : : record : elements-2
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
w : 008000 : 001001 : rec : User Defined
|
||||
arg : 008000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
y : 004000 : 001001 : integer : User Defined
|
||||
x : 004000 : 001001 : integer : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
T2 : 001001 : : rec -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
w : 007000 : 001001 : rec : Record Instance
|
||||
arg : 007000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 004000 : 001001 : integer : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,11 +1,11 @@
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
type rec: [integer: x; integer: y]
|
||||
|
||||
type T1: integer -> integer
|
||||
type T2: rec -> integer
|
||||
type arr: 1 -> integer
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
function foo: T1
|
||||
function bar1: T2
|
||||
function bar2: T2
|
||||
@ -14,11 +14,11 @@ foo (x) := {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
bar1 (a) := {
|
||||
return a.x * a.y;
|
||||
bar1 (x, y) := {
|
||||
return x * y;
|
||||
}
|
||||
|
||||
bar2 as (r,s) := {
|
||||
bar2 (r,s) := {
|
||||
return r * s;
|
||||
}
|
||||
|
||||
@ -32,3 +32,4 @@ entry (arg) := {
|
||||
result := bar2(5,7); (* implicitly build a rec type value, assign 5 and 7 to fields x and y, but call them r and s *)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
type testarr : 1 -> integer
|
||||
|
||||
entry (arg) := {
|
||||
[integer:x; address: arr; address: arr2; Boolean : b2; Boolean : b1]
|
||||
[integer:x; testarr: arr; testarr: arr2; Boolean : b2; Boolean : b1]
|
||||
|
||||
x := 3 + 2 * 8;
|
||||
x := 3 - 2 / 8;
|
||||
|
@ -0,0 +1,7 @@
|
||||
type rec: [integer: x; integer: y]
|
||||
type main: rec -> integer
|
||||
function test: main
|
||||
|
||||
test (arg, arg2) := {
|
||||
return 0;
|
||||
}
|
@ -47,11 +47,11 @@ foo (x) := {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
bar1 (a) := {
|
||||
return a.x * a.y;
|
||||
bar1(a,b) := {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
bar2 as (r,s) := {
|
||||
bar2(r,s) := {
|
||||
if (r < s) then {
|
||||
while (!(r < s)) {
|
||||
r := r + 1;
|
||||
@ -78,4 +78,4 @@ entry (arg) := {
|
||||
result := bar2(5,7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
type main: string -> integer
|
||||
type rec: [integer: rec_x; integer: rec_y]
|
||||
|
||||
function entry: main
|
||||
|
||||
entry (arg) := {
|
||||
[integer:x]
|
||||
x := 3 + 2 * 8;
|
||||
[integer: arg_x; integer: arg_y; rec: arg_record; Boolean: arg_bool]
|
||||
arg_x := 3 + 2 * 8;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
entry(arg) := {
|
||||
[int : x]
|
||||
[integer : x]
|
||||
return 0;
|
||||
}
|
||||
}
|
16
tests/sprint2/test/sp2_sp2_arrayargs.alpha
Normal file
16
tests/sprint2/test/sp2_sp2_arrayargs.alpha
Normal file
@ -0,0 +1,16 @@
|
||||
type string: 1 -> character
|
||||
type a_of_s: 1 -> string
|
||||
|
||||
(* maybe some other type definitions *)
|
||||
|
||||
entry(arg) := {
|
||||
[ string: one_name; string: another_name; a_of_s: many_names ]
|
||||
another_name := reserve another_name(4); (* reserve space for an an array of character, with 4 members *)
|
||||
many_names := reserve a_of_s(many_names);
|
||||
many_names(0) := one_name;
|
||||
many_names(1) := another_name;
|
||||
many_names(2) := reserve a_of_s(2)(6); (* reserve space for an item of the same type as a_of_s(2), an array of character, with 6 members *)
|
||||
many_names(2)(0) := "P";
|
||||
|
||||
return 0;
|
||||
}
|
16
tests/sprint2/test/sp2_sp2_arrayargs.alpha~
Normal file
16
tests/sprint2/test/sp2_sp2_arrayargs.alpha~
Normal file
@ -0,0 +1,16 @@
|
||||
type string: 1 -> character
|
||||
type a_of_s: 1 -> string
|
||||
|
||||
(* maybe some other type definitions *)
|
||||
|
||||
entry(arg) := {
|
||||
[ string: one_name; string: another_name; a_of_s: many_names ]
|
||||
another_name := reserve another_name(4); (* reserve space for an an array of character, with 4 members *)
|
||||
many_names := reserve a_of_s(3);
|
||||
many_names(0) := one_name;
|
||||
many_names(1) := another_name;
|
||||
many_names(2) := reserve a_of_s(2)(6); (* reserve space for an item of the same type as a_of_s(2), an array of character, with 6 members *)
|
||||
many_names(2)(0) := "P";
|
||||
|
||||
return 0;
|
||||
}
|
34
tests/sprint3/expected/sp3_and_or_type_check.expected
Normal file
34
tests/sprint3/expected/sp3_and_or_type_check.expected
Normal file
@ -0,0 +1,34 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
test : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : rec -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
b : 005000 : 001001 : Boolean : Primitive Instance
|
||||
x : 005000 : 001001 : integer : Primitive Instance
|
||||
arg : 005000 : 001001 : integer : Primitive Instance
|
||||
undefined : 005000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 023009 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 021014 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 017009 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 015017 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 011012 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 007015 : 005000 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
@ -1,17 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
b1 : 005000 : 001001 : Boolean : User Defined
|
||||
b2 : 005000 : 001001 : Boolean : User Defined
|
||||
arr2 : 005000 : 001001 : address : User Defined
|
||||
arr : 005000 : 001001 : address : User Defined
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
b1 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
b2 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
arr2 : 004000 : 001001 : address : Primitive Instance
|
||||
arr : 004000 : 001001 : address : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
arg : 004000 : 001001 : string : Array Instance
|
||||
|
@ -1,17 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
b1 : 005000 : 001001 : Boolean : User Defined
|
||||
b2 : 005000 : 001001 : Boolean : User Defined
|
||||
arr2 : 005000 : 001001 : address : User Defined
|
||||
arr : 005000 : 001001 : address : User Defined
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
b1 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
b2 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
arr2 : 004000 : 001001 : address : Primitive Instance
|
||||
arr : 004000 : 001001 : address : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
arg : 004000 : 001001 : string : Array Instance
|
||||
|
@ -1,17 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
a_of_s : 001001 : : 1 -> string : Type of Array
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
many_names : 010000 : 001001 : a_of_s : User Defined
|
||||
another_name : 010000 : 001001 : string : User Defined
|
||||
one_name : 010000 : 001001 : string : User Defined
|
||||
arg : 010000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
a_of_s : 001001 : : 1 -> string : Type of Array
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
many_names : 009000 : 001001 : a_of_s : Array Instance
|
||||
another_name : 009000 : 001001 : string : Array Instance
|
||||
one_name : 009000 : 001001 : string : Array Instance
|
||||
arg : 009000 : 001001 : string : Array Instance
|
||||
|
@ -1,18 +1,26 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
a : 005000 : 001001 : character : User Defined
|
||||
b1 : 005000 : 001001 : Boolean : User Defined
|
||||
b2 : 005000 : 001001 : Boolean : User Defined
|
||||
arr2 : 005000 : 001001 : address : User Defined
|
||||
arr : 005000 : 001001 : address : User Defined
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
rec : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
r : 006000 : 001001 : rec : Record Instance
|
||||
a : 006000 : 001001 : character : Primitive Instance
|
||||
b1 : 006000 : 001001 : Boolean : Primitive Instance
|
||||
b2 : 006000 : 001001 : Boolean : Primitive Instance
|
||||
arr2 : 006000 : 001001 : address : Primitive Instance
|
||||
arr : 006000 : 001001 : address : Primitive Instance
|
||||
x : 006000 : 001001 : integer : Primitive Instance
|
||||
arg : 006000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 003000 : 001001 : integer : Primitive Instance
|
||||
x : 003000 : 001001 : integer : Primitive Instance
|
||||
|
@ -1,17 +1,20 @@
|
||||
NAME : SCOPE : PARENT : TYPE : Extra annotation
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
entry : 001001 : : main : User Defined
|
||||
main : 001001 : : primitive function type : User Defined
|
||||
integer : 001001 : : Primitive : size-4 bytes
|
||||
address : 001001 : : Primitive : size-8 bytes
|
||||
character : 001001 : : Primitive : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive : size-1 bytes
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
b1 : 005000 : 001001 : Boolean : User Defined
|
||||
b2 : 005000 : 001001 : Boolean : User Defined
|
||||
arr2 : 005000 : 001001 : address : User Defined
|
||||
arr : 005000 : 001001 : address : User Defined
|
||||
x : 005000 : 001001 : integer : User Defined
|
||||
arg : 005000 : 001001 : string : User Defined
|
||||
-------------------------:--------:--------:--------------------------:------------------------------
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
b1 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
b2 : 004000 : 001001 : Boolean : Primitive Instance
|
||||
arr2 : 004000 : 001001 : address : Primitive Instance
|
||||
arr : 004000 : 001001 : address : Primitive Instance
|
||||
x : 004000 : 001001 : integer : Primitive Instance
|
||||
arg : 004000 : 001001 : string : Array Instance
|
||||
|
25
tests/sprint3/expected/sp3_multiple_args.expected
Normal file
25
tests/sprint3/expected/sp3_multiple_args.expected
Normal file
@ -0,0 +1,25 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
bar : 001001 : : undefined : Function Definition
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
T2 : 001001 : : rec -> integer : Type of Function
|
||||
rec : 001001 : : Record Type : elements-2 size-6 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
w : 013000 : 001001 : rec : Record Instance
|
||||
result : 013000 : 001001 : integer : Primitive Instance
|
||||
arg : 013000 : 001001 : string : Array Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
: 009000 : 001001 : : Empty Scope
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : character : Primitive Instance
|
19
tests/sprint3/expected/sp3_primitive_type_check.expected
Normal file
19
tests/sprint3/expected/sp3_primitive_type_check.expected
Normal file
@ -0,0 +1,19 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
entry : 001001 : : undefined : Function Definition
|
||||
main : 001001 : : string -> integer : Type of Function
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
bool : 015000 : 001001 : Boolean : Primitive Instance
|
||||
char : 015000 : 001001 : character : Primitive Instance
|
||||
add : 015000 : 001001 : address : Primitive Instance
|
||||
i : 015000 : 001001 : integer : Primitive Instance
|
||||
arg : 015000 : 001001 : string : Array Instance
|
29
tests/sprint3/expected/sp3_record_size_check.expected
Normal file
29
tests/sprint3/expected/sp3_record_size_check.expected
Normal file
@ -0,0 +1,29 @@
|
||||
NAME : SCOPE : PARENT : TYPE : EXTRA ANNOTATION :
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
tricky : 001001 : : Record Type : elements-4 size-16 bytes
|
||||
rec : 001001 : : Record Type : elements-6 size-24 bytes
|
||||
tom : 001001 : : Record Type : elements-2 size-8 bytes
|
||||
integer : 001001 : : Primitive Type : size-4 bytes
|
||||
address : 001001 : : Primitive Type : size-8 bytes
|
||||
character : 001001 : : Primitive Type : size-1 bytes
|
||||
string : 001001 : : 1 -> character : Type of Array
|
||||
Boolean : 001001 : : Primitive Type : size-4 bytes
|
||||
reserve type : 001001 : : integer -> address : Type of Function
|
||||
reserve : 001001 : : undefined : Function Definition
|
||||
release type : 001001 : : address -> integer : Type of Function
|
||||
release : 001001 : : undefined : Function Definition
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
k2 : 003000 : 001001 : integer : Primitive Instance
|
||||
b2 : 003000 : 001001 : Boolean : Primitive Instance
|
||||
k1 : 003000 : 001001 : integer : Primitive Instance
|
||||
b1 : 003000 : 001001 : Boolean : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 002000 : 001001 : integer : Primitive Instance
|
||||
b : 002000 : 001001 : Boolean : Primitive Instance
|
||||
d : 002000 : 001001 : character : Primitive Instance
|
||||
c : 002000 : 001001 : character : Primitive Instance
|
||||
prev : 002000 : 001001 : tom : Record Instance
|
||||
x : 002000 : 001001 : integer : Primitive Instance
|
||||
------------------------------:--------:--------:-----------------------------------:-----------------------------------:
|
||||
y : 001000 : 001001 : integer : Primitive Instance
|
||||
x : 001000 : 001001 : integer : Primitive Instance
|
40
tests/sprint3/test/sp3_and_or_type_check.alpha
Normal file
40
tests/sprint3/test/sp3_and_or_type_check.alpha
Normal file
@ -0,0 +1,40 @@
|
||||
type rec: [integer: x; integer: y]
|
||||
type main: rec -> integer
|
||||
function test: main
|
||||
|
||||
test (arg) := {
|
||||
[integer:x; Boolean: b]
|
||||
while (true) {
|
||||
x := 0;
|
||||
}
|
||||
|
||||
while (7) {
|
||||
x := 1;
|
||||
}
|
||||
|
||||
if (true) then {
|
||||
x := 1;
|
||||
} else {
|
||||
x := 0;
|
||||
}
|
||||
|
||||
if (x) then {
|
||||
x := 0;
|
||||
} else {
|
||||
x := 1;
|
||||
}
|
||||
|
||||
b := b | b;
|
||||
b := b & b;
|
||||
b := 1 | b;
|
||||
b := b | 1;
|
||||
b := b & 1;
|
||||
b := 1 & b;
|
||||
b := 1 = 1;
|
||||
|
||||
|
||||
|
||||
b := 1 = b;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,15 +1,19 @@
|
||||
type main: string -> integer
|
||||
|
||||
type rec: [integer: x; integer: y]
|
||||
function entry: main
|
||||
|
||||
entry (arg) := {
|
||||
[integer:x; address: arr; address: arr2; Boolean : b2; Boolean : b1; character : a]
|
||||
[integer:x; address: arr; address: arr2; Boolean : b2; Boolean : b1; character : a; rec : r]
|
||||
|
||||
x := 3 + 2 * 8;
|
||||
x := 3 - 2 / 8;
|
||||
x := a * 2 % 8;
|
||||
b2 := 3 * 2 % 8;
|
||||
x := 3 % 2 * 8;
|
||||
x := 3 + arr - 8;
|
||||
|
||||
return 0;
|
||||
x := 3 + 2 * 8;
|
||||
x := 3 - 2 / 8;
|
||||
x := a * 2 % 8;
|
||||
b2 := 3 * 2 % 8;
|
||||
x := 3 % 2 * 8;
|
||||
x := 3 + arr - 8;
|
||||
x := r.x;
|
||||
x := a.x;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
17
tests/sprint3/test/sp3_multiple_args.alpha
Normal file
17
tests/sprint3/test/sp3_multiple_args.alpha
Normal file
@ -0,0 +1,17 @@
|
||||
type rec: [character: x; integer: y]
|
||||
|
||||
type T2: rec -> integer
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
function bar: T2
|
||||
|
||||
bar2 (r,s) := {
|
||||
return r;
|
||||
}
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
result := bar('c', 7);
|
||||
return 0;
|
||||
}
|
17
tests/sprint3/test/sp3_multiple_args.alpha~
Normal file
17
tests/sprint3/test/sp3_multiple_args.alpha~
Normal file
@ -0,0 +1,17 @@
|
||||
type rec: [character: x; integer: y]
|
||||
|
||||
type T2: rec -> integer
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
function bar: T2
|
||||
|
||||
bar2 (r,s) := {
|
||||
return s;
|
||||
}
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
result := bar('c', 7);
|
||||
return 0;
|
||||
}
|
23
tests/sprint3/test/sp3_primitive_type_check.alpha
Normal file
23
tests/sprint3/test/sp3_primitive_type_check.alpha
Normal file
@ -0,0 +1,23 @@
|
||||
(*
|
||||
Testing the following type checks:
|
||||
- integer : primitive
|
||||
- character : primitive
|
||||
- boolean : primitive
|
||||
|
||||
- address (not included, special case)
|
||||
*)
|
||||
|
||||
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
entry (arg) := {
|
||||
[integer: i; address: add; character: char; Boolean: bool]
|
||||
|
||||
i := 3 + 2 * 8;
|
||||
char := 'a';
|
||||
bool := true;
|
||||
|
||||
return 0;
|
||||
}
|
3
tests/sprint3/test/sp3_record_size_check.alpha
Normal file
3
tests/sprint3/test/sp3_record_size_check.alpha
Normal file
@ -0,0 +1,3 @@
|
||||
type tom : [integer : x; integer: y]
|
||||
type rec : [integer : x; tom : prev; character : c; character : d; Boolean: b; integer : y]
|
||||
type tricky : [Boolean : b1; integer : k1; Boolean : b2; integer : k2]
|
Reference in New Issue
Block a user