WONKY



LOG | FILES | OVERVIEW


#ifndef LEXER_H
#define LEXER_H LEXER_H
#include <lexer.hh>

#include <queue.h>
#include <program.h>
#include <common.h>
#include <wonky_malloc.h>
#include <source_file.h>

#include <automata.h>
#include <id_node.h>
#include <token.h>

#include <translation_unit.h>
#include <lex_preprocessing_directive.h> 

#include <gcc_error.h>

struct Lexer_Data
{
			
	size_t where_in_src;
	size_t which_column;
	size_t which_row;

	_Bool is_in_the_begining_of_line;
	_Bool is_in_if_directive_body; /*hack*/

	enum Automata_View automata_view;

	struct Source_File *src;
	struct Program *program;

	struct Source_Location *previous_token_location;

	struct token *buffer_token;

};





struct Preprocessing_Translation_Unit* lex(struct Source_File *src,struct Program *program);
struct Preprocessing_Translation_Unit* lex_inner(struct Lexer_Data *lexer_data);
struct Lexer_Data* get_lexer_data(struct Source_File *src,struct Program *program);

struct token* lex_token_from_string(char *str,size_t string_length);

void lexer_skip_white_space(struct Lexer_Data *lexer_data);
_Bool lexer_eof(struct Lexer_Data *lexer_data);

struct token* lexer_extract_next_token(struct Lexer_Data *lexer_data);
struct token* lexer_extract_next_token_for_elif_directive_body(struct Lexer_Data *lexer_data);
struct token* lexer_extract_next_token_inner(struct Lexer_Data *lexer_data);

struct Automata_Node* lexer_feed_automata_until_error(struct Lexer_Data *lexer_data);

struct Automata_Node *lexer_feed_automata_next_char(struct Lexer_Data *lexer_data,struct Automata_Node *node);

struct token *lexer_make_token_finishing_on_node(struct Lexer_Data *lexer_data,struct Automata_Node *finishing_node,size_t start_position);


struct token *lex_defined_unary_operator(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token *lex_preprocessing_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
_Bool lexer_get_and_check(struct Lexer_Data *lexer_data,enum LEXER_TYPE token_type);
_Bool lexer_check(struct Lexer_Data *lexer_data,enum LEXER_TYPE token_type);

enum Source_Chars lexer_get_ch_accounting_for_linesplices(struct Program *program,const char *src,size_t src_size,size_t *where_in_src,size_t *which_line,size_t *which_column);
enum Source_Chars lexer_get_ch_accounting_for_linesplices_and_comments(struct Program *program,const char *src,size_t src_size,size_t *where_in_src,size_t *which_line,size_t *which_column);


void delete_lexer_data(struct Lexer_Data *lexer_data);

#endif