Make ltx cli nicer
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
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,
|
||||
}
|
||||
Reference in New Issue
Block a user