Token
Token structure produced my the tokenizer.
Properties
struct {
token: Tag
location: Location
}Location
Properties
struct {
start: usize
end: usize
}Tag
Properties
enum {
identifier
value
value_int
eof
invalid
}Location
Properties
struct {
start: usize
end: usize
}Tag
Properties
enum {
identifier
value
value_int
eof
invalid
}Offset
Index used to know token starts and ends.
u32TokenIndex
Index used to know token tags.
u32TokenList
MultiArrayList used to generate the neccessary information for the parser to use.
std.MultiArrayList(struct {
tag: Token.Tag,
start: Offset,
})Tokenizer
Tokenizer that will produce lexicar tokens so that the
parser can consume and load it to the EnvMap.
Properties
struct {
/// The source that will be used to produce tokens.
buffer: [:0]const u8
/// Current index into the source
index: usize
}Init
Sets the initial state.
Signature
pub fn init(source: [:0]const u8) TokenizerNext
Advances the tokenizer's state and produces a single token.
Signature
pub fn next(self: *Tokenizer) TokenParserEnv
Parses the enviroment variables strings and loads them
into a EnvMap.
Properties
struct {
/// Slice of produced token tags from the tokenizer.
token_tags: []const Token.Tag
/// Slice of produced token starts from the tokenizer.
token_starts: []const Offset
/// The current index in any of the previous slices.
token_index: TokenIndex
/// The source that will be used to load values from.
source: [:0]const u8
/// The enviroment map that will be used to load the variables to.
env_map: *EnvMap
}ParseAndLoad
Parses all token tags and loads the all into the EnvMap.
Signature
pub fn parseAndLoad(self: *ParserEnv) !voidParseAndLoadOne
Parses a single line and load it to memory. IDENT -> VALUE/VALUE_INT
Signature
pub fn parseAndLoadOne(self: *ParserEnv) (Allocator.Error || error{UnexpectedToken})!voidParseIdentifier
Parses the identifier token.
Returns and error if the current token is not a identifier one.
Signature
pub fn parseIdentifier(self: *ParserEnv) error{UnexpectedToken}!TokenIndexParseIntValue
Parses the value_int token.
Returns null if the current token is not a value_int one.
Signature
pub fn parseIntValue(self: *ParserEnv) ?TokenIndexParseValue
Parses the value or value_int token.
Returns and error if the current token is not a value or value_int one.
Signature
pub fn parseValue(self: *ParserEnv) error{UnexpectedToken}!TokenIndexParseToEnviromentVariables
Parses and loads all possible enviroment variables from the
provided source.
Can error if the parser encounters unexpected token values.
Signature
pub fn parseToEnviromentVariables(
allocator: Allocator,
source: [:0]const u8,
env_map: *EnvMap,
) (Allocator.Error || error{UnexpectedToken})!void