WONKY



LOG | FILES | OVERVIEW


#ifndef WONKY_LEX_PREPROCESSING_DIRECTIVE_H
#define WONKY_LEX_PREPROCESSING_DIRECTIVE_H WONKY_LEX_PREPROCESSING_DIRECTIVE_H
#include <lex_preprocessing_directive.hh> 

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

#include <automata.h>
#include <token.h>
#include <macro.h>
#include <lexer.h>

#include <source_file.h>


struct token* preprocessing_lex_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);

struct token* preprocessing_lex_include_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);

struct token* preprocessing_lex_if_directive(struct Lexer_Data *lexer_data,struct Source_Location *where,enum LEXER_TYPE if_type);
struct token* preprocessing_lex_elif_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
/*not chomping the ending #endif token is used for the #elif tokens*/
struct token* preprocessing_lex_iflike_directive_inner(struct Lexer_Data *lexer_data,struct Source_Location *where);
void preprocessing_lex_if_directive_control_statement(struct Lexer_Data *lexer_data,struct Queue *control_statement_tokens);
struct token* preprocessing_lex_ifdef_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_ifndef_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_ifdefndef_directive(struct Lexer_Data *lexer_data,struct Source_Location *where,enum LEXER_TYPE type);

void preprocessing_lex_finish_iflike_directive(struct Lexer_Data *lexer_data,struct Queue *if_true,struct Queue *if_false);

struct token* preprocessing_lex_define_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_normal_define_directive(struct Lexer_Data *lexer_data,struct Source_Location *where,struct identifier *id,struct token *first_replacement_token);
struct token* preprocessing_lex_functionlike_define_directive(struct Lexer_Data *lexer_data,struct Source_Location *where,struct identifier *id);

struct token* preprocessing_lex_undef_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);

struct token* preprocessing_lex_line_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_error_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_pragma_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_lex_defined_unary_operator(struct Lexer_Data *lexer_data,struct Source_Location *where);

struct token* preprocessing_lex_hastag_unary_operator(struct Lexer_Data *lexer_data,struct Source_Location *where,struct functionlike_define_directive *directive);
struct token* preprocessing_lex_hastag_hashtag_operator_in_functionlike_macro(struct Lexer_Data *lexer_data,struct Source_Location *where,struct functionlike_define_directive *directive,struct token *previous_token);

struct token* preprocessing_return_else_token(struct Lexer_Data *lexer_data,struct Source_Location *where);
struct token* preprocessing_return_endif_token(struct Lexer_Data *lexer_data,struct Source_Location *where);

void preprocessing_push_tokens_into_queue_until_eol(struct Lexer_Data *lexer_data,struct Queue *queue);

struct token* preprocessing_get_token_for_functionlike_macro_substitution_list(struct Lexer_Data *lexer_data,struct Source_Location *where,struct functionlike_define_directive *directive);
void preprocessing_push_functionlike_macro_substitution_tokens(struct Lexer_Data *lexer_data,struct Source_Location *where,struct functionlike_define_directive *directive);
void preprocessing_goto_end_of_line(struct Lexer_Data *lexer_data);

struct token* preprocessing_extract_next_token(struct Lexer_Data *lexer_data);
struct token* preprocessing_extract_next_directive(struct Lexer_Data *lexer_data);
struct token* preprocessing_extract_next_token_in_iflike_directive_control_statement(struct Lexer_Data *lexer_data);
struct token* preprocessing_extract_next_directive_in_iflike_statement_body(struct Lexer_Data *lexer_data);
struct token* preprocessing_extract_next_token_inner(struct Lexer_Data *lexer_data,_Bool extract_directive,_Bool extract_defined_statement);
_Bool preprocessing_get_and_check_token(struct Lexer_Data *lexer_data,enum LEXER_TYPE token_type);

struct Automata_Node* preprocessing_feed_automata_until_error(struct Lexer_Data *lexer_data);
struct Automata_Node* preprocessing_feed_automata_next_char(struct Lexer_Data *lexer_data,struct Automata_Node *node);

void preprocessing_skip_white_space(struct Lexer_Data *lexer_data);
void preprocessing_skip_white_space_inner(struct Program *program,char *src,size_t src_size,size_t *where_in_src,size_t *which_line,size_t *which_col);

_Bool preprocessing_eol(struct Lexer_Data *lexer_data);
struct token *preprocessing_make_token_finishing_on_node(struct Lexer_Data *lexer_data,struct Automata_Node *finishing_node,size_t start_position,_Bool create_directive,_Bool create_defined_statement);

void preprocessing_parse_functionlike_macro_id_list(struct Lexer_Data *lexer_data,struct token_functionlike_define_directive *directive);

_Bool preprocessing_has_hit_hashtag(struct Lexer_Data *lexer_data);

#endif