@@ -117,7 +117,7 @@ let Value = defer(() =>
117
117
let Pattern = defer ( ( ) =>
118
118
repeat1 (
119
119
PatternElement )
120
- // Flatten indented Placeables .
120
+ // Flatten block_text and block_placeable which return lists .
121
121
. map ( flatten ( 1 ) )
122
122
. chain ( list_into ( FTL . Pattern ) ) ) ;
123
123
@@ -131,26 +131,34 @@ let VariantList = defer(() =>
131
131
. map ( keep_abstract )
132
132
. chain ( list_into ( FTL . VariantList ) ) ) ;
133
133
134
+ /* ----------------------------------------------------------------- */
135
+ /* TextElement and Placeable can occur inline or as block.
136
+ * Text needs to be indented and start with a non-special character.
137
+ * Placeables can start at the beginning of the line or be indented.
138
+ * Adjacent TextElements are joined in AST creation. */
139
+
134
140
let PatternElement = defer ( ( ) =>
135
141
either (
136
- TextElement ,
137
- Placeable ,
138
- sequence (
139
- // Joined with preceding TextElements during AST construction.
140
- blank_block . chain ( into ( FTL . TextElement ) ) . abstract ,
141
- maybe ( blank_inline ) ,
142
- Placeable . abstract )
143
- . map ( keep_abstract ) ) ) ;
142
+ inline_text ,
143
+ block_text ,
144
+ inline_placeable ,
145
+ block_placeable ) ) ;
144
146
145
- let TextElement = defer ( ( ) =>
146
- repeat1 (
147
- either (
148
- text_char ,
149
- text_cont ) )
147
+ let inline_text = defer ( ( ) =>
148
+ repeat1 ( text_char )
150
149
. map ( join )
151
150
. chain ( into ( FTL . TextElement ) ) ) ;
152
151
153
- let Placeable = defer ( ( ) =>
152
+ let block_text = defer ( ( ) =>
153
+ sequence (
154
+ blank_block . chain ( into ( FTL . TextElement ) ) . abstract ,
155
+ blank_inline ,
156
+ indented_char . chain ( into ( FTL . TextElement ) ) . abstract ,
157
+ maybe ( inline_text . abstract )
158
+ )
159
+ . map ( keep_abstract ) ) ;
160
+
161
+ let inline_placeable = defer ( ( ) =>
154
162
sequence (
155
163
string ( "{" ) ,
156
164
maybe ( blank ) ,
@@ -163,6 +171,13 @@ let Placeable = defer(() =>
163
171
. map ( element_at ( 2 ) )
164
172
. chain ( into ( FTL . Placeable ) ) ) ;
165
173
174
+ let block_placeable = defer ( ( ) =>
175
+ sequence (
176
+ blank_block . chain ( into ( FTL . TextElement ) ) . abstract ,
177
+ maybe ( blank_inline ) ,
178
+ inline_placeable . abstract )
179
+ . map ( keep_abstract ) ) ;
180
+
166
181
/* ------------------------------------------------------------------- */
167
182
/* Rules for validating expressions in Placeables and as selectors of
168
183
* SelectExpressions are documented in spec/valid.md and enforced in
@@ -177,7 +192,7 @@ let InlineExpression = defer(() =>
177
192
VariantExpression ,
178
193
MessageReference ,
179
194
TermReference ,
180
- Placeable ) ) ;
195
+ inline_placeable ) ) ;
181
196
182
197
/* -------- */
183
198
/* Literals */
@@ -417,18 +432,13 @@ let text_char = defer(() =>
417
432
not ( string ( "{" ) ) ,
418
433
regular_char ) ) ) ;
419
434
420
- let text_cont = defer ( ( ) =>
421
- sequence (
422
- blank_block . abstract ,
423
- blank_inline ,
424
- and (
425
- not ( string ( "." ) ) ,
426
- not ( string ( "*" ) ) ,
427
- not ( string ( "[" ) ) ,
428
- not ( string ( "}" ) ) ,
429
- text_char ) . abstract )
430
- . map ( keep_abstract )
431
- . map ( join ) ) ;
435
+ let indented_char = defer ( ( ) =>
436
+ and (
437
+ not ( string ( "." ) ) ,
438
+ not ( string ( "*" ) ) ,
439
+ not ( string ( "[" ) ) ,
440
+ not ( string ( "}" ) ) ,
441
+ text_char ) ) ;
432
442
433
443
let quoted_text_char =
434
444
either (
0 commit comments