Skip to content

Commit

Permalink
added documentation to syntax rules
Browse files Browse the repository at this point in the history
  • Loading branch information
marekuzel committed Dec 6, 2023
1 parent 0acfd78 commit 4510c71
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
@@ -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] = {
Expand Down
116 changes: 114 additions & 2 deletions src/syntax_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit 4510c71

Please sign in to comment.