-
Notifications
You must be signed in to change notification settings - Fork 0
/
ideas.txt
109 lines (94 loc) · 2.46 KB
/
ideas.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
on each line, we can determine:
- indent level
- block definition
- name validity
- attributes
- inline content
- flow content
- chunks of content
- phrases
how to determine an end to a block?
- indent level went down (end of a flow and/or block(s))
- new block at same indent (field/empty block)
- end of file (end of all open blocks)
- if paragraph, blank line
take line
check indentation
- if same
- if block, new block
- if was paragraph
- if increase
split on colon
- no colon => break
- yes colon
- segment 1 is block definition
- no => break
- segment 2 has parenthesis
- yes => parse as attriubutes
- segment 2 has non-whitespace content
- yes => parse as text_content
parse_line
-> block_header | flow_content ;
what indent means:
- same: either wrapped flow, or new sibling block
- error if flow start: incorrect paragraph indent
- shallower: new sibling of parent
- deeper: new child
- error if parent is flow
parse line
- walk through line char by char, managing state
state
- current state
- look for transitions
- build up string as we go (may be multiple string slices)
iterate through source file, generating events
as you go, look for errors, create elements
hmm, maybe break the lines down semantically, like "is
indented x times from previous" "has valid block name prefix"
and so on, and then make decisions in a more blocky way like
that, instead of just like walking through every char
line:
- has block definition
- REQ: before first space = '{valid name}:'
- OPT: attributes
- OPT: text_content
- has ordered list item
- REQ: before first space = '{num}.'
- has unordered list item
- REQ: before first space = '* '
- is blank
- REQ: trim().is_empty()
- else: is paragraph
line state:
- normal (reading in blocks line by line)
- unordered list (currently consuming ul)
- ordered list (currently consuming ol)
- paragraph (currently consuming paragraph)
read line
- initial state
- while lines
- get parsed line
- run transition
element
- has a name
- has ?attributes
- has ?associated-flow
- has ?children
- either CDATA or element
element_stack
- has active element
- add child
- if indent, push last child as active
- if outdent, pop active element
open(e)
- set {e.parent} to {active}
- push() {e} to stack
close()
- pop() stack
if indent
- open
if no indent
- close
- open
if unindent
- close