|
20 | 20 | * <require> :== \REQUIRE + <open-text> |
21 | 21 | * <ensure> :== \ENSURE + <open-text> |
22 | 22 | * |
23 | | - * <block> :== ( <control> | <function> |
24 | | - * | <statement> | <comment> | <call> )[0..n] |
| 23 | + * <block> :== ( <control> | <function> | <statement> | |
| 24 | + * <comment> )[0..n] |
25 | 25 | * |
26 | 26 | * <control> :== <if> | <for> | <while> |
27 | 27 | * <if> :== \IF{<cond>} + <block> |
|
41 | 41 | * |
42 | 42 | * <comment> :== \COMMENT{<close-text>} |
43 | 43 | * |
44 | | - * <call> :== \CALL{<name>}({<close-text>}) |
45 | | - * |
46 | 44 | * <cond> :== <close-text> |
47 | | - * <open-text> :== <atom> + <open-text> | { <close-text> } | <empty> |
48 | | - * <close-text> :== <atom> + <close-text> | { <close-text> } | <empty> |
| 45 | + * <open-text> :== ( <atom> | <call> ) + <open-text> | |
| 46 | + * { <close-text> } | <empty> |
| 47 | + * <close-text> :== ( <atom> | <call> ) + <close-text> | |
| 48 | + * { <close-text> } | <empty> |
49 | 49 | * |
50 | 50 | * <atom> :== <ordinary>[1..n] | <special> | <symbol> |
51 | 51 | * | <size> | <font> | <bool> | <math> |
52 | 52 | * <name> :== <ordinary> |
53 | 53 | * |
| 54 | + * <call> :== \CALL{<name>}({<close-text>}) |
54 | 55 | * <special> :== \\ | \{ | \} | \$ | \& | \# | \% | \_ |
55 | 56 | * <cond-symbol> :== \AND | \OR | \NOT | \TRUE | \FALSE | \TO |
56 | 57 | * <text-symbol> :== \textbackslash |
@@ -239,9 +240,6 @@ Parser.prototype._parseBlock = function() { |
239 | 240 | var commentNode = this._parseComment(); |
240 | 241 | if (commentNode) { blockNode.addChild(commentNode); continue; } |
241 | 242 |
|
242 | | - var callNode = this._parseCall(); |
243 | | - if (callNode) { blockNode.addChild(callNode); continue; } |
244 | | - |
245 | 243 | break; |
246 | 244 | } |
247 | 245 |
|
@@ -390,17 +388,19 @@ Parser.prototype._parseText = function(openOrClose) { |
390 | 388 | var textNode = new ParseNode(openOrClose + '-text'); |
391 | 389 | // any whitespace between Atom and CloseText |
392 | 390 | var anyWhitespace = false; |
393 | | - var atomNode; |
| 391 | + var subTextNode; |
394 | 392 | while (true) { |
395 | | - atomNode = this._parseAtom(); |
396 | | - if (atomNode) { |
397 | | - if (anyWhitespace) atomNode.whitespace |= anyWhitespace; |
398 | | - textNode.addChild(atomNode); |
| 393 | + // atom or call |
| 394 | + subTextNode = this._parseAtom() || this._parseCall(); |
| 395 | + if (subTextNode) { |
| 396 | + if (anyWhitespace) subTextNode.whitespace |= anyWhitespace; |
| 397 | + textNode.addChild(subTextNode); |
399 | 398 | continue; |
400 | 399 | } |
401 | 400 |
|
| 401 | + // or close text |
402 | 402 | if (this._lexer.accept('open')) { |
403 | | - var subTextNode = this._parseCloseText(); |
| 403 | + subTextNode = this._parseCloseText(); |
404 | 404 |
|
405 | 405 | anyWhitespace = this._lexer.get().whitespace; |
406 | 406 | subTextNode.whitespace = anyWhitespace; |
|
0 commit comments