source: grammar/dashmarkup.wi @ 5d8653579b142c17f6c0a9c4d36eb89f6e754f6b

Revision 5d8653579b142c17f6c0a9c4d36eb89f6e754f6b, 5.5 KB checked in by Stanislaw Klekot <dozzie@…>, 3 years ago (diff)

Added support for empty table cells.

  • Property mode set to 100644
Line 
1
2#-----------------------------------------------------------------------------
3# root productions
4
5document: _empty_line? _paragraph (_empty_line _paragraph)* _document_trailing
6;
7
8_document_trailing: _empty_line?
9                  | _empty_line
10                    NEW_SECTION
11                    (_empty_line block_definition)* _empty_line?
12;
13
14_empty_line: EMPTY_LINE+
15;
16
17_paragraph: heading_paragraph
18          | text_paragraph
19          | code_paragraph
20          | list_paragraph
21          | table_paragraph
22;
23
24#-----------------------------------------------------------------------------
25# common useful productions {{
26
27space: ' '
28     | NL
29;
30
31_printable: _printable_atom+
32;
33
34# anything that can appear on its own and would mean literal text (no
35# formatting, no s///, no escape characters \n, no nothing -- just the entered
36# text), in order of appearance in lexer
37_printable_atom: COMMA
38               | STRING
39               | Q_CHAR
40               | WORD
41               | NUMBER
42               | PUNCT
43               | macro_call
44               | macro_call_silent
45               | block_call
46               | MACRO_VALUE
47;
48
49#-----------------------------------------------------------
50# macros and %blocks support {{
51
52macro_call: MACRO_CALL ' ' _macro_arguments ']]'
53          | MACRO_CALL ' '? ']]'
54;
55
56macro_call_silent: MACRO_CALL_SILENT ' ' _macro_arguments ']]'
57                 | MACRO_CALL_SILENT ' '? ']]'
58;
59
60block_call: BLOCK_CALL ' ' _macro_arguments ']]'
61          | BLOCK_CALL ' '? ']]'
62;
63
64_macro_arguments: macro_arg (_comma macro_arg)* ' '?
65;
66
67_comma: ' ' ' '* COMMA ' '*
68      | COMMA ' '*
69;
70
71macro_arg: NUMBER
72         | STRING
73         | MACRO_VALUE
74;
75
76# }}}
77#-----------------------------------------------------------
78# %blocks definition section {{
79
80# XXX: tree postprocessing depends on this static structure:
81# BLOCK_CALL, arguments (possibly empty list), body, discard all the rest
82block_definition: BLOCK_CALL block_arguments ']]' ' '? '{{{' block_body '}}}'
83;
84
85block_arguments: ' ' MACRO_VALUE (_comma MACRO_VALUE)*
86               | ' '?
87;
88
89# TODO: more paragraphs in the block allowed
90block_body: _paragraph
91;
92
93# }}}
94#-----------------------------------------------------------
95
96_raw_text: _printable (space _printable)*
97;
98
99#_raw_text_ending_space: _printable (space _printable)* space?
100#;
101
102_non_space_sequence: _non_space_atom+
103;
104
105_non_space_atom: _simple_format
106               | _printable_atom
107;
108
109_text_ending_space: _non_space_sequence (space _non_space_sequence)* space?
110;
111
112_text_single_line_must_end_space: (_non_space_sequence ' ')+
113;
114
115# }}}
116#-----------------------------------------------------------------------------
117# text paragraph {{
118
119text_paragraph: text_paragraph_line (LINE_BREAK text_paragraph_line)*
120;
121
122text_paragraph_line: _text_ending_space
123;
124
125# }}}
126#-----------------------------------------------------------------------------
127# formatted text {{
128
129_simple_format: bold_text
130              | italic_text
131              | strike_text
132              | tt_text
133              | link
134              | image
135;
136
137link: '[[' link_target ']]'
138    | '[[' link_target space link_description ']]'
139;
140
141image: '[[!' image_target ']]'
142;
143
144link_target: _url
145;
146
147image_target: _url
148;
149
150_url: _printable
151;
152
153link_description: _printable (space _printable)*
154                | image space?
155;
156
157bold_text: '**' _raw_text '**'
158;
159italic_text: '__' _raw_text '__'
160;
161strike_text: '~~' _raw_text '~~'
162;
163tt_text: '{{' _raw_text '}}'
164;
165
166# }}}
167#-----------------------------------------------------------------------------
168# heading paragraph {{
169
170heading_paragraph: HEADER_S space? _text_ending_space HEADER_E space?
171;
172
173# }}}
174#-----------------------------------------------------------------------------
175# code paragraph {{
176
177# well, nothing fancy: lexer did all the job here
178code_paragraph: PRE
179;
180
181# }}}
182#-----------------------------------------------------------------------------
183# numbered/enumerated paragraph {{
184
185list_paragraph: _some_list
186;
187
188_some_list: numbered_list
189          | alpha_list
190          | bullet_list
191          | undecorated_list
192;
193
194numbered_list: BEGIN_INDENT numbered_list_element+ END_INDENT
195;
196
197numbered_list_element: LIST_NUMERIC _list_item _some_list?
198;
199
200alpha_list: BEGIN_INDENT alpha_list_element+ END_INDENT
201;
202
203alpha_list_element: LIST_ALPHA _list_item _some_list?
204;
205
206bullet_list: BEGIN_INDENT bullet_list_element+ END_INDENT
207;
208
209bullet_list_element: LIST_BULLET _list_item _some_list?
210;
211
212undecorated_list: BEGIN_INDENT undecorated_list_element+ END_INDENT
213;
214
215undecorated_list_element: LIST_UNDECO _list_item _some_list?
216;
217
218_list_item: list_item_line (LINE_BREAK_INDENTED list_item_line)*
219;
220
221list_item_line: _text_ending_space
222;
223
224# }}}
225#-----------------------------------------------------------------------------
226# table paragraph {{
227
228table_paragraph: table_row+
229;
230
231table_row: TABLE_ROW_START   table_cell  _trowrest_starting_plain NL
232         | TABLE_ROW_H_START header_cell _trowrest_starting_header NL
233;
234
235_trowrest_starting_plain: TABLE_CELL   table_cell  _trowrest_starting_plain
236                        | TABLE_CELL_R header_cell _trowrest_starting_header
237                        | TABLE_ROW_END
238;
239
240_trowrest_starting_header: TABLE_CELL_L  table_cell  _trowrest_starting_plain
241                         | TABLE_CELL_LR header_cell _trowrest_starting_header
242                         | TABLE_ROW_H_END
243;
244
245# <td>..</td>
246table_cell: _table_cell
247;
248
249# <th>..</th>
250header_cell: _table_cell
251;
252
253_table_cell: ' ' _text_single_line_must_end_space
254           | ' '
255;
256
257# }}}
258#-----------------------------------------------------------------------------
259
Note: See TracBrowser for help on using the repository browser.