├── APIs.md ├── README.md └── scripts ├── test-all.sh ├── test-codegen.sh ├── test-err.sh ├── test-lexer.sh ├── test-parser.sh ├── test-pcode.sh └── test-typechecker.sh /APIs.md: -------------------------------------------------------------------------------- 1 | # APIs 2 | Use this to find which file a function or struct is written in 3 | 4 | ## AST 5 | Functions and structs related to creating and printing an abstract syntax tree 6 | 7 | ### ast.c 8 | 9 | void printIndent(FILE *fp, int depth) {} 10 | void printstring(FILE *fp, char *string, int depth) {} 11 | void printbool(FILE *fp, bool value, int depth) {} 12 | void printint(FILE *fp, int value, int depth) {} 13 | void printToken(FILE *fp, struct Token *token, int depth) {} 14 | void printDataType(FILE *fp, struct DataType *datatype, int depth) {} 15 | void printScope(FILE *fp, struct Scope *scope, int depth) {} 16 | void printSymbol(FILE *fp, struct Symbol *symbol, int depth) {} 17 | void printstringTyped(FILE *fp, char *string, int depth) {} 18 | void printboolTyped(FILE *fp, bool value, int depth) {} 19 | void printintTyped(FILE *fp, int value, int depth) {} 20 | void printTokenTyped(FILE *fp, struct Token *token, int depth) {} 21 | void printDataTypeTyped(FILE *fp, struct DataType *datatype, int depth) {} 22 | void printScopeTyped(FILE *fp, struct Scope *scope, int depth) {} 23 | void printSymbolTyped(FILE *fp, struct Symbol *symbol, int depth) {} 24 | struct TranslationUnit *newTranslationUnit() {} 25 | struct Block *newBlock() {} 26 | struct FuncDecl *newFuncDecl() {} 27 | struct TypedIdent *newTypedIdent() {} 28 | struct TypedIdentList *newTypedIdentList() {} 29 | struct TypedIdentListElement *newTypedIdentListElement() {} 30 | void addTypedIdent(struct TypedIdentList *list, struct TypedIdent *node) {} 31 | struct FuncDeclList *newFuncDeclList() {} 32 | struct FuncDeclListElement *newFuncDeclListElement() {} 33 | void addFuncDecl(struct FuncDeclList *list, struct FuncDecl *node) {} 34 | struct Statement *newStatement(enum statement_union kind) {} 35 | struct StatementList *newStatementList() {} 36 | struct StatementListElement *newStatementListElement() {} 37 | void addStatement(struct StatementList *list, struct Statement *node) {} 38 | struct Expression *newExpression(enum expression_union kind) {} 39 | struct ExpressionList *newExpressionList() {} 40 | struct ExpressionListElement *newExpressionListElement() {} 41 | void addExpression(struct ExpressionList *list, struct Expression *node) {} 42 | void printTranslationUnit(FILE *fp, struct TranslationUnit *node, int depth) {} 43 | void printTranslationUnitTyped(FILE *fp, struct TranslationUnit *node, int depth) {} 44 | void printBlock(FILE *fp, struct Block *node, int depth) {} 45 | void printBlockTyped(FILE *fp, struct Block *node, int depth) {} 46 | void printFuncDecl(FILE *fp, struct FuncDecl *node, int depth) {} 47 | void printFuncDeclTyped(FILE *fp, struct FuncDecl *node, int depth) {} 48 | void printTypedIdent(FILE *fp, struct TypedIdent *node, int depth) {} 49 | void printTypedIdentTyped(FILE *fp, struct TypedIdent *node, int depth) {} 50 | void printTypedIdentList(FILE *fp, struct TypedIdentList *list, int depth) {} 51 | void printTypedIdentListTyped(FILE *fp, struct TypedIdentList *list, int depth) {} 52 | void printFuncDeclList(FILE *fp, struct FuncDeclList *list, int depth) {} 53 | void printFuncDeclListTyped(FILE *fp, struct FuncDeclList *list, int depth) {} 54 | void printStatement(FILE *fp, struct Statement *node, int depth) {} 55 | void printStatementTyped(FILE *fp, struct Statement *node, int depth) {} 56 | void printStatementList(FILE *fp, struct StatementList *list, int depth) {} 57 | void printStatementListTyped(FILE *fp, struct StatementList *list, int depth) {} 58 | void printExpression(FILE *fp, struct Expression *node, int depth) {} 59 | void printExpressionTyped(FILE *fp, struct Expression *node, int depth) {} 60 | void printExpressionList(FILE *fp, struct ExpressionList *list, int depth) {} 61 | void printExpressionListTyped(FILE *fp, struct ExpressionList *list, int depth) {} 62 | 63 | ### ast.h 64 | 65 | struct Translation Unit {}; 66 | struct FuncDecl {}; 67 | struct TypedIdent {}; 68 | struct TypedIdentList {}; 69 | struct TypedIdentListElement {}; 70 | struct FuncDeclList {}; 71 | struct FuncDeclListElement {}; 72 | enum statement_union {}; 73 | struct Statement {}; 74 | struct StatementList {}; 75 | struct StatementListElement {}; 76 | enum expression_union {}; 77 | struct Expression {}; 78 | struct ExpressionList {}; 79 | struct ExpressionListElement {}; 80 | 81 | 82 | ## Codegen 83 | Functions and structs related to generating pcode from a Typed Abstract Syntax Tree 84 | 85 | ### codegen.c 86 | 87 | // declarations 88 | static void visitTranslationUnit(struct TranslationUnit *node) {} 89 | static void visitBlock(struct Block *node) {} 90 | static void visitVarDecls(struct TypedIdentList *list) {} 91 | static void visitFuncDecls(struct FuncDeclList *list) {} 92 | static void visitFuncDecl(struct FuncDecl *node) {} 93 | static void visitFormals(struct TypedIdentList *list) {} 94 | 95 | // statements 96 | static void visitStatement(struct Statement *node) {} 97 | static void visitAssignStatement(struct Statement *node) {} 98 | static void visitCallStatement(struct Statement *node) {} 99 | static void visitReturnStatement(struct Statement *node) {} 100 | static void visitCompoundStatement(struct Statement *list) {} 101 | static void visitIfStatement(struct Statement *node) {} 102 | static void visitWhileStatement(struct Statement *node) {} 103 | static void visitReadStatement(struct Statement *node) {} 104 | static void visitWriteStatement(struct Statement *node) {} 105 | 106 | // expressions 107 | static int visitExpression(struct Expression *node, int reg_base) {} 108 | static int visitBinaryExpressionInt(struct Expression *node, int reg_base) {} 109 | static int visitUnaryExpressionInt(struct Expression *node, int reg_base) {} 110 | static int visitBinaryExpressionBool(struct Expression *node, int reg_base) {} 111 | static int visitUnaryExpressionBool(struct Expression *node, int reg_base) {} 112 | static int visitNumberFactor(struct Expression *node, int reg_base) {} 113 | static int visitBooleanFactor(struct Expression *node, int reg_base) {} 114 | static int visitVariableFactor(struct Expression *node, int reg_base) {} 115 | static int visitFunctionFactor(struct Expression *node, int reg_base) {} 116 | 117 | // common functions for statements and expressions 118 | static void setVariable(struct Symbol *symbol, int reg) {} 119 | static void setupFunctionCall(struct Symbol *fsymbol, struct ExpressionList *parameters, int reg) {} 120 | 121 | // helper functions for emitting ops 122 | static int emit(Instruction instr) {} 123 | static void backpatch(int branch_instruction_address, int new_disp) {} 124 | 125 | // definitions 126 | #define FP 12 127 | #define SP 13 128 | #define LN 14 129 | #define IP 15 130 | 131 | #define OFFSET_FIRST_PARAM -4 132 | #define OFFSET_RET_VAL -3 133 | #define OFFSET_STATIC_LINK -2 134 | #define OFFSET_RET_ADDR -1 135 | #define OFFSET_FIRST_LOCAL 136 | 137 | ### codegen.h 138 | 139 | void codegen(struct TranslationUnit *node); 140 | void print_pcode(FILE *fp); 141 | 142 | ### codegen_instr.h 143 | 144 | // macros for each VM intruction 145 | #define VM_* 146 | 147 | ### codegen_tools.c 148 | 149 | void print_instruction(FILE *fp, Instruction instruction) {} 150 | void print_pcode(FILE *fp) {} 151 | char *register_name(int reg) {} 152 | 153 | 154 | ## Datatype 155 | Functions and structs related to storing datatype information for a variable, function, or factor 156 | 157 | ### datatype.c 158 | 159 | struct DataType *getInt() {} 160 | struct DataType *getBool() {} 161 | struct DataType *getVoid() {} 162 | struct DataType *getPrimitiveType(struct TypedIdent *typedident) {} 163 | struct DataType *getFuncType(struct FuncDecl *funcdecl) {} 164 | bool isPrimitiveType(struct DataType *datatype) {} 165 | bool isFuncType(struct DataType *datatype) {} 166 | bool isInt(struct DataType *datatype) {} 167 | bool isBool(struct DataType *datatype) {} 168 | bool isVoid(struct DataType *datatype) {} 169 | bool equalTypes(struct DataType *a, struct DataType *b) {} 170 | void print_data_type(FILE *fp, struct DataType *datatype) {} 171 | 172 | ### datatype.h 173 | 174 | enum primitive_type {}; 175 | struct TupleElement {}; 176 | enum datatype_kind {}; 177 | struct DataType {}; 178 | 179 | 180 | ## Parser 181 | Functions for turning tokens into an AST 182 | 183 | ### parser.c 184 | 185 | struct TranslationUnit* parser(struct Token** token_list_in) {} 186 | static struct TranslationUnit *program() {} 187 | static struct Block *block() {} 188 | static struct TypedIdentList *vardecls() {} 189 | static struct FuncDeclList *funcdecls() {} 190 | static struct TypedIdentList *formals() {} 191 | static struct Token *type() {} 192 | static struct Statement *statement() {} 193 | static struct ExpressionList *exprlist() {} 194 | static struct Expression *expr() {} 195 | bool static is_relop() {} 196 | static struct Expression *simpleexpr() {} 197 | bool static is_termop() {} 198 | static struct Expression *term() {} 199 | bool static is_factorop() {} 200 | static struct Expression *factor() {} 201 | 202 | ### parser_tools.c 203 | 204 | static void next() {} 205 | static void previous() {} 206 | static struct Token *token() {} 207 | static void parse_error() {} 208 | static bool is_token(enum tok_kind kind) {} 209 | static bool lookahead_token(enum tok_kind kind) {} 210 | static bool ensure_token(enum tok_kind kind) {} 211 | 212 | 213 | ## SymTab 214 | Functions and structs related to creating and storing the scope and symbols for syntactic components 215 | 216 | ### symtab.c 217 | 218 | struct Scope *addScope(char *name, struct Scope *parent) {} 219 | struct Scope *getParentScope(struct Scope *scope) {} 220 | struct Symbol *addVariable(struct Scope *scope, char *name, struct TypedIdent *node) {} 221 | struct Symbol *addFunction(struct Scope *scope, char *name, struct FuncDecl *node) {} 222 | static struct Symbol *addSymbol(struct Scope *scope, char *name, struct Symbol *symbol) {} 223 | struct Symbol *getSymbol(struct Scope *scope, char *name) {} 224 | struct Symbol *searchSymbol(struct Scope *scope, char *name) {} 225 | void print_space(FILE *fp, int depth) {} 226 | void print_scope(FILE *fp, struct Scope *scope, int depth) {} 227 | 228 | ### symtab.h 229 | 230 | struct Symbol {}; 231 | struct SymbolList {}; 232 | struct SymbolListElement {}; 233 | struct Scope {}; 234 | struct ScopeList {}; 235 | struct ScopeListElement {}; 236 | 237 | 238 | ## Token 239 | Functions for converting source code into tokens 240 | 241 | ### token.c 242 | 243 | struct Token* new_identifier(int kind, char *lexeme) {} 244 | struct Token* new_number(int kind, int number) {} 245 | struct Token* new_token(int kind) {} 246 | struct Token *alloc_token() {} 247 | struct Token** alloc_token_list() {} 248 | void print_token_kind(FILE *fp, enum tok_kind kind) {} 249 | void print_token(FILE *fp, struct Token *token) {} 250 | void write_tokens(FILE *fp, struct Token **list) {} 251 | 252 | ### token.h 253 | 254 | enum tok_kind {}; 255 | struct Token {}; 256 | 257 | 258 | ## Typechecker 259 | Functions for verifying the type matching of an existing AST 260 | 261 | ### typechecker.c 262 | 263 | static void visitTranslationUnit(struct TranslationUnit *node) {} 264 | static void visitBlock(struct Block *node) {} 265 | static void visitVarDecl(struct TypedIdent *node) {} 266 | static void visitVarDecls(struct TypedIdentList *list) {} 267 | static void visitFuncDecl(struct FuncDecl *node) {} 268 | static void visitFormal(struct TypedIdent *node) {} 269 | static void visitFormals(struct TypedIdentList *list) {} 270 | static void visitFuncDeclList(struct FuncDeclList *list) {} 271 | static void visitStatement(struct Statement *node) {} 272 | static void visitAssignStatement(struct Statement *node) {} 273 | static void visitCallStatement(struct Statement *node) {} 274 | static void visitReturnStatement(struct Statement *node) {} 275 | static void visitCompoundStatement(struct Statement *list) {} 276 | static void visitIfStatement(struct Statement *node) {} 277 | static void visitWhileStatement(struct Statement *node) {} 278 | static void visitReadStatement(struct Statement *node) {} 279 | static void visitWriteStatement(struct Statement *node) {} 280 | static void visitExpressionList(struct ExpressionList *list) {} 281 | static void visitExpression(struct Expression *node) {} 282 | static void visitBinaryExpression(struct Expression *node) {} 283 | static void visitUnaryExpression(struct Expression *node) {} 284 | static void visitNumberFactor(struct Expression *node) {} 285 | static void visitBooleanFactor(struct Expression *node) {} 286 | static void visitVariableFactor(struct Expression *node) {} 287 | static void visitFunctionFactor(struct Expression *node) {} 288 | 289 | ### typechecker_tools.c 290 | 291 | void print_symtab(FILE *fp) {} 292 | void type_error(char *msg) {} 293 | 294 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SysSoftwareScripts 2 | Test scripts for each part of the Systems Software project (UCF COP 3402) 3 | 4 | Function and Struct index: [APIs](APIs.md) 5 | 6 | ## Running testscripts 7 | 8 | Place the `scripts` folder inside of your `project-` folder. Your `project-` folder 9 | should also be next to your `syllabus` folder (E.g. place both folders on the desktop). 10 | 11 | To run an individual script, open a terminal in the `scripts` folder and run `bash test-