F diff --git a/src/frontend/lex/lex_preprocessing_directive.c b/src/frontend/lex/lex_preprocessing_directive.c
--- a/src/frontend/lex/lex_preprocessing_directive.c
+++ b/src/frontend/lex/lex_preprocessing_directive.c
struct token* preprocessing_lex_directive(struct Lexer_Data *lexer_data,struct Source_Location *where)
{
- return get_error_token("PREPROCESSING DIRECTIVES NOT DONE",where,lexer_data->program);
+ return preprocessing_extract_next_token(lexer_data);
}
struct token* preprocessing_lex_defined_unary_operator(struct Lexer_Data *lexer_data,struct Source_Location *where)
{
return get_error_token("PREPROCESSING DIRECTIVES NOT DONE",where,lexer_data->program);
}
+ struct token* preprocessing_extract_next_token(struct Lexer_Data *lexer_data)
+ {
+
+ struct token *ret;
+ struct Automata_Node *hold_node;
+ size_t where_does_the_token_start_in_the_source_file;
+
+ do{
+
+
+ preprocessing_skip_white_space(lexer_data);
+ where_does_the_token_start_in_the_source_file=lexer_data->where_in_src;
+
+ hold_node=preprocessing_feed_automata_until_error(lexer_data);
+
+ if(preprocessing_eol(lexer_data))
+ return NULL;
+
+ if(hold_node==NULL)
+ return get_error_token("Unrecognised lexical element",get_source_location(
+ lexer_data->which_column,
+ lexer_data->which_row,
+ lexer_data->where_in_src,
+ lexer_data->src->src_name
+ ),
+ lexer_data->program);
+ }while(hold_node->keyword==KW_COMMENT);
+
+ ret=preprocessing_make_token_finishing_on_node(lexer_data, hold_node, where_does_the_token_start_in_the_source_file);
+ lexer_data->is_in_the_begining_of_line=0;
+ return ret;
+ }
+ struct Automata_Node* preprocessing_feed_automata_until_error(struct Lexer_Data *lexer_data)
+ {
+ struct Automata_Node *head;
+ struct Automata_Node *follower;
+
+ head=&chonky[0];
+ follower=NULL;
+
+ while(head!=NULL)
+ {
+ follower=head;
+ head=preprocessing_feed_automata_next_char(lexer_data,head);
+ }
+
+ return follower;
+ }
+ struct Automata_Node *preprocessing_feed_automata_next_char(struct Lexer_Data *lexer_data,struct Automata_Node *node)
+ {
+ enum {
+ UNKNOWN_CHAR,
+ START_OF_POSSIBLE_LINE_SPLICE,
+ KNOWN_CHAR
+ } state;
+ size_t hold_where_in_src;
+ size_t hold_which_column;
+ size_t hold_which_row;
+ struct Automata_Node *ret;
+ enum Source_Chars ch;
+
+ state=UNKNOWN_CHAR;
+ hold_where_in_src=lexer_data->where_in_src;
+ hold_which_column=lexer_data->which_column;
+ hold_which_row=lexer_data->which_row;
+
+
+ do{
+
+ if(lexer_eof(lexer_data))
+ return NULL;
+
+ switch(state)
+ {
+ case UNKNOWN_CHAR:
+ if(lexer_data->src->src[lexer_data->where_in_src] == '\\')
+ {
+ state=START_OF_POSSIBLE_LINE_SPLICE;
+ ++lexer_data->where_in_src;
+ ++lexer_data->which_column;
+ }else
+ {
+ state=KNOWN_CHAR;
+ }
+ break;
+ case START_OF_POSSIBLE_LINE_SPLICE:
+ if(lexer_data->src->src[lexer_data->where_in_src] == '\n')
+ {
+ state=UNKNOWN_CHAR;
+ ++lexer_data->where_in_src;
+ lexer_data->which_column=0;
+ ++lexer_data->which_row;
+ }else
+ {
+ state=KNOWN_CHAR;
+ }
+ break;
+ default:
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
+
+ }while(state!=KNOWN_CHAR);
+
+
+ ch=get_ch(& lexer_data->src->src[lexer_data->where_in_src],1);
+
+ if(ch==CHAR_VERTICAL_TAB)
+ return NULL;
+
+ if(node->delta[ch]==id_node)
+ {
+ ret=get_new_id_node(node,ch);
+ }else
+ {
+ ret=node->delta[ch];
+ }
+ if(ret==NULL)
+ {
+ lexer_data->where_in_src=hold_where_in_src;
+ lexer_data->which_column=hold_which_column;
+ lexer_data->which_row=hold_which_row;
+
+ return NULL;
+ }else
+ {
+ ++lexer_data->which_column;
+ ++lexer_data->where_in_src;
+ return ret;
+ }
+ }
+ void preprocessing_skip_white_space(struct Lexer_Data *lexer_data)
+ {
+ enum White_Space_States
+ {
+ BLANK_SPACE,
+ POSSIBLE_LINE_SPLICE,
+ NON_WHITE_SPACE
+ }state=BLANK_SPACE;
+
+ while(state!=NON_WHITE_SPACE && !preprocessing_eol(lexer_data))
+ {
+ switch(lexer_data->src->src[lexer_data->where_in_src])
+ {
+ case '\n':
+ if(state==POSSIBLE_LINE_SPLICE)
+ {
+ state=BLANK_SPACE;
+ ++lexer_data->where_in_src;
+ ++lexer_data->which_row;
+ lexer_data->which_column=0;
+ }else
+ {
+ return;
+ }
+ break;
+ case ' ':
+ case '\t':
+ case '\v':
+ if(state==POSSIBLE_LINE_SPLICE)
+ state=NON_WHITE_SPACE;
+ else
+ {
+ ++lexer_data->where_in_src;
+ ++lexer_data->which_column;
+ }
+
+ break;
+ case '\\':
+ if(state==POSSIBLE_LINE_SPLICE)
+ {
+ state=NON_WHITE_SPACE;
+ }else
+ {
+ ++lexer_data->where_in_src;
+ ++lexer_data->which_column;
+ state=POSSIBLE_LINE_SPLICE;
+ }
+ break;
+ default:
+ state=NON_WHITE_SPACE;
+ }
+ }
+ }
+ _Bool preprocessing_eol(struct Lexer_Data *lexer_data)
+ {
+ return lexer_data->src->src[lexer_data->where_in_src]=='\n' || lexer_eof(lexer_data);
+ }
+ struct token *preprocessing_make_token_finishing_on_node(struct Lexer_Data *lexer_data,struct Automata_Node *finishing_node,size_t start_position)
+ {
+ struct Source_Location *token_location;
+
+ wonky_assert(lexer_data->where_in_src > start_position);
+ wonky_assert(is_valid_automata_node(finishing_node));
+
+ token_location=get_source_location(
+ lexer_data->which_row,
+ lexer_data->which_column,
+ lexer_data->where_in_src,
+ lexer_data->src->src_name
+ );
+
+ switch(finishing_node->preprocessing_keyword)
+ {
+ case PKW_IF:
+ return get_error_token("PREPROCESSING IF NOT DONE",token_location,lexer_data->program);
+ case PKW_IFDEF:
+ return get_error_token("PREPROCESSING IFDEF NOT DONE",token_location,lexer_data->program);
+ case PKW_IFNDEF:
+ return get_error_token("PREPROCESSING IFNDEF NOT DONE",token_location,lexer_data->program);
+ case PKW_ELIF:
+ return get_error_token("PREPROCESSING ELIF NOT DONE",token_location,lexer_data->program);
+ case PKW_ELSE:
+ return get_error_token("PREPROCESSING ELSE NOT DONE",token_location,lexer_data->program);
+ case PKW_ENDIF:
+ return get_error_token("PREPROCESSING ENDIF NOT DONE",token_location,lexer_data->program);
+ case PKW_INCLUDE:
+ return get_error_token("PREPROCESSING INCLUDE NOT DONE",token_location,lexer_data->program);
+ case PKW_DEFINE:
+ return get_error_token("PREPROCESSING DEFINE NOT DONE",token_location,lexer_data->program);
+ case PKW_UNDEF:
+ return get_error_token("PREPROCESSING UNDEF NOT DONE",token_location,lexer_data->program);
+ case PKW_LINE:
+ return get_error_token("PREPROCESSING LINE NOT DONE",token_location,lexer_data->program);
+ case PKW_ERROR:
+ return get_error_token("PREPROCESSING ERROR NOT DONE",token_location,lexer_data->program);
+ case PKW_PRAGMA:
+ return get_error_token("PREPROCESSING PRAGMA NOT DONE",token_location,lexer_data->program);
+ case PKW_DEFINED:
+ return get_error_token("PREPROCESSING DEFINED NOT DONE",token_location,lexer_data->program);
+ default:
+ return lexer_make_token_finishing_on_node(lexer_data,finishing_node,start_position);
+ }
+
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
#endif
F diff --git a/src/frontend/lex/lex_preprocessing_directive.h b/src/frontend/lex/lex_preprocessing_directive.h
--- a/src/frontend/lex/lex_preprocessing_directive.h
+++ b/src/frontend/lex/lex_preprocessing_directive.h
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_extract_next_token(struct Lexer_Data *lexer_data);
+ 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);
+ _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);
+
#endif
F diff --git a/src/syntax/automatas/automata.h b/src/syntax/automatas/automata.h
--- a/src/syntax/automatas/automata.h
+++ b/src/syntax/automatas/automata.h
{
enum Automata_Action action;
enum LEXER_TYPE keyword;
+ enum LEXER_TYPE preprocessing_keyword;
struct identifier *data;
struct Automata_Node *delta[CHAR_ENUM_END];
F diff --git a/src/syntax/automatas/generator/generator.c b/src/syntax/automatas/generator/generator.c
--- a/src/syntax/automatas/generator/generator.c
+++ b/src/syntax/automatas/generator/generator.c
while(node_queue->size>0)
{
current_node=Queue_Pop(node_queue);
- fprintf(out,"{ \n.action=%s,\n.keyword=%s,\n.data=%s,\n.delta={",current_node->action_string,current_node->kw_string,current_node->data_string);
+ fprintf(out,"{ \n.action=%s,\n.keyword=%s,\n.preprocessing_keyword=%s,\n.data=%s,\n.delta={",current_node->action_string,current_node->kw_string,current_node->pkw_string,current_node->data_string);
for(i=0;i<CHAR_ENUM_END;++i)
if(current_node->output.delta[i]!=NULL)
{
size_t i;
struct Generator_Node *ret;
- ret=get_generator_node(null_str,no_type_str,automata_no_action_str);
+ ret=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
for(i=0;i<number_of_keywords;++i)
insert_keyword(ret,keywords+i);
current=(struct Generator_Node*)current->output.delta[get_ch(entry->keyword+where_in_keyword,1)],++where_in_keyword)
{
if(current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]==NULL)
- current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]=(struct Automata_Node*)get_generator_node(null_str,no_type_str,automata_no_action_str);
+ current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]=(struct Automata_Node*)get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
}
if(current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]==NULL)
- current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]=(struct Automata_Node*)get_generator_node(entry->data_string,entry->kw_string,entry->action_string);
+ current->output.delta[get_ch(entry->keyword+where_in_keyword,1)]=(struct Automata_Node*)get_generator_node(entry->data_string,entry->kw_string,entry->preprocessing_kw_string,entry->action_string);
else
{
((struct Generator_Node*)current->output.delta[get_ch(entry->keyword+where_in_keyword,1)])->kw_string=entry->kw_string;
return (struct Generator_Node*)current->output.delta[get_ch(entry->keyword+where_in_keyword,1)];
}
- struct Generator_Node* get_generator_node(const char *data_string,const char *kw_string,const char *action_string)
+ struct Generator_Node* get_generator_node(const char *data_string,const char *kw_string,const char *pkw_string,const char *action_string)
{
struct Generator_Node *ret;
ret->node_number=NODE_NOT_NUMBERED;
ret->data_string=data_string;
ret->kw_string=kw_string;
+ ret->pkw_string=pkw_string;
ret->action_string=action_string;
return ret;
struct Generator_Node *current_node;
_Bool push_nodes;
- id_node=get_generator_node(null_str,id_type_str,automata_dispense_token_str);
+ id_node=get_generator_node(null_str,id_type_str,id_type_str,automata_dispense_token_str);
node_queue=wonky_malloc(sizeof(struct Queue));
Queue_Init(node_queue);
add_integer_suffix(add_decimal_number_nodes(node),"KW_LONG_DECIMAL_CONSTANT","KW_LONG_LONG_DECIMAL_CONSTANT");
- oct_hex_split=get_generator_node(null_str,"KW_OCTAL_CONSTANT",automata_dispense_token_str);
+ oct_hex_split=get_generator_node(null_str,"KW_OCTAL_CONSTANT","KW_OCTAL_CONSTANT",automata_dispense_token_str);
connect_node(node,oct_hex_split,NULL,CHAR_0,CHAR_0,0);
add_integer_suffix(oct_hex_split,"KW_LONG_OCTAL_CONSTANT","KW_LONG_LONG_OCTAL_CONSTANT");
struct Generator_Node* add_decimal_number_nodes(struct Generator_Node *node)
{
struct Generator_Node *decimal_node;
- decimal_node=get_generator_node(null_str,"KW_DECIMAL_CONSTANT",automata_dispense_token_str);
+ decimal_node=get_generator_node(null_str,"KW_DECIMAL_CONSTANT","KW_DECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,decimal_node,NULL,CHAR_1,CHAR_9,0);
connect_node(decimal_node,decimal_node,NULL,CHAR_0,CHAR_9,0);
add_finishing_float_nodes(decimal_node,1);
struct Generator_Node *hexadecimal_node_start;
struct Generator_Node *hexadecimal_node;
- hexadecimal_node_start=get_generator_node(null_str,no_type_str,automata_no_action_str);
+ hexadecimal_node_start=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
connect_node(node,hexadecimal_node_start,NULL,CHAR_x,CHAR_x,0);
connect_node(node,hexadecimal_node_start,NULL,CHAR_X,CHAR_X,0);
- hexadecimal_node=get_generator_node(null_str,"KW_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
+ hexadecimal_node=get_generator_node(null_str,"KW_HEXADECIMAL_CONSTANT","KW_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(hexadecimal_node_start,hexadecimal_node,NULL,CHAR_0,CHAR_9,0);
connect_node(hexadecimal_node_start,hexadecimal_node,NULL,CHAR_a,CHAR_f,0);
add_finishing_float_nodes(node,1);
- octal_node=get_generator_node(null_str,"KW_OCTAL_CONSTANT",automata_dispense_token_str);
+ octal_node=get_generator_node(null_str,"KW_OCTAL_CONSTANT","KW_OCTAL_CONSTANT",automata_dispense_token_str);
connect_node(node,octal_node,NULL,CHAR_0,CHAR_7,0);
connect_node(octal_node,octal_node,NULL,CHAR_0,CHAR_7,0);
struct Generator_Node *long_node;
struct Generator_Node *long_long_node;
- long_node=get_generator_node(null_str,l,automata_dispense_token_str);
- long_long_node=get_generator_node(null_str,ll,automata_dispense_token_str);
+ long_node=get_generator_node(null_str,l,l,automata_dispense_token_str);
+ long_long_node=get_generator_node(null_str,ll,ll,automata_dispense_token_str);
connect_node(tail,long_node,NULL,CHAR_l,CHAR_l,0);
connect_node(tail,long_node,NULL,CHAR_L,CHAR_L,0);
{
struct Generator_Node *prefixed_string_node;
- prefixed_string_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
+ prefixed_string_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
connect_node(node,prefixed_string_node,NULL,CHAR_L,CHAR_L,0);
add_string_char_nodes_inner(prefixed_string_node,"KW_WIDE_STRING","KW_WIDE_CHAR_CONSTANT");
struct Generator_Node *inner_char_node;
struct Generator_Node *ending_char_node;
- inner_string_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- ending_string_node=get_generator_node(null_str,str_kw,automata_dispense_token_str);
+ inner_string_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ ending_string_node=get_generator_node(null_str,str_kw,str_kw,automata_dispense_token_str);
- inner_char_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- ending_char_node=get_generator_node(null_str,char_kw,automata_dispense_token_str);
+ inner_char_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ ending_char_node=get_generator_node(null_str,char_kw,char_kw,automata_dispense_token_str);
connect_node(node,inner_char_node,NULL,CHAR_SINGLE_QUOTE,CHAR_SINGLE_QUOTE,0);
struct Generator_Node *float_node;
struct Generator_Node *long_double_node;
- float_node=get_generator_node(null_str,f,automata_dispense_token_str);
- long_double_node=get_generator_node(null_str,l,automata_dispense_token_str);
+ float_node=get_generator_node(null_str,f,f,automata_dispense_token_str);
+ long_double_node=get_generator_node(null_str,l,l,automata_dispense_token_str);
connect_node(node,float_node,NULL,CHAR_f,CHAR_f,0);
connect_node(node,float_node,NULL,CHAR_F,CHAR_F,0);
if(has_read_digits)
{
- dot_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
+ dot_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT","KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,dot_node,NULL,CHAR_DOT,CHAR_DOT,0);
connect_node(dot_node,dot_node,NULL,CHAR_0,CHAR_9,0);
return dot_node;
}else
{
- dot_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- digit_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
+ dot_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ digit_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT","KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,dot_node,NULL,CHAR_DOT,CHAR_DOT,0);
connect_node(dot_node,digit_node,NULL,CHAR_0,CHAR_9,0);
connect_node(digit_node,digit_node,NULL,CHAR_0,CHAR_9,0);
if(has_read_digits)
{
- dot_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
+ dot_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT","KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,dot_node,NULL,CHAR_DOT,CHAR_DOT,0);
connect_node(dot_node,dot_node,NULL,CHAR_0,CHAR_9,0);
connect_node(dot_node,dot_node,NULL,CHAR_a,CHAR_f,0);
return dot_node;
}else
{
- dot_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- digit_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
+ dot_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ digit_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT","KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,dot_node,NULL,CHAR_DOT,CHAR_DOT,0);
connect_node(dot_node,digit_node,NULL,CHAR_0,CHAR_9,0);
connect_node(dot_node,digit_node,NULL,CHAR_a,CHAR_f,0);
struct Generator_Node *digit_node;
struct Generator_Node *e_node;
- e_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- digit_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
+ e_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ digit_node=get_generator_node(null_str,"KW_DOUBLE_DECIMAL_CONSTANT","KW_DOUBLE_DECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,e_node,NULL,CHAR_e,CHAR_e,0);
connect_node(node,e_node,NULL,CHAR_E,CHAR_E,0);
struct Generator_Node *digit_node;
struct Generator_Node *p_node;
- p_node=get_generator_node(null_str,no_type_str,automata_no_action_str);
- digit_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
+ p_node=get_generator_node(null_str,no_type_str,no_type_str,automata_no_action_str);
+ digit_node=get_generator_node(null_str,"KW_DOUBLE_HEXADECIMAL_CONSTANT","KW_DOUBLE_HEXADECIMAL_CONSTANT",automata_dispense_token_str);
connect_node(node,p_node,NULL,CHAR_p,CHAR_p,0);
connect_node(node,p_node,NULL,CHAR_P,CHAR_P,0);
F diff --git a/src/syntax/automatas/generator/generator.h b/src/syntax/automatas/generator/generator.h
--- a/src/syntax/automatas/generator/generator.h
+++ b/src/syntax/automatas/generator/generator.h
ssize_t node_number;
const char *data_string;
const char *kw_string;
+ const char *pkw_string;
const char *action_string;
struct Automata_Node output;
};
struct Generator_Node* make_chonky();
struct Generator_Node* make_generator(const struct Keyword_Entry *keywords,size_t number_of_keywords);
struct Generator_Node* insert_keyword(struct Generator_Node *node,const struct Keyword_Entry *entry);
- struct Generator_Node* get_generator_node(const char *data_string,const char *kw_string,const char *action_string);
+ struct Generator_Node* get_generator_node(const char *data_string,const char *kw_string,const char *pkw_string,const char *action_string);
void add_id_nodes(struct Generator_Node *node);
void add_number_nodes(struct Generator_Node *node);
F diff --git a/src/syntax/automatas/generator/keyword_list.c b/src/syntax/automatas/generator/keyword_list.c
--- a/src/syntax/automatas/generator/keyword_list.c
+++ b/src/syntax/automatas/generator/keyword_list.c
{
{
.keyword="auto",
+ .preprocessing_kw_string="KW_AUTO",
.kw_string="KW_AUTO",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="do",
+ .preprocessing_kw_string="KW_DO",
.kw_string="KW_DO",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="double",
+ .preprocessing_kw_string="KW_DOUBLE",
.kw_string="KW_DOUBLE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="int",
+ .preprocessing_kw_string="KW_INT",
.kw_string="KW_INT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="struct",
+ .preprocessing_kw_string="KW_STRUCT",
.kw_string="KW_STRUCT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="break",
+ .preprocessing_kw_string="KW_BREAK",
.kw_string="KW_BREAK",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="else",
+ .preprocessing_kw_string="KW_ELSE",
.kw_string="KW_ELSE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="long",
+ .preprocessing_kw_string="KW_LONG",
.kw_string="KW_LONG",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="switch",
+ .preprocessing_kw_string="KW_SWITCH",
.kw_string="KW_SWITCH",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="case",
+ .preprocessing_kw_string="KW_CASE",
.kw_string="KW_CASE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="enum",
+ .preprocessing_kw_string="KW_ENUM",
.kw_string="KW_ENUM",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="register",
+ .preprocessing_kw_string="KW_REGISTER",
.kw_string="KW_REGISTER",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="typedef",
+ .preprocessing_kw_string="KW_TYPEDEF",
.kw_string="KW_TYPEDEF",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="char",
+ .preprocessing_kw_string="KW_CHAR",
.kw_string="KW_CHAR",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="extern",
+ .preprocessing_kw_string="KW_EXTERN",
.kw_string="KW_EXTERN",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="return",
+ .preprocessing_kw_string="KW_REGISTER",
.kw_string="KW_RETURN",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="union",
+ .preprocessing_kw_string="KW_UNION",
.kw_string="KW_UNION",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="const",
+ .preprocessing_kw_string="KW_CONST",
.kw_string="KW_CONST",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="float",
+ .preprocessing_kw_string="KW_FLOAT",
.kw_string="KW_FLOAT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="short",
+ .preprocessing_kw_string="KW_SHORT",
.kw_string="KW_SHORT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="unsigned",
+ .preprocessing_kw_string="KW_UNSIGNED",
.kw_string="KW_UNSIGNED",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="continue",
+ .preprocessing_kw_string="KW_CONTINUE",
.kw_string="KW_CONTINUE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="for",
+ .preprocessing_kw_string="KW_FOR",
.kw_string="KW_FOR",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="signed",
+ .preprocessing_kw_string="KW_SIGNED",
.kw_string="KW_SIGNED",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="void",
+ .preprocessing_kw_string="KW_VOID",
.kw_string="KW_VOID",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="default",
+ .preprocessing_kw_string="KW_DEFAULT",
.kw_string="KW_DEFAULT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="goto",
+ .preprocessing_kw_string="KW_GOTO",
.kw_string="KW_GOTO",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="sizeof",
+ .preprocessing_kw_string="KW_SIZEOF",
.kw_string="KW_SIZEOF",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="volatile",
+ .preprocessing_kw_string="KW_VOLATILE",
.kw_string="KW_VOLATILE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="if",
+ .preprocessing_kw_string="KW_IF",
.kw_string="KW_IF",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="static",
+ .preprocessing_kw_string="KW_STATIC",
.kw_string="KW_STATIC",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="while",
+ .preprocessing_kw_string="KW_WHILE",
.kw_string="KW_WHILE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="!",
+ .preprocessing_kw_string="KW_EXCLAMATION",
.kw_string="KW_EXCLAMATION",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="%",
+ .preprocessing_kw_string="KW_PERCENT",
.kw_string="KW_PERCENT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="&",
+ .preprocessing_kw_string="KW_AND",
.kw_string="KW_AND",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="&&",
+ .preprocessing_kw_string="KW_AND_AND",
.kw_string="KW_AND_AND",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="(",
+ .preprocessing_kw_string="KW_OPEN_NORMAL",
.kw_string="KW_OPEN_NORMAL",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=")",
+ .preprocessing_kw_string="KW_CLOSE_NORMAL",
.kw_string="KW_CLOSE_NORMAL",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="*",
+ .preprocessing_kw_string="KW_STAR",
.kw_string="KW_STAR",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="+",
+ .preprocessing_kw_string="KW_PLUS",
.kw_string="KW_PLUS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=",",
+ .preprocessing_kw_string="KW_COMMA",
.kw_string="KW_COMMA",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="-",
+ .preprocessing_kw_string="KW_MINUS",
.kw_string="KW_MINUS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=".",
+ .preprocessing_kw_string="KW_DOT",
.kw_string="KW_DOT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="->",
+ .preprocessing_kw_string="KW_ARROW",
.kw_string="KW_ARROW",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=":",
+ .preprocessing_kw_string="KW_COLUMN",
.kw_string="KW_COLUMN",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=";",
+ .preprocessing_kw_string="KW_SEMI_COLUMN",
.kw_string="KW_SEMI_COLUMN",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<",
+ .preprocessing_kw_string="KW_LESS",
.kw_string="KW_LESS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="=",
+ .preprocessing_kw_string="KW_EQ",
.kw_string="KW_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="==",
+ .preprocessing_kw_string="KW_EQEQ",
.kw_string="KW_EQEQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=">",
+ .preprocessing_kw_string="KW_MORE",
.kw_string="KW_MORE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="?",
+ .preprocessing_kw_string="KW_QUESTION",
.kw_string="KW_QUESTION",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="[",
+ .preprocessing_kw_string="KW_OPEN_SQUARE",
.kw_string="KW_OPEN_SQUARE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="]",
+ .preprocessing_kw_string="KW_CLOSE_SQUARE",
.kw_string="KW_CLOSE_SQUARE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="^",
+ .preprocessing_kw_string="KW_HAT",
.kw_string="KW_HAT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="{",
+ .preprocessing_kw_string="KW_OPEN_CURLY",
.kw_string="KW_OPEN_CURLY",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="}",
+ .preprocessing_kw_string="KW_CLOSE_CURLY",
.kw_string="KW_CLOSE_CURLY",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="|",
+ .preprocessing_kw_string="KW_PIPE",
.kw_string="KW_PIPE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="||",
+ .preprocessing_kw_string="KW_PIPE_PIPE",
.kw_string="KW_PIPE_PIPE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="~",
+ .preprocessing_kw_string="KW_TILDE",
.kw_string="KW_TILDE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="++",
+ .preprocessing_kw_string="KW_PLUSPLUS",
.kw_string="KW_PLUSPLUS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="--",
+ .preprocessing_kw_string="KW_MINUSMINUS",
.kw_string="KW_MINUSMINUS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=">>",
+ .preprocessing_kw_string="KW_SHIFT_RIGHT",
.kw_string="KW_SHIFT_RIGHT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<<",
+ .preprocessing_kw_string="KW_SHIFT_LEFT",
.kw_string="KW_SHIFT_LEFT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<=",
+ .preprocessing_kw_string="KW_LESS_EQ",
.kw_string="KW_LESS_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=">=",
+ .preprocessing_kw_string="KW_MORE_EQ",
.kw_string="KW_MORE_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="!=",
+ .preprocessing_kw_string="KW_NOT_EQ",
.kw_string="KW_NOT_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="+=",
+ .preprocessing_kw_string="KW_PLUS_EQ",
.kw_string="KW_PLUS_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="-=",
+ .preprocessing_kw_string="KW_MINUS_EQ",
.kw_string="KW_MINUS_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="*=",
+ .preprocessing_kw_string="KW_STAR_EQ",
.kw_string="KW_STAR_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="%=",
+ .preprocessing_kw_string="KW_PERCENT_EQ",
.kw_string="KW_PERCENT_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="/=",
+ .preprocessing_kw_string="KW_DIV_EQ",
.kw_string="KW_DIV_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<<=",
+ .preprocessing_kw_string="KW_SHIFT_LEFT_EQ",
.kw_string="KW_SHIFT_LEFT_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=">>=",
+ .preprocessing_kw_string="KW_SHIFT_RIGHT_EQ",
.kw_string="KW_SHIFT_RIGHT_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="&=",
+ .preprocessing_kw_string="KW_AND_EQ",
.kw_string="KW_AND_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="^=",
+ .preprocessing_kw_string="KW_HAT_EQ",
.kw_string="KW_HAT_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="|=",
+ .preprocessing_kw_string="KW_PIPE_EQ",
.kw_string="KW_PIPE_EQ",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="#",
+ .preprocessing_kw_string="KW_HASHTAG",
.kw_string="KW_HASHTAG",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="##",
+ .preprocessing_kw_string="KW_HASHTAG_HASHTAG",
.kw_string="KW_HASHTAG_HASHTAG",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="...",
+ .preprocessing_kw_string="KW_ELIPSIS",
.kw_string="KW_ELIPSIS",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="/",
+ .preprocessing_kw_string="KW_DIV",
.kw_string="KW_DIV",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="inline",
+ .preprocessing_kw_string="KW_INLINE",
.kw_string="KW_INLINE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="restrict",
+ .preprocessing_kw_string="KW_RESTRICT",
.kw_string="KW_RESTRICT",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="_Bool",
+ .preprocessing_kw_string="KW_BOOL",
.kw_string="KW_BOOL",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="_Complex",
+ .preprocessing_kw_string="KW_COMPLEX",
.kw_string="KW_COMPLEX",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="_Imaginary",
+ .preprocessing_kw_string="KW_IMAGINARY",
.kw_string="KW_IMAGINARY",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<:",
+ .preprocessing_kw_string="KW_OPEN_SQUARE",
.kw_string="KW_OPEN_SQUARE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword=":>",
+ .preprocessing_kw_string="KW_CLOSE_SQUARE",
.kw_string="KW_CLOSE_SQUARE",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="<%",
+ .preprocessing_kw_string="KW_OPEN_CURLY",
.kw_string="KW_OPEN_CURLY",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="%>",
+ .preprocessing_kw_string="KW_CLOSE_CURLY",
.kw_string="KW_CLOSE_CURLY",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="%:",
+ .preprocessing_kw_string="KW_HASHTAG",
.kw_string="KW_HASHTAG",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="%:%:",
+ .preprocessing_kw_string="KW_HASHTAG_HASHTAG",
.kw_string="KW_HASHTAG_HASHTAG",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="NULL"
},
{
.keyword="defined",
- .kw_string="PKW_DEFINED",
+ .preprocessing_kw_string="PKW_DEFINED",
+ .kw_string="KW_ID",
.action_string="AUTOMATA_ACTION_DISPENSE_TOKEN",
.data_string="&defined_special_identifier"
},
F diff --git a/src/syntax/automatas/generator/keyword_list.h b/src/syntax/automatas/generator/keyword_list.h
--- a/src/syntax/automatas/generator/keyword_list.h
+++ b/src/syntax/automatas/generator/keyword_list.h
struct Keyword_Entry
{
const char *keyword;
+ const char *preprocessing_kw_string;
const char *kw_string;
const char *action_string;
const char *data_string;
F diff --git a/src/syntax/automatas/id_node.c b/src/syntax/automatas/id_node.c
--- a/src/syntax/automatas/id_node.c
+++ b/src/syntax/automatas/id_node.c
ret->action=AUTOMATA_ACTION_DISPENSE_TOKEN;
ret->keyword=KW_ID;
+ ret->preprocessing_keyword=KW_ID;
ret->data=NULL;
base->delta[delta]=ret;