F diff --git a/build/cmake/libs/innards.txt b/build/cmake/libs/innards.txt
--- a/build/cmake/libs/innards.txt
+++ b/build/cmake/libs/innards.txt
src/syntax/source_file.c
src/syntax/token/token.c
src/syntax/automatas/automata.c
+ src/syntax/automatas/id_node.c
src/semantics/program/translation_unit.c
)
F diff --git a/src/environment/error/gcc_error.c b/src/environment/error/gcc_error.c
--- a/src/environment/error/gcc_error.c
+++ b/src/environment/error/gcc_error.c
ret=wonky_calloc(filename_length+64,1);
- sprintf(ret,"%s %zu:%zu ",filename,line,column);
+ sprintf(ret,"%s %zu:%zu ",filename,line+1,column);
return ret;
}
F diff --git a/src/frontend/lex/lexer.c b/src/frontend/lex/lexer.c
--- a/src/frontend/lex/lexer.c
+++ b/src/frontend/lex/lexer.c
case '\n':
state=BLANK_SPACE;
++lexer_data->where_in_src;
+ ++lexer_data->which_row;
+ lexer_data->which_column=0;
lexer_data->is_in_the_begining_of_line=1;
break;
case ' ':
if(state==POSSIBLE_LINE_SPLICE)
state=NON_WHITE_SPACE;
else
+ {
++lexer_data->where_in_src;
+ ++lexer_data->which_column;
+ }
break;
case '\\':
}else
{
++lexer_data->where_in_src;
+ ++lexer_data->which_column;
state=POSSIBLE_LINE_SPLICE;
}
break;
{
state=UNKNOWN_CHAR;
++lexer_data->where_in_src;
- ++lexer_data->which_column;
- lexer_data->which_row=0;
+ lexer_data->which_column=0;
+ ++lexer_data->which_row;
}else
{
state=KNOWN_CHAR;
ch=get_ch(& lexer_data->src->src[lexer_data->where_in_src],1);
- ret=node->delta[ch];
+ 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;
wonky_assert(is_valid_automata_node(finishing_node));
token_location=get_source_location(
- lexer_data->which_column,
lexer_data->which_row,
+ lexer_data->which_column,
lexer_data->where_in_src,
lexer_data->src->src_name
);
F diff --git a/src/frontend/lex/lexer.h b/src/frontend/lex/lexer.h
--- a/src/frontend/lex/lexer.h
+++ b/src/frontend/lex/lexer.h
#include <source_file.h>
#include <automata.h>
+ #include <id_node.h>
#include <token.h>
#include <translation_unit.h>
+ #include <lex_preprocessing_directive.h>
struct Lexer_Data
{
F diff --git a/src/semantics/program/translation_unit.c b/src/semantics/program/translation_unit.c
--- a/src/semantics/program/translation_unit.c
+++ b/src/semantics/program/translation_unit.c
Stack_Init(ret->call_stack);
Queue_Init(ret->ungeted_tokens);
- ret->current_location=NULL;/*todo*/
+
+ ret->current_location=((struct token*)unit->tokens->first->data)->location;/*todo: make sure translation unit has a token*/
ret->program=NULL;/*todo*/
return ret;
F diff --git a/src/syntax/automatas/automata.c b/src/syntax/automatas/automata.c
--- a/src/syntax/automatas/automata.c
+++ b/src/syntax/automatas/automata.c
}
-
#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
#include <stddef.h>
#include <identifier.h>
#include <token.h>
+ #include <wonky_malloc.h>
extern enum Source_Chars compress[256];
struct Automata_Node
};
enum Source_Chars get_ch(const char *str,size_t limit);
-
+ struct Automata_Node* get_new_id_node(struct Automata_Node *base,enum Source_Chars delta);
extern struct Automata_Node chonky[];
extern struct Automata_Node chonky_jr[];
extern struct identifier defined_special_identifier;
+
#endif
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
void print_automatas()
{
FILE *chonky_c;
+ struct Generator_Node *chonky;
chonky_c=fopen("chonky.c","w");
if(chonky_c==NULL)
exit(1);
}
+ chonky=make_chonky();
fprintf(chonky_c,"#ifndef WONKY_CHONKY_C\n#define WONKY_CHONKY_C WONKY_CHONKY_C\n#include <stddef.h>\n#include <automata.h>\n\n");
- print_automata(make_chonky(),"chonky",chonky_c);
+ print_automata(chonky,"chonky",chonky_c);
+ fprintf(chonky_c,"\nstruct Automata_Node *id_node=&chonky[%zd];\n\n",global_id_node->node_number);
fprintf(chonky_c,"\n#endif");
}
void print_automata(struct Generator_Node *root,const char *name,FILE *out)
wonky_assert(node_queue->size==0);
wonky_free(node_queue);
+ global_id_node=id_node;
}
void add_number_nodes(struct Generator_Node *node)
{
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
int main();
static const ssize_t NODE_NOT_NUMBERED=-1;
+ static struct Generator_Node *global_id_node=NULL;
+
static const char *null_str="NULL";
static const char *no_type_str="KW_NOTYPE";
static const char *id_type_str="KW_ID";
F diff --git a/src/syntax/automatas/id_node.c b/src/syntax/automatas/id_node.c
new file mode 100644
--- /dev/null
+++ b/src/syntax/automatas/id_node.c
+ #ifndef WONKY_ID_NODE_C
+ #define WONKY_ID_NODE_C WONKY_ID_NODE_C
+
+ #include <id_node.h>
+
+ struct Automata_Node* get_new_id_node(struct Automata_Node *base,enum Source_Chars delta)
+ {
+ struct Automata_Node *ret;
+ enum Source_Chars i;
+
+ ret=wonky_malloc(sizeof(struct Automata_Node));
+
+ ret->action=AUTOMATA_ACTION_DISPENSE_TOKEN;
+ ret->keyword=KW_ID;
+ ret->data=NULL;
+
+ base->delta[delta]=ret;
+
+ for(i=0;i<CHAR_ENUM_END;++i)
+ ret->delta[i]=id_node->delta[i];
+
+ return ret;
+ }
+
+
+ #endif
F diff --git a/src/syntax/automatas/id_node.h b/src/syntax/automatas/id_node.h
new file mode 100644
--- /dev/null
+++ b/src/syntax/automatas/id_node.h
+ #ifndef WONKY_ID_NODE_H
+ #define WONKY_ID_NODE_H WONKY_ID_NODE_H
+
+ #include <automata.h>
+
+
+ extern struct Automata_Node *id_node;
+ struct Automata_Node* get_new_id_node(struct Automata_Node *base,enum Source_Chars delta);
+
+ #endif
F diff --git a/src/syntax/token/token.c b/src/syntax/token/token.c
--- a/src/syntax/token/token.c
+++ b/src/syntax/token/token.c
struct token *ret;
ret=wonky_malloc(sizeof(struct token));
ret->type=LT_EOF;
+ ret->location=NULL;
return ret;
}