Remove TokenMode
This commit is contained in:
@@ -35,15 +35,6 @@ print_token :: proc(token: Token, depth: int) {
|
|||||||
value_str = v
|
value_str = v
|
||||||
case int:
|
case int:
|
||||||
value_str = fmt.aprintf("%d", v, allocator = context.temp_allocator)
|
value_str = fmt.aprintf("%d", v, allocator = context.temp_allocator)
|
||||||
case TokenMode:
|
|
||||||
switch v {
|
|
||||||
case TokenMode.Start:
|
|
||||||
value_str = "Start"
|
|
||||||
case TokenMode.End:
|
|
||||||
value_str = "End"
|
|
||||||
case TokenMode.Modeless:
|
|
||||||
value_str = "Modeless"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if value_str != "" {
|
if value_str != "" {
|
||||||
|
|||||||
+2
-9
@@ -12,16 +12,9 @@ TokenType :: enum {
|
|||||||
Paragraph,
|
Paragraph,
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenMode :: enum {
|
|
||||||
Start,
|
|
||||||
End,
|
|
||||||
Modeless,
|
|
||||||
}
|
|
||||||
|
|
||||||
TokenValue :: union {
|
TokenValue :: union {
|
||||||
string,
|
string,
|
||||||
int,
|
int,
|
||||||
TokenMode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Token :: struct {
|
Token :: struct {
|
||||||
@@ -58,14 +51,14 @@ parse_header :: proc(line: string) -> (int, string) {
|
|||||||
|
|
||||||
parse :: proc(lines: []string, allocator := context.allocator) -> [dynamic]Token {
|
parse :: proc(lines: []string, allocator := context.allocator) -> [dynamic]Token {
|
||||||
token_tree := [dynamic]Token{}
|
token_tree := [dynamic]Token{}
|
||||||
append(&token_tree, Token{TokenType.Paragraph, TokenMode.Start, nil})
|
append(&token_tree, Token{TokenType.Paragraph, nil, nil})
|
||||||
current_token := &token_tree[0]
|
current_token := &token_tree[0]
|
||||||
|
|
||||||
for untrimmed_line in lines {
|
for untrimmed_line in lines {
|
||||||
line := strings.trim_space(untrimmed_line)
|
line := strings.trim_space(untrimmed_line)
|
||||||
|
|
||||||
if len(line) == 0 {
|
if len(line) == 0 {
|
||||||
append(¤t_token.children, Token{TokenType.BreakLine, TokenMode.Modeless, nil})
|
append(¤t_token.children, Token{TokenType.BreakLine, nil, nil})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user