0
/* pushelt - push an element onto the (list) contents of an element */
0
static void pushelt(element new, element *lst) {
0
assert((*lst).key == LIST);
0
- (*lst).c
ontents.list = cons(new, (*lst).contents.list);
0
+ (*lst).c
hildren = cons(new, (*lst).children);
0
/* reverse - reverse a list, returning pointer to new list */
0
-/* mk_list - constructs an element with key 'key' and c
ontents 'lst' (reversed).
0
+/* mk_list - constructs an element with key 'key' and c
hildren from 'lst' (reversed).
0
* This is designed to be used with pushelt to build lists in a parser action.
0
* The reversing is necessary because pushelt adds to the head of a list. */
0
static element mk_list(int key, element lst) {
0
- result.c
ontents.list = reverse(lst.contents.list);
0
+ result.c
hildren = reverse(lst.children);
0
- if (match_inlines((*l1).c
ontents.list, (*l2).contents.list))
0
+ if (match_inlines((*l1).c
hildren, (*l2).children))
0
BlockQuoteLine = '>' ' '? Line
0
BlockQuoteRaw = a:StartList ( b:BlockQuoteLine { pushelt(b, &a); } )+
0
- { char *c = concat_string_list(reverse(a.c
ontents.list));
0
+ { char *c = concat_string_list(reverse(a.c
hildren));
0
strcat(c, "\n"); /* Note: an extra byte was allocated for this */
0
VerbatimChunk = a:StartList
0
( c:BlankLine { pushelt(c, &a); } )*
0
( b:NonblankIndentedLine { pushelt(b, &a); } )+
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); }
0
Verbatim = a:StartList ( b:VerbatimChunk { pushelt(b, &a); } )+
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); $$.key = VERBATIM; }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); $$.key = VERBATIM; }
0
HorizontalRule = NonindentSpace
0
( '*' Sp '*' Sp '*' (Sp '*')*
0
b:BulletListBlock { pushelt(b, &a); }
0
( c:BulletListContinuationBlock { pushelt(c, &a); } )*
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); $$.key = LISTITEM; }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); $$.key = LISTITEM; }
0
BulletListBlock = a:StartList b:Line { pushelt(b, &a); } (c:ListBlockLine { pushelt(c, &a); })*
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); }
0
BulletListContinuationBlock = a:StartList
0
b.contents.str = strdup("\001"); /* block separator */
0
( Indent c:BulletListBlock { pushelt(c, &a); } )+
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); }
0
Enumerator = NonindentSpace [0-9]+ '.' Spacechar+
0
b:OrderedListBlock { pushelt(b, &a); }
0
( c:OrderedListContinuationBlock { pushelt(c, &a); } )*
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); $$.key = LISTITEM; }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); $$.key = LISTITEM; }
0
OrderedListBlock = a:StartList b:Line { pushelt(b, &a); }
0
( c:ListBlockLine { pushelt(c, &a); } )*
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); }
0
OrderedListContinuationBlock = a:StartList
0
( Indent c:OrderedListBlock { pushelt(c, &a); } )+
0
- { $$ = mk_str(concat_string_list(reverse(a.c
ontents.list))); }
0
+ { $$ = mk_str(concat_string_list(reverse(a.c
hildren))); }
0
BlankLines = < BlankLine* >
0
{ $$ = mk_str(yytext); }
0
ReferenceLinkDouble = a:Label < Spnl > b:Label
0
- if (find_reference(&match, b.contents.list))
0
- $$ = mk_link(a.contents.list, match.url, match.title);
0
+ if (find_reference(&match, b.children))
0
+ $$ = mk_link(a.children, match.url, match.title);
0
/* $$.key == LIST; (not needed because $$.key set by Label match */
0
- $$.c
ontents.list = cons(mk_str("["), cons(a, cons(mk_str("]"), cons(mk_str(yytext),
0
+ $$.c
hildren = cons(mk_str("["), cons(a, cons(mk_str("]"), cons(mk_str(yytext),
0
cons(mk_str("["), cons(b, cons(mk_str("]"), NULL)))))));
0
ReferenceLinkSingle = a:Label < (Spnl "[]")? >
0
- if (find_reference(&match, a.contents.list)) {
0
- $$ = mk_link(a.contents.list, match.url, match.title);
0
+ if (find_reference(&match, a.children)) {
0
+ $$ = mk_link(a.children, match.url, match.title);
0
- $$.c
ontents.list = cons(mk_str("["), cons(a, cons(mk_str("]"),cons(mk_str(yytext),NULL))));
0
+ $$.c
hildren = cons(mk_str("["), cons(a, cons(mk_str("]"),cons(mk_str(yytext),NULL))));
0
ExplicitLink = l:Label Spnl '(' Sp s:Source Spnl t:Title Sp ')'
0
- { $$ = mk_link(l.c
ontents.list, s.contents.str, t.contents.str); }
0
+ { $$ = mk_link(l.c
hildren, s.contents.str, t.contents.str); }
0
Source = ( '<' < SourceContents > '>' | < SourceContents > )
0
{ $$ = mk_str(yytext); }
0
Reference = NonindentSpace l:Label ':' Spnl s:RefSrc Spnl t:RefTitle BlankLine*
0
- { $$ = mk_link(l.c
ontents.list, s.contents.str, t.contents.str); $$.key = REFERENCE; }
0
+ { $$ = mk_link(l.c
hildren, s.contents.str, t.contents.str); $$.key = REFERENCE; }
0
References = a:StartList
0
( b:Reference { pushelt(b, &a); } | SkipBlock )*
0
- { references = a.c
ontents.list; }
0
+ { references = a.c
hildren; }
0
# StartList starts a list data structure that can be added to with pushelt:
0
- { $$.key = LIST; $$.c
ontents.list = NULL; }
0
+ { $$.key = LIST; $$.c
hildren = NULL; }
0
Line = ( < (!'\r' !'\n' .)* Newline > | < .+ > Eof )
0
{ $$ = mk_str(yytext); }
Comments
No one has commented yet.