Files
silly-stuff/ltx/types.odin
T
2026-08-06 19:22:44 -04:00

82 lines
1.1 KiB
Odin

package ltx
Ltx :: struct {
source: string,
source_path: string,
nodes: [dynamic]Node,
idx: int,
pos: struct {
line: u32,
col: u32,
},
}
Tokens :: enum {
Backslash,
LeftBrace,
RightBrace,
LeftBracket,
RightBracket,
Assign,
Quote,
}
TokenArray := [Tokens]rune {
.Assign = '=',
.Backslash = '\\',
.LeftBrace = '{',
.RightBrace = '}',
.LeftBracket = '[',
.RightBracket = ']',
.Quote = '"',
}
Node_Kind :: enum {
Text,
Tag,
}
Attr_Type :: enum {
Flag,
Attribute,
}
Field :: struct {
value: string,
type: Attr_Type,
}
Node :: struct {
name: string,
kind: Node_Kind,
text: string,
attributes: map[string]Field,
children: [dynamic]Node,
}
Ltx_Error :: enum u32 {
None = 0,
EOF,
KeyExpected,
ClosingBracketExpected,
ClosingBraceExpected,
UnexpectedRightBrace,
ValueExpected,
KeyAlreadyExists,
InvalidKey,
CannotReadFile,
// InvalidKeyStart,
}
Cli_Output_Type :: enum {
None,
PlainText,
XML,
SmartIndentedText,
}
Cli_Args :: struct {
type: Cli_Output_Type,
file_path: string,
}