37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
#include "machine_state.h"
|
|
#include "machine_state_struct.h"
|
|
|
|
void RegexMachineStateBase_Init(RegexMachineStateBase* base, enum RegexMachineStateType type)
|
|
{
|
|
base->next = NULL;
|
|
base->type = type;
|
|
}
|
|
|
|
void RegexMachineStateOption_Init(RegexMachineStateOption* option)
|
|
{
|
|
RegexMachineStateBase_Init(&option->base, REGEXMACHINESTATETYPE_OPTION);
|
|
option->next_option = NULL;
|
|
}
|
|
|
|
void RegexMachineStateGroup_Init(RegexMachineStateGroup* group, char* name, size_t number)
|
|
{
|
|
RegexMachineStateBase_Init(&group->base, REGEXMACHINESTATETYPE_GROUP);
|
|
group->name = name;
|
|
group->number = number;
|
|
}
|
|
|
|
void RegexMachineStateAccept_Init(RegexMachineStateAccept* accept)
|
|
{
|
|
RegexMachineStateBase_Init(&accept->base, REGEXMACHINESTATETYPE_ACCEPT);
|
|
accept->sequence = (StringView) {.source = NULL, .length = 0};
|
|
}
|
|
|
|
void RegexMachineStateRepeat_Init(RegexMachineStateRepeat* repeat, size_t min, size_t max, bool greedy, bool possessive, RegexMachineStateBase* repeatable)
|
|
{
|
|
RegexMachineStateBase_Init(&repeat->base, REGEXMACHINESTATETYPE_REPEAT);
|
|
repeat->min = min;
|
|
repeat->max = max;
|
|
repeat->greedy = greedy;
|
|
repeat->possessive = possessive;
|
|
repeat->repeatable = repeatable;
|
|
}
|