File tree Expand file tree Collapse file tree 8 files changed +32
-5
lines changed
Expand file tree Collapse file tree 8 files changed +32
-5
lines changed Original file line number Diff line number Diff line change 11#ifndef ERBX_AST_H
22#define ERBX_AST_H
33
4+ #include <stdlib.h>
5+
46#include "array.h"
57
68typedef struct AST_STRUCT {
@@ -26,4 +28,6 @@ typedef struct AST_STRUCT {
2628
2729AST_T * ast_init (int type );
2830
31+ size_t ast_sizeof (void );
32+
2933#endif
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ typedef struct BUFFER_STRUCT {
1010} buffer_T ;
1111
1212void buffer_init (buffer_T * buffer );
13+
1314void buffer_append (buffer_T * buffer , const char * text );
1415void buffer_prepend (buffer_T * buffer , const char * text );
1516void buffer_concat (buffer_T * destination , buffer_T * source );
Original file line number Diff line number Diff line change 22#define ERBX_LEXER_H
33
44#include "token.h"
5- #include <stdio .h>
5+ #include <stdlib .h>
66
77typedef struct LEXER_STRUCT {
88 char * source ;
@@ -44,4 +44,6 @@ token_T* lexer_parse_single_quoted_id(lexer_T* lexer);
4444token_T * lexer_parse_tag_name (lexer_T * lexer );
4545token_T * lexer_parse_whitespace (lexer_T * lexer );
4646
47+ size_t lexer_sizeof (void );
48+
4749#endif
Original file line number Diff line number Diff line change 11#ifndef ERBX_PARSER_H
22#define ERBX_PARSER_H
33
4+ #include <stdlib.h>
5+
46#include "lexer.h"
57#include "ast.h"
68
@@ -13,4 +15,6 @@ parser_T* parser_init(lexer_T* lexer);
1315token_T * parser_consume (parser_T * parser , int type );
1416AST_T * parser_parse (parser_T * parser );
1517
18+ size_t parser_sizeof (void );
19+
1620#endif
Original file line number Diff line number Diff line change 11#ifndef ERBX_TOKEN_H
22#define ERBX_TOKEN_H
33
4+ #include <stdlib.h>
5+
46typedef struct TOKEN_STRUCT {
57 char * value ;
68 enum {
@@ -29,4 +31,6 @@ token_T* token_init(char* value, int type);
2931char * token_to_string (token_T * token );
3032const char * token_type_to_string (int type );
3133
34+ size_t token_sizeof (void );
35+
3236#endif
Original file line number Diff line number Diff line change 22#include "include/macros.h"
33
44#include <string.h>
5- #include <stdlib .h>
5+ #include <stdio .h>
66#include <ctype.h>
77
8+ size_t lexer_sizeof (void ) {
9+ return sizeof (struct LEXER_STRUCT );
10+ }
11+
812lexer_T * lexer_init (char * source ) {
9- lexer_T * lexer = calloc (1 , sizeof ( struct LEXER_STRUCT ));
13+ lexer_T * lexer = calloc (1 , lexer_sizeof ( ));
1014
1115 lexer -> state = STATE_NONE ;
1216 lexer -> source = source ;
Original file line number Diff line number Diff line change 55#include <stdlib.h>
66#include <string.h>
77
8+ size_t parser_sizeof (void ) {
9+ return sizeof (struct PARSER_STRUCT );
10+ }
11+
812parser_T * parser_init (lexer_T * lexer ) {
9- parser_T * parser = calloc (1 , sizeof ( struct PARSER_STRUCT ));
13+ parser_T * parser = calloc (1 , parser_sizeof ( ));
1014 parser -> lexer = lexer ;
1115 parser -> token = lexer_next_token (lexer );
1216
Original file line number Diff line number Diff line change 44#include <string.h>
55#include <stdio.h>
66
7+ size_t token_sizeof (void ) {
8+ return sizeof (struct TOKEN_STRUCT );
9+ }
10+
711token_T * token_init (char * value , int type ) {
8- token_T * token = calloc (1 , sizeof ( struct TOKEN_STRUCT ));
12+ token_T * token = calloc (1 , token_sizeof ( ));
913 token -> value = value ;
1014 token -> type = type ;
1115
You can’t perform that action at this time.
0 commit comments