feat add func call and rewrite codes
This commit is contained in:
@@ -2,13 +2,17 @@
|
||||
#define __LEXER_H__
|
||||
|
||||
#include "token.h"
|
||||
#ifndef LEXER_MAX_TOKEN_SIZE
|
||||
#define LEXER_MAX_TOKEN_SIZE 63
|
||||
#endif
|
||||
#ifndef LEXER_BUFFER_SIZE
|
||||
#define LEXER_BUFFER_SIZE 4095
|
||||
#endif
|
||||
|
||||
typedef int (*lexer_sread_fn)(void *dst_buf, int dst_size,
|
||||
int elem_size, int count, void *stream);
|
||||
|
||||
struct Lexer {
|
||||
typedef struct lexer {
|
||||
int line;
|
||||
int index;
|
||||
// const char current_file_name[LEXER_BUFFER_SIZE+1];
|
||||
@@ -19,22 +23,15 @@ struct Lexer {
|
||||
|
||||
lexer_sread_fn sread;
|
||||
void* stream;
|
||||
};
|
||||
} lexer_t;
|
||||
|
||||
struct Token {
|
||||
enum TokenType type;
|
||||
struct TokenConstant constant;
|
||||
};
|
||||
|
||||
void init_lexer(struct Lexer* lexer, const char* file_name, void* stream,
|
||||
void init_lexer(lexer_t* lexer, const char* file_name, void* stream,
|
||||
lexer_sread_fn sread);
|
||||
|
||||
//
|
||||
void get_token(struct Lexer* lexer, struct Token* token);
|
||||
// pure token getter it will included empty token like TOKEN_FLUSH
|
||||
void get_token(lexer_t* lexer, tok_t* token);
|
||||
|
||||
// get_token maybe got invalid (with parser as TOKEN_FLUSH)
|
||||
void get_valid_token(struct Lexer* lexer, struct Token* token);
|
||||
|
||||
const char* get_token_name(enum TokenType token);
|
||||
void get_valid_token(lexer_t* lexer, tok_t* token);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user