diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5b79a5415be450374d4fd7937805c31124ee120f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +.cache/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000000000000000000000000000000000000..340b494f9cba1f1b4a5392d7666098074ccf6200 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required( VERSION 3.8 ) +project(CMINUSF) + +set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -std=c99") + +SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb") +SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall") +SET(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fsanitize=address") + +set(default_build_type "Debug") + +if(NOT(CMAKE_BUILD_TYPE_SHADOW STREQUAL CMAKE_BUILD_TYPE)) + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${default_build_type}'") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) + else() + message(STATUS "Building in ${CMAKE_BUILD_TYPE} mode") + endif() + + set(CMAKE_BUILD_TYPE_SHADOW ${CMAKE_BUILD_TYPE} CACHE STRING "used to detect changes in build type" FORCE) +endif() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +find_package(FLEX REQUIRED) +find_package(BISON REQUIRED) +find_package(LLVM REQUIRED CONFIG) +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") +llvm_map_components_to_libnames( + llvm_libs + support + core +) + +INCLUDE_DIRECTORIES( + include + include/cminusfc + include/common + include/lightir + ${LLVM_INCLUDE_DIRS} +) + +add_definitions(${LLVM_DEFINITIONS}) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + +include_directories(${PROJECT_SOURCE_DIR}) +include_directories(${PROJECT_BINARY_DIR}) +add_subdirectory(src) diff --git a/README.md b/README.md index a09d895628a05d851df3345e951a0cd251a208e8..1f3b2246b60ef464a1b6cdc26e36ba55ca32978b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,25 @@ -- Lab0 已经发布 `git checkout lab0` -- Lab1 已经发布 `git checkout lab1` +# 简介 + +本仓库为 USTC 编译原理和技术 2024 的课程实验仓库。在本学期的编译实验中,你们将构建一个从词法分析器开始到后端代码生成的JIANMU编译器。 + +你们需要 fork 此 repo 到自己的仓库下,随后在自己的仓库中完成实验。 + + +## 测试脚本使用方法 + +eval_phase1.sh: 测试phase1 词法分析器+语法分析器部分 + + -all: 测试所有测试集 (easy, normal, hard, testcases_general) + + easy/normal/hard/testcases_general + yes/no/verbose: 测试单个测试集 + + yes: 使用diff判断正确性 + + no: 不使用diff判断正确性 + + verbose: 使用diff判断正确性,并看到更详细的输出 + +eval_phase2.sh: 测试phase2 syntax_tree -> ast 部分 + + 使用方法与eval_phase1.sh完全相同, 会自动跳过生成syntax_tree fail的样例 + \ No newline at end of file diff --git a/include/common/ast.hpp b/include/common/ast.hpp new file mode 100644 index 0000000000000000000000000000000000000000..059ce970899b9bafb58ed35efaeccc91e1954371 --- /dev/null +++ b/include/common/ast.hpp @@ -0,0 +1,254 @@ +#pragma once + +extern "C" { +#include "syntax_tree.h" +extern syntax_tree *parse(const char *input); +} +#include +#include +#include + +enum CminusType { TYPE_INT, TYPE_FLOAT, TYPE_VOID }; + +enum RelOp { + // <= + OP_LE, + // < + OP_LT, + // > + OP_GT, + // >= + OP_GE, + // == + OP_EQ, + // != + OP_NEQ +}; + +enum AddOp { + // + + OP_PLUS, + // - + OP_MINUS +}; + +enum MulOp { + // * + OP_MUL, + // / + OP_DIV +}; + +class AST; + +struct ASTNode; +struct ASTProgram; +struct ASTDeclaration; +struct ASTNum; +struct ASTVarDeclaration; +struct ASTFunDeclaration; +struct ASTParam; + +struct ASTCompoundStmt; +struct ASTStatement; +struct ASTExpressionStmt; +struct ASTSelectionStmt; +struct ASTIterationStmt; +struct ASTReturnStmt; +struct ASTFactor; +struct ASTExpression; +struct ASTVar; +struct ASTAssignExpression; +struct ASTSimpleExpression; +struct ASTAdditiveExpression; +struct ASTTerm; +struct ASTCall; + +class ASTVisitor; + +class AST { + public: + AST() = delete; + AST(syntax_tree *); + AST(AST &&tree) { + root = tree.root; + tree.root = nullptr; + }; + ASTProgram *get_root() { return root.get(); } + void run_visitor(ASTVisitor &visitor); + + private: + ASTNode *transform_node_iter(syntax_tree_node *); + std::shared_ptr root = nullptr; +}; + +struct ASTNode { + virtual void accept(ASTVisitor &) = 0; + virtual ~ASTNode() = default; +}; + +struct ASTProgram : ASTNode { + virtual void accept(ASTVisitor &) override final; + virtual ~ASTProgram() = default; + std::vector> declarations; +}; + +struct ASTDeclaration : ASTNode { + virtual ~ASTDeclaration() = default; + CminusType type; + std::string id; +}; + +struct ASTFactor : ASTNode { + virtual ~ASTFactor() = default; +}; + +struct ASTNum : ASTFactor { + virtual void accept(ASTVisitor &) override final; + CminusType type; + union { + int i_val; + float f_val; + }; +}; + +struct ASTVarDeclaration : ASTDeclaration { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr num; +}; + +struct ASTFunDeclaration : ASTDeclaration { + virtual void accept(ASTVisitor &) override final; + std::vector> params; + std::shared_ptr compound_stmt; +}; + +struct ASTParam : ASTNode { + virtual void accept(ASTVisitor &) override final; + CminusType type; + std::string id; + // true if it is array param + bool isarray; +}; + +struct ASTStatement : ASTNode { + virtual ~ASTStatement() = default; +}; + +struct ASTCompoundStmt : ASTStatement { + virtual void accept(ASTVisitor &) override final; + std::vector> local_declarations; + std::vector> statement_list; +}; + +struct ASTExpressionStmt : ASTStatement { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr expression; +}; + +struct ASTSelectionStmt : ASTStatement { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr expression; + std::shared_ptr if_statement; + // should be nullptr if no else structure exists + std::shared_ptr else_statement; +}; + +struct ASTIterationStmt : ASTStatement { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr expression; + std::shared_ptr statement; +}; + +struct ASTReturnStmt : ASTStatement { + virtual void accept(ASTVisitor &) override final; + // should be nullptr if return void + std::shared_ptr expression; +}; + +struct ASTExpression : ASTFactor {}; + +struct ASTAssignExpression : ASTExpression { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr var; + std::shared_ptr expression; +}; + +struct ASTSimpleExpression : ASTExpression { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr additive_expression_l; + std::shared_ptr additive_expression_r; + RelOp op; +}; + +struct ASTVar : ASTFactor { + virtual void accept(ASTVisitor &) override final; + std::string id; + // nullptr if var is of int type + std::shared_ptr expression; +}; + +struct ASTAdditiveExpression : ASTNode { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr additive_expression; + AddOp op; + std::shared_ptr term; +}; + +struct ASTTerm : ASTNode { + virtual void accept(ASTVisitor &) override final; + std::shared_ptr term; + MulOp op; + std::shared_ptr factor; +}; + +struct ASTCall : ASTFactor { + virtual void accept(ASTVisitor &) override final; + std::string id; + std::vector> args; +}; + +class ASTVisitor { + public: + virtual void visit(ASTProgram &) = 0; + virtual void visit(ASTNum &) = 0; + virtual void visit(ASTVarDeclaration &) = 0; + virtual void visit(ASTFunDeclaration &) = 0; + virtual void visit(ASTParam &) = 0; + virtual void visit(ASTCompoundStmt &) = 0; + virtual void visit(ASTExpressionStmt &) = 0; + virtual void visit(ASTSelectionStmt &) = 0; + virtual void visit(ASTIterationStmt &) = 0; + virtual void visit(ASTReturnStmt &) = 0; + virtual void visit(ASTAssignExpression &) = 0; + virtual void visit(ASTSimpleExpression &) = 0; + virtual void visit(ASTAdditiveExpression &) = 0; + virtual void visit(ASTVar &) = 0; + virtual void visit(ASTTerm &) = 0; + virtual void visit(ASTCall &) = 0; +}; + +class ASTPrinter : public ASTVisitor { + public: + virtual void visit(ASTProgram &) override final; + virtual void visit(ASTNum &) override final; + virtual void visit(ASTVarDeclaration &) override final; + virtual void visit(ASTFunDeclaration &) override final; + virtual void visit(ASTParam &) override final; + virtual void visit(ASTCompoundStmt &) override final; + virtual void visit(ASTExpressionStmt &) override final; + virtual void visit(ASTSelectionStmt &) override final; + virtual void visit(ASTIterationStmt &) override final; + virtual void visit(ASTReturnStmt &) override final; + virtual void visit(ASTAssignExpression &) override final; + virtual void visit(ASTSimpleExpression &) override final; + virtual void visit(ASTAdditiveExpression &) override final; + virtual void visit(ASTVar &) override final; + virtual void visit(ASTTerm &) override final; + virtual void visit(ASTCall &) override final; + void add_depth() { depth += 2; } + void remove_depth() { depth -= 2; } + + private: + int depth = 0; +}; diff --git a/include/common/logging.hpp b/include/common/logging.hpp new file mode 100644 index 0000000000000000000000000000000000000000..032e8d465291742ed90af66975989d2baf4811e5 --- /dev/null +++ b/include/common/logging.hpp @@ -0,0 +1,82 @@ +#ifndef LOGGING_HPP +#define LOGGING_HPP + +#include +#include +#include + +enum LogLevel +{ + DEBUG = 0, + INFO, + WARNING, + ERROR +}; +struct LocationInfo +{ + LocationInfo(std::string file, int line, const char *func) : file_(file), line_(line), func_(func) {} + ~LocationInfo() = default; + + std::string file_; + int line_; + const char *func_; +}; +class LogStream; +class LogWriter; + +class LogWriter +{ +public: + LogWriter(LocationInfo location, LogLevel loglevel) + : location_(location), log_level_(loglevel) + { + char *logv = std::getenv("LOGV"); + if (logv) + { + std::string string_logv = logv; + env_log_level = std::stoi(logv); + } + else + { + env_log_level = 4; + } + }; + + void operator<(const LogStream &stream); + +private: + void output_log(const std::ostringstream &g); + LocationInfo location_; + LogLevel log_level_; + int env_log_level; +}; + +class LogStream +{ +public: + template + LogStream &operator<<(const T &val) noexcept + { + sstream_ << val; + return *this; + } + + friend class LogWriter; + +private: + std::stringstream sstream_{}; +}; + +std::string level2string(LogLevel level); +std::string get_short_name(const char *file_path); + +#define __FILESHORTNAME__ get_short_name(__FILE__) +#define LOG_IF(level) \ + LogWriter(LocationInfo(__FILESHORTNAME__, __LINE__, __FUNCTION__), level) < LogStream() +#define LOG(level) LOG_##level +#define LOG_DEBUG LOG_IF(DEBUG) +#define LOG_INFO LOG_IF(INFO) +#define LOG_WARNING LOG_IF(WARNING) +#define LOG_ERROR LOG_IF(ERROR) + +#endif diff --git a/include/common/syntax_tree.h b/include/common/syntax_tree.h new file mode 100644 index 0000000000000000000000000000000000000000..6eea3c1898d2ae673da043b8134c5d3f389fa65c --- /dev/null +++ b/include/common/syntax_tree.h @@ -0,0 +1,31 @@ +#ifndef __SYNTAXTREE_H__ +#define __SYNTAXTREE_H__ + +#include + +#define SYNTAX_TREE_NODE_NAME_MAX 30 + +struct _syntax_tree_node { + struct _syntax_tree_node * parent; + struct _syntax_tree_node * children[10]; + int children_num; + + char name[SYNTAX_TREE_NODE_NAME_MAX]; +}; +typedef struct _syntax_tree_node syntax_tree_node; + +syntax_tree_node * new_anon_syntax_tree_node(); +syntax_tree_node * new_syntax_tree_node(const char * name); +int syntax_tree_add_child(syntax_tree_node * parent, syntax_tree_node * child); +void del_syntax_tree_node(syntax_tree_node * node, int recursive); + +struct _syntax_tree { + syntax_tree_node * root; +}; +typedef struct _syntax_tree syntax_tree; + +syntax_tree* new_syntax_tree(); +void del_syntax_tree(syntax_tree * tree); +void print_syntax_tree(FILE * fout, syntax_tree * tree); + +#endif /* SyntaxTree.h */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..67f7a885c76e8f058c4bc7b38a70345eba17a119 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(parser) +add_subdirectory(common) +add_subdirectory(logging) +add_subdirectory(cminusfc) diff --git a/src/cminusfc/CMakeLists.txt b/src/cminusfc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..948fa79fe7cf76cc5ca18d954921b690dc53c106 --- /dev/null +++ b/src/cminusfc/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable( + cminusfc + main.cpp +) + +target_link_libraries( + cminusfc + common + syntax + stdc++fs +) + +install( + TARGETS cminusfc + RUNTIME DESTINATION bin +) diff --git a/src/cminusfc/main.cpp b/src/cminusfc/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ae74c583a960d2ab0341e29d98c338685ea0be3a --- /dev/null +++ b/src/cminusfc/main.cpp @@ -0,0 +1,116 @@ +#include "ast.hpp" + +#include +#include +#include + +using std::string; +using std::operator""s; + +struct Config +{ + string exe_name; // compiler exe name + std::filesystem::path input_file; + std::filesystem::path output_file; + + bool emitast{false}; + + Config(int argc, char **argv) : argc(argc), argv(argv) + { + parse_cmd_line(); + check(); + } + +private: + int argc{-1}; + char **argv{nullptr}; + + void parse_cmd_line(); + void check(); + // print helper infomation and exit + void print_help() const; + void print_err(const string &msg) const; +}; + +int main(int argc, char **argv) +{ + Config config(argc, argv); + auto syntax_tree = parse(config.input_file.c_str()); + auto ast = AST(syntax_tree); + ASTPrinter printer; + ast.run_visitor(printer); + + return 0; +} + +void Config::parse_cmd_line() +{ + exe_name = argv[0]; + for (int i = 1; i < argc; ++i) + { + if (argv[i] == "-h"s || argv[i] == "--help"s) + { + print_help(); + } + else if (argv[i] == "-o"s) + { + if (output_file.empty() && i + 1 < argc) + { + output_file = argv[i + 1]; + i += 1; + } + else + { + print_err("bad output file"); + } + } + else if (argv[i] == "-emit-ast"s) + { + emitast = true; + } + else + { + if (input_file.empty()) + { + input_file = argv[i]; + } + else + { + string err = + "unrecognized command-line option \'"s + argv[i] + "\'"s; + print_err(err); + } + } + } +} + +void Config::check() +{ + if (input_file.empty()) + { + print_err("no input file"); + } + if (input_file.extension() != ".cminus") + { + print_err("file format not recognized"); + } + if (output_file.empty()) + { + output_file = input_file.stem(); + } +} + +void Config::print_help() const +{ + std::cout << "Usage: " << exe_name + << " [-h|--help] [-o ] [-mem2reg] [-emit-llvm] [-S] " + "" + << std::endl; + exit(0); +} + +void Config::print_err(const string &msg) const +{ + std::cout << exe_name << ": " << msg << std::endl; + exit(-1); +} diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5fe66a7fe24ab42e40a7f15ef1b92680c34d07f1 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(common STATIC + syntax_tree.c + ast.cpp + logging.cpp +) + +target_link_libraries(common) + diff --git a/src/common/ast.cpp b/src/common/ast.cpp new file mode 100644 index 0000000000000000000000000000000000000000..acafd5afd14577a36a86c3f0858ce62500663763 --- /dev/null +++ b/src/common/ast.cpp @@ -0,0 +1,594 @@ +#include "ast.hpp" + +#include +#include +#include + +#define _AST_NODE_ERROR_ \ + std::cerr << "Abort due to node cast error." \ + "Contact with TAs to solve your problem." \ + << std::endl; \ + std::abort(); +// NOTE: use std::string instead of strcmp to compare strings, +// 注意使用这里的接口 +#define _STR_EQ(a, b) (strcmp((a), (b)) == 0) + +void AST::run_visitor(ASTVisitor &visitor) { root->accept(visitor); } + +AST::AST(syntax_tree *s) { + if (s == nullptr) { + std::cerr << "empty input tree!" << std::endl; + std::abort(); + } + auto node = transform_node_iter(s->root); + del_syntax_tree(s); + root = std::shared_ptr(static_cast(node)); +} + +ASTNode *AST::transform_node_iter(syntax_tree_node *n) { + /* + example: + program -> declaration-list + declaration-list -> declaration-list declaration | declaration + 将其转化成AST中ASTProgram的结构 + */ + if (_STR_EQ(n->name, "program")) { + auto node = new ASTProgram(); + // flatten declaration list + std::stack + s; // 为什么这里要用stack呢?如果用其他数据结构应该如何实现 + auto list_ptr = n->children[0]; + while (list_ptr->children_num == 2) { + s.push(list_ptr->children[1]); + list_ptr = list_ptr->children[0]; + } + s.push(list_ptr->children[0]); + + while (!s.empty()) { + auto child_node = + static_cast(transform_node_iter(s.top())); + + auto child_node_shared = std::shared_ptr(child_node); + node->declarations.push_back(child_node_shared); + s.pop(); + } + return node; + } else if (_STR_EQ(n->name, "declaration")) { + return transform_node_iter(n->children[0]); + } else if (_STR_EQ(n->name, "var-declaration")) { + auto node = new ASTVarDeclaration(); + // NOTE: 思考 ASTVarDeclaration的结构,需要填充的字段有哪些 + // type + // 为什么不会有 TYPE_VOID? + if (_STR_EQ(n->children[0]->children[0]->name, "int")) + node->type = TYPE_INT; + else + node->type = TYPE_FLOAT; + // id & num + // 由不同的表达式填充 + if (n->children_num == 3) { + node->id = n->children[1]->name; + } else if (n->children_num == 6) { + node->id = n->children[1]->name; + int num = std::stoi(n->children[3]->name); + auto num_node = std::make_shared(); + num_node->i_val = num; + num_node->type = TYPE_INT; + node->num = num_node; + } else { + std::cerr << "[ast]: var-declaration transform failure!" << std::endl; + std::abort(); + } + return node; + } else if (_STR_EQ(n->name, "fun-declaration")) { + // fun-declaration -> type-specifier ID ( params ) compound-stmt + // 由表达式和 ASTFunDeclaration的结构,我们需要填充 + // type, id, params, compound_stmt 这四个字段 + auto node = new ASTFunDeclaration(); + // type 字段填充 + if (_STR_EQ(n->children[0]->children[0]->name, "int")) { + node->type = TYPE_INT; + } else if (_STR_EQ(n->children[0]->children[0]->name, "float")) { + node->type = TYPE_FLOAT; + } else { + node->type = TYPE_VOID; + } + // id 字段填充 + node->id = n->children[1]->name; + + /* + params 字段填充 + 注意这里的params是一个列表,每个元素都是一个ASTParam,需要flatten + params -> param-list | void + param-list -> param-list , param | param + */ + // TODO: 1.fill in the fields of ASTFunDeclaration + // 1.1 flatten params + + // 1.2 compound_stmt 字段填充 + + return node; + } else if (_STR_EQ(n->name, "param")) { + // param -> type-specifier ID | type-specifier ID [ ] + // ASTParam的结构 主要需要填充的属性有 type, id, isarray + auto node = new ASTParam(); + // type, id, isarray + if (_STR_EQ(n->children[0]->children[0]->name, "int")) + node->type = TYPE_INT; + else + node->type = TYPE_FLOAT; + node->id = n->children[1]->name; + if (n->children_num > 2) + node->isarray = true; + return node; + } else if (_STR_EQ(n->name, "compound-stmt")) { + auto node = new ASTCompoundStmt(); + // TODO: 2.fill in the fields of ASTCompoundStmt + /* + 文法表达式如下 + compound-stmt -> { local-declarations statement-list } + local-declarations -> local-declarations var-declaration | empty + statement-list -> statement-list statement | empty + */ + // local declarations + // 2.1 flatten local declarations + + // statement list + // 2.2 flatten statement-list + + return node; + } else if (_STR_EQ(n->name, "statement")) { + return transform_node_iter(n->children[0]); + } else if (_STR_EQ(n->name, "expression-stmt")) { + auto node = new ASTExpressionStmt(); + if (n->children_num == 2) { + auto expr_node = + static_cast(transform_node_iter(n->children[0])); + + auto expr_node_ptr = std::shared_ptr(expr_node); + node->expression = expr_node_ptr; + } + return node; + } else if (_STR_EQ(n->name, "selection-stmt")) { + auto node = new ASTSelectionStmt(); + // TODO: 5.fill in the fields of ASTSelectionStmt + /* + selection-stmt -> if ( expression ) statement | if ( expression ) + statement else statement ASTSelectionStmt的结构,需要填充的字段有 + expression, if_statement, else_statement + */ + // 5.1 expresstion + + // 5.2 if statement + + // check whether this selection statement contains + // 5.3 else structure + + return node; + } else if (_STR_EQ(n->name, "iteration-stmt")) { + auto node = new ASTIterationStmt(); + + auto expr_node = + static_cast(transform_node_iter(n->children[2])); + auto expr_node_ptr = std::shared_ptr(expr_node); + node->expression = expr_node_ptr; + + auto stmt_node = + static_cast(transform_node_iter(n->children[4])); + auto stmt_node_ptr = std::shared_ptr(stmt_node); + node->statement = stmt_node_ptr; + + return node; + } else if (_STR_EQ(n->name, "return-stmt")) { + auto node = new ASTReturnStmt(); + if (n->children_num == 3) { + auto expr_node = + static_cast(transform_node_iter(n->children[1])); + node->expression = std::shared_ptr(expr_node); + } + return node; + } else if (_STR_EQ(n->name, "expression")) { + // simple-expression + if (n->children_num == 1) { + return transform_node_iter(n->children[0]); + } + auto node = new ASTAssignExpression(); + + auto var_node = static_cast(transform_node_iter(n->children[0])); + node->var = std::shared_ptr(var_node); + + auto expr_node = + static_cast(transform_node_iter(n->children[2])); + node->expression = std::shared_ptr(expr_node); + + return node; + } else if (_STR_EQ(n->name, "var")) { + auto node = new ASTVar(); + node->id = n->children[0]->name; + if (n->children_num == 4) { + auto expr_node = + static_cast(transform_node_iter(n->children[2])); + node->expression = std::shared_ptr(expr_node); + } + return node; + } else if (_STR_EQ(n->name, "simple-expression")) { + auto node = new ASTSimpleExpression(); + auto expr_node_1 = static_cast( + transform_node_iter(n->children[0])); + node->additive_expression_l = + std::shared_ptr(expr_node_1); + + if (n->children_num == 3) { + auto op_name = n->children[1]->children[0]->name; + if (_STR_EQ(op_name, "<=")) + node->op = OP_LE; + else if (_STR_EQ(op_name, "<")) + node->op = OP_LT; + else if (_STR_EQ(op_name, ">")) + node->op = OP_GT; + else if (_STR_EQ(op_name, ">=")) + node->op = OP_GE; + else if (_STR_EQ(op_name, "==")) + node->op = OP_EQ; + else if (_STR_EQ(op_name, "!=")) + node->op = OP_NEQ; + + auto expr_node_2 = static_cast( + transform_node_iter(n->children[2])); + node->additive_expression_r = + std::shared_ptr(expr_node_2); + } + return node; + } else if (_STR_EQ(n->name, "additive-expression")) { + auto node = new ASTAdditiveExpression(); + if (n->children_num == 3) { + // TODO: 4.fill in the fields of ASTAdditiveExpression + /* + 文法表达式如下 + additive-expression -> additive-expression addop term | term + */ + // additive_expression, term, op + + } else { + auto term_node = + static_cast(transform_node_iter(n->children[0])); + node->term = std::shared_ptr(term_node); + } + return node; + } else if (_STR_EQ(n->name, "term")) { + auto node = new ASTTerm(); + if (n->children_num == 3) { + auto term_node = + static_cast(transform_node_iter(n->children[0])); + node->term = std::shared_ptr(term_node); + + auto op_name = n->children[1]->children[0]->name; + if (_STR_EQ(op_name, "*")) + node->op = OP_MUL; + else if (_STR_EQ(op_name, "/")) + node->op = OP_DIV; + + auto factor_node = + static_cast(transform_node_iter(n->children[2])); + node->factor = std::shared_ptr(factor_node); + } else { + auto factor_node = + static_cast(transform_node_iter(n->children[0])); + node->factor = std::shared_ptr(factor_node); + } + return node; + } else if (_STR_EQ(n->name, "factor")) { + int i = 0; + if (n->children_num == 3) + i = 1; + auto name = n->children[i]->name; + if (_STR_EQ(name, "expression") || _STR_EQ(name, "var") || + _STR_EQ(name, "call")) + return transform_node_iter(n->children[i]); + else { + auto num_node = new ASTNum(); + // TODO: 3.fill in the fields of ASTNum + /* + 文法表达式如下 + factor -> ( expression ) | var | call | integer | float + float -> FLOATPOINT + integer -> INTEGER + */ + if (_STR_EQ(name, "integer")) { + // 3.1 + + } else if (_STR_EQ(name, "float")) { + // 3.2 + + } else { + _AST_NODE_ERROR_ + } + return num_node; + } + } else if (_STR_EQ(n->name, "call")) { + auto node = new ASTCall(); + node->id = n->children[0]->name; + // flatten args + if (_STR_EQ(n->children[2]->children[0]->name, "arg-list")) { + auto list_ptr = n->children[2]->children[0]; + auto s = std::stack(); + while (list_ptr->children_num == 3) { + s.push(list_ptr->children[2]); + list_ptr = list_ptr->children[0]; + } + s.push(list_ptr->children[0]); + + while (!s.empty()) { + auto expr_node = + static_cast(transform_node_iter(s.top())); + auto expr_node_ptr = std::shared_ptr(expr_node); + node->args.push_back(expr_node_ptr); + s.pop(); + } + } + return node; + } else { + std::cerr << "[ast]: transform failure!" << std::endl; + std::abort(); + } +} + +void ASTProgram::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTNum::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTVarDeclaration::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTFunDeclaration::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTParam::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTCompoundStmt::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTExpressionStmt::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTSelectionStmt::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTIterationStmt::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTReturnStmt::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTAssignExpression::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTSimpleExpression::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTAdditiveExpression::accept(ASTVisitor &visitor) { + return visitor.visit(*this); +} +void ASTVar::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTTerm::accept(ASTVisitor &visitor) { return visitor.visit(*this); } +void ASTCall::accept(ASTVisitor &visitor) { return visitor.visit(*this); } + +// NOTE: 打印AST的相关接口,无需修改 + +#define _DEBUG_PRINT_N_(N) \ + { std::cout << std::string(N, '-'); } + +void ASTPrinter::visit(ASTProgram &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "program" << std::endl; + add_depth(); + for (auto decl : node.declarations) { + decl->accept(*this); + } + remove_depth(); +} + +void ASTPrinter::visit(ASTNum &node) { + _DEBUG_PRINT_N_(depth); + if (node.type == TYPE_INT) { + std::cout << "num (int): " << node.i_val << std::endl; + } else if (node.type == TYPE_FLOAT) { + std::cout << "num (float): " << node.f_val << std::endl; + } else { + _AST_NODE_ERROR_ + } +} + +void ASTPrinter::visit(ASTVarDeclaration &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "var-declaration: " << node.id; + if (node.num != nullptr) { + std::cout << "[]" << std::endl; + add_depth(); + node.num->accept(*this); + remove_depth(); + return; + } + std::cout << std::endl; +} + +void ASTPrinter::visit(ASTFunDeclaration &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "fun-declaration: " << node.id << std::endl; + add_depth(); + for (auto param : node.params) { + param->accept(*this); + } + + node.compound_stmt->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTParam &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "param: " << node.id; + if (node.isarray) + std::cout << "[]"; + std::cout << std::endl; +} + +void ASTPrinter::visit(ASTCompoundStmt &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "compound-stmt" << std::endl; + add_depth(); + for (auto decl : node.local_declarations) { + decl->accept(*this); + } + + for (auto stmt : node.statement_list) { + stmt->accept(*this); + } + remove_depth(); +} + +void ASTPrinter::visit(ASTExpressionStmt &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "expression-stmt" << std::endl; + add_depth(); + if (node.expression != nullptr) + node.expression->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTSelectionStmt &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "selection-stmt" << std::endl; + add_depth(); + node.expression->accept(*this); + node.if_statement->accept(*this); + if (node.else_statement != nullptr) + node.else_statement->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTIterationStmt &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "iteration-stmt" << std::endl; + add_depth(); + node.expression->accept(*this); + node.statement->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTReturnStmt &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "return-stmt"; + if (node.expression == nullptr) { + std::cout << ": void" << std::endl; + } else { + std::cout << std::endl; + add_depth(); + node.expression->accept(*this); + remove_depth(); + } +} + +void ASTPrinter::visit(ASTAssignExpression &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "assign-expression" << std::endl; + add_depth(); + node.var->accept(*this); + node.expression->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTSimpleExpression &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "simple-expression"; + if (node.additive_expression_r == nullptr) { + std::cout << std::endl; + } else { + std::cout << ": "; + if (node.op == OP_LT) { + std::cout << "<"; + } else if (node.op == OP_LE) { + std::cout << "<="; + } else if (node.op == OP_GE) { + std::cout << ">="; + } else if (node.op == OP_GT) { + std::cout << ">"; + } else if (node.op == OP_EQ) { + std::cout << "=="; + } else if (node.op == OP_NEQ) { + std::cout << "!="; + } else { + std::abort(); + } + std::cout << std::endl; + } + add_depth(); + node.additive_expression_l->accept(*this); + if (node.additive_expression_r != nullptr) + node.additive_expression_r->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTAdditiveExpression &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "additive-expression"; + if (node.additive_expression == nullptr) { + std::cout << std::endl; + } else { + std::cout << ": "; + if (node.op == OP_PLUS) { + std::cout << "+"; + } else if (node.op == OP_MINUS) { + std::cout << "-"; + } else { + std::abort(); + } + std::cout << std::endl; + } + add_depth(); + if (node.additive_expression != nullptr) + node.additive_expression->accept(*this); + node.term->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTVar &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "var: " << node.id; + if (node.expression != nullptr) { + std::cout << "[]" << std::endl; + add_depth(); + node.expression->accept(*this); + remove_depth(); + return; + } + std::cout << std::endl; +} + +void ASTPrinter::visit(ASTTerm &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "term"; + if (node.term == nullptr) { + std::cout << std::endl; + } else { + std::cout << ": "; + if (node.op == OP_MUL) { + std::cout << "*"; + } else if (node.op == OP_DIV) { + std::cout << "/"; + } else { + std::abort(); + } + std::cout << std::endl; + } + add_depth(); + if (node.term != nullptr) + node.term->accept(*this); + + node.factor->accept(*this); + remove_depth(); +} + +void ASTPrinter::visit(ASTCall &node) { + _DEBUG_PRINT_N_(depth); + std::cout << "call: " << node.id << "()" << std::endl; + add_depth(); + for (auto arg : node.args) { + arg->accept(*this); + } + remove_depth(); +} diff --git a/src/common/logging.cpp b/src/common/logging.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9d508956a1b2b051adfa19da833bb6ad9a3dec13 --- /dev/null +++ b/src/common/logging.cpp @@ -0,0 +1,42 @@ +#include "logging.hpp" + +void LogWriter::operator<(const LogStream &stream) { + std::ostringstream msg; + msg << stream.sstream_.rdbuf(); + output_log(msg); +} + +void LogWriter::output_log(const std::ostringstream &msg) { + if (log_level_ >= env_log_level) + std::cout << "[" << level2string(log_level_) << "] " + << "(" << location_.file_ + << ":" << location_.line_ + << "L "<< location_.func_<<")" + << msg.str() << std::endl; + +} +std::string level2string(LogLevel level) { + switch (level) + { + case DEBUG: + return "DEBUG"; + + case INFO: + return "INFO"; + + case WARNING: + return "WARNING"; + + case ERROR: + return "ERROR"; + + default: + return ""; + } +} +std::string get_short_name(const char * file_path) { + std::string short_file_path = file_path; + int index = short_file_path.find_last_of('/'); + + return short_file_path.substr(index+1); +} diff --git a/src/common/syntax_tree.c b/src/common/syntax_tree.c new file mode 100644 index 0000000000000000000000000000000000000000..0ac6e6bdd1e1b2a656d64363bb80a12129bb9cfa --- /dev/null +++ b/src/common/syntax_tree.c @@ -0,0 +1,77 @@ +#include +#include + +#include "syntax_tree.h" + +syntax_tree_node * new_syntax_tree_node(const char * name) +{ + syntax_tree_node * new_node = (syntax_tree_node *)malloc(sizeof(syntax_tree_node)); + if (name) + strncpy(new_node->name, name, SYNTAX_TREE_NODE_NAME_MAX); + else + new_node->name[0] = '\0'; + new_node->children_num = 0; + return new_node; +} + +int syntax_tree_add_child(syntax_tree_node * parent, syntax_tree_node * child) +{ + if (!parent || !child) return -1; + parent->children[parent->children_num++] = child; + return parent->children_num; +} + +void del_syntax_tree_node(syntax_tree_node * node, int recursive) +{ + if (!node) return; + + int i; + if (recursive) { + for (i = 0; i < node->children_num; i++) { + del_syntax_tree_node(node->children[i], 1); + } + } + free(node); +} + +syntax_tree * new_syntax_tree() +{ + return (syntax_tree *)malloc(sizeof(syntax_tree)); +} + +void del_syntax_tree(syntax_tree * tree) +{ + if (!tree) return; + + if (tree->root) { + del_syntax_tree_node(tree->root, 1); + } + free(tree); +} + +void print_syntax_tree_node(FILE * fout, syntax_tree_node * node, int level) +{ + // assume fout valid now + + // check if "node" empty pointer + if (!node) return; + + // print myself + int i; + for (i = 0; i < level; i++) { + fprintf(fout, "| "); + } + fprintf(fout, ">--%s %s\n", (node->children_num ? "+" : "*"), node->name); + + for (i = 0; i < node->children_num; i++) { + print_syntax_tree_node(fout, node->children[i], level + 1); + } +} + +void print_syntax_tree(FILE * fout, syntax_tree * tree) +{ + if (!fout) return; + + print_syntax_tree_node(fout, tree->root, 0); +} + diff --git a/src/logging/CMakeLists.txt b/src/logging/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..4a82d9dd2f6dc54f132308ee0ef0ab94f53c25b9 --- /dev/null +++ b/src/logging/CMakeLists.txt @@ -0,0 +1,14 @@ +add_executable(test_ast test_ast.cpp) +add_executable(test_logging test_logging.cpp) +target_link_libraries(test_ast syntax common) +target_link_libraries(test_logging common) + +install( + TARGETS test_logging + RUNTIME DESTINATION bin +) + +install( + TARGETS test_ast + RUNTIME DESTINATION bin +) diff --git a/src/logging/test_ast.cpp b/src/logging/test_ast.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2693fc2e897e5bba1d4ac58aa9eac6692e480f43 --- /dev/null +++ b/src/logging/test_ast.cpp @@ -0,0 +1,15 @@ +#include "ast.hpp" + +#include + +int main(int argc, char **argv) { + if (argc != 2) { + std::cout << "usage: " << argv[0] << " " << std::endl; + } else { + auto s = parse(argv[1]); + auto a = AST(s); + auto printer = ASTPrinter(); + a.run_visitor(printer); + } + return 0; +} diff --git a/src/logging/test_logging.cpp b/src/logging/test_logging.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b2b85d44a5e5baf27348baa53a32815438dc94a --- /dev/null +++ b/src/logging/test_logging.cpp @@ -0,0 +1,12 @@ +#include "logging.hpp" +// 引入头文件 +int main() { + LOG(DEBUG) << "This is DEBUG log item."; + // 使用关键字LOG,括号中填入要输出的日志等级 + // 紧接着就是<<以及日志的具体信息,这一步就跟使用std::cout一样 + LOG(INFO) << "This is INFO log item"; + LOG(WARNING) << "This is WARNING log item"; + LOG(ERROR) << "This is ERROR log item"; + + return 0; +} \ No newline at end of file diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f5b83c9140eabb6ec59758658c482a1634914d89 --- /dev/null +++ b/src/parser/CMakeLists.txt @@ -0,0 +1,26 @@ +flex_target(lex lexical_analyzer.l ${CMAKE_CURRENT_BINARY_DIR}/lexical_analyzer.c) +bison_target(syntax syntax_analyzer.y + ${CMAKE_CURRENT_BINARY_DIR}/syntax_analyzer.c + DEFINES_FILE ${PROJECT_BINARY_DIR}/syntax_analyzer.h) + +add_flex_bison_dependency(lex syntax) +add_library(syntax STATIC + ${BISON_syntax_OUTPUTS} + ${FLEX_lex_OUTPUTS} +) + +include_directories(${PROJECT_BINARY_DIR}) +add_executable(parser parser.c) +target_link_libraries(parser syntax common) +add_executable(lexer lexer.c) +target_link_libraries(lexer syntax common) + +install( + TARGETS parser + RUNTIME DESTINATION bin +) + +install( + TARGETS lexer + RUNTIME DESTINATION bin +) diff --git a/src/parser/lexer.c b/src/parser/lexer.c new file mode 100755 index 0000000000000000000000000000000000000000..7920b92602a7fd1453814465e9ffec8f321a73b2 --- /dev/null +++ b/src/parser/lexer.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +/// +extern int lines; +extern int pos_start; +extern int pos_end; + +/// +extern FILE *yyin; +extern char *yytext; +extern int yylex(); + +// Mac-only hack. +YYSTYPE yylval; + +/// +int main(int argc, const char **argv) { + if (argc != 2) { + printf("usage: lexer input_file\n"); + return 0; + } + + const char *input_file = argv[1]; + yyin = fopen(input_file, "r"); + if (!yyin) { + fprintf(stderr, "cannot open file: %s\n", input_file); + return 1; + } + + int token; + printf("%5s\t%10s\t%s\t%s\n", "Token", "Text", "Line", "Column (Start,End)"); + while ((token = yylex())) { + printf("%-5d\t%10s\t%d\t(%d,%d)\n", + token, yytext, + lines, pos_start, pos_end); + } + return 0; +} diff --git a/src/parser/lexical_analyzer.l b/src/parser/lexical_analyzer.l new file mode 100644 index 0000000000000000000000000000000000000000..e3d89c994763b296090d993da3847e014f0fc211 --- /dev/null +++ b/src/parser/lexical_analyzer.l @@ -0,0 +1,46 @@ +%option noyywrap +%{ +/*****************声明和选项设置 begin*****************/ +#include +#include + +#include "syntax_tree.h" +#include "syntax_analyzer.h" + +int lines=1; +int pos_start=1; +int pos_end=1; + +void pass_node(char *text){ + yylval.node = new_syntax_tree_node(text); +} + +/*****************声明和选项设置 end*****************/ + +%} + +%x COMMENT + +%% + /* to do for students */ + /* two cases for you, pass_node will send flex's token to bison */ +\+ {pos_start = pos_end; pos_end += 1; pass_node(yytext); return ADD;} +\- {pos_start = pos_end; pos_end += 1; pass_node(yytext); return SUB;} +\* {pos_start = pos_end; pos_end += 1; pass_node(yytext); return MUL;} +\/ {pos_start = pos_end; pos_end += 1; pass_node(yytext); return DIV;} +\< {pos_start = pos_end; pos_end += 1; pass_node(yytext); return LT;} +\<= {pos_start = pos_end; pos_end += 2; pass_node(yytext); return LTE;} +\> {pos_start = pos_end; pos_end += 1; pass_node(yytext); return GT;} +\>= {pos_start = pos_end; pos_end += 2; pass_node(yytext); return GTE;} +== {pos_start = pos_end; pos_end += 2; pass_node(yytext); return EQ;} +!= {pos_start = pos_end; pos_end += 2; pass_node(yytext); return NEQ;} += {pos_start = pos_end; pos_end += 1; pass_node(yytext); return ASSIGN;} +; {pos_start = pos_end; pos_end += 1; pass_node(yytext); return SEMICOLON;} +, {pos_start = pos_end; pos_end += 1; pass_node(yytext); return COMMA;} + /* TODO: phase1. 请在这里补充其他的词法规则 */ + + +. { pos_start = pos_end; pos_end++; return ERROR; } + + /****请在此补全所有flex的模式与动作 end******/ +%% diff --git a/src/parser/parser.c b/src/parser/parser.c new file mode 100644 index 0000000000000000000000000000000000000000..e73874676daf7422cab2e5c516a859288447b0d9 --- /dev/null +++ b/src/parser/parser.c @@ -0,0 +1,21 @@ +#include "syntax_tree.h" +extern syntax_tree *parse(const char*); + +int main(int argc, char *argv[]) +{ + syntax_tree *tree = NULL; + const char *input = NULL; + + if (argc == 2) { + input = argv[1]; + } else if(argc >= 3) { + printf("usage: %s \n", argv[0]); + return 1; + } + + // Call the syntax analyzer. + tree = parse(input); + print_syntax_tree(stdout, tree); + del_syntax_tree(tree); + return 0; +} diff --git a/src/parser/syntax_analyzer.y b/src/parser/syntax_analyzer.y new file mode 100644 index 0000000000000000000000000000000000000000..71a07eca0ed5be9593308ab6022ebbc747472810 --- /dev/null +++ b/src/parser/syntax_analyzer.y @@ -0,0 +1,181 @@ +%{ +#include +#include +#include +#include + +#include "syntax_tree.h" + +// external functions from lex +extern int yylex(); +extern int yyparse(); +extern int yyrestart(); +extern FILE * yyin; + +// external variables from lexical_analyzer module +extern int lines; +extern char * yytext; +extern int pos_end; +extern int pos_start; + +// Global syntax tree +syntax_tree *gt; + +// Error reporting +void yyerror(const char *s); + +// Helper functions written for you with love +syntax_tree_node *node(const char *node_name, int children_num, ...); +%} + +/* Complete this definition. + Hint: See pass_node(), node(), and syntax_tree.h. + Use forward declaring. */ +%union { + struct _syntax_tree_node * node; + char * name; +} + +/* Your tokens here. */ +%token ERROR +%token ADD +%token SUB +%token MUL +%token DIV +%token LT +%token LTE +%token GT +%token GTE +%token EQ +%token NEQ +%token ASSIGN +%token SEMICOLON +%token COMMA +%token LPARENTHESE +%token RPARENTHESE +%token LBRACKET +%token RBRACKET +%token LBRACE +%token RBRACE +%token ELSE +%token IF +%token INT +%token RETURN +%token VOID +%token WHILE +%token IDENTIFIER +%token INTEGER +%token FLOAT // 这个token 对应float 关键字 +%token FLOATPOINT // 这个token 对应 浮点数值, 如果分不清的同学可以参考type-specifier的文法和对应产生式规则 +//%token EOL +//%token BLANK +//%token COMMENT +%type program declaration-list declaration var-declaration type-specifier fun-declaration params param-list param compound-stmt local-declarations statement-list statement expression-stmt selection-stmt iteration-stmt return-stmt expression var simple-expression relop additive-expression addop term mulop factor integer float call args arg-list + +/* compulsory starting symbol */ +%start program + +%% +/* Your rules here. TA has completed many */ + +program : declaration-list {$$ = node( "program", 1, $1); gt->root = $$;} + ; + +declaration-list : declaration-list declaration {$$ = node( "declaration-list", 2, $1, $2);} + | declaration {$$ = node( "declaration-list", 1, $1);} + ; + +declaration : var-declaration {$$ = node( "declaration", 1, $1);} + | fun-declaration {$$ = node( "declaration", 1, $1);} + ; + +var-declaration : type-specifier IDENTIFIER SEMICOLON {$$ = node( "var-declaration", 3, $1, $2, $3);} + | type-specifier IDENTIFIER LBRACKET INTEGER RBRACKET SEMICOLON {$$ = node( "var-declaration", 6, $1, $2, $3, $4, $5, $6);} + ; + +type-specifier : INT {$$ = node( "type-specifier", 1, $1);} + | FLOAT { $$ = node( "type-specifier", 1, $1); } + | VOID {$$ = node( "type-specifier", 1, $1);} + ; + +fun-declaration : type-specifier IDENTIFIER LPARENTHESE params RPARENTHESE compound-stmt {$$ = node( "fun-declaration", 6, $1, $2, $3, $4, $5, $6);} + ; + +params : param-list {$$ = node( "params", 1, $1);} + | VOID {$$ = node( "params", 1, $1);} + ; + +param-list : param-list COMMA param {$$ = node( "param-list", 3, $1, $2, $3);} + | param {$$ = node( "param-list", 1, $1);} + ; + +param : type-specifier IDENTIFIER {$$ = node( "param", 2, $1, $2);} + | type-specifier IDENTIFIER LBRACKET RBRACKET {$$ = node( "param", 4, $1, $2, $3, $4);} + ; + +compound-stmt : LBRACE local-declarations statement-list RBRACE {$$ = node( "compound-stmt", 4, $1, $2, $3, $4);} + ; + +local-declarations : local-declarations var-declaration {$$ = node( "local-declarations", 2, $1, $2);} +| {$$ = node( "local-declarations",0);} + ; + +statement-list : statement-list statement {$$ = node( "statement-list", 2, $1, $2);} +| {$$ = node( "statement-list",0);} + ; +// TODO: phase1. 补充其他的文法产生式逻辑 + +%% + +/// The error reporting function. +void yyerror(const char * s) +{ + // TO STUDENTS: This is just an example. + // You can customize it as you like. + fprintf(stderr, "error at line %d column %d: %s\n", lines, pos_start, s); +} + +/// Parse input from file `input_path`, and prints the parsing results +/// to stdout. If input_path is NULL, read from stdin. +/// +/// This function initializes essential states before running yyparse(). +syntax_tree *parse(const char *input_path) +{ + if (input_path != NULL) { + if (!(yyin = fopen(input_path, "r"))) { + fprintf(stderr, "[ERR] Open input file %s failed.\n", input_path); + exit(1); + } + } else { + yyin = stdin; + } + + lines = pos_start = pos_end = 1; + gt = new_syntax_tree(); + yyrestart(yyin); + yyparse(); + return gt; +} + +/// A helper function to quickly construct a tree node. +/// +/// e.g. $$ = node("program", 1, $1); +syntax_tree_node *node(const char *name, int children_num, ...) +{ + syntax_tree_node *p = new_syntax_tree_node(name); + syntax_tree_node *child; + // 这里表示 epsilon结点是通过 children_num == 0 来判断的 + if (children_num == 0) { + child = new_syntax_tree_node("epsilon"); + syntax_tree_add_child(p, child); + } else { + va_list ap; + va_start(ap, children_num); + for (int i = 0; i < children_num; ++i) { + child = va_arg(ap, syntax_tree_node *); + syntax_tree_add_child(p, child); + } + va_end(ap); + } + return p; +} diff --git a/tests/1-parser/cleanup.sh b/tests/1-parser/cleanup.sh new file mode 100755 index 0000000000000000000000000000000000000000..0fe99f19466534968de14baa7c1a79339002ed2b --- /dev/null +++ b/tests/1-parser/cleanup.sh @@ -0,0 +1,3 @@ +#!/bin/sh +rm -rf output_student/* +rm -rf output_student_ast/* diff --git a/tests/1-parser/eval_phase1.sh b/tests/1-parser/eval_phase1.sh new file mode 100755 index 0000000000000000000000000000000000000000..4618cdd128b55c6ee842bec2bac87ebc4b1c2498 --- /dev/null +++ b/tests/1-parser/eval_phase1.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +# DO NOT MODIFY! +# If you need customized behavior, please create your own script. + +function run_tests() { + local TESTCASE_DIR=$1 + local OUTPUT_DIR=$2 + local OUTPUT_STD_DIR=$3 + local score=0 + local total=0 + + mkdir -p "$OUTPUT_DIR" + + # 对每个 .cminus 文件生成 syntax_tree 文件 + for testcase in "$TESTCASE_DIR"/*.cminus; do + filename="$(basename "$testcase")" + + echo "[info] Analyzing $filename" + + # 生成学生的 syntax_tree 文件 + "$BUILD_DIR"/parser "$testcase" > "$OUTPUT_DIR/${filename%.cminus}.syntax_tree" + + # 比较当前文件的输出与标准输出 + if [[ ${2:-no} != "no" ]]; then + echo "[info] Comparing $filename..." + + # 如果是详细模式 + if [[ ${2:-no} == "verbose" ]]; then + diff "$OUTPUT_DIR/${filename%.cminus}.syntax_tree" "$OUTPUT_STD_DIR/${filename%.cminus}.syntax_tree" + else + diff -q "$OUTPUT_DIR/${filename%.cminus}.syntax_tree" "$OUTPUT_STD_DIR/${filename%.cminus}.syntax_tree" + fi + + # 检查 diff 的返回值 + if [ $? -eq 0 ]; then + echo "[info] $filename is correct!" + let score=score+1 # 正确时得分+1 + else + echo "[info] $filename differs from the expected output." + fi + fi + + let total=total+1 # 总文件数+1 + + rm -f "$CUR_DIR/${filename%.cminus}" + done + + # 输出当前测试集的得分 + echo "[info] Score for $TESTCASE_DIR: $score/$total" + return $score +} + +# 检查命令行参数是否足够 +if [[ $# -lt 1 ]]; then + echo "usage: ./eval_phase1.sh []" + echo " can be one of 'easy', 'normal', 'hard', 'testcases_general', or '-all'." + echo " can be one of 'no', 'yes', and 'verbose'. the default value is 'no'" + exit 1 +fi + +CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +BUILD_DIR="$CUR_DIR/../../build" + +# 检查是否使用了 -all 选项 +if [[ $1 == "-all" ]]; then + TOTAL_SCORE=0 + TOTAL_FILES=0 + # 定义四个测试集 + TESTCASES=("easy" "normal" "hard" "testcases_general") + + for TESTCASE in "${TESTCASES[@]}"; do + if [[ $TESTCASE == "testcases_general" ]]; then + TESTCASE_DIR="$CUR_DIR/../$TESTCASE" + else + TESTCASE_DIR="$CUR_DIR/input/$TESTCASE" + fi + OUTPUT_DIR="$CUR_DIR/output_student/$TESTCASE" + OUTPUT_STD_DIR="$CUR_DIR/output_standard/$TESTCASE" + + # 计算有效文件数 + VALID_FILES=$(find "$TESTCASE_DIR" -maxdepth 1 -name '*.cminus' | wc -l) + echo "[info] Found $VALID_FILES valid files in $TESTCASE_DIR" + + run_tests "$TESTCASE_DIR" "$OUTPUT_DIR" "$OUTPUT_STD_DIR" $2 + CURRENT_SCORE=$? + + let TOTAL_SCORE+=CURRENT_SCORE + TOTAL_FILES=$(($TOTAL_FILES + $VALID_FILES)) + done + + # 输出总分 + echo "[info] Total score for all testcases: $TOTAL_SCORE/$TOTAL_FILES" + +else + # 单个测试集处理 + TESTCASE="$1" + if [[ $TESTCASE == "easy" || $TESTCASE == "normal" || $TESTCASE == "hard" ]]; then + TESTCASE_DIR="$CUR_DIR/input/$TESTCASE" + elif [[ $TESTCASE == "testcases_general" ]]; then + TESTCASE_DIR="$CUR_DIR/../$TESTCASE" + fi + + OUTPUT_DIR="$CUR_DIR/output_student/$TESTCASE" + OUTPUT_STD_DIR="$CUR_DIR/output_standard/$TESTCASE" + + # 运行单个测试集 + run_tests "$TESTCASE_DIR" "$OUTPUT_DIR" "$OUTPUT_STD_DIR" $2 +fi \ No newline at end of file diff --git a/tests/1-parser/eval_phase2.sh b/tests/1-parser/eval_phase2.sh new file mode 100755 index 0000000000000000000000000000000000000000..b9aa9c4ac2d9df857c16bc4bda93c55053aab52a --- /dev/null +++ b/tests/1-parser/eval_phase2.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# DO NOT MODIFY! +# If you need customized behavior, please create your own script. + +function run_tests() { + local TESTCASE_DIR=$1 + local OUTPUT_DIR=$2 + local OUTPUT_STD_DIR=$3 + local score=0 + local total=0 + + mkdir -p "$OUTPUT_DIR" + + # 对每个 .cminus 文件生成 ast 文件 + for testcase in "$TESTCASE_DIR"/*.cminus; do + filename="$(basename "$testcase")" + + # 检查文件名是否以 FAIL 开头,跳过该文件 + if [[ "$filename" == FAIL* ]]; then + echo "[info] Skipping $filename (starts with FAIL)" + continue + fi + + echo "[info] Analyzing $filename" + + # 生成学生的 AST 文件 + "$BUILD_DIR"/cminusfc "$testcase" > "$OUTPUT_DIR/${filename%.cminus}.ast" + + # 比较当前文件的输出与标准输出 + if [[ ${2:-no} != "no" ]]; then + echo "[info] Comparing $filename..." + + # 如果是详细模式 + if [[ ${2:-no} == "verbose" ]]; then + diff "$OUTPUT_DIR/${filename%.cminus}.ast" "$OUTPUT_STD_DIR/${filename%.cminus}.ast" + else + diff -q "$OUTPUT_DIR/${filename%.cminus}.ast" "$OUTPUT_STD_DIR/${filename%.cminus}.ast" + fi + + # 检查 diff 的返回值 + if [ $? -eq 0 ]; then + echo "[info] $filename is correct!" + let score=score+1 # 正确时得分+1 + else + echo "[info] $filename differs from the expected output." + fi + fi + + let total=total+1 # 总文件数+1 + + rm -f "$CUR_DIR/${filename%.cminus}" + done + + # 输出当前测试集的得分 + echo "[info] Score for $TESTCASE_DIR: $score/$total" + return $score +} + +# 检查命令行参数是否足够 +if [[ $# -lt 1 ]]; then + echo "usage: ./eval_phase2.sh []" + echo " can be one of 'easy', 'normal', 'hard', 'testcases_general', or '-all'." + echo " can be one of 'no', 'yes', and 'verbose'. the default value is 'no'" + exit 1 +fi + +CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +BUILD_DIR="$CUR_DIR/../../build" + +# 检查是否使用了 -all 选项 +if [[ $1 == "-all" ]]; then + TOTAL_SCORE=0 + TOTAL_FILES=0 + # 定义四个测试集 + TESTCASES=("easy" "normal" "hard" "testcases_general") + + for TESTCASE in "${TESTCASES[@]}"; do + if [[ $TESTCASE == "testcases_general" ]]; then + TESTCASE_DIR="$CUR_DIR/../$TESTCASE" + else + TESTCASE_DIR="$CUR_DIR/input/$TESTCASE" + fi + OUTPUT_DIR="$CUR_DIR/output_student_ast/$TESTCASE" + OUTPUT_STD_DIR="$CUR_DIR/output_standard_ast/$TESTCASE" + + # 计算有效文件数,跳过以 FAIL 开头的文件 + VALID_FILES=$(find "$TESTCASE_DIR" -maxdepth 1 -name '*.cminus' ! -name 'FAIL*' | wc -l) + echo "[info] Found $VALID_FILES valid files in $TESTCASE_DIR" + + # 运行测试集并跳过以 FAIL 开头的文件 + run_tests "$TESTCASE_DIR" "$OUTPUT_DIR" "$OUTPUT_STD_DIR" $2 + CURRENT_SCORE=$? + + let TOTAL_SCORE+=CURRENT_SCORE + TOTAL_FILES=$(($TOTAL_FILES + $VALID_FILES)) + done + + # 输出总分 + echo "[info] Total score for all testcases: $TOTAL_SCORE/$TOTAL_FILES" + +else + # 单个测试集处理 + TESTCASE="$1" + if [[ $TESTCASE == "easy" || $TESTCASE == "normal" || $TESTCASE == "hard" ]]; then + TESTCASE_DIR="$CUR_DIR/input/$TESTCASE" + elif [[ $TESTCASE == "testcases_general" ]]; then + TESTCASE_DIR="$CUR_DIR/../$TESTCASE" + fi + + OUTPUT_DIR="$CUR_DIR/output_student_ast/$TESTCASE" + OUTPUT_STD_DIR="$CUR_DIR/output_standard_ast/$TESTCASE" + + # 运行单个测试集 + run_tests "$TESTCASE_DIR" "$OUTPUT_DIR" "$OUTPUT_STD_DIR" $2 +fi \ No newline at end of file diff --git a/tests/1-parser/input/easy/FAIL_comment.cminus b/tests/1-parser/input/easy/FAIL_comment.cminus new file mode 100644 index 0000000000000000000000000000000000000000..e49690810a9e51db293ade92650d46e32e653a88 --- /dev/null +++ b/tests/1-parser/input/easy/FAIL_comment.cminus @@ -0,0 +1 @@ +/* unclosed comment \ No newline at end of file diff --git a/tests/1-parser/input/easy/FAIL_comment2.cminus b/tests/1-parser/input/easy/FAIL_comment2.cminus new file mode 100644 index 0000000000000000000000000000000000000000..a9af2297ed79a78b09ec0d991615a830304c914b --- /dev/null +++ b/tests/1-parser/input/easy/FAIL_comment2.cminus @@ -0,0 +1,5 @@ +// cminus dont support comment like that + +int main(void){ + return 0; +} \ No newline at end of file diff --git a/tests/1-parser/input/easy/FAIL_function.cminus b/tests/1-parser/input/easy/FAIL_function.cminus new file mode 100644 index 0000000000000000000000000000000000000000..869c521a29508f6c9511d2de3280af34020e215e --- /dev/null +++ b/tests/1-parser/input/easy/FAIL_function.cminus @@ -0,0 +1,3 @@ +/* unclosed function */ +int main(void) +{ \ No newline at end of file diff --git a/tests/1-parser/input/easy/FAIL_id.cminus b/tests/1-parser/input/easy/FAIL_id.cminus new file mode 100644 index 0000000000000000000000000000000000000000..b3d65089c0d1f9f5165dc548dfdf5bacdb690c20 --- /dev/null +++ b/tests/1-parser/input/easy/FAIL_id.cminus @@ -0,0 +1,3 @@ +int a1; +int f1(void) {} +int f2(void) {} diff --git a/tests/1-parser/input/easy/expr.cminus b/tests/1-parser/input/easy/expr.cminus new file mode 100644 index 0000000000000000000000000000000000000000..787f1ca60c1407318ceb4736a24b26589147f495 --- /dev/null +++ b/tests/1-parser/input/easy/expr.cminus @@ -0,0 +1,16 @@ +/*Basic num part*/ +int main(void){ + a = 0; + + x = 0.0; + x = 1.; + x = .1; + + a = 1+1; + a = a-1; + + x = x*1; + x = a/x; + + return 0; +} \ No newline at end of file diff --git a/tests/1-parser/input/easy/id.cminus b/tests/1-parser/input/easy/id.cminus new file mode 100644 index 0000000000000000000000000000000000000000..b6cf78b416cae7c848fc72b1676f0636ba5ae50a --- /dev/null +++ b/tests/1-parser/input/easy/id.cminus @@ -0,0 +1,3 @@ +int a; +int f(void) {} +int g(void) {} diff --git a/tests/1-parser/input/hard/You_Should_Pass.cminus b/tests/1-parser/input/hard/You_Should_Pass.cminus new file mode 100644 index 0000000000000000000000000000000000000000..33dd800c6404d2dce9236403dedda65e5f0675ab --- /dev/null +++ b/tests/1-parser/input/hard/You_Should_Pass.cminus @@ -0,0 +1,33 @@ +/* + I konw it's weird, even stupid, to code C like this. w(゚Д゚)w + HOWEVER, we have to use some tricky cases to test your answer. +*/ + +float GVAR; +void NeverEverDeclareLikeThis; +int GARRAY[2333]; + +void MyFuncA(int floatNum, float intNum, void voidNums[]){ + int IKnowYouAreVoid; + return MyFuncB(IKnowYouAreVoid); +} + +float MyFuncB(void){ + int IAmVoid[0]; + return MyFuncA(.0, 0, IAmVoid); +} + +int main(void){ + + int a; int b; int c; + + a = b = c = (85 == 84 + 0.4); + + if(a = b){ + GARRAY[ ( MyFuncB() ) ] = GARRAY[c = 1.*.1 == 1.1]; + }else if (MyFuncC(NotDeclared)){ + + }else; + + return 0.; +} \ No newline at end of file diff --git a/tests/1-parser/input/hard/assoc.cminus b/tests/1-parser/input/hard/assoc.cminus new file mode 100644 index 0000000000000000000000000000000000000000..527a92f48b9828f0ef0fd7e71825dddcc60a6c06 --- /dev/null +++ b/tests/1-parser/input/hard/assoc.cminus @@ -0,0 +1,5 @@ +/* associativity and precedence */ +int main(void) +{ + a = b = c = 1 + 1 / 2 * 1 * (1 + 1 + 1 - 1 / 1) + 3 + 4 * 3; +} diff --git a/tests/1-parser/input/hard/gcd.cminus b/tests/1-parser/input/hard/gcd.cminus new file mode 100644 index 0000000000000000000000000000000000000000..c8725006a83bc1680c470b21285f2eb82061cc24 --- /dev/null +++ b/tests/1-parser/input/hard/gcd.cminus @@ -0,0 +1,16 @@ +int gcd (int u, int v) { /* calculate the gcd of u and v */ + if (v == 0) return u; + else return gcd(v, u - u / v * v); /* v,u-u/v*v is equals to u mod v*/ +} +int main(void) { + int x; int y; int temp; + x = 72; + y = 18; + if (x 0) { + hanoi(getint(), 1, 2, 3); + putch(10); + n = n - 1; + } + return 0; +} diff --git a/tests/1-parser/input/hard/if.cminus b/tests/1-parser/input/hard/if.cminus new file mode 100644 index 0000000000000000000000000000000000000000..1eddf0af97731f7de7b5f8a2ca73082ba42a2c72 --- /dev/null +++ b/tests/1-parser/input/hard/if.cminus @@ -0,0 +1,6 @@ +/* else should be bound to the closest if */ +int main(void) +{ + if (1) {} else if (2) {} else {} + return 0; +} diff --git a/tests/1-parser/input/hard/selectionsort.cminus b/tests/1-parser/input/hard/selectionsort.cminus new file mode 100644 index 0000000000000000000000000000000000000000..07193433aabcc50ddf91caa187b15d7fb530cb2c --- /dev/null +++ b/tests/1-parser/input/hard/selectionsort.cminus @@ -0,0 +1,42 @@ +/* this is the sample program in C- in the book "Compiler Construction" */ +/* A program to perform selection sort on a 10 element array. */ +int x[10]; +int minloc ( int a[], int low, int high ) +{ int i; int x; int k; + k = low; + x = a[low]; + i = low + 1; + while (i < high) + { if (a[i] < x) + { x = a[i]; + k = i; } + i = i + 1; + } + return k; + } + + void sort( int a[], int low, int high) + { int i; int k; + i = low; + while ( i < high-1) + { int t; + k = minloc(a, i, high); + t = a[k]; + a[k] = a[i]; + a[i] = t; + i = i + 1; + } + } + + void main(void) + { int i; + i = 0; + while ( i < 10) + { x[i] = input(); + i = i + 1; } + sort(x, 0, 10); + i = 0; + while (i < 10) + { output(x[i]); + i = i + 1; } + } diff --git a/tests/1-parser/input/normal/FAIL_assign.cminus b/tests/1-parser/input/normal/FAIL_assign.cminus new file mode 100644 index 0000000000000000000000000000000000000000..605bfa0c3a52f62725e167c35da0bbbfd2ceeedb --- /dev/null +++ b/tests/1-parser/input/normal/FAIL_assign.cminus @@ -0,0 +1,5 @@ +int main(void) +{ + a=1; + 1=a; +} diff --git a/tests/1-parser/input/normal/FAIL_local-decl.cminus b/tests/1-parser/input/normal/FAIL_local-decl.cminus new file mode 100644 index 0000000000000000000000000000000000000000..bab7f08f6cedb1c09b170db4ab2707f2c6cbc3ff --- /dev/null +++ b/tests/1-parser/input/normal/FAIL_local-decl.cminus @@ -0,0 +1,6 @@ +int main(void){ + int a; + a = 1; + int b; + return 0; +} \ No newline at end of file diff --git a/tests/1-parser/input/normal/array.cminus b/tests/1-parser/input/normal/array.cminus new file mode 100644 index 0000000000000000000000000000000000000000..3d1cab55a2f83d8e436f01c829fb77773a510c96 --- /dev/null +++ b/tests/1-parser/input/normal/array.cminus @@ -0,0 +1,5 @@ +int main(void) { + int array[1]; + array[1] = 0; + return 0; +} diff --git a/tests/1-parser/input/normal/func.cminus b/tests/1-parser/input/normal/func.cminus new file mode 100644 index 0000000000000000000000000000000000000000..6907c2ba8ce43f388843f5d0e5e3a5497fbf55f8 --- /dev/null +++ b/tests/1-parser/input/normal/func.cminus @@ -0,0 +1,7 @@ +float foo(float a, float b[]) { + return 1; +} + +int main(void) { + return 0; +} diff --git a/tests/1-parser/input/normal/if.cminus b/tests/1-parser/input/normal/if.cminus new file mode 100644 index 0000000000000000000000000000000000000000..d892bd95da19d5ef197fc72337f758d361412afb --- /dev/null +++ b/tests/1-parser/input/normal/if.cminus @@ -0,0 +1,17 @@ +/*Basic selection part*/ + +int main(void){ + int a; int b; + + a = 1; + b = 1; + + if(a != b){ + if(a == b); + else{ + a = b; + } + } + + return 0; +} \ No newline at end of file diff --git a/tests/1-parser/input/normal/local-decl.cminus b/tests/1-parser/input/normal/local-decl.cminus new file mode 100644 index 0000000000000000000000000000000000000000..7ee059989e9c9d9047886ed16cf9f0460198c997 --- /dev/null +++ b/tests/1-parser/input/normal/local-decl.cminus @@ -0,0 +1,5 @@ +int main(void) { + int i; float j; + void v; + return 0; +} diff --git a/tests/1-parser/input/normal/skip_spaces.cminus b/tests/1-parser/input/normal/skip_spaces.cminus new file mode 100644 index 0000000000000000000000000000000000000000..5233dedabeb2d92ac7fd534ced1b774fa7f03d55 --- /dev/null +++ b/tests/1-parser/input/normal/skip_spaces.cminus @@ -0,0 +1,28 @@ +/* + +int main() { + int arr[100]; + int i; + int sum; + i = 0; + sum = 0; + while (getint()) { + arr[i] = getint(); + i = i + 1; + }*/ +int main(void) { + int arr[100]; + int i; + int sum; + i = 0; + sum = 0; + while (getint()) { + arr[i] = getint(); + i = i + 1; + } + while (i) { + i = i - 1; + sum = sum + arr[i]; + } + return sum - 79; +} diff --git a/tests/1-parser/output_standard/easy/FAIL_comment.syntax_tree b/tests/1-parser/output_standard/easy/FAIL_comment.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/easy/FAIL_comment2.syntax_tree b/tests/1-parser/output_standard/easy/FAIL_comment2.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/easy/FAIL_function.syntax_tree b/tests/1-parser/output_standard/easy/FAIL_function.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/easy/FAIL_id.syntax_tree b/tests/1-parser/output_standard/easy/FAIL_id.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/easy/expr.syntax_tree b/tests/1-parser/output_standard/easy/expr.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..9ebc41726ea78bfe8d3b74f24864d0d45aa61af3 --- /dev/null +++ b/tests/1-parser/output_standard/easy/expr.syntax_tree @@ -0,0 +1,176 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | >--* 0.0 +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | >--* 1. +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | >--* .1 +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* x +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* x +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | >--* / +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* x +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/easy/id.syntax_tree b/tests/1-parser/output_standard/easy/id.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..7ca2718ca2fc741099e448f23a42569bb0fdc396 --- /dev/null +++ b/tests/1-parser/output_standard/easy/id.syntax_tree @@ -0,0 +1,42 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration +| | | | | >--+ var-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* int +| | | | | | >--* a +| | | | | | >--* ; +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* f +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--* void +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* g +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--* epsilon +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/You_Should_Pass.syntax_tree b/tests/1-parser/output_standard/hard/You_Should_Pass.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..d3cc5dc34c61a6df3888b0765f9defef0e1e8bd0 --- /dev/null +++ b/tests/1-parser/output_standard/hard/You_Should_Pass.syntax_tree @@ -0,0 +1,369 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration-list +| | | | | >--+ declaration-list +| | | | | | >--+ declaration-list +| | | | | | | >--+ declaration +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* float +| | | | | | | | | >--* GVAR +| | | | | | | | | >--* ; +| | | | | | >--+ declaration +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* void +| | | | | | | | >--* NeverEverDeclareLikeThis +| | | | | | | | >--* ; +| | | | | >--+ declaration +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* GARRAY +| | | | | | | >--* [ +| | | | | | | >--* 2333 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | >--+ declaration +| | | | | >--+ fun-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* void +| | | | | | >--* MyFuncA +| | | | | | >--* ( +| | | | | | >--+ params +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param-list +| | | | | | | | | | >--+ param +| | | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | | >--* int +| | | | | | | | | | | >--* floatNum +| | | | | | | | | >--* , +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* float +| | | | | | | | | | >--* intNum +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* void +| | | | | | | | | >--* voidNums +| | | | | | | | | >--* [ +| | | | | | | | | >--* ] +| | | | | | >--* ) +| | | | | | >--+ compound-stmt +| | | | | | | >--* { +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* IKnowYouAreVoid +| | | | | | | | | >--* ; +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ return-stmt +| | | | | | | | | | >--* return +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* MyFuncB +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* IKnowYouAreVoid +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--* } +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* float +| | | | | >--* MyFuncB +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--* void +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* IAmVoid +| | | | | | | | >--* [ +| | | | | | | | >--* 0 +| | | | | | | | >--* ] +| | | | | | | | >--* ; +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | >--* MyFuncA +| | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | | | | >--* .0 +| | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* IAmVoid +| | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* a +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* b +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* c +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* a +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* b +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* c +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 85 +| | | | | | | | | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | | | | | | | | >--* == +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 84 +| | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | | | >--* 0.4 +| | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* b +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* GARRAY +| | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* MyFuncB +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* GARRAY +| | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* c +| | | | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1. +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* .1 +| | | | | | | | | | | | | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | | | | | | | | | | | | >--* == +| | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1.1 +| | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | | | | >--* else +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | >--* if +| | | | | | | | | | | >--* ( +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* MyFuncC +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | >--* NotDeclared +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | >--* ) +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--* } +| | | | | | | | | | | >--* else +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | >--* 0. +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/assoc.syntax_tree b/tests/1-parser/output_standard/hard/assoc.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..8420eb9dd0b0e9bfdc88568607ce4ff07fcf0f16 --- /dev/null +++ b/tests/1-parser/output_standard/hard/assoc.syntax_tree @@ -0,0 +1,120 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ expression-stmt +| | | | | | | | >--+ expression +| | | | | | | | | >--+ var +| | | | | | | | | | >--* a +| | | | | | | | | >--* = +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* b +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* c +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | >--* / +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | >--* / +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 4 +| | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/gcd.syntax_tree b/tests/1-parser/output_standard/hard/gcd.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..a2b03f931c5fae67ed03421920aedb9caafaf843 --- /dev/null +++ b/tests/1-parser/output_standard/hard/gcd.syntax_tree @@ -0,0 +1,291 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* gcd +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param-list +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* u +| | | | | | | >--* , +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* v +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* == +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | >--* return +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | >--* ; +| | | | | | | | | >--* else +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | >--* return +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* gcd +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | | | >--* / +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* x +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* y +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* temp +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 72 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* y +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 18 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ selection-stmt +| | | | | | | | | | >--* if +| | | | | | | | | | >--* ( +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | >--* < +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | >--* ) +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | >--* { +| | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* temp +| | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* temp +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--* } +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | >--* gcd +| | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/hanoi.syntax_tree b/tests/1-parser/output_standard/hard/hanoi.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..f91ceec470e0de068e96579c0753dd4eba8a267c --- /dev/null +++ b/tests/1-parser/output_standard/hard/hanoi.syntax_tree @@ -0,0 +1,558 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration +| | | | | >--+ fun-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* void +| | | | | | >--* move +| | | | | | >--* ( +| | | | | | >--+ params +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* x +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* y +| | | | | | >--* ) +| | | | | | >--+ compound-stmt +| | | | | | | >--* { +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | >--* putint +| | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | >--* putch +| | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 32 +| | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | >--* putint +| | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* putch +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 44 +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* putch +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 32 +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--* } +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* void +| | | | | >--* hanoi +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param-list +| | | | | | | | | | >--+ param +| | | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | | >--* int +| | | | | | | | | | | >--* n +| | | | | | | | | >--* , +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* one +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* two +| | | | | | | >--* , +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* three +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* == +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* move +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* one +| | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | >--* three +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | >--* ; +| | | | | | | | | >--* else +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | >--* hanoi +| | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* one +| | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* three +| | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* two +| | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | >--* move +| | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* one +| | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* three +| | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | >--* hanoi +| | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* two +| | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* one +| | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* three +| | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* n +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* n +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* getint +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* > +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | >--* hanoi +| | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* getint +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | >--* putch +| | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* n +| | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/if.syntax_tree b/tests/1-parser/output_standard/hard/if.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..78b818cbba1feca022de2ee601bd6ff83beb63c1 --- /dev/null +++ b/tests/1-parser/output_standard/hard/if.syntax_tree @@ -0,0 +1,81 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--* } +| | | | | | | | | >--* else +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | >--* if +| | | | | | | | | | | >--* ( +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | >--* ) +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--* } +| | | | | | | | | | | >--* else +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/hard/selectionsort.syntax_tree b/tests/1-parser/output_standard/hard/selectionsort.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..6eb1dcc64c61cc6ffa45903005fb4e80246a3f26 --- /dev/null +++ b/tests/1-parser/output_standard/hard/selectionsort.syntax_tree @@ -0,0 +1,765 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration-list +| | | | | >--+ declaration +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* x +| | | | | | | >--* [ +| | | | | | | >--* 10 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | >--+ declaration +| | | | | >--+ fun-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* int +| | | | | | >--* minloc +| | | | | | >--* ( +| | | | | | >--+ params +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param-list +| | | | | | | | | | >--+ param +| | | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | | >--* int +| | | | | | | | | | | >--* a +| | | | | | | | | | | >--* [ +| | | | | | | | | | | >--* ] +| | | | | | | | | >--* , +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* low +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* high +| | | | | | >--* ) +| | | | | | >--+ compound-stmt +| | | | | | | >--* { +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--+ local-declarations +| | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ var-declaration +| | | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | | >--* int +| | | | | | | | | | | >--* i +| | | | | | | | | | | >--* ; +| | | | | | | | | >--+ var-declaration +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* x +| | | | | | | | | | >--* ; +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* k +| | | | | | | | | >--* ; +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* low +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* low +| | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* low +| | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ iteration-stmt +| | | | | | | | | | | >--* while +| | | | | | | | | | | >--* ( +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | >--* < +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* high +| | | | | | | | | | | >--* ) +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | | | | | | | >--* if +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | | | | | | | >--* < +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | | | | | >--* } +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--* } +| | | | | | | | >--+ statement +| | | | | | | | | >--+ return-stmt +| | | | | | | | | | >--* return +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | >--* ; +| | | | | | | >--* } +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* void +| | | | | >--* sort +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* a +| | | | | | | | | | >--* [ +| | | | | | | | | | >--* ] +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* low +| | | | | | | >--* , +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* high +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* i +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* k +| | | | | | | | >--* ; +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* i +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* low +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* < +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* high +| | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | >--* - +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ var-declaration +| | | | | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | | | | >--* int +| | | | | | | | | | | | | >--* t +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | | >--* minloc +| | | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* high +| | | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* t +| | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* k +| | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* t +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* i +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ iteration-stmt +| | | | | | | | | | | >--* while +| | | | | | | | | | | >--* ( +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | >--* < +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | | >--* ) +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | >--* input +| | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--* } +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* sort +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* i +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ iteration-stmt +| | | | | | | | >--* while +| | | | | | | | >--* ( +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* i +| | | | | | | | | | >--+ relop +| | | | | | | | | | | >--* < +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 10 +| | | | | | | | >--* ) +| | | | | | | | >--+ statement +| | | | | | | | | >--+ compound-stmt +| | | | | | | | | | >--* { +| | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | >--* output +| | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | >--* } +| | | | | >--* } diff --git a/tests/1-parser/output_standard/normal/FAIL_assign.syntax_tree b/tests/1-parser/output_standard/normal/FAIL_assign.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/normal/FAIL_local-decl.syntax_tree b/tests/1-parser/output_standard/normal/FAIL_local-decl.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard/normal/array.syntax_tree b/tests/1-parser/output_standard/normal/array.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..d5b549b2c72bf910f81a4fc7b6a6da1efa50af81 --- /dev/null +++ b/tests/1-parser/output_standard/normal/array.syntax_tree @@ -0,0 +1,63 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* array +| | | | | | | >--* [ +| | | | | | | >--* 1 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* array +| | | | | | | | | | | >--* [ +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | >--* ] +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/normal/func.syntax_tree b/tests/1-parser/output_standard/normal/func.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..6464b70de3afa0c9c27e22ace2a23862a9d2b44a --- /dev/null +++ b/tests/1-parser/output_standard/normal/func.syntax_tree @@ -0,0 +1,71 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* float +| | | | | >--* foo +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param-list +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* float +| | | | | | | | | >--* a +| | | | | | | >--* , +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* float +| | | | | | | | >--* b +| | | | | | | | >--* [ +| | | | | | | | >--* ] +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/normal/if.syntax_tree b/tests/1-parser/output_standard/normal/if.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..d239b5cde83ffa94dc5a13eafcec2ef0f1176669 --- /dev/null +++ b/tests/1-parser/output_standard/normal/if.syntax_tree @@ -0,0 +1,147 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* b +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--* epsilon +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* b +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* != +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* b +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | | | | >--* if +| | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | | | | >--* == +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--* else +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | | >--* } +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/normal/local-decl.syntax_tree b/tests/1-parser/output_standard/normal/local-decl.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..de7614ac3d375ee1914f93adb84cb5a915842a87 --- /dev/null +++ b/tests/1-parser/output_standard/normal/local-decl.syntax_tree @@ -0,0 +1,48 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* i +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* float +| | | | | | | | >--* j +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* void +| | | | | | | >--* v +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 0 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/normal/skip_spaces.syntax_tree b/tests/1-parser/output_standard/normal/skip_spaces.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..781d45be1d026d23f72a0ae4eb531fb1e17bb254 --- /dev/null +++ b/tests/1-parser/output_standard/normal/skip_spaces.syntax_tree @@ -0,0 +1,237 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* arr +| | | | | | | | | >--* [ +| | | | | | | | | >--* 100 +| | | | | | | | | >--* ] +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* i +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* sum +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* sum +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ iteration-stmt +| | | | | | | | | | >--* while +| | | | | | | | | | >--* ( +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* getint +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ) +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | >--* { +| | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* arr +| | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | >--* getint +| | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--* } +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* sum +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* sum +| | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* arr +| | | | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* sum +| | | | | | | | | | | >--+ addop +| | | | | | | | | | | | >--* - +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | >--* 79 +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/1-return.syntax_tree b/tests/1-parser/output_standard/testcases_general/1-return.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..14f915622f73699628e9b5fd1ac808ccc78053a5 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/1-return.syntax_tree @@ -0,0 +1,23 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/10-funcall.syntax_tree b/tests/1-parser/output_standard/testcases_general/10-funcall.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..23c02ad407026b983df2c9a4efae9fdcb85ccd8c --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/10-funcall.syntax_tree @@ -0,0 +1,92 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* void +| | | | | >--* test +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* a +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | >--* test +| | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/11-funcall_chain.syntax_tree b/tests/1-parser/output_standard/testcases_general/11-funcall_chain.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..d2d487b833343b0671ddd11cfd8d068331dbed6b --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/11-funcall_chain.syntax_tree @@ -0,0 +1,135 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* addone +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | >--* + +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* result +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* result +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* addone +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | >--* addone +| | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* addone +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* addone +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1230 +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* result +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/12-funcall_recursion.syntax_tree b/tests/1-parser/output_standard/testcases_general/12-funcall_recursion.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..7face444a68485a9a6342ff2d46423832c630219 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/12-funcall_recursion.syntax_tree @@ -0,0 +1,150 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* factorial +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | >--+ relop +| | | | | | | | | | | | >--* == +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | >--* return +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | >--* ; +| | | | | | | | | >--* else +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | >--* return +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | >--* factorial +| | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* result +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* result +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* factorial +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* result +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/13-if_stmt.syntax_tree b/tests/1-parser/output_standard/testcases_general/13-if_stmt.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..15393ff9ce920c03db5de51b04ab9b076ebeda4b --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/13-if_stmt.syntax_tree @@ -0,0 +1,86 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--* epsilon +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ selection-stmt +| | | | | | | | | | >--* if +| | | | | | | | | | >--* ( +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | >--* ) +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 4 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/14-while_stmt.syntax_tree b/tests/1-parser/output_standard/testcases_general/14-while_stmt.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..cab56f7844222a381e4b070726ebf39c1d3b1d76 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/14-while_stmt.syntax_tree @@ -0,0 +1,87 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* i +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* i +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/15-if_while.syntax_tree b/tests/1-parser/output_standard/testcases_general/15-if_while.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..fbc2e5f4b190c50854169919db0d6df730039bf2 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/15-if_while.syntax_tree @@ -0,0 +1,215 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* i +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* b +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* b +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* i +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | | | | >--* if +| | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | | | | >--* < +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 5 +| | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--* else +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | | >--* } +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | >--+ addop +| | | | | | | | | | | | >--* + +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* b +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/16-if_chain.syntax_tree b/tests/1-parser/output_standard/testcases_general/16-if_chain.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e9d43269e892ea418a11cc7b2cab6bcedb40e43d --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/16-if_chain.syntax_tree @@ -0,0 +1,147 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* a +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* b +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* c +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* c +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* b +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ selection-stmt +| | | | | | | | | >--* if +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* b +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ selection-stmt +| | | | | | | | | | | >--* if +| | | | | | | | | | | >--* ( +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* c +| | | | | | | | | | | >--* ) +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 4 +| | | | | | | | | | | | | >--* ; +| | | | | | | | | | | >--* else +| | | | | | | | | | | >--+ statement +| | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/17-while_chain.syntax_tree b/tests/1-parser/output_standard/testcases_general/17-while_chain.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..05b930f8971a46af1feffaa795bcbc1359f9f2e1 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/17-while_chain.syntax_tree @@ -0,0 +1,165 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* i +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* j +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* i +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ iteration-stmt +| | | | | | | | | >--* while +| | | | | | | | | >--* ( +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | >--* ) +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | >--* { +| | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* j +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | >--+ iteration-stmt +| | | | | | | | | | | | | | >--* while +| | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | >--* j +| | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | | | | | >--* { +| | | | | | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | >--* j +| | | | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* j +| | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | | | >--* } +| | | | | | | | | | | >--* } +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* i +| | | | | | | | | | | >--+ addop +| | | | | | | | | | | | >--* + +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* j +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/18-global_var.syntax_tree b/tests/1-parser/output_standard/testcases_general/18-global_var.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..17be8b969492cf068acc320830b915f0ab2122cd --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/18-global_var.syntax_tree @@ -0,0 +1,52 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration +| | | | >--+ var-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* a +| | | | | >--* ; +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/19-global_local_var.syntax_tree b/tests/1-parser/output_standard/testcases_general/19-global_local_var.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..8fb61e8ae7f7965bfaafb26f1ab740ed798b9724 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/19-global_local_var.syntax_tree @@ -0,0 +1,110 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration +| | | | | >--+ var-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* int +| | | | | | >--* a +| | | | | | >--* ; +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* void +| | | | | >--* GlobalAssign +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--* void +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* a +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 10 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | >--* GlobalAssign +| | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 20 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/2-decl_int.syntax_tree b/tests/1-parser/output_standard/testcases_general/2-decl_int.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..e548f2ad6d02221028c7dbf139ba3f3dd38e851c --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/2-decl_int.syntax_tree @@ -0,0 +1,29 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/20-gcd_array.syntax_tree b/tests/1-parser/output_standard/testcases_general/20-gcd_array.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..915aaee3de3b976c942e7ede910e61a5c31a3667 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/20-gcd_array.syntax_tree @@ -0,0 +1,429 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration-list +| | | >--+ declaration-list +| | | | >--+ declaration-list +| | | | | >--+ declaration-list +| | | | | | >--+ declaration +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* x +| | | | | | | | >--* [ +| | | | | | | | >--* 1 +| | | | | | | | >--* ] +| | | | | | | | >--* ; +| | | | | >--+ declaration +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* y +| | | | | | | >--* [ +| | | | | | | >--* 1 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | >--+ declaration +| | | | | >--+ fun-declaration +| | | | | | >--+ type-specifier +| | | | | | | >--* int +| | | | | | >--* gcd +| | | | | | >--* ( +| | | | | | >--+ params +| | | | | | | >--+ param-list +| | | | | | | | >--+ param-list +| | | | | | | | | >--+ param +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* u +| | | | | | | | >--* , +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* v +| | | | | | >--* ) +| | | | | | >--+ compound-stmt +| | | | | | | >--* { +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ selection-stmt +| | | | | | | | | | >--* if +| | | | | | | | | | >--* ( +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | >--* == +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | >--* ) +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | | >--* return +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | >--* ; +| | | | | | | | | | >--* else +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ return-stmt +| | | | | | | | | | | | >--* return +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | | | | >--* gcd +| | | | | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | | | | | | | | | | | >--* - +| | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* / +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | | | | | | | >--+ mulop +| | | | | | | | | | | | | | | | | | | | | | | | | >--* * +| | | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | >--* ) +| | | | | | | | | | | | >--* ; +| | | | | | | >--* } +| | | >--+ declaration +| | | | >--+ fun-declaration +| | | | | >--+ type-specifier +| | | | | | >--* int +| | | | | >--* funArray +| | | | | >--* ( +| | | | | >--+ params +| | | | | | >--+ param-list +| | | | | | | >--+ param-list +| | | | | | | | >--+ param +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* u +| | | | | | | | | >--* [ +| | | | | | | | | >--* ] +| | | | | | | >--* , +| | | | | | | >--+ param +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* v +| | | | | | | | >--* [ +| | | | | | | | >--* ] +| | | | | >--* ) +| | | | | >--+ compound-stmt +| | | | | | >--* { +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--+ local-declarations +| | | | | | | | | >--+ local-declarations +| | | | | | | | | | >--* epsilon +| | | | | | | | | >--+ var-declaration +| | | | | | | | | | >--+ type-specifier +| | | | | | | | | | | >--* int +| | | | | | | | | | >--* a +| | | | | | | | | | >--* ; +| | | | | | | | >--+ var-declaration +| | | | | | | | | >--+ type-specifier +| | | | | | | | | | >--* int +| | | | | | | | | >--* b +| | | | | | | | | >--* ; +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* temp +| | | | | | | | >--* ; +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--+ statement-list +| | | | | | | | | | >--+ statement-list +| | | | | | | | | | | >--* epsilon +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* u +| | | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | | >--* ; +| | | | | | | | | >--+ statement +| | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | >--* b +| | | | | | | | | | | | >--* = +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* v +| | | | | | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | | | | | | | >--* ] +| | | | | | | | | | | >--* ; +| | | | | | | | >--+ statement +| | | | | | | | | >--+ selection-stmt +| | | | | | | | | | >--* if +| | | | | | | | | | >--* ( +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | >--* < +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | >--* ) +| | | | | | | | | | >--+ statement +| | | | | | | | | | | >--+ compound-stmt +| | | | | | | | | | | | >--* { +| | | | | | | | | | | | >--+ local-declarations +| | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | >--+ statement-list +| | | | | | | | | | | | | | | | >--* epsilon +| | | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | >--* temp +| | | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | | >--+ statement +| | | | | | | | | | | | | | >--+ expression-stmt +| | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | | >--* = +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* temp +| | | | | | | | | | | | | | | >--* ; +| | | | | | | | | | | | >--* } +| | | | | | | >--+ statement +| | | | | | | | >--+ return-stmt +| | | | | | | | | >--* return +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | | >--* gcd +| | | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* b +| | | | | | | | | | | | | | | >--* ) +| | | | | | | | | >--* ; +| | | | | | >--* } +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* x +| | | | | | | | | | | | >--* [ +| | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | | >--* ] +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 90 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* y +| | | | | | | | | | | >--* [ +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 0 +| | | | | | | | | | | >--* ] +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 18 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ call +| | | | | | | | | | | | | | >--* funArray +| | | | | | | | | | | | | | >--* ( +| | | | | | | | | | | | | | >--+ args +| | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | >--+ arg-list +| | | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | | >--* x +| | | | | | | | | | | | | | | | >--* , +| | | | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | | | | | | | | >--* y +| | | | | | | | | | | | | | >--* ) +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/21-comment.syntax_tree b/tests/1-parser/output_standard/testcases_general/21-comment.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..14f915622f73699628e9b5fd1ac808ccc78053a5 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/21-comment.syntax_tree @@ -0,0 +1,23 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--* epsilon +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/3-decl_float.syntax_tree b/tests/1-parser/output_standard/testcases_general/3-decl_float.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..d42a0199e3f3b6bbed377204e1e5f44644293ba9 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/3-decl_float.syntax_tree @@ -0,0 +1,29 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* float +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/4-decl_int_array.syntax_tree b/tests/1-parser/output_standard/testcases_general/4-decl_int_array.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..5c5ad5a44c693926d0eed10583f6cfb2ac801815 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/4-decl_int_array.syntax_tree @@ -0,0 +1,32 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* [ +| | | | | | | >--* 10 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/5-decl_float_array.syntax_tree b/tests/1-parser/output_standard/testcases_general/5-decl_float_array.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..eb3ce1abe4f0e603cc60a2a1209664364777ed3b --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/5-decl_float_array.syntax_tree @@ -0,0 +1,32 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* void +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* float +| | | | | | | >--* a +| | | | | | | >--* [ +| | | | | | | >--* 10 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--* epsilon +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/6-num_add_int.syntax_tree b/tests/1-parser/output_standard/testcases_general/6-num_add_int.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..0dc24fd70e9258de5db10b58a57e97602ccc4cc6 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/6-num_add_int.syntax_tree @@ -0,0 +1,58 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1000 +| | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 234 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/7-assign_int_var_local.syntax_tree b/tests/1-parser/output_standard/testcases_general/7-assign_int_var_local.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..276c6b7e21b6ace3f3d0add59e7f09a739490e1c --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/7-assign_int_var_local.syntax_tree @@ -0,0 +1,51 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 1234 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/8-assign_int_array_local.syntax_tree b/tests/1-parser/output_standard/testcases_general/8-assign_int_array_local.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..7e7acd88ef9b278cd4dfcd42fbb29c0e93060f28 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/8-assign_int_array_local.syntax_tree @@ -0,0 +1,72 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--* epsilon +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* a +| | | | | | | >--* [ +| | | | | | | >--* 10 +| | | | | | | >--* ] +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--* epsilon +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* a +| | | | | | | | | | | >--* [ +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | >--* ] +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | >--* 1234 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* a +| | | | | | | | | | | | | | >--* [ +| | | | | | | | | | | | | | >--+ expression +| | | | | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | | | | | >--* ] +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard/testcases_general/9-assign_cast.syntax_tree b/tests/1-parser/output_standard/testcases_general/9-assign_cast.syntax_tree new file mode 100644 index 0000000000000000000000000000000000000000..69fc176e92d27fe522dee156ccd4eb8b27321f64 --- /dev/null +++ b/tests/1-parser/output_standard/testcases_general/9-assign_cast.syntax_tree @@ -0,0 +1,93 @@ +>--+ program +| >--+ declaration-list +| | >--+ declaration +| | | >--+ fun-declaration +| | | | >--+ type-specifier +| | | | | >--* int +| | | | >--* main +| | | | >--* ( +| | | | >--+ params +| | | | | >--* void +| | | | >--* ) +| | | | >--+ compound-stmt +| | | | | >--* { +| | | | | >--+ local-declarations +| | | | | | >--+ local-declarations +| | | | | | | >--+ local-declarations +| | | | | | | | >--* epsilon +| | | | | | | >--+ var-declaration +| | | | | | | | >--+ type-specifier +| | | | | | | | | >--* int +| | | | | | | | >--* a +| | | | | | | | >--* ; +| | | | | | >--+ var-declaration +| | | | | | | >--+ type-specifier +| | | | | | | | >--* int +| | | | | | | >--* b +| | | | | | | >--* ; +| | | | | >--+ statement-list +| | | | | | >--+ statement-list +| | | | | | | >--+ statement-list +| | | | | | | | >--+ statement-list +| | | | | | | | | >--* epsilon +| | | | | | | | >--+ statement +| | | | | | | | | >--+ expression-stmt +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ var +| | | | | | | | | | | | >--* a +| | | | | | | | | | | >--* = +| | | | | | | | | | | >--+ expression +| | | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 1 +| | | | | | | | | | | | | >--+ relop +| | | | | | | | | | | | | | >--* < +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 3 +| | | | | | | | | | >--* ; +| | | | | | | >--+ statement +| | | | | | | | >--+ expression-stmt +| | | | | | | | | >--+ expression +| | | | | | | | | | >--+ var +| | | | | | | | | | | >--* b +| | | | | | | | | | >--* = +| | | | | | | | | | >--+ expression +| | | | | | | | | | | >--+ simple-expression +| | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | | >--+ integer +| | | | | | | | | | | | | | | | | >--* 2 +| | | | | | | | | | | | | >--+ addop +| | | | | | | | | | | | | | >--* + +| | | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | | >--+ float +| | | | | | | | | | | | | | | | >--* 2.4 +| | | | | | | | | >--* ; +| | | | | | >--+ statement +| | | | | | | >--+ return-stmt +| | | | | | | | >--* return +| | | | | | | | >--+ expression +| | | | | | | | | >--+ simple-expression +| | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | >--+ additive-expression +| | | | | | | | | | | | >--+ term +| | | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | | >--* a +| | | | | | | | | | | >--+ addop +| | | | | | | | | | | | >--* + +| | | | | | | | | | | >--+ term +| | | | | | | | | | | | >--+ factor +| | | | | | | | | | | | | >--+ var +| | | | | | | | | | | | | | >--* b +| | | | | | | | >--* ; +| | | | | >--* } diff --git a/tests/1-parser/output_standard_ast/easy/FAIL_comment.ast b/tests/1-parser/output_standard_ast/easy/FAIL_comment.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/easy/FAIL_comment2.ast b/tests/1-parser/output_standard_ast/easy/FAIL_comment2.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/easy/FAIL_function.ast b/tests/1-parser/output_standard_ast/easy/FAIL_function.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/easy/FAIL_id.ast b/tests/1-parser/output_standard_ast/easy/FAIL_id.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/easy/expr.ast b/tests/1-parser/output_standard_ast/easy/expr.ast new file mode 100644 index 0000000000000000000000000000000000000000..5cc69d98a67f320e017f6908b211f8b74b1f6497 --- /dev/null +++ b/tests/1-parser/output_standard_ast/easy/expr.ast @@ -0,0 +1,74 @@ +program +--fun-declaration: main +----compound-stmt +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term +----------------num (float): 0 +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term +----------------num (float): 1 +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term +----------------num (float): 0.1 +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression: + +--------------additive-expression +----------------term +------------------num (int): 1 +--------------term +----------------num (int): 1 +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression: - +--------------additive-expression +----------------term +------------------var: a +--------------term +----------------num (int): 1 +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term: * +----------------term +------------------var: x +----------------num (int): 1 +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term: / +----------------term +------------------var: a +----------------var: x +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/easy/id.ast b/tests/1-parser/output_standard_ast/easy/id.ast new file mode 100644 index 0000000000000000000000000000000000000000..b9073b212aaedca60da94f5a92dde4838d7420db --- /dev/null +++ b/tests/1-parser/output_standard_ast/easy/id.ast @@ -0,0 +1,6 @@ +program +--var-declaration: a +--fun-declaration: f +----compound-stmt +--fun-declaration: g +----compound-stmt diff --git a/tests/1-parser/output_standard_ast/hard/You_Should_Pass.ast b/tests/1-parser/output_standard_ast/hard/You_Should_Pass.ast new file mode 100644 index 0000000000000000000000000000000000000000..1c4f1889cc3f9c50c6e513a53d11a80575ad1f0b --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/You_Should_Pass.ast @@ -0,0 +1,115 @@ +program +--var-declaration: GVAR +--var-declaration: NeverEverDeclareLikeThis +--var-declaration: GARRAY[] +----num (int): 2333 +--fun-declaration: MyFuncA +----param: floatNum +----param: intNum +----param: voidNums[] +----compound-stmt +------var-declaration: IKnowYouAreVoid +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: MyFuncB() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: IKnowYouAreVoid +--fun-declaration: MyFuncB +----compound-stmt +------var-declaration: IAmVoid[] +--------num (int): 0 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: MyFuncA() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (float): 0 +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 0 +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: IAmVoid +--fun-declaration: main +----compound-stmt +------var-declaration: a +------var-declaration: b +------var-declaration: c +------expression-stmt +--------assign-expression +----------var: a +----------assign-expression +------------var: b +------------assign-expression +--------------var: c +--------------simple-expression +----------------additive-expression +------------------term +--------------------simple-expression: == +----------------------additive-expression +------------------------term +--------------------------num (int): 85 +----------------------additive-expression: + +------------------------additive-expression +--------------------------term +----------------------------num (int): 84 +------------------------term +--------------------------num (float): 0.4 +------selection-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------var: b +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: GARRAY[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------call: MyFuncB() +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: GARRAY[] +----------------------assign-expression +------------------------var: c +------------------------simple-expression: == +--------------------------additive-expression +----------------------------term: * +------------------------------term +--------------------------------num (float): 1 +------------------------------num (float): 0.1 +--------------------------additive-expression +----------------------------term +------------------------------num (float): 1.1 +--------selection-stmt +----------simple-expression +------------additive-expression +--------------term +----------------call: MyFuncC() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: NotDeclared +----------compound-stmt +----------expression-stmt +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (float): 0 diff --git a/tests/1-parser/output_standard_ast/hard/assoc.ast b/tests/1-parser/output_standard_ast/hard/assoc.ast new file mode 100644 index 0000000000000000000000000000000000000000..68b893e8f28bfb692e4f7127086fbe68508762f4 --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/assoc.ast @@ -0,0 +1,45 @@ +program +--fun-declaration: main +----compound-stmt +------expression-stmt +--------assign-expression +----------var: a +----------assign-expression +------------var: b +------------assign-expression +--------------var: c +--------------simple-expression +----------------additive-expression: + +------------------additive-expression: + +--------------------additive-expression: + +----------------------additive-expression +------------------------term +--------------------------num (int): 1 +----------------------term: * +------------------------term: * +--------------------------term: / +----------------------------term +------------------------------num (int): 1 +----------------------------num (int): 2 +--------------------------num (int): 1 +------------------------simple-expression +--------------------------additive-expression: - +----------------------------additive-expression: + +------------------------------additive-expression: + +--------------------------------additive-expression +----------------------------------term +------------------------------------num (int): 1 +--------------------------------term +----------------------------------num (int): 1 +------------------------------term +--------------------------------num (int): 1 +----------------------------term: / +------------------------------term +--------------------------------num (int): 1 +------------------------------num (int): 1 +--------------------term +----------------------num (int): 3 +------------------term: * +--------------------term +----------------------num (int): 4 +--------------------num (int): 3 diff --git a/tests/1-parser/output_standard_ast/hard/gcd.ast b/tests/1-parser/output_standard_ast/hard/gcd.ast new file mode 100644 index 0000000000000000000000000000000000000000..6bbf7063dfb02ee30c028966d43b7524b69df798 --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/gcd.ast @@ -0,0 +1,105 @@ +program +--fun-declaration: gcd +----param: u +----param: v +----compound-stmt +------selection-stmt +--------simple-expression: == +----------additive-expression +------------term +--------------var: v +----------additive-expression +------------term +--------------num (int): 0 +--------return-stmt +----------simple-expression +------------additive-expression +--------------term +----------------var: u +--------return-stmt +----------simple-expression +------------additive-expression +--------------term +----------------call: gcd() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: v +------------------simple-expression +--------------------additive-expression: - +----------------------additive-expression +------------------------term +--------------------------var: u +----------------------term: * +------------------------term: / +--------------------------term +----------------------------var: u +--------------------------var: v +------------------------var: v +--fun-declaration: main +----compound-stmt +------var-declaration: x +------var-declaration: y +------var-declaration: temp +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 72 +------expression-stmt +--------assign-expression +----------var: y +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 18 +------selection-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: x +----------additive-expression +------------term +--------------var: y +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: temp +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: x +----------expression-stmt +------------assign-expression +--------------var: x +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: y +----------expression-stmt +------------assign-expression +--------------var: y +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: temp +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: gcd() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: x +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: y +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/hard/hanoi.ast b/tests/1-parser/output_standard_ast/hard/hanoi.ast new file mode 100644 index 0000000000000000000000000000000000000000..2d2d9c9548b8effb17513c3ce9a220437b4743af --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/hanoi.ast @@ -0,0 +1,203 @@ +program +--fun-declaration: move +----param: x +----param: y +----compound-stmt +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: putint() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: x +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: putch() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 32 +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: putint() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: y +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: putch() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 44 +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: putch() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 32 +--fun-declaration: hanoi +----param: n +----param: one +----param: two +----param: three +----compound-stmt +------selection-stmt +--------simple-expression: == +----------additive-expression +------------term +--------------var: n +----------additive-expression +------------term +--------------num (int): 1 +--------expression-stmt +----------simple-expression +------------additive-expression +--------------term +----------------call: move() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: one +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: three +--------compound-stmt +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: hanoi() +--------------------simple-expression +----------------------additive-expression: - +------------------------additive-expression +--------------------------term +----------------------------var: n +------------------------term +--------------------------num (int): 1 +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: one +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: three +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: two +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: move() +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: one +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: three +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: hanoi() +--------------------simple-expression +----------------------additive-expression: - +------------------------additive-expression +--------------------------term +----------------------------var: n +------------------------term +--------------------------num (int): 1 +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: two +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: one +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: three +--fun-declaration: main +----compound-stmt +------var-declaration: n +------expression-stmt +--------assign-expression +----------var: n +----------simple-expression +------------additive-expression +--------------term +----------------call: getint() +------iteration-stmt +--------simple-expression: > +----------additive-expression +------------term +--------------var: n +----------additive-expression +------------term +--------------num (int): 0 +--------compound-stmt +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: hanoi() +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------call: getint() +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------num (int): 1 +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------num (int): 2 +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------num (int): 3 +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: putch() +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------num (int): 10 +----------expression-stmt +------------assign-expression +--------------var: n +--------------simple-expression +----------------additive-expression: - +------------------additive-expression +--------------------term +----------------------var: n +------------------term +--------------------num (int): 1 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/hard/if.ast b/tests/1-parser/output_standard_ast/hard/if.ast new file mode 100644 index 0000000000000000000000000000000000000000..8a9ca956630bd90d212e347a31bb34070959f97d --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/if.ast @@ -0,0 +1,21 @@ +program +--fun-declaration: main +----compound-stmt +------selection-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 1 +--------compound-stmt +--------selection-stmt +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 2 +----------compound-stmt +----------compound-stmt +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/hard/selectionsort.ast b/tests/1-parser/output_standard_ast/hard/selectionsort.ast new file mode 100644 index 0000000000000000000000000000000000000000..29e7d302c568f049dcbed85c0fa7c4137eab0855 --- /dev/null +++ b/tests/1-parser/output_standard_ast/hard/selectionsort.ast @@ -0,0 +1,283 @@ +program +--var-declaration: x[] +----num (int): 10 +--fun-declaration: minloc +----param: a[] +----param: low +----param: high +----compound-stmt +------var-declaration: i +------var-declaration: x +------var-declaration: k +------expression-stmt +--------assign-expression +----------var: k +----------simple-expression +------------additive-expression +--------------term +----------------var: low +------expression-stmt +--------assign-expression +----------var: x +----------simple-expression +------------additive-expression +--------------term +----------------var: a[] +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: low +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression: + +--------------additive-expression +----------------term +------------------var: low +--------------term +----------------num (int): 1 +------iteration-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: i +----------additive-expression +------------term +--------------var: high +--------compound-stmt +----------selection-stmt +------------simple-expression: < +--------------additive-expression +----------------term +------------------var: a[] +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: i +--------------additive-expression +----------------term +------------------var: x +------------compound-stmt +--------------expression-stmt +----------------assign-expression +------------------var: x +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: a[] +--------------------------simple-expression +----------------------------additive-expression +------------------------------term +--------------------------------var: i +--------------expression-stmt +----------------assign-expression +------------------var: k +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: i +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: k +--fun-declaration: sort +----param: a[] +----param: low +----param: high +----compound-stmt +------var-declaration: i +------var-declaration: k +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------var: low +------iteration-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: i +----------additive-expression: - +------------additive-expression +--------------term +----------------var: high +------------term +--------------num (int): 1 +--------compound-stmt +----------var-declaration: t +----------expression-stmt +------------assign-expression +--------------var: k +--------------simple-expression +----------------additive-expression +------------------term +--------------------call: minloc() +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: a +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: i +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: high +----------expression-stmt +------------assign-expression +--------------var: t +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: a[] +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: k +----------expression-stmt +------------assign-expression +--------------var: a[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: k +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: a[] +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: i +----------expression-stmt +------------assign-expression +--------------var: a[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: i +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: t +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +--fun-declaration: main +----compound-stmt +------var-declaration: i +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------iteration-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: i +----------additive-expression +------------term +--------------num (int): 10 +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: x[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: i +--------------simple-expression +----------------additive-expression +------------------term +--------------------call: input() +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: sort() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: x +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 0 +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 10 +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------iteration-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: i +----------additive-expression +------------term +--------------num (int): 10 +--------compound-stmt +----------expression-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------call: output() +--------------------simple-expression +----------------------additive-expression +------------------------term +--------------------------var: x[] +----------------------------simple-expression +------------------------------additive-expression +--------------------------------term +----------------------------------var: i +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 diff --git a/tests/1-parser/output_standard_ast/normal/FAIL_assign.ast b/tests/1-parser/output_standard_ast/normal/FAIL_assign.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/normal/FAIL_local-decl.ast b/tests/1-parser/output_standard_ast/normal/FAIL_local-decl.ast new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tests/1-parser/output_standard_ast/normal/array.ast b/tests/1-parser/output_standard_ast/normal/array.ast new file mode 100644 index 0000000000000000000000000000000000000000..e152d56a731e6eafe539760808968089518151ee --- /dev/null +++ b/tests/1-parser/output_standard_ast/normal/array.ast @@ -0,0 +1,21 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: array[] +--------num (int): 1 +------expression-stmt +--------assign-expression +----------var: array[] +------------simple-expression +--------------additive-expression +----------------term +------------------num (int): 1 +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/normal/func.ast b/tests/1-parser/output_standard_ast/normal/func.ast new file mode 100644 index 0000000000000000000000000000000000000000..366d183765c15838d8fc59c65170cb0b741e412d --- /dev/null +++ b/tests/1-parser/output_standard_ast/normal/func.ast @@ -0,0 +1,17 @@ +program +--fun-declaration: foo +----param: a +----param: b[] +----compound-stmt +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 1 +--fun-declaration: main +----compound-stmt +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/normal/if.ast b/tests/1-parser/output_standard_ast/normal/if.ast new file mode 100644 index 0000000000000000000000000000000000000000..f2a9c9e2bc72683bcbf250cf4a3b063d2df00349 --- /dev/null +++ b/tests/1-parser/output_standard_ast/normal/if.ast @@ -0,0 +1,50 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------var-declaration: b +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1 +------expression-stmt +--------assign-expression +----------var: b +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1 +------selection-stmt +--------simple-expression: != +----------additive-expression +------------term +--------------var: a +----------additive-expression +------------term +--------------var: b +--------compound-stmt +----------selection-stmt +------------simple-expression: == +--------------additive-expression +----------------term +------------------var: a +--------------additive-expression +----------------term +------------------var: b +------------expression-stmt +------------compound-stmt +--------------expression-stmt +----------------assign-expression +------------------var: a +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: b +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/normal/local-decl.ast b/tests/1-parser/output_standard_ast/normal/local-decl.ast new file mode 100644 index 0000000000000000000000000000000000000000..93f6efafbe0f20aabe708a7da12d664ee1a1e4fb --- /dev/null +++ b/tests/1-parser/output_standard_ast/normal/local-decl.ast @@ -0,0 +1,11 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: i +------var-declaration: j +------var-declaration: v +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------num (int): 0 diff --git a/tests/1-parser/output_standard_ast/normal/skip_spaces.ast b/tests/1-parser/output_standard_ast/normal/skip_spaces.ast new file mode 100644 index 0000000000000000000000000000000000000000..33fb1d659a04518cc534b88d1dba4be899fb08ab --- /dev/null +++ b/tests/1-parser/output_standard_ast/normal/skip_spaces.ast @@ -0,0 +1,86 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: arr[] +--------num (int): 100 +------var-declaration: i +------var-declaration: sum +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: sum +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------iteration-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: getint() +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: arr[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: i +--------------simple-expression +----------------additive-expression +------------------term +--------------------call: getint() +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +------iteration-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: i +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: - +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +----------expression-stmt +------------assign-expression +--------------var: sum +--------------simple-expression +----------------additive-expression: + +------------------additive-expression +--------------------term +----------------------var: sum +------------------term +--------------------var: arr[] +----------------------simple-expression +------------------------additive-expression +--------------------------term +----------------------------var: i +------return-stmt +--------simple-expression +----------additive-expression: - +------------additive-expression +--------------term +----------------var: sum +------------term +--------------num (int): 79 diff --git a/tests/1-parser/output_standard_ast/testcases_general/1-return.ast b/tests/1-parser/output_standard_ast/testcases_general/1-return.ast new file mode 100644 index 0000000000000000000000000000000000000000..6894f207adce03b88f66290d6b5ca15b2ec88e1c --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/1-return.ast @@ -0,0 +1,4 @@ +program +--fun-declaration: main +----compound-stmt +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/10-funcall.ast b/tests/1-parser/output_standard_ast/testcases_general/10-funcall.ast new file mode 100644 index 0000000000000000000000000000000000000000..12c7349ab8b6e24d37c3352fcc7fe96164a8dc69 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/10-funcall.ast @@ -0,0 +1,25 @@ +program +--fun-declaration: test +----param: a +----compound-stmt +------return-stmt: void +--fun-declaration: main +----compound-stmt +------var-declaration: a +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: test() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: a +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/11-funcall_chain.ast b/tests/1-parser/output_standard_ast/testcases_general/11-funcall_chain.ast new file mode 100644 index 0000000000000000000000000000000000000000..806d28a30c74e7a3bb1205b9d93b44d2e8b8f363 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/11-funcall_chain.ast @@ -0,0 +1,43 @@ +program +--fun-declaration: addone +----param: a +----compound-stmt +------return-stmt +--------simple-expression +----------additive-expression: + +------------additive-expression +--------------term +----------------var: a +------------term +--------------num (int): 1 +--fun-declaration: main +----compound-stmt +------var-declaration: result +------expression-stmt +--------assign-expression +----------var: result +----------simple-expression +------------additive-expression +--------------term +----------------call: addone() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------call: addone() +--------------------------simple-expression +----------------------------additive-expression +------------------------------term +--------------------------------call: addone() +----------------------------------simple-expression +------------------------------------additive-expression +--------------------------------------term +----------------------------------------call: addone() +------------------------------------------simple-expression +--------------------------------------------additive-expression +----------------------------------------------term +------------------------------------------------num (int): 1230 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: result diff --git a/tests/1-parser/output_standard_ast/testcases_general/12-funcall_recursion.ast b/tests/1-parser/output_standard_ast/testcases_general/12-funcall_recursion.ast new file mode 100644 index 0000000000000000000000000000000000000000..0c1199a92ca179ed4c68d6315d19e79c45a8288a --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/12-funcall_recursion.ast @@ -0,0 +1,50 @@ +program +--fun-declaration: factorial +----param: a +----compound-stmt +------selection-stmt +--------simple-expression: == +----------additive-expression +------------term +--------------var: a +----------additive-expression +------------term +--------------num (int): 0 +--------return-stmt +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1 +--------return-stmt +----------simple-expression +------------additive-expression +--------------term: * +----------------term +------------------var: a +----------------call: factorial() +------------------simple-expression +--------------------additive-expression: - +----------------------additive-expression +------------------------term +--------------------------var: a +----------------------term +------------------------num (int): 1 +--fun-declaration: main +----compound-stmt +------var-declaration: result +------expression-stmt +--------assign-expression +----------var: result +----------simple-expression +------------additive-expression +--------------term +----------------call: factorial() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------num (int): 10 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: result diff --git a/tests/1-parser/output_standard_ast/testcases_general/13-if_stmt.ast b/tests/1-parser/output_standard_ast/testcases_general/13-if_stmt.ast new file mode 100644 index 0000000000000000000000000000000000000000..9ccda4317ce30652fb41861304c6900807405678 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/13-if_stmt.ast @@ -0,0 +1,31 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 2 +------selection-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a +--------expression-stmt +----------assign-expression +------------var: a +------------simple-expression +--------------additive-expression +----------------term +------------------num (int): 3 +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 4 +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/14-while_stmt.ast b/tests/1-parser/output_standard_ast/testcases_general/14-while_stmt.ast new file mode 100644 index 0000000000000000000000000000000000000000..0b1c9389bf025a1cbe4145bc7d476b04aae9edf3 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/14-while_stmt.ast @@ -0,0 +1,28 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: i +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------iteration-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: i +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: - +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/15-if_while.ast b/tests/1-parser/output_standard_ast/testcases_general/15-if_while.ast new file mode 100644 index 0000000000000000000000000000000000000000..8a4ee2c85548d5d5bf175d62b46f5bc3c65ca5df --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/15-if_while.ast @@ -0,0 +1,80 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: i +------var-declaration: a +------var-declaration: b +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: b +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------iteration-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: i +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: - +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +----------selection-stmt +------------simple-expression: < +--------------additive-expression +----------------term +------------------var: i +--------------additive-expression +----------------term +------------------num (int): 5 +------------expression-stmt +--------------assign-expression +----------------var: a +----------------simple-expression +------------------additive-expression: + +--------------------additive-expression +----------------------term +------------------------var: a +--------------------term +----------------------var: i +------------compound-stmt +--------------expression-stmt +----------------assign-expression +------------------var: b +------------------simple-expression +--------------------additive-expression: + +----------------------additive-expression +------------------------term +--------------------------var: b +----------------------term +------------------------var: i +------return-stmt +--------simple-expression +----------additive-expression: + +------------additive-expression +--------------term +----------------var: a +------------term +--------------var: b diff --git a/tests/1-parser/output_standard_ast/testcases_general/16-if_chain.ast b/tests/1-parser/output_standard_ast/testcases_general/16-if_chain.ast new file mode 100644 index 0000000000000000000000000000000000000000..6185e1611218f84956f132b59d152a1706b9e810 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/16-if_chain.ast @@ -0,0 +1,56 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------var-declaration: b +------var-declaration: c +------expression-stmt +--------assign-expression +----------var: c +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 2 +------expression-stmt +--------assign-expression +----------var: b +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1 +------selection-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: b +--------selection-stmt +----------simple-expression +------------additive-expression +--------------term +----------------var: c +----------expression-stmt +------------assign-expression +--------------var: a +--------------simple-expression +----------------additive-expression +------------------term +--------------------num (int): 4 +----------expression-stmt +------------assign-expression +--------------var: a +--------------simple-expression +----------------additive-expression +------------------term +--------------------num (int): 3 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a diff --git a/tests/1-parser/output_standard_ast/testcases_general/17-while_chain.ast b/tests/1-parser/output_standard_ast/testcases_general/17-while_chain.ast new file mode 100644 index 0000000000000000000000000000000000000000..b979989663e0037507a42dcb933cf8e630539cf9 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/17-while_chain.ast @@ -0,0 +1,59 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: i +------var-declaration: j +------expression-stmt +--------assign-expression +----------var: i +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------iteration-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: i +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: i +--------------simple-expression +----------------additive-expression: - +------------------additive-expression +--------------------term +----------------------var: i +------------------term +--------------------num (int): 1 +----------expression-stmt +------------assign-expression +--------------var: j +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: i +----------iteration-stmt +------------simple-expression +--------------additive-expression +----------------term +------------------var: j +------------compound-stmt +--------------expression-stmt +----------------assign-expression +------------------var: j +------------------simple-expression +--------------------additive-expression: - +----------------------additive-expression +------------------------term +--------------------------var: j +----------------------term +------------------------num (int): 1 +------return-stmt +--------simple-expression +----------additive-expression: + +------------additive-expression +--------------term +----------------var: i +------------term +--------------var: j diff --git a/tests/1-parser/output_standard_ast/testcases_general/18-global_var.ast b/tests/1-parser/output_standard_ast/testcases_general/18-global_var.ast new file mode 100644 index 0000000000000000000000000000000000000000..143fd7ba38d33f78a0147b218f3d95ba68dc7cd5 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/18-global_var.ast @@ -0,0 +1,16 @@ +program +--var-declaration: a +--fun-declaration: main +----compound-stmt +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a diff --git a/tests/1-parser/output_standard_ast/testcases_general/19-global_local_var.ast b/tests/1-parser/output_standard_ast/testcases_general/19-global_local_var.ast new file mode 100644 index 0000000000000000000000000000000000000000..f785d13c60eb8b3c67f35eb58e87f5b84b9dce4f --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/19-global_local_var.ast @@ -0,0 +1,32 @@ +program +--var-declaration: a +--fun-declaration: GlobalAssign +----compound-stmt +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 10 +------return-stmt: void +--fun-declaration: main +----compound-stmt +------var-declaration: a +------expression-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: GlobalAssign() +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 20 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a diff --git a/tests/1-parser/output_standard_ast/testcases_general/2-decl_int.ast b/tests/1-parser/output_standard_ast/testcases_general/2-decl_int.ast new file mode 100644 index 0000000000000000000000000000000000000000..45376af73c72e7a5ac121ac41c490e2e587b7a66 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/2-decl_int.ast @@ -0,0 +1,5 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/20-gcd_array.ast b/tests/1-parser/output_standard_ast/testcases_general/20-gcd_array.ast new file mode 100644 index 0000000000000000000000000000000000000000..7ff2f9474d3c7c81d95bb2009749bd4853ccab65 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/20-gcd_array.ast @@ -0,0 +1,151 @@ +program +--var-declaration: x[] +----num (int): 1 +--var-declaration: y[] +----num (int): 1 +--fun-declaration: gcd +----param: u +----param: v +----compound-stmt +------selection-stmt +--------simple-expression: == +----------additive-expression +------------term +--------------var: v +----------additive-expression +------------term +--------------num (int): 0 +--------return-stmt +----------simple-expression +------------additive-expression +--------------term +----------------var: u +--------return-stmt +----------simple-expression +------------additive-expression +--------------term +----------------call: gcd() +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------var: v +------------------simple-expression +--------------------additive-expression: - +----------------------additive-expression +------------------------term +--------------------------var: u +----------------------term: * +------------------------term: / +--------------------------term +----------------------------var: u +--------------------------var: v +------------------------var: v +--fun-declaration: funArray +----param: u[] +----param: v[] +----compound-stmt +------var-declaration: a +------var-declaration: b +------var-declaration: temp +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------var: u[] +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------num (int): 0 +------expression-stmt +--------assign-expression +----------var: b +----------simple-expression +------------additive-expression +--------------term +----------------var: v[] +------------------simple-expression +--------------------additive-expression +----------------------term +------------------------num (int): 0 +------selection-stmt +--------simple-expression: < +----------additive-expression +------------term +--------------var: a +----------additive-expression +------------term +--------------var: b +--------compound-stmt +----------expression-stmt +------------assign-expression +--------------var: temp +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: a +----------expression-stmt +------------assign-expression +--------------var: a +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: b +----------expression-stmt +------------assign-expression +--------------var: b +--------------simple-expression +----------------additive-expression +------------------term +--------------------var: temp +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: gcd() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: a +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: b +--fun-declaration: main +----compound-stmt +------expression-stmt +--------assign-expression +----------var: x[] +------------simple-expression +--------------additive-expression +----------------term +------------------num (int): 0 +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 90 +------expression-stmt +--------assign-expression +----------var: y[] +------------simple-expression +--------------additive-expression +----------------term +------------------num (int): 0 +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 18 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------call: funArray() +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: x +----------------simple-expression +------------------additive-expression +--------------------term +----------------------var: y diff --git a/tests/1-parser/output_standard_ast/testcases_general/21-comment.ast b/tests/1-parser/output_standard_ast/testcases_general/21-comment.ast new file mode 100644 index 0000000000000000000000000000000000000000..6894f207adce03b88f66290d6b5ca15b2ec88e1c --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/21-comment.ast @@ -0,0 +1,4 @@ +program +--fun-declaration: main +----compound-stmt +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/3-decl_float.ast b/tests/1-parser/output_standard_ast/testcases_general/3-decl_float.ast new file mode 100644 index 0000000000000000000000000000000000000000..45376af73c72e7a5ac121ac41c490e2e587b7a66 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/3-decl_float.ast @@ -0,0 +1,5 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/4-decl_int_array.ast b/tests/1-parser/output_standard_ast/testcases_general/4-decl_int_array.ast new file mode 100644 index 0000000000000000000000000000000000000000..89a760365c0d88a7dc1306ef854ddb4abeb22238 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/4-decl_int_array.ast @@ -0,0 +1,6 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a[] +--------num (int): 10 +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/5-decl_float_array.ast b/tests/1-parser/output_standard_ast/testcases_general/5-decl_float_array.ast new file mode 100644 index 0000000000000000000000000000000000000000..89a760365c0d88a7dc1306ef854ddb4abeb22238 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/5-decl_float_array.ast @@ -0,0 +1,6 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a[] +--------num (int): 10 +------return-stmt: void diff --git a/tests/1-parser/output_standard_ast/testcases_general/6-num_add_int.ast b/tests/1-parser/output_standard_ast/testcases_general/6-num_add_int.ast new file mode 100644 index 0000000000000000000000000000000000000000..f00f69658a4ab9b87ee003ced0634e99903b69d7 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/6-num_add_int.ast @@ -0,0 +1,19 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression: + +--------------additive-expression +----------------term +------------------num (int): 1000 +--------------term +----------------num (int): 234 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a diff --git a/tests/1-parser/output_standard_ast/testcases_general/7-assign_int_var_local.ast b/tests/1-parser/output_standard_ast/testcases_general/7-assign_int_var_local.ast new file mode 100644 index 0000000000000000000000000000000000000000..5118d87f6060d8458b484e5132b5f860f24b6acd --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/7-assign_int_var_local.ast @@ -0,0 +1,16 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1234 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a diff --git a/tests/1-parser/output_standard_ast/testcases_general/8-assign_int_array_local.ast b/tests/1-parser/output_standard_ast/testcases_general/8-assign_int_array_local.ast new file mode 100644 index 0000000000000000000000000000000000000000..146e3fe17bc0acac6c0fe534cf4b451192a654b5 --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/8-assign_int_array_local.ast @@ -0,0 +1,25 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a[] +--------num (int): 10 +------expression-stmt +--------assign-expression +----------var: a[] +------------simple-expression +--------------additive-expression +----------------term +------------------num (int): 3 +----------simple-expression +------------additive-expression +--------------term +----------------num (int): 1234 +------return-stmt +--------simple-expression +----------additive-expression +------------term +--------------var: a[] +----------------simple-expression +------------------additive-expression +--------------------term +----------------------num (int): 3 diff --git a/tests/1-parser/output_standard_ast/testcases_general/9-assign_cast.ast b/tests/1-parser/output_standard_ast/testcases_general/9-assign_cast.ast new file mode 100644 index 0000000000000000000000000000000000000000..ae6285dad397db2cb20670527c1a65712d668ddb --- /dev/null +++ b/tests/1-parser/output_standard_ast/testcases_general/9-assign_cast.ast @@ -0,0 +1,33 @@ +program +--fun-declaration: main +----compound-stmt +------var-declaration: a +------var-declaration: b +------expression-stmt +--------assign-expression +----------var: a +----------simple-expression: < +------------additive-expression +--------------term +----------------num (int): 1 +------------additive-expression +--------------term +----------------num (int): 3 +------expression-stmt +--------assign-expression +----------var: b +----------simple-expression +------------additive-expression: + +--------------additive-expression +----------------term +------------------num (int): 2 +--------------term +----------------num (float): 2.4 +------return-stmt +--------simple-expression +----------additive-expression: + +------------additive-expression +--------------term +----------------var: a +------------term +--------------var: b diff --git a/tests/testcases_general/1-return.cminus b/tests/testcases_general/1-return.cminus new file mode 100644 index 0000000000000000000000000000000000000000..464e22a87038092c2d4e4aeb431643e36df98bb5 --- /dev/null +++ b/tests/testcases_general/1-return.cminus @@ -0,0 +1 @@ +void main(void) { return; } diff --git a/tests/testcases_general/1-return.out b/tests/testcases_general/1-return.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/1-return.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/10-funcall.cminus b/tests/testcases_general/10-funcall.cminus new file mode 100644 index 0000000000000000000000000000000000000000..858c51614ed2447f326713443c36fcbaf2d4504a --- /dev/null +++ b/tests/testcases_general/10-funcall.cminus @@ -0,0 +1,10 @@ +void test(int a) { + return; +} + +void main(void) { + int a; + a = 10; + test(a); + return; +} diff --git a/tests/testcases_general/10-funcall.out b/tests/testcases_general/10-funcall.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/10-funcall.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/11-funcall_chain.cminus b/tests/testcases_general/11-funcall_chain.cminus new file mode 100644 index 0000000000000000000000000000000000000000..be23aab8b8b1c17fc6895c381528bb5fd36b18f5 --- /dev/null +++ b/tests/testcases_general/11-funcall_chain.cminus @@ -0,0 +1,6 @@ +int addone(int a) { return a + 1; } +int main(void) { + int result; + result = addone(addone(addone(addone(1230)))); + return result; +} diff --git a/tests/testcases_general/11-funcall_chain.out b/tests/testcases_general/11-funcall_chain.out new file mode 100644 index 0000000000000000000000000000000000000000..cd7da05e3d264bd30a49a5f2c4c647a4ee0d3ec3 --- /dev/null +++ b/tests/testcases_general/11-funcall_chain.out @@ -0,0 +1 @@ +210 diff --git a/tests/testcases_general/12-funcall_recursion.cminus b/tests/testcases_general/12-funcall_recursion.cminus new file mode 100644 index 0000000000000000000000000000000000000000..3f7b7330b168d9ef5443f880d7e8ef613418b31d --- /dev/null +++ b/tests/testcases_general/12-funcall_recursion.cminus @@ -0,0 +1,11 @@ +int factorial(int a) { + if(a==0) + return 1; + else + return a*factorial(a-1); +} +int main(void) { + int result; + result = factorial(10); + return result; +} diff --git a/tests/testcases_general/12-funcall_recursion.out b/tests/testcases_general/12-funcall_recursion.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/12-funcall_recursion.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/13-if_stmt.cminus b/tests/testcases_general/13-if_stmt.cminus new file mode 100644 index 0000000000000000000000000000000000000000..bb4a607d3daf3bede48965c96f7da02b3534cc9b --- /dev/null +++ b/tests/testcases_general/13-if_stmt.cminus @@ -0,0 +1,8 @@ +void main(void) { + int a; + a = 2; + if (a) + a = 3; + a = 4; + return; +} diff --git a/tests/testcases_general/13-if_stmt.out b/tests/testcases_general/13-if_stmt.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/13-if_stmt.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/14-while_stmt.cminus b/tests/testcases_general/14-while_stmt.cminus new file mode 100644 index 0000000000000000000000000000000000000000..0fdd8115af00ee82607b2bfc6dc309e2e30b2bf4 --- /dev/null +++ b/tests/testcases_general/14-while_stmt.cminus @@ -0,0 +1,8 @@ +void main(void) { + int i; + i = 10; + while (i) { + i = i - 1; + } + return; +} diff --git a/tests/testcases_general/14-while_stmt.out b/tests/testcases_general/14-while_stmt.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/14-while_stmt.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/15-if_while.cminus b/tests/testcases_general/15-if_while.cminus new file mode 100644 index 0000000000000000000000000000000000000000..34dfc7a113021e3376f5a8722bc7661a93d3fc2e --- /dev/null +++ b/tests/testcases_general/15-if_while.cminus @@ -0,0 +1,17 @@ +int main(void) { + int i; + int a; + int b; + a = 0; + b = 0; + i = 10; + while (i) { + i = i - 1; + if (i < 5) + a = a + i; + else { + b = b + i; + } + } + return a + b; +} diff --git a/tests/testcases_general/15-if_while.out b/tests/testcases_general/15-if_while.out new file mode 100644 index 0000000000000000000000000000000000000000..ea90ee31980757b2e469741512bcb39e73494e78 --- /dev/null +++ b/tests/testcases_general/15-if_while.out @@ -0,0 +1 @@ +45 diff --git a/tests/testcases_general/16-if_chain.cminus b/tests/testcases_general/16-if_chain.cminus new file mode 100644 index 0000000000000000000000000000000000000000..a7c2358ddd4db99be6987478df30ab75c3ee5247 --- /dev/null +++ b/tests/testcases_general/16-if_chain.cminus @@ -0,0 +1,14 @@ +int main(void) { + int a; + int b; + int c; + c = 0; + a = 2; + b = 1; + if (b) + if (c) + a = 4; + else + a = 3; + return a; +} diff --git a/tests/testcases_general/16-if_chain.out b/tests/testcases_general/16-if_chain.out new file mode 100644 index 0000000000000000000000000000000000000000..00750edc07d6415dcc07ae0351e9397b0222b7ba --- /dev/null +++ b/tests/testcases_general/16-if_chain.out @@ -0,0 +1 @@ +3 diff --git a/tests/testcases_general/17-while_chain.cminus b/tests/testcases_general/17-while_chain.cminus new file mode 100644 index 0000000000000000000000000000000000000000..4eafefdf076269f55064abcff00400d003ba5871 --- /dev/null +++ b/tests/testcases_general/17-while_chain.cminus @@ -0,0 +1,13 @@ +int main(void) { + int i; + int j; + i = 10; + while (i) { + i = i - 1; + j = i; + while(j) { + j = j - 1; + } + } + return i + j; +} \ No newline at end of file diff --git a/tests/testcases_general/17-while_chain.out b/tests/testcases_general/17-while_chain.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/17-while_chain.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/18-global_var.cminus b/tests/testcases_general/18-global_var.cminus new file mode 100644 index 0000000000000000000000000000000000000000..cec0e56023ddaccdcba52e0158198c67f61353d6 --- /dev/null +++ b/tests/testcases_general/18-global_var.cminus @@ -0,0 +1,5 @@ +int a; +int main(void) { + a = 10; + return a; +} \ No newline at end of file diff --git a/tests/testcases_general/18-global_var.out b/tests/testcases_general/18-global_var.out new file mode 100644 index 0000000000000000000000000000000000000000..f599e28b8ab0d8c9c57a486c89c4a5132dcbd3b2 --- /dev/null +++ b/tests/testcases_general/18-global_var.out @@ -0,0 +1 @@ +10 diff --git a/tests/testcases_general/19-global_local_var.cminus b/tests/testcases_general/19-global_local_var.cminus new file mode 100644 index 0000000000000000000000000000000000000000..06221438c823f6da99dfcda649be72804dad37b1 --- /dev/null +++ b/tests/testcases_general/19-global_local_var.cminus @@ -0,0 +1,11 @@ +int a; +void GlobalAssign(void) { + a = 10; + return; +} +int main(void) { + int a; + GlobalAssign(); + a = 20; + return a; +} diff --git a/tests/testcases_general/19-global_local_var.out b/tests/testcases_general/19-global_local_var.out new file mode 100644 index 0000000000000000000000000000000000000000..209e3ef4b6247ce746048d5711befda46206d235 --- /dev/null +++ b/tests/testcases_general/19-global_local_var.out @@ -0,0 +1 @@ +20 diff --git a/tests/testcases_general/2-decl_int.cminus b/tests/testcases_general/2-decl_int.cminus new file mode 100644 index 0000000000000000000000000000000000000000..b4f1e348f4c38dff38af682a7d5be7dc7d53376f --- /dev/null +++ b/tests/testcases_general/2-decl_int.cminus @@ -0,0 +1,4 @@ +void main(void) { + int a; + return; +} diff --git a/tests/testcases_general/2-decl_int.out b/tests/testcases_general/2-decl_int.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/2-decl_int.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/20-gcd_array.cminus b/tests/testcases_general/20-gcd_array.cminus new file mode 100644 index 0000000000000000000000000000000000000000..033ccbaca9a9907714a8966b05f7923732ca2ab2 --- /dev/null +++ b/tests/testcases_general/20-gcd_array.cminus @@ -0,0 +1,29 @@ +int x[1]; +int y[1]; + +int gcd(int u, int v) { + if (v == 0) + return u; + else + return gcd(v, u - u / v * v); +} + +int funArray(int u[], int v[]) { + int a; + int b; + int temp; + a = u[0]; + b = v[0]; + if (a < b) { + temp = a; + a = b; + b = temp; + } + return gcd(a, b); +} + +int main(void) { + x[0] = 90; + y[0] = 18; + return funArray(x, y); +} \ No newline at end of file diff --git a/tests/testcases_general/20-gcd_array.out b/tests/testcases_general/20-gcd_array.out new file mode 100644 index 0000000000000000000000000000000000000000..3c032078a4a21c5c51d3c93d91717c1dabbb8cd0 --- /dev/null +++ b/tests/testcases_general/20-gcd_array.out @@ -0,0 +1 @@ +18 diff --git a/tests/testcases_general/21-comment.cminus b/tests/testcases_general/21-comment.cminus new file mode 100644 index 0000000000000000000000000000000000000000..63d6e026a1fadbbc7521909ab0191f5c82d2c744 --- /dev/null +++ b/tests/testcases_general/21-comment.cminus @@ -0,0 +1,2 @@ +/*this is comment*/ +void main(void) { return; } \ No newline at end of file diff --git a/tests/testcases_general/21-comment.out b/tests/testcases_general/21-comment.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/21-comment.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/3-decl_float.cminus b/tests/testcases_general/3-decl_float.cminus new file mode 100644 index 0000000000000000000000000000000000000000..61949dfbea293c310dddadffff473ba0d1eb53a7 --- /dev/null +++ b/tests/testcases_general/3-decl_float.cminus @@ -0,0 +1,4 @@ +void main(void) { + float a; + return; +} diff --git a/tests/testcases_general/3-decl_float.out b/tests/testcases_general/3-decl_float.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/3-decl_float.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/4-decl_int_array.cminus b/tests/testcases_general/4-decl_int_array.cminus new file mode 100644 index 0000000000000000000000000000000000000000..249926a0c8a34c4a37191343224bbe5909247950 --- /dev/null +++ b/tests/testcases_general/4-decl_int_array.cminus @@ -0,0 +1,4 @@ +void main(void) { + int a[10]; + return; +} diff --git a/tests/testcases_general/4-decl_int_array.out b/tests/testcases_general/4-decl_int_array.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/4-decl_int_array.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/5-decl_float_array.cminus b/tests/testcases_general/5-decl_float_array.cminus new file mode 100644 index 0000000000000000000000000000000000000000..bd2895274d14e525cd98797b54f69c8921f2e4ab --- /dev/null +++ b/tests/testcases_general/5-decl_float_array.cminus @@ -0,0 +1,4 @@ +void main(void) { + float a[10]; + return; +} diff --git a/tests/testcases_general/5-decl_float_array.out b/tests/testcases_general/5-decl_float_array.out new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/tests/testcases_general/5-decl_float_array.out @@ -0,0 +1 @@ +0 diff --git a/tests/testcases_general/6-num_add_int.cminus b/tests/testcases_general/6-num_add_int.cminus new file mode 100644 index 0000000000000000000000000000000000000000..f0495538f8d59acfcb09ef2a97a88a943e2b8bb0 --- /dev/null +++ b/tests/testcases_general/6-num_add_int.cminus @@ -0,0 +1,5 @@ +int main(void) { + int a; + a = 1000 + 234; + return a; +} diff --git a/tests/testcases_general/6-num_add_int.out b/tests/testcases_general/6-num_add_int.out new file mode 100644 index 0000000000000000000000000000000000000000..cd7da05e3d264bd30a49a5f2c4c647a4ee0d3ec3 --- /dev/null +++ b/tests/testcases_general/6-num_add_int.out @@ -0,0 +1 @@ +210 diff --git a/tests/testcases_general/7-assign_int_var_local.cminus b/tests/testcases_general/7-assign_int_var_local.cminus new file mode 100644 index 0000000000000000000000000000000000000000..907faddead433d02410164179bd5adb62ab1913a --- /dev/null +++ b/tests/testcases_general/7-assign_int_var_local.cminus @@ -0,0 +1,5 @@ +int main(void) { + int a; + a = 1234; + return a; +} diff --git a/tests/testcases_general/7-assign_int_var_local.out b/tests/testcases_general/7-assign_int_var_local.out new file mode 100644 index 0000000000000000000000000000000000000000..cd7da05e3d264bd30a49a5f2c4c647a4ee0d3ec3 --- /dev/null +++ b/tests/testcases_general/7-assign_int_var_local.out @@ -0,0 +1 @@ +210 diff --git a/tests/testcases_general/8-assign_int_array_local.cminus b/tests/testcases_general/8-assign_int_array_local.cminus new file mode 100644 index 0000000000000000000000000000000000000000..f8c64da3d0dbc25f046745d8e8463a63257cf35b --- /dev/null +++ b/tests/testcases_general/8-assign_int_array_local.cminus @@ -0,0 +1,5 @@ +int main(void) { + int a[10]; + a[3] = 1234; + return a[3]; +} diff --git a/tests/testcases_general/8-assign_int_array_local.out b/tests/testcases_general/8-assign_int_array_local.out new file mode 100644 index 0000000000000000000000000000000000000000..cd7da05e3d264bd30a49a5f2c4c647a4ee0d3ec3 --- /dev/null +++ b/tests/testcases_general/8-assign_int_array_local.out @@ -0,0 +1 @@ +210 diff --git a/tests/testcases_general/9-assign_cast.cminus b/tests/testcases_general/9-assign_cast.cminus new file mode 100644 index 0000000000000000000000000000000000000000..b463e3878360764c81f26ff68cd588c8e303f747 --- /dev/null +++ b/tests/testcases_general/9-assign_cast.cminus @@ -0,0 +1,7 @@ +int main(void) { + int a; + int b; + a = 1 < 3; + b = 2 + 2.4; + return a + b; +} diff --git a/tests/testcases_general/9-assign_cast.out b/tests/testcases_general/9-assign_cast.out new file mode 100644 index 0000000000000000000000000000000000000000..7ed6ff82de6bcc2a78243fc9c54d3ef5ac14da69 --- /dev/null +++ b/tests/testcases_general/9-assign_cast.out @@ -0,0 +1 @@ +5 diff --git a/tests/testcases_general/README.md b/tests/testcases_general/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4bd99bb4a5c93061838fc2948a0f1eae81902b1f --- /dev/null +++ b/tests/testcases_general/README.md @@ -0,0 +1,22 @@ +| case name | 语法特性 | +| ---- | ---- | +| 1-return.cminus | base case | +| 2-decl_int.cminus | int变量声明 | +| 3-decl_float.cminus | float变量声明 | +| 4-decl_int_array.cminus | int数组变量声明 | +| 5-decl_float_array.cminus | float数组变量声明 | +| 6-num_add_int.cminus | 加法运算 | +| 7-assign_int_var_local.cminus | 赋值语句 | +| 8-assign_int_array_local.cminus | 数组赋值语句 | +| 9-assign_cast.cminus | 类型转换情况 | +| 10-funcall.cminus | 函数调用 | +| 11-funcall_chain.cminus | 函数嵌套调用 | +| 12-funcall_recursion.cminus | 函数递归 | +| 13-if_stmt.cminus | if选择语句 | +| 14-while_stmt.cminus | while循环语句 | +| 15-if_while.cminus | if与while语句嵌套 | +| 16-if_recursion.cminus | if嵌套 | +| 17-while_recursion.cminus | while嵌套 | +| 18-global_var.cminus | 全局变量 | +| 19-global_local_var.cminus | 全局变量与局部变量重名 | +| 20-gcd_array.cminus | 稍微复杂一些的case | \ No newline at end of file