37 lines
593 B
C
37 lines
593 B
C
|
|
#include <debug.h>
|
|
|
|
#include <memory/smalloc.h>
|
|
|
|
#include <string/inc.h>
|
|
|
|
#include "../position/inc.h"
|
|
|
|
#include "struct.h"
|
|
#include "new.h"
|
|
|
|
struct token* new_token(
|
|
enum token_kind kind,
|
|
struct string* text,
|
|
struct position* start_position,
|
|
struct position* end_position)
|
|
{
|
|
ENTER;
|
|
|
|
struct token* this = smalloc(sizeof(*this));
|
|
|
|
this->kind = kind;
|
|
|
|
this->text = inc_string(text);
|
|
|
|
this->start = inc_position(start_position);
|
|
|
|
this->end = inc_position(end_position);
|
|
|
|
this->refcount = 1;
|
|
|
|
EXIT;
|
|
return this;
|
|
}
|
|
|
|
|