From 4510c71e04ee2612a7392f7b0416f62d857c6506 Mon Sep 17 00:00:00 2001 From: marekuzel Date: Thu, 7 Dec 2023 00:18:38 +0100 Subject: [PATCH] added documentation to syntax rules --- src/scanner.c | 9 ++++ src/syntax_rules.h | 116 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 2 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 1fd4ed4..025df63 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1,3 +1,12 @@ +/** + * Project: Compliler IFJ23 implementation + * File: scanner.c + * + * @brief implementation of lexical analysis + * + * @author Markéte Belatková xbelat02 +*/ + #include "scanner.h" char keywords[NOF_KEYWORDS][MAX_DTT_KWD_LEN] = { diff --git a/src/syntax_rules.h b/src/syntax_rules.h index 3a79538..09778fc 100644 --- a/src/syntax_rules.h +++ b/src/syntax_rules.h @@ -22,44 +22,156 @@ Implementaion of syntax rules ***************************** */ +/** + * @brief rule to check if token is identifier + * @param[in] parser + * + * @return Error SYNTAX_ERROR if token is not identifier + */ Error parser_rule_id(Parser_t *); +/** + * @brief rule to check if token is identifier and function + * @param[in] parser + * + * @return Error SYNTAX_ERROR if token is not identifier and function in global scope + */ Error parser_rule_funcID(Parser_t *); +/** + * @brief rule to check syntax of a statement + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is incorrect + */ Error parser_rule_stmt(Parser_t *); +/** + * @brief rules to check syntax of value assignment to variable/constant + * @param[in] parser + * + * @return Error if syntax is incorrect + */ Error parser_rule_stmtAssign(Parser_t *); -Error parser_rule_elseF(Parser_t *); - +/** + * @brief rule to check syntax of function definition + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_defFunc(Parser_t *); +/** + * @brief rule to check syntax of function return block + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_funcRet(Parser_t *); +/** + * @brief rule to check syntax of function parameters in definition + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_paramsDef(Parser_t *); +/** + * @brief rule to recursively check syntax of function parameters in definition + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_paramsDefSeq(Parser_t *); +/** + * @brief rules to check syntax of else block + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_elseF(Parser_t *); +/** + * @brief rules to check type + * @param[in] parser + * + * @return Error SYNATX_ERROR if syntax is not correct + */ Error parser_rule_type(Parser_t *); +/** + * @brief recursive rule to check syntax of stmt ended with "} + * @param[in] parser" + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_stmtSeq(Parser_t *); +/** + * @brief recursive rule to check syntax of stmt ended with "}" and return token with expression + * @param[in] parser" + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_stmtSeqRet(Parser_t *); +/** + * @brief rule to check syntax of expression via bu_analysis + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_expr(Parser_t *); +/** + * @brief recursive rule to check syntax of stmt ended with "}" and return token + * @param[in] parser" + * + * @return Error + */ Error parser_rule_stmtVoidSeqRet(Parser_t *); +/** + * @brief rule to check syntax of function call + * @param[in] parser + * + * @return Error + */ Error parser_rule_callFunc(Parser_t *); +/** + * @brief rule to check syntax of function call parameter + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_paramsCall (Parser_t*); +/** + * @brief recursive rule to check syntax of function call parameter + * @param[in] parser + * + * @return Error + */ Error parser_rule_paramsCallSeq (Parser_t*); +/** + * @brief main rule to check syntax of program + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_stmtMainSeq (Parser_t *); +/** + * @brief rule to check syntax of function definition parameter name + * @param[in] parser + * + * @return Error SYNTAX_ERROR if syntax is not correct + */ Error parser_rule_name (Parser_t *); #define CHECK_TOKEN_TYPE(parser, expected_type) \