-
Notifications
You must be signed in to change notification settings - Fork 2
/
parser.leg.go
12824 lines (12713 loc) · 236 KB
/
parser.leg.go
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Original C version https://github.com/jgm/peg-markdown/
* Copyright 2008 John MacFarlane (jgm at berkeley dot edu).
*
* Modifications and translation from C into Go
* based on markdown_parser.leg and utility_functions.c
* Copyright 2010 Michael Teichgräber (mt at wmipf dot de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License or the MIT
* license. See LICENSE for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
package rst
// PEG grammar and parser actions for restructuredtext syntax.
import (
"fmt"
"io"
"log"
"strings"
)
const (
parserIfaceVersion_18 = iota
)
// Semantic value of a parsing action.
type element struct {
key int
contents
children *element
next *element
}
// Information (label, URL and title) for a link.
type link struct {
label *element
url string
title string
}
// code contents
type code struct {
lang string
}
// Union for contents of an Element (string, list, code, or link).
type contents struct {
str string
*link
*code
}
// Types of semantic values returned by parsers.
const (
LIST = iota /* A generic list of values. For ordered and bullet lists, see below. */
RAW /* Raw markdown to be processed further */
SPACE
LINEBREAK
ELLIPSIS
EMDASH
ENDASH
APOSTROPHE
SINGLEQUOTED
DOUBLEQUOTED
STR
LINK
IMAGE
CODE
HTML
EMPH
STRONG
STRIKE
PLAIN
PARA
LISTITEM
BULLETLIST
ORDEREDLIST
H1TITLE
H1 /* Code assumes that H1..6 are in order. */
H2
H3
H4
H5
H6
TABLE
TABLESEPARATOR
TABLECELL
CELLSPAN
TABLEROW
TABLEBODY
TABLEHEAD
CODEBLOCK
BLOCKQUOTE
VERBATIM
HTMLBLOCK
HRULE
REFERENCE
NOTE
DEFINITIONLIST
DEFTITLE
DEFDATA
numVAL
)
type state struct {
extension Extensions
heap elemHeap
tree *element /* Results of parse. */
references *element /* List of link references found. */
notes *element /* List of footnotes found. */
}
const (
ruleDoc = iota
ruleDocblock
ruleBlock
rulePara
rulePlain
ruleSetextBottom
ruleHeadingTitle
ruleHeading
ruleImage
ruleCodeBlock
ruleDoctestBlock
ruleBlockQuoteRaw
ruleBlockQuoteChunk
ruleBlockQuote
ruleNonblankIndentedLine
ruleVerbatimChunk
ruleVerbatim
ruleHorizontalRule
ruleTable
ruleSimpleTable
ruleGridTable
ruleHeaderLessGridTable
ruleGridTableHeader
ruleGridTableBody
ruleGridTableRow
ruleTableCell
ruleGridTableHeaderSep
ruleGridTableSep
ruleBullet
ruleBulletList
ruleListTight
ruleListLoose
ruleListItem
ruleListItemTight
ruleListBlock
ruleListContinuationBlock
ruleEnumerator
ruleOrderedList
ruleListBlockLine
ruleHtmlBlockOpenAddress
ruleHtmlBlockCloseAddress
ruleHtmlBlockAddress
ruleHtmlBlockOpenBlockquote
ruleHtmlBlockCloseBlockquote
ruleHtmlBlockBlockquote
ruleHtmlBlockOpenCenter
ruleHtmlBlockCloseCenter
ruleHtmlBlockCenter
ruleHtmlBlockOpenDir
ruleHtmlBlockCloseDir
ruleHtmlBlockDir
ruleHtmlBlockOpenDiv
ruleHtmlBlockCloseDiv
ruleHtmlBlockDiv
ruleHtmlBlockOpenDl
ruleHtmlBlockCloseDl
ruleHtmlBlockDl
ruleHtmlBlockOpenFieldset
ruleHtmlBlockCloseFieldset
ruleHtmlBlockFieldset
ruleHtmlBlockOpenForm
ruleHtmlBlockCloseForm
ruleHtmlBlockForm
ruleHtmlBlockOpenH1
ruleHtmlBlockCloseH1
ruleHtmlBlockH1
ruleHtmlBlockOpenH2
ruleHtmlBlockCloseH2
ruleHtmlBlockH2
ruleHtmlBlockOpenH3
ruleHtmlBlockCloseH3
ruleHtmlBlockH3
ruleHtmlBlockOpenH4
ruleHtmlBlockCloseH4
ruleHtmlBlockH4
ruleHtmlBlockOpenH5
ruleHtmlBlockCloseH5
ruleHtmlBlockH5
ruleHtmlBlockOpenH6
ruleHtmlBlockCloseH6
ruleHtmlBlockH6
ruleHtmlBlockOpenMenu
ruleHtmlBlockCloseMenu
ruleHtmlBlockMenu
ruleHtmlBlockOpenNoframes
ruleHtmlBlockCloseNoframes
ruleHtmlBlockNoframes
ruleHtmlBlockOpenNoscript
ruleHtmlBlockCloseNoscript
ruleHtmlBlockNoscript
ruleHtmlBlockOpenOl
ruleHtmlBlockCloseOl
ruleHtmlBlockOl
ruleHtmlBlockOpenP
ruleHtmlBlockCloseP
ruleHtmlBlockP
ruleHtmlBlockOpenPre
ruleHtmlBlockClosePre
ruleHtmlBlockPre
ruleHtmlBlockOpenTable
ruleHtmlBlockCloseTable
ruleHtmlBlockTable
ruleHtmlBlockOpenUl
ruleHtmlBlockCloseUl
ruleHtmlBlockUl
ruleHtmlBlockOpenDd
ruleHtmlBlockCloseDd
ruleHtmlBlockDd
ruleHtmlBlockOpenDt
ruleHtmlBlockCloseDt
ruleHtmlBlockDt
ruleHtmlBlockOpenFrameset
ruleHtmlBlockCloseFrameset
ruleHtmlBlockFrameset
ruleHtmlBlockOpenLi
ruleHtmlBlockCloseLi
ruleHtmlBlockLi
ruleHtmlBlockOpenTbody
ruleHtmlBlockCloseTbody
ruleHtmlBlockTbody
ruleHtmlBlockOpenTd
ruleHtmlBlockCloseTd
ruleHtmlBlockTd
ruleHtmlBlockOpenTfoot
ruleHtmlBlockCloseTfoot
ruleHtmlBlockTfoot
ruleHtmlBlockOpenTh
ruleHtmlBlockCloseTh
ruleHtmlBlockTh
ruleHtmlBlockOpenThead
ruleHtmlBlockCloseThead
ruleHtmlBlockThead
ruleHtmlBlockOpenTr
ruleHtmlBlockCloseTr
ruleHtmlBlockTr
ruleHtmlBlockOpenScript
ruleHtmlBlockCloseScript
ruleHtmlBlockScript
ruleHtmlBlockOpenHead
ruleHtmlBlockCloseHead
ruleHtmlBlockHead
ruleHtmlBlockInTags
ruleHtmlBlock
ruleHtmlBlockSelfClosing
ruleHtmlBlockType
ruleStyleOpen
ruleStyleClose
ruleInStyleTags
ruleStyleBlock
ruleInlines
ruleInline
ruleSpace
ruleStr
ruleStrChunk
ruleAposChunk
ruleEscapedChar
ruleEntity
ruleEndline
ruleNormalEndline
ruleTerminalEndline
ruleLineBreak
ruleSymbol
ruleApplicationDepent
ruleUlOrStarLine
ruleStarLine
ruleUlLine
ruleWhitespace
ruleEmph
ruleStrong
ruleStrike
ruleLink
ruleReferenceLink
ruleUnquotedRefLinkUnderbar
ruleQuotedRefLinkUnderbar
ruleExplicitLink
ruleSource
ruleSourceContents
ruleTitle
ruleTitleSingle
ruleTitleDouble
ruleAutoLink
ruleEmbeddedLink
ruleAutoLinkUrl
ruleAutoLinkEmail
ruleReference
ruleQuotedReference
ruleUnquotedReference
ruleUnquotedLinkSource
ruleRefSource
ruleQuotedRefSource
ruleEmbeddedRefSource
ruleLabel
ruleRefSrc
ruleReferences
ruleTicks2
ruleCode
ruleRawHtml
ruleBlankLine
ruleQuoted
ruleHtmlAttribute
ruleHtmlComment
ruleHtmlTag
ruleEof
ruleSpacechar
ruleNonspacechar
ruleNewline
ruleSp
ruleSpnl
ruleSpecialChar
ruleNormalChar
ruleAlphanumeric
ruleAlphanumericAscii
ruleDigit
ruleHexEntity
ruleDecEntity
ruleCharEntity
ruleNonindentSpace
ruleIndent
ruleIndentedLine
ruleOptionallyIndentedLine
ruleStartList
ruleDoctestLine
ruleLine
ruleRawLine
ruleSkipBlock
ruleExtendedSpecialChar
ruleSmart
ruleApostrophe
ruleEllipsis
ruleDash
ruleEnDash
ruleEmDash
ruleSingleQuoteStart
ruleSingleQuoteEnd
ruleSingleQuoted
ruleDoubleQuoteStart
ruleDoubleQuoteEnd
ruleDoubleQuoted
ruleNoteReference
ruleRawNoteReference
ruleNote
ruleFootnote
ruleNotes
ruleRawNoteBlock
ruleDefinitionList
ruleDefinition
ruleDListTitle
ruleDefTight
ruleDefLoose
ruleDefmark
ruleDefMarker
)
type yyParser struct {
state
Buffer string
Min, Max int
rules [251]func() bool
commit func(int) bool
ResetBuffer func(string) string
}
func (p *yyParser) Parse(ruleId int) (err error) {
if p.rules[ruleId]() {
// Make sure thunkPosition is 0 (there may be a yyPop action on the stack).
p.commit(0)
return
}
return p.parseErr()
}
type errPos struct {
Line, Pos int
}
func (e *errPos) String() string {
return fmt.Sprintf("%d:%d", e.Line, e.Pos)
}
type unexpectedCharError struct {
After, At errPos
Char byte
}
func (e *unexpectedCharError) Error() string {
return fmt.Sprintf("%v: unexpected character '%c'", &e.At, e.Char)
}
type unexpectedEOFError struct {
After errPos
}
func (e *unexpectedEOFError) Error() string {
return fmt.Sprintf("%v: unexpected end of file", &e.After)
}
func (p *yyParser) parseErr() (err error) {
var pos, after errPos
pos.Line = 1
for i, c := range p.Buffer[0:] {
if c == '\n' {
pos.Line++
pos.Pos = 0
} else {
pos.Pos++
}
if i == p.Min {
if p.Min != p.Max {
after = pos
} else {
break
}
} else if i == p.Max {
break
}
}
if p.Max >= len(p.Buffer) {
if p.Min == p.Max {
err = io.EOF
} else {
err = &unexpectedEOFError{after}
}
} else {
err = &unexpectedCharError{after, pos, p.Buffer[p.Max]}
}
return
}
func (p *yyParser) Init() {
var position int
var yyp int
var yy *element
var yyval = make([]*element, 256)
actions := [...]func(string, int){
/* 0 Doc */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 1 Doc */
func(yytext string, _ int) {
a := yyval[yyp-1]
p.tree = reverse(a)
yyval[yyp-1] = a
},
/* 2 Docblock */
func(yytext string, _ int) {
p.tree = yy
},
/* 3 Para */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = a
yy.key = PARA
yyval[yyp-1] = a
},
/* 4 Plain */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = a
yy.key = PLAIN
yyval[yyp-1] = a
},
/* 5 HeadingTitle */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 6 HeadingTitle */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(H1TITLE, a)
yyval[yyp-1] = a
},
/* 7 Heading */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 8 Heading */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(getHeadingElm(string(yytext[0])), a)
yyval[yyp-1] = a
},
/* 9 Image */
func(yytext string, _ int) {
l := yyval[yyp-1]
a := yyval[yyp-2]
t := yyval[yyp-3]
g := yyval[yyp-4]
tt := p.mkElem(LIST)
title := ""
if a != nil && a.contents.str != "" {
title = a.contents.str
}
tt = p.mkLink(p.mkString(l.contents.str), l.contents.str, title)
tt.key = IMAGE
if t != nil {
gg := p.mkLink(p.mkString(t.contents.str), t.contents.str, "")
gg.children = tt
yy = gg
} else {
yy = tt
yy.children = nil
}
a = nil
t = nil
g = nil
l = nil
yyval[yyp-3] = t
yyval[yyp-4] = g
yyval[yyp-1] = l
yyval[yyp-2] = a
},
/* 10 CodeBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
l := yyval[yyp-2]
a = cons(yy, a)
yyval[yyp-2] = l
yyval[yyp-1] = a
},
/* 11 CodeBlock */
func(yytext string, _ int) {
l := yyval[yyp-2]
a := yyval[yyp-1]
yy = p.mkCodeBlock(a, l.contents.str)
l = nil
yyval[yyp-2] = l
yyval[yyp-1] = a
},
/* 12 DoctestBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 13 DoctestBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 14 DoctestBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkCodeBlock(a, "python")
yyval[yyp-1] = a
},
/* 15 BlockQuoteRaw */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 16 BlockQuoteRaw */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, true)
yy.key = RAW
yyval[yyp-1] = a
},
/* 17 BlockQuoteChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(p.mkString("\n"), a)
yyval[yyp-1] = a
},
/* 18 BlockQuoteChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 19 BlockQuoteChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, false)
yyval[yyp-1] = a
},
/* 20 BlockQuote */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 21 BlockQuote */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkElem(BLOCKQUOTE)
yy.children = a
yyval[yyp-1] = a
},
/* 22 VerbatimChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(p.mkString("\n"), a)
yyval[yyp-1] = a
},
/* 23 VerbatimChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 24 VerbatimChunk */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, false)
yyval[yyp-1] = a
},
/* 25 Verbatim */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 26 Verbatim */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, false)
yy.key = VERBATIM
yyval[yyp-1] = a
},
/* 27 HorizontalRule */
func(yytext string, _ int) {
yy = p.mkElem(HRULE)
},
/* 28 GridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy.key = TABLEHEAD
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 29 GridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = yy
yyval[yyp-1] = a
},
/* 30 GridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 31 GridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(TABLE, a)
yyval[yyp-1] = a
},
/* 32 HeaderLessGridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 33 HeaderLessGridTable */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(TABLE, a)
yyval[yyp-1] = a
},
/* 34 GridTableHeader */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 35 GridTableHeader */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(TABLEBODY, a)
yyval[yyp-1] = a
},
/* 36 GridTableBody */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 37 GridTableBody */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(TABLEBODY, a)
yyval[yyp-1] = a
},
/* 38 GridTableRow */
func(yytext string, _ int) {
a := yyval[yyp-1]
// TODO: support inline text
raw := p.mkString(yytext)
raw.key = RAW
yy = p.mkElem(TABLECELL)
yy.children = raw
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 39 GridTableRow */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(TABLEROW, a)
yyval[yyp-1] = a
},
/* 40 TableCell */
func(yytext string, _ int) {
a := yyval[yyp-1]
yyval[yyp-1] = a
},
/* 41 BulletList */
func(yytext string, _ int) {
yy.key = BULLETLIST
},
/* 42 ListTight */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 43 ListTight */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkList(LIST, a)
yyval[yyp-1] = a
},
/* 44 ListLoose */
func(yytext string, _ int) {
a := yyval[yyp-1]
b := yyval[yyp-2]
li := b.children
li.contents.str += "\n\n"
a = cons(b, a)
yyval[yyp-1] = a
yyval[yyp-2] = b
},
/* 45 ListLoose */
func(yytext string, _ int) {
a := yyval[yyp-1]
b := yyval[yyp-2]
yy = p.mkList(LIST, a)
yyval[yyp-1] = a
yyval[yyp-2] = b
},
/* 46 ListItem */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 47 ListItem */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 48 ListItem */
func(yytext string, _ int) {
a := yyval[yyp-1]
raw := p.mkStringFromList(a, false)
raw.key = RAW
yy = p.mkElem(LISTITEM)
yy.children = raw
yyval[yyp-1] = a
},
/* 49 ListItemTight */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 50 ListItemTight */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 51 ListItemTight */
func(yytext string, _ int) {
a := yyval[yyp-1]
raw := p.mkStringFromList(a, false)
raw.key = RAW
yy = p.mkElem(LISTITEM)
yy.children = raw
yyval[yyp-1] = a
},
/* 52 ListBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 53 ListBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 54 ListBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, false)
yyval[yyp-1] = a
},
/* 55 ListContinuationBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
if len(yytext) == 0 {
a = cons(p.mkString("\001"), a) // block separator
} else {
a = cons(p.mkString(yytext), a)
}
yyval[yyp-1] = a
},
/* 56 ListContinuationBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 57 ListContinuationBlock */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkStringFromList(a, false)
yyval[yyp-1] = a
},
/* 58 OrderedList */
func(yytext string, _ int) {
yy.key = ORDEREDLIST
},
/* 59 HtmlBlock */
func(yytext string, _ int) {
if p.extension.FilterHTML {
yy = p.mkList(LIST, nil)
} else {
yy = p.mkString(yytext)
yy.key = HTMLBLOCK
}
},
/* 60 StyleBlock */
func(yytext string, _ int) {
if p.extension.FilterStyles {
yy = p.mkList(LIST, nil)
} else {
yy = p.mkString(yytext)
yy.key = HTMLBLOCK
}
},
/* 61 Inlines */
func(yytext string, _ int) {
a := yyval[yyp-1]
c := yyval[yyp-2]
a = cons(yy, a)
yyval[yyp-2] = c
yyval[yyp-1] = a
},
/* 62 Inlines */
func(yytext string, _ int) {
a := yyval[yyp-1]
c := yyval[yyp-2]
a = cons(c, a)
yyval[yyp-1] = a
yyval[yyp-2] = c
},
/* 63 Inlines */
func(yytext string, _ int) {
a := yyval[yyp-1]
c := yyval[yyp-2]
yy = p.mkList(LIST, a)
yyval[yyp-1] = a
yyval[yyp-2] = c
},
/* 64 Space */
func(yytext string, _ int) {
yy = p.mkString(" ")
yy.key = SPACE
},
/* 65 Str */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(p.mkString(yytext), a)
yyval[yyp-1] = a
},
/* 66 Str */
func(yytext string, _ int) {
a := yyval[yyp-1]
a = cons(yy, a)
yyval[yyp-1] = a
},
/* 67 Str */
func(yytext string, _ int) {
a := yyval[yyp-1]
if a.next == nil {
yy = a
} else {
yy = p.mkList(LIST, a)
}
yyval[yyp-1] = a
},
/* 68 StrChunk */
func(yytext string, _ int) {
yy = p.mkString(yytext)
},
/* 69 AposChunk */
func(yytext string, _ int) {
yy = p.mkElem(APOSTROPHE)
},
/* 70 EscapedChar */
func(yytext string, _ int) {
yy = p.mkString(yytext)
},
/* 71 Entity */
func(yytext string, _ int) {
yy = p.mkString(yytext)
yy.key = HTML
},
/* 72 NormalEndline */
func(yytext string, _ int) {
yy = p.mkString("\n")
yy.key = SPACE
},
/* 73 TerminalEndline */
func(yytext string, _ int) {
yy = nil
},
/* 74 LineBreak */
func(yytext string, _ int) {
yy = p.mkElem(LINEBREAK)
},
/* 75 Symbol */
func(yytext string, _ int) {
yy = p.mkString(yytext)
},
/* 76 ApplicationDepent */
func(yytext string, _ int) {
a := yyval[yyp-1]
yy = p.mkString(yytext)
a = nil
yyval[yyp-1] = a
},
/* 77 UlOrStarLine */
func(yytext string, _ int) {
yy = p.mkString(yytext)