Index: trunk/flexbisonparse/parsetree.h |
— | — | @@ -13,7 +13,8 @@ |
14 | 14 | Article, Paragraph, Heading, TextBlock, TextToken, ExtensionToken, |
15 | 15 | Newlines, PreBlock, PreLine, Bold, Italics, Comment, |
16 | 16 | LinkEtc, LinkTarget, LinkOption, Template, TemplateVar, |
17 | | - Table, TableRow, TableCell, TableHead /* 20 */, Attribute, AttributeGroup, |
| 17 | + Table, TableRow, TableCell, TableHead /* 20 */, TableCaption, |
| 18 | + Attribute, AttributeGroup, |
18 | 19 | |
19 | 20 | /* After first parse */ |
20 | 21 | ListBlock, ListLine, ListBullet, ListNumbered, |
— | — | @@ -115,6 +116,7 @@ |
116 | 117 | Node convertTableRowToText (int info); |
117 | 118 | Node convertTableCellToText (int info); |
118 | 119 | Node convertTableHeadToText (int info); |
| 120 | +Node convertTableCaptionToText (int info); |
119 | 121 | Node convertHeadingToText (int info); |
120 | 122 | |
121 | 123 | /* Parameter must be a TextBlock. Turns something like |
Index: trunk/flexbisonparse/wikiparse.y |
— | — | @@ -36,15 +36,15 @@ |
37 | 37 | textelement textelementnoboit textelementnobold textelementnoital textelementinlink |
38 | 38 | textnoboit textnobold textnoital textinlink textorempty zeroormorenewlines |
39 | 39 | zeroormorenewlinessave textintbl textelementintbl textintmpl textelementintmpl |
40 | | - template templatevar |
| 40 | + template templatevar tablecaption |
41 | 41 | TEXT EXTENSION |
42 | 42 | %type <ad> ATTRIBUTE |
43 | | -%type <num> HEADING ENDHEADING TABLEBEGIN TABLECELL TABLEHEAD TABLEROW EQUALS ATTRAPO ATTRQ |
| 43 | +%type <num> HEADING ENDHEADING EQUALS ATTRAPO ATTRQ |
| 44 | + TABLEBEGIN TABLECELL TABLEHEAD TABLEROW TABLECAPTION |
44 | 45 | |
45 | 46 | %token EXTENSION BEGINCOMMENT TEXT ENDCOMMENT OPENLINK OPENDBLSQBR CLOSEDBLSQBR PIPE |
46 | 47 | NEWLINE PRELINE LISTBULLET LISTNUMBERED HEADING ENDHEADING APO5 APO3 APO2 TABLEBEGIN |
47 | | - TABLECELL TABLEHEAD TABLEROW TABLEEND ATTRIBUTE EQUALS ATTRAPO ATTRQ |
48 | | - // Not yet used: |
| 48 | + TABLECELL TABLEHEAD TABLEROW TABLEEND TABLECAPTION ATTRIBUTE EQUALS ATTRAPO ATTRQ |
49 | 49 | OPENPENTUPLECURLY CLOSEPENTUPLECURLY OPENTEMPLATEVAR CLOSETEMPLATEVAR OPENTEMPLATE |
50 | 50 | CLOSETEMPLATE |
51 | 51 | |
— | — | @@ -283,6 +283,8 @@ |
284 | 284 | { debugf ("tablerow#8 "); $$ = 0; } |
285 | 285 | | TABLEROW |
286 | 286 | { debugf ("tablerow#9 "); $$ = 0; } |
| 287 | + | tablecaption |
| 288 | + { debugf ("tablerow#10 "); $$ = $1; } |
287 | 289 | |
288 | 290 | tablecells : tablecell { debugf ("tablecells#1 "); $$ = $1; } |
289 | 291 | | tablecells tablecell { debugf ("tablecells#2 "); $$ = nodeAddSibling ($1, $2); } |
— | — | @@ -317,6 +319,19 @@ |
318 | 320 | | oneormorenewlines blocksintbl |
319 | 321 | { debugf ("tablecellcontents#2 "); $$ = $2; } |
320 | 322 | |
| 323 | +tablecaption : TABLECAPTION attributes PIPE textintbl |
| 324 | + { debugf ("tablecaption#1 "); $$ = nodeAddChild2 (newNode (TableCaption), $2, $4); } |
| 325 | + | TABLECAPTION attributes textintbl |
| 326 | + { debugf ("tablecaption#2 "); $$ = nodeAddChild (newNode (TableCaption), makeTextBlock (convertAttributesToText ($2), $3)); } |
| 327 | + | TABLECAPTION textintbl |
| 328 | + { debugf ("tablecaption#3 "); $$ = nodeAddChild (newNode (TableCaption), $2); } |
| 329 | + | TABLECAPTION attributes PIPE |
| 330 | + { debugf ("tablecaption#4 "); $$ = nodeAddChild (newNode (TableCaption), makeTextBlock (convertAttributesToText ($2), newNodeS (TextToken, "|"))); } |
| 331 | + | TABLECAPTION attributes |
| 332 | + { debugf ("tablecaption#5 "); $$ = nodeAddChild (newNode (TableCaption), convertAttributesToText ($2)); } |
| 333 | + | TABLECAPTION |
| 334 | + { debugf ("tablecaption#6 "); $$ = 0; } |
| 335 | + |
321 | 336 | /* In order to reduce the second one (ATTRIBUTE EQUALS TEXT) correctly, this rule must |
322 | 337 | * be further up than textelement. */ |
323 | 338 | attribute : ATTRIBUTE |
— | — | @@ -363,15 +378,16 @@ |
364 | 379 | | TABLEROW { debugf ("textelement#11 "); $$ = convertTableRowToText ($1); } |
365 | 380 | | TABLECELL { debugf ("textelement#12 "); $$ = convertTableCellToText ($1); } |
366 | 381 | | TABLEHEAD { debugf ("textelement#13 "); $$ = convertTableHeadToText ($1); } |
367 | | - | ATTRIBUTE { debugf ("textelement#14 "); $$ = convertAttributeDataToText ($1); } |
368 | | - | CLOSEPENTUPLECURLY { debugf ("textelement#15 "); $$ = newNodeS (TextToken, "}}}}}"); } |
369 | | - | CLOSETEMPLATEVAR { debugf ("textelement#16 "); $$ = newNodeS (TextToken, "}}}"); } |
370 | | - | CLOSETEMPLATE { debugf ("textelement#17 "); $$ = newNodeS (TextToken, "}}"); } |
371 | | - | comment { debugf ("textelement#18 "); $$ = $1; } |
372 | | - | linketc { debugf ("textelement#19 "); $$ = $1; } |
373 | | - | italicsorbold { debugf ("textelement#20 "); $$ = $1; } |
374 | | - | template { debugf ("textelement#21 "); $$ = $1; } |
375 | | - | templatevar { debugf ("textelement#22 "); $$ = $1; } |
| 382 | + | TABLECAPTION { debugf ("textelement#14 "); $$ = convertTableCaptionToText ($1); } |
| 383 | + | ATTRIBUTE { debugf ("textelement#15 "); $$ = convertAttributeDataToText ($1); } |
| 384 | + | CLOSEPENTUPLECURLY { debugf ("textelement#16 "); $$ = newNodeS (TextToken, "}}}}}"); } |
| 385 | + | CLOSETEMPLATEVAR { debugf ("textelement#17 "); $$ = newNodeS (TextToken, "}}}"); } |
| 386 | + | CLOSETEMPLATE { debugf ("textelement#18 "); $$ = newNodeS (TextToken, "}}"); } |
| 387 | + | comment { debugf ("textelement#19 "); $$ = $1; } |
| 388 | + | linketc { debugf ("textelement#20 "); $$ = $1; } |
| 389 | + | italicsorbold { debugf ("textelement#21 "); $$ = $1; } |
| 390 | + | template { debugf ("textelement#22 "); $$ = $1; } |
| 391 | + | templatevar { debugf ("textelement#23 "); $$ = $1; } |
376 | 392 | |
377 | 393 | textelementnoital : TEXT { debugf ("textelementnoital#1 "); $$ = $1; } |
378 | 394 | | EXTENSION { debugf ("textelementnoital#2 "); $$ = $1; } |
— | — | @@ -382,15 +398,16 @@ |
383 | 399 | | TABLEROW { debugf ("textelementnoital#7 "); $$ = convertTableRowToText ($1); } |
384 | 400 | | TABLECELL { debugf ("textelementnoital#8 "); $$ = convertTableCellToText ($1); } |
385 | 401 | | TABLEHEAD { debugf ("textelementnoital#9 "); $$ = convertTableHeadToText ($1); } |
386 | | - | ATTRIBUTE { debugf ("textelementnoital#10 "); $$ = convertAttributeDataToText ($1); } |
387 | | - | CLOSEPENTUPLECURLY { debugf ("textelementnoital#11 "); $$ = newNodeS (TextToken, "}}}}}"); } |
388 | | - | CLOSETEMPLATEVAR { debugf ("textelementnoital#12 "); $$ = newNodeS (TextToken, "}}}"); } |
389 | | - | CLOSETEMPLATE { debugf ("textelementnoital#13 "); $$ = newNodeS (TextToken, "}}"); } |
390 | | - | comment { debugf ("textelementnoital#14 "); $$ = $1; } |
391 | | - | linketc { debugf ("textelementnoital#15 "); $$ = $1; } |
392 | | - | boldnoitalics { debugf ("textelementnoital#16 "); $$ = $1; } |
393 | | - | template { debugf ("textelementnoital#17 "); $$ = $1; } |
394 | | - | templatevar { debugf ("textelementnoital#18 "); $$ = $1; } |
| 402 | + | TABLECAPTION { debugf ("textelementnoital#10 "); $$ = convertTableCaptionToText ($1); } |
| 403 | + | ATTRIBUTE { debugf ("textelementnoital#11 "); $$ = convertAttributeDataToText ($1); } |
| 404 | + | CLOSEPENTUPLECURLY { debugf ("textelementnoital#12 "); $$ = newNodeS (TextToken, "}}}}}"); } |
| 405 | + | CLOSETEMPLATEVAR { debugf ("textelementnoital#13 "); $$ = newNodeS (TextToken, "}}}"); } |
| 406 | + | CLOSETEMPLATE { debugf ("textelementnoital#14 "); $$ = newNodeS (TextToken, "}}"); } |
| 407 | + | comment { debugf ("textelementnoital#15 "); $$ = $1; } |
| 408 | + | linketc { debugf ("textelementnoital#16 "); $$ = $1; } |
| 409 | + | boldnoitalics { debugf ("textelementnoital#17 "); $$ = $1; } |
| 410 | + | template { debugf ("textelementnoital#18 "); $$ = $1; } |
| 411 | + | templatevar { debugf ("textelementnoital#19 "); $$ = $1; } |
395 | 412 | |
396 | 413 | textelementnobold : TEXT { debugf ("textelementnobold#1 "); $$ = $1; } |
397 | 414 | | EXTENSION { debugf ("textelementnobold#2 "); $$ = $1; } |
— | — | @@ -401,15 +418,16 @@ |
402 | 419 | | TABLEROW { debugf ("textelementnobold#7 "); $$ = convertTableRowToText ($1); } |
403 | 420 | | TABLECELL { debugf ("textelementnobold#8 "); $$ = convertTableCellToText ($1); } |
404 | 421 | | TABLEHEAD { debugf ("textelementnobold#9 "); $$ = convertTableHeadToText ($1); } |
405 | | - | ATTRIBUTE { debugf ("textelementnobold#10 "); $$ = convertAttributeDataToText ($1); } |
406 | | - | CLOSEPENTUPLECURLY { debugf ("textelementnobold#11 "); $$ = newNodeS (TextToken, "}}}}}"); } |
407 | | - | CLOSETEMPLATEVAR { debugf ("textelementnobold#12 "); $$ = newNodeS (TextToken, "}}}"); } |
408 | | - | CLOSETEMPLATE { debugf ("textelementnobold#13 "); $$ = newNodeS (TextToken, "}}"); } |
409 | | - | comment { debugf ("textelementnobold#14 "); $$ = $1; } |
410 | | - | linketc { debugf ("textelementnobold#15 "); $$ = $1; } |
411 | | - | italicsnobold { debugf ("textelementnobold#16 "); $$ = $1; } |
412 | | - | template { debugf ("textelementnobold#17 "); $$ = $1; } |
413 | | - | templatevar { debugf ("textelementnobold#18 "); $$ = $1; } |
| 422 | + | TABLECAPTION { debugf ("textelementnobold#10 "); $$ = convertTableCaptionToText ($1); } |
| 423 | + | ATTRIBUTE { debugf ("textelementnobold#11 "); $$ = convertAttributeDataToText ($1); } |
| 424 | + | CLOSEPENTUPLECURLY { debugf ("textelementnobold#12 "); $$ = newNodeS (TextToken, "}}}}}"); } |
| 425 | + | CLOSETEMPLATEVAR { debugf ("textelementnobold#13 "); $$ = newNodeS (TextToken, "}}}"); } |
| 426 | + | CLOSETEMPLATE { debugf ("textelementnobold#14 "); $$ = newNodeS (TextToken, "}}"); } |
| 427 | + | comment { debugf ("textelementnobold#15 "); $$ = $1; } |
| 428 | + | linketc { debugf ("textelementnobold#16 "); $$ = $1; } |
| 429 | + | italicsnobold { debugf ("textelementnobold#17 "); $$ = $1; } |
| 430 | + | template { debugf ("textelementnobold#18 "); $$ = $1; } |
| 431 | + | templatevar { debugf ("textelementnobold#19 "); $$ = $1; } |
414 | 432 | |
415 | 433 | textelementnoboit : TEXT { debugf ("textelementnoboit#1 "); $$ = $1; } |
416 | 434 | | EXTENSION { debugf ("textelementnoboit#2 "); $$ = $1; } |
— | — | @@ -420,14 +438,15 @@ |
421 | 439 | | TABLEROW { debugf ("textelementnoboit#7 "); $$ = convertTableRowToText ($1); } |
422 | 440 | | TABLECELL { debugf ("textelementnoboit#8 "); $$ = convertTableCellToText ($1); } |
423 | 441 | | TABLEHEAD { debugf ("textelementnoboit#9 "); $$ = convertTableHeadToText ($1); } |
424 | | - | ATTRIBUTE { debugf ("textelementnoital#10 "); $$ = convertAttributeDataToText ($1); } |
425 | | - | CLOSEPENTUPLECURLY { debugf ("textelementnobold#11 "); $$ = newNodeS (TextToken, "}}}}}"); } |
426 | | - | CLOSETEMPLATEVAR { debugf ("textelementnobold#12 "); $$ = newNodeS (TextToken, "}}}"); } |
427 | | - | CLOSETEMPLATE { debugf ("textelementnobold#13 "); $$ = newNodeS (TextToken, "}}"); } |
428 | | - | comment { debugf ("textelementnoboit#14 "); $$ = $1; } |
429 | | - | linketc { debugf ("textelementnoboit#15 "); $$ = $1; } |
430 | | - | template { debugf ("textelementnoboit#16 "); $$ = $1; } |
431 | | - | templatevar { debugf ("textelementnoboit#17 "); $$ = $1; } |
| 442 | + | TABLECAPTION { debugf ("textelementnoboit#10 "); $$ = convertTableCaptionToText ($1); } |
| 443 | + | ATTRIBUTE { debugf ("textelementnoboit#11 "); $$ = convertAttributeDataToText ($1); } |
| 444 | + | CLOSEPENTUPLECURLY { debugf ("textelementnobold#12 "); $$ = newNodeS (TextToken, "}}}}}"); } |
| 445 | + | CLOSETEMPLATEVAR { debugf ("textelementnobold#13 "); $$ = newNodeS (TextToken, "}}}"); } |
| 446 | + | CLOSETEMPLATE { debugf ("textelementnobold#14 "); $$ = newNodeS (TextToken, "}}"); } |
| 447 | + | comment { debugf ("textelementnoboit#15 "); $$ = $1; } |
| 448 | + | linketc { debugf ("textelementnoboit#16 "); $$ = $1; } |
| 449 | + | template { debugf ("textelementnoboit#17 "); $$ = $1; } |
| 450 | + | templatevar { debugf ("textelementnoboit#18 "); $$ = $1; } |
432 | 451 | |
433 | 452 | textelementintbl : TEXT { debugf ("textelementintbl#1 "); $$ = $1; } |
434 | 453 | | EXTENSION { debugf ("textelementintbl#2 "); $$ = $1; } |
— | — | @@ -457,15 +476,16 @@ |
458 | 477 | | TABLEROW { debugf ("textelementinlink#9 "); $$ = convertTableRowToText ($1); } |
459 | 478 | | TABLECELL { debugf ("textelementinlink#10 "); $$ = convertTableCellToText ($1); } |
460 | 479 | | TABLEHEAD { debugf ("textelementinlink#11 "); $$ = convertTableHeadToText ($1); } |
461 | | - | ATTRIBUTE { debugf ("textelementinlink#12 "); $$ = convertAttributeDataToText ($1); } |
462 | | - | CLOSEPENTUPLECURLY { debugf ("textelementinlink#13 "); $$ = newNodeS (TextToken, "}}}}}"); } |
463 | | - | CLOSETEMPLATEVAR { debugf ("textelementinlink#14 "); $$ = newNodeS (TextToken, "}}}"); } |
464 | | - | CLOSETEMPLATE { debugf ("textelementinlink#15 "); $$ = newNodeS (TextToken, "}}"); } |
465 | | - | comment { debugf ("textelementinlink#16 "); $$ = $1; } |
466 | | - | linketc { debugf ("textelementinlink#17 "); $$ = $1; } |
467 | | - | italicsorbold { debugf ("textelementinlink#18 "); $$ = $1; } |
468 | | - | template { debugf ("textelementinlink#19 "); $$ = $1; } |
469 | | - | templatevar { debugf ("textelementinlink#20 "); $$ = $1; } |
| 480 | + | TABLECAPTION { debugf ("textelementinlink#12 "); $$ = convertTableCaptionToText ($1); } |
| 481 | + | ATTRIBUTE { debugf ("textelementinlink#13 "); $$ = convertAttributeDataToText ($1); } |
| 482 | + | CLOSEPENTUPLECURLY { debugf ("textelementinlink#14 "); $$ = newNodeS (TextToken, "}}}}}"); } |
| 483 | + | CLOSETEMPLATEVAR { debugf ("textelementinlink#15 "); $$ = newNodeS (TextToken, "}}}"); } |
| 484 | + | CLOSETEMPLATE { debugf ("textelementinlink#16 "); $$ = newNodeS (TextToken, "}}"); } |
| 485 | + | comment { debugf ("textelementinlink#17 "); $$ = $1; } |
| 486 | + | linketc { debugf ("textelementinlink#18 "); $$ = $1; } |
| 487 | + | italicsorbold { debugf ("textelementinlink#19 "); $$ = $1; } |
| 488 | + | template { debugf ("textelementinlink#20 "); $$ = $1; } |
| 489 | + | templatevar { debugf ("textelementinlink#21 "); $$ = $1; } |
470 | 490 | |
471 | 491 | textelementintmpl : TEXT { debugf ("textelementintmpl#1 "); $$ = $1; } |
472 | 492 | | EXTENSION { debugf ("textelementintmpl#2 "); $$ = $1; } |
— | — | @@ -480,12 +500,13 @@ |
481 | 501 | | TABLEROW { debugf ("textelementintmpl#11 "); $$ = convertTableRowToText ($1); } |
482 | 502 | | TABLECELL { debugf ("textelementintmpl#12 "); $$ = convertTableCellToText ($1); } |
483 | 503 | | TABLEHEAD { debugf ("textelementintmpl#13 "); $$ = convertTableHeadToText ($1); } |
484 | | - | ATTRIBUTE { debugf ("textelementintmpl#14 "); $$ = convertAttributeDataToText ($1); } |
485 | | - | comment { debugf ("textelementintmpl#15 "); $$ = $1; } |
486 | | - | linketc { debugf ("textelementintmpl#16 "); $$ = $1; } |
487 | | - | italicsorbold { debugf ("textelementintmpl#17 "); $$ = $1; } |
488 | | - | template { debugf ("textelementintmpl#18 "); $$ = $1; } |
489 | | - | templatevar { debugf ("textelementintmpl#19 "); $$ = $1; } |
| 504 | + | TABLECAPTION { debugf ("textelementintmpl#14 "); $$ = convertTableCaptionToText ($1); } |
| 505 | + | ATTRIBUTE { debugf ("textelementintmpl#15 "); $$ = convertAttributeDataToText ($1); } |
| 506 | + | comment { debugf ("textelementintmpl#16 "); $$ = $1; } |
| 507 | + | linketc { debugf ("textelementintmpl#17 "); $$ = $1; } |
| 508 | + | italicsorbold { debugf ("textelementintmpl#18 "); $$ = $1; } |
| 509 | + | template { debugf ("textelementintmpl#19 "); $$ = $1; } |
| 510 | + | templatevar { debugf ("textelementintmpl#20 "); $$ = $1; } |
490 | 511 | |
491 | 512 | template : OPENTEMPLATE textintmpl CLOSETEMPLATE |
492 | 513 | { debugf ("template#1 "); $$ = nodeAddChild (newNode (Template), $2); } |
Index: trunk/flexbisonparse/wikilex.l |
— | — | @@ -105,9 +105,10 @@ |
106 | 106 | "{|"" "* { BEGIN(attributes); debuglex ("TABLEBEGIN "); yylval.num = yyleng-2; return TABLEBEGIN; } |
107 | 107 | "||"" "* { yylval.num = 2*(yyleng-2); BEGIN(attributes); debuglex2 ("TABLECELL(%u) ", yylval.num); return TABLECELL; } |
108 | 108 | ^"|"" "* { yylval.num = 2*(yyleng-1)+1; BEGIN(attributes); debuglex2 ("TABLECELL(%u) ", yylval.num); return TABLECELL; } |
109 | | -"!!"" "* { BEGIN(attributes); debuglex ("TABLEHEAD "); yylval.num = 2*(yyleng-2); return TABLEHEAD; } |
110 | | -^"!"" "* { BEGIN(attributes); debuglex ("TABLEHEAD "); yylval.num = 2*(yyleng-1)+1; return TABLEHEAD; } |
111 | | -"|""-"+" "* { BEGIN(attributes); debuglex ("TABLEROW "); yylval.num = encodeTableRowInfo (yytext, yyleng); return TABLEROW; } |
| 109 | +"!!"" "* { BEGIN(attributes); debuglex ("TABLEHEAD "); yylval.num = 2*(yyleng-2); return TABLEHEAD; } |
| 110 | +^"!"" "* { BEGIN(attributes); debuglex ("TABLEHEAD "); yylval.num = 2*(yyleng-1)+1; return TABLEHEAD; } |
| 111 | +"|""-"+" "* { BEGIN(attributes); debuglex ("TABLEROW "); yylval.num = encodeTableRowInfo (yytext, yyleng); return TABLEROW; } |
| 112 | +"|+"" "* { BEGIN(attributes); debuglex ("TABLECAPTION "); yylval.num = yyleng-2; return TABLECAPTION; } |
112 | 113 | "|}" { BEGIN(cannotbelistorheadingorpre); debuglex ("TABLEEND "); return TABLEEND; } |
113 | 114 | |
114 | 115 | <attributes>[-a-zA-Z:_]+" "* { |
Index: trunk/flexbisonparse/parsetree.c |
— | — | @@ -575,6 +575,11 @@ |
576 | 576 | return newNodeS (TextToken, addSpaces (info % 2 ? "!" : "!!", info/2)); |
577 | 577 | } |
578 | 578 | |
| 579 | +Node convertTableCaptionToText (int info) |
| 580 | +{ |
| 581 | + return newNodeS (TextToken, addSpaces ("|+", info)); |
| 582 | +} |
| 583 | + |
579 | 584 | Node convertHeadingToText (int info) |
580 | 585 | { |
581 | 586 | int i; |
— | — | @@ -756,6 +761,7 @@ |
757 | 762 | node->type == TableRow ? "tablerow" : |
758 | 763 | node->type == TableCell ? "tablecell" : |
759 | 764 | node->type == TableHead ? "tablehead" : |
| 765 | + node->type == TableCaption ? "caption" : |
760 | 766 | node->type == AttributeGroup? "attrs" : |
761 | 767 | |
762 | 768 | /* Fallback value */ |
Index: trunk/flexbisonparse/test.txt |
— | — | @@ -8,8 +8,9 @@ |
9 | 9 | ** graphics |
10 | 10 | ** sound |
11 | 11 | |
12 | | -{| || Version 1 || not bad |
13 | | -|- || Version 2 || much better |} |
| 12 | +{| !! Version 1 || not bad |
| 13 | +|- !! Version 2 || much better |
| 14 | +|+ An informative table |} |
14 | 15 | |
15 | 16 | This is a || token in the middle of text. |
16 | 17 | |