1
- def get_parsed_tokens (tokens , parsed , token_idx , depth = 0 ):
1
+ def get_parsed_tokens (tokens , parsed , token_idx , depth = - 1 ):
2
2
"""
3
3
start -> tabs -> property -> equals -> value -> newline
4
4
^ v ^ v
@@ -13,13 +13,21 @@ def get_parsed_tokens(tokens, parsed, token_idx, depth=0):
13
13
if state == "start" and token ["type" ] == "TABS" and is_less_deep (depth , token ):
14
14
return
15
15
elif state == "start" and token ["type" ] == "TABS" and is_deeper (depth , token ):
16
- parsed .append ( { "type" : "lines_tokens" , "content" : [] } )
17
- get_parsed_tokens (tokens , parsed [- 1 ]["content" ], token_idx , depth + 1 )
18
- elif state == "start" and token ["type" ] == "TABS" :
19
- parsed .append ( [ { "type" : "lines_tokens" , "content" : [] } ] )
16
+ parsed .append (
17
+ { "type" : "lines_tokens" , "content" : [
18
+ [
19
+ { "type" : "extra" , "content" : token ["content" ] }
20
+ ]
21
+ ]}
22
+ )
20
23
token_idx [0 ] += 1
21
- get_parsed_tokens (tokens , parsed [- 1 ], token_idx , depth )
22
- elif (state == "start" or state == "tabs" ) and token ["type" ] == "WORD" :
24
+ get_parsed_tokens (tokens , parsed [- 1 ]["content" ][0 ], token_idx , depth + 1 )
25
+ elif state == "start" and token ["type" ] == "TABS" :
26
+ return
27
+ elif state == "start" and token ["type" ] == "WORD" and depth == - 1 :
28
+ parsed .append ([])
29
+ get_parsed_tokens (tokens , parsed [- 1 ], token_idx , depth + 1 )
30
+ elif state == "start" and token ["type" ] == "WORD" :
23
31
parsed .append ( { "type" : "property" , "content" : token ["content" ] } )
24
32
state = "property"
25
33
token_idx [0 ] += 1
0 commit comments