diff --git a/assignment1/problem3/struct.h b/assignment1/problem3/struct.h index 4110002..8126d73 100644 --- a/assignment1/problem3/struct.h +++ b/assignment1/problem3/struct.h @@ -23,7 +23,7 @@ typedef struct ASTString_str { } ASTString; -/* AST Node structure, describe in ./README.md */ +/* AST Node structure */ typedef struct ASTNode_str { /* 1: string, 2: left (, 3: right ) */ diff --git a/assignment1/problem3/uncompress.c b/assignment1/problem3/uncompress.c index bf2ad89..83c07e1 100644 --- a/assignment1/problem3/uncompress.c +++ b/assignment1/problem3/uncompress.c @@ -1,3 +1,10 @@ +/* + * Author: Walter + * Student ID: 1930006025 + * Assignment_1_Problem_3 + * uncompress using AST method + */ + #include #include #include diff --git a/assignment1/problem3/uncompress.h b/assignment1/problem3/uncompress.h index 1a52844..cb79b19 100644 --- a/assignment1/problem3/uncompress.h +++ b/assignment1/problem3/uncompress.h @@ -1,3 +1,32 @@ +/* + * Author: Walter + * Student ID: 1930006025 + * Assignment_1_Problem_3 + * + * AST (Abstract Syntax Tree) is a tree representation of the abstract + * syntactic structure of source code written in a programming language. + * Each node of the tree denotes a construct occurring in the source code. + * + * First of all, ASTScanner can scan the source code with LL(1) parser, + * return a token (ASTNode) of source code, there are 3 types of token. + * 1: string + * 2: loop start with repeat times + * 3: end loop + * + * Then ASTScanAll() can take all token into tree. + * + * For example: + * source code start3(miku6(aaa)asdf)end will generate the following tree: + * + * "start" -> 3 -> "end" + * | + * -> "miku" -> 6 -> "asdf" + * | + * -> "aaa" + * + * ASTCompileTree() can compile the tree into output. + */ + #ifndef UNCOMPRESS #define UNCOMPRESS