feat: add code style rules

This commit is contained in:
samsonium
2026-10-09 23:01:19 +03:00
parent 45206e3d07
commit 1d7cc88c22
11 changed files with 562 additions and 474 deletions
+1 -2
View File
@@ -6,5 +6,4 @@
// Print AST
void fzl_debug_print_ast(fzl_node_t *root);
#endif//FZL_DEBUG_H
#endif // FZL_DEBUG_H
+29 -25
View File
@@ -1,39 +1,44 @@
#ifndef FZL_PARSER_H
#define FZL_PARSER_H
#include <stddef.h>
#include <compiler/fzl_token.h>
#include <compiler/fzl_reader.h>
#include <compiler/fzl_token.h>
#include <stddef.h>
// AST node type
typedef enum {
FZL_NODETYPE_BLOCK,
FZL_NODETYPE_CALL,
FZL_NODETYPE_LITERAL,
typedef enum
{
FZL_NODETYPE_BLOCK,
FZL_NODETYPE_CALL,
FZL_NODETYPE_LITERAL,
} fzl_nodetype_t;
// AST node descriptor
typedef struct fzl_node {
fzl_nodetype_t type;
fzl_token_t *token;
struct fzl_node *parent;
struct fzl_node *next;
typedef struct fzl_node
{
fzl_nodetype_t type;
fzl_token_t *token;
struct fzl_node *parent;
struct fzl_node *next;
union {
struct {
struct fzl_node **entries;
size_t entry_count;
} list;
};
union
{
struct
{
struct fzl_node **entries;
size_t entry_count;
} list;
};
} fzl_node_t;
// Token sequence parser descriptor
typedef struct {
fzl_reader_ll_t *first;
size_t token_count;
typedef struct
{
fzl_reader_ll_t *first;
size_t token_count;
fzl_reader_ll_t *cursor;
fzl_node_t *root;
fzl_reader_ll_t *cursor;
fzl_node_t *root;
} fzl_parser_t;
// Allocate parser
@@ -49,10 +54,9 @@ int fzl_parse(fzl_parser_t *parser);
char *fzl_parser_geterror();
// Free node
void fzl_freenode(fzl_node_t* node);
void fzl_freenode(fzl_node_t *node);
// Free parser
void fzl_freeparser(fzl_parser_t *parser);
#endif//FZL_PARSER_H
#endif // FZL_PARSER_H
+15 -14
View File
@@ -1,25 +1,27 @@
#ifndef FZL_READER_H
#define FZL_READER_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <compiler/fzl_token.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Tokens linked list descriptor
typedef struct fzl_reader_ll {
fzl_token_t *token;
struct fzl_reader_ll *next;
typedef struct fzl_reader_ll
{
fzl_token_t *token;
struct fzl_reader_ll *next;
} fzl_reader_ll_t;
// Source reader description
typedef struct {
fzl_reader_ll_t *first;
fzl_reader_ll_t *last;
typedef struct
{
fzl_reader_ll_t *first;
fzl_reader_ll_t *last;
char *source;
size_t position;
bool at_end;
char *source;
size_t position;
bool at_end;
} fzl_reader_t;
// Allocate new reader
@@ -34,5 +36,4 @@ char *fzl_reader_geterror();
// Free reader
void fzl_freereader(fzl_reader_t *reader);
#endif//FZL_READER_H
#endif // FZL_READER_H
+20 -20
View File
@@ -1,36 +1,36 @@
#ifndef FZL_TOKEN_H
#define FZL_TOKEN_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
// Token type
typedef enum {
FZL_TOKTYPE_NAME,
FZL_TOKTYPE_LPAIR,
FZL_TOKTYPE_RPAIR,
FZL_TOKTYPE_COMMA,
FZL_TOKTYPE_STR_LITERAL
typedef enum
{
FZL_TOKTYPE_NAME,
FZL_TOKTYPE_LPAIR,
FZL_TOKTYPE_RPAIR,
FZL_TOKTYPE_COMMA,
FZL_TOKTYPE_STR_LITERAL
} fzl_toktype_t;
// Token descriptor
typedef struct {
fzl_toktype_t type;
uint16_t i0;
uint16_t i1;
bool store_value;
void *value;
uint16_t value_sz;
typedef struct
{
fzl_toktype_t type;
uint16_t i0;
uint16_t i1;
bool store_value;
void *value;
uint16_t value_sz;
} fzl_token_t;
// Allocate new token
fzl_token_t *fzl_mktoken(
const fzl_toktype_t type, uint16_t from, uint16_t to,
void *value, size_t value_sz);
fzl_token_t *fzl_mktoken(const fzl_toktype_t type, uint16_t from, uint16_t to,
void *value, size_t value_sz);
// Free token and its contents
void fzl_freetoken(fzl_token_t *token);
#endif//FZL_TOKEN_H
#endif // FZL_TOKEN_H