Anonymous avatar Anonymous committed 9322fda

Cleanup comments and debugging remains

Comments (0)

Files changed (1)

   (preceded-by (satisfies space-chars)
                (result #\space)))
 
-;; Sp
 (define space*
   (zero-or-more space-char))
 
-;; Space
 (define space+
   (one-or-more space-char))
 
   (->> (preceded-by (is #\return) (maybe #\newline))
        (any-of (is #\newline))))
 
-;; Spnl
 (define space-new-line
   (preceded-by space* (maybe (preceded-by new-line space*))))
 
                               text)))
                 (is #\]))))
 
-;; SourceContents = ( ( !'(' !')' !'>' Nonspacechar )+ | '(' SourceContents ')')*
-;;                  | ""
-
 (define explicit-link-source-contents
   (mutually-recursive-parser
    (-> (none-of (satisfies (char-set #\( #\) #\>)))
        (zero-or-more)
        (as-string))))
 
-;; Source  = ( '<' < SourceContents > '>' | < SourceContents > )
-;;           { $$ = mk_str(yytext); }
-
 (define explicit-link-source
   (any-of (enclosed-by (is #\<)
                        (explicit-link-source-contents)
       ((label (link-label))
        (_ space-new-line)
        (href (preceded-by (is #\()
-                          explicit-link-source
-                          ;; (-> (none-of parentheses)
-                          ;;     (preceded-by non-space-char)
-                          ;;     (zero-or-more)
-                          ;;     (as-string))
-                          ))
+                          explicit-link-source))
        (title (maybe (preceded-by space+ link-title)))
        (_ (is #\))))
     (result `(explicit-link
               (label . ,label)))))
 
 
-;; AutoLinkEmail = '<' ( "mailto:" )? < [-A-Za-z0-9+_./!%~$]+ '@' ( !Newline !'>' . )+ > '>'
-;;                 {   char *mailto = malloc(strlen(yytext) + 8);
-;;                     sprintf(mailto, "mailto:%s", yytext);
-;;                     $$ = mk_link(mk_str(yytext), mailto, "");
-;;                     free(mailto);
-;;                 }
-
 (define auto-link-email
   (sequence* ((_ (preceded-by (is #\<) (maybe (char-seq "mailto:"))))
               (email (-> (sequence
-                           (one-or-more (satisfies #[-A-Za-z0-9+_./!%~$]))
+                           (one-or-more (satisfies #[-a-za-z0-9+_./!%~$]))
                            (is #\@)
                            (one-or-more (preceded-by (none-of new-line (is #\>)) item)))
                          (as-string)))
               (href ,(string-append "mailto:" email))
               (label ,email)))))
 
-;; AutoLinkUrl =   '<' < [A-Za-z]+ "://" ( !Newline !'>' . )+ > '>'
-;;                 {   $$ = mk_link(mk_str(yytext), yytext, ""); }
-
 (define auto-link-url
   (sequence* ((_ (is #\<))
-              (uri (-> (sequence (one-or-more (satisfies #[A-Za-z]))
+              (uri (-> (sequence (one-or-more (satisfies #[a-za-z]))
                                  (char-seq "://")
                                  (-> (none-of new-line (is #\>))
                                      (preceded-by item)
               (href ,uri)
               (label ,uri)))))
 
-;; AutoLink = AutoLinkUrl | AutoLinkEmail
-
 (define auto-link
   (any-of auto-link-url auto-link-email))
 
 (define ul-or-star-line
   (any-of (line-of #\*) (line-of #\_)))
 
-;; EscapedChar =   '\\' !Newline < [-\\`|*_{}[\]()#+.!><] >
-
 (define escaped-char
   (->> (string->char-set "-\\`|*_{}[]()#+.!><")
        (satisfies)
        (preceded-by (is #\\) (none-of new-line))))
 
-
-;; Ticks1 = "`" !'`'
-;; Ticks2 = "``" !'`'
-;; Ticks3 = "```" !'`'
-;; Ticks4 = "````" !'`'
-;; Ticks5 = "`````" !'`'
-
-;; Code = ( Ticks1 Sp < ( ( !'`' Nonspacechar )+ | !Ticks1 '`'+ | !( Sp Ticks1 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks1
-;;        | Ticks2 Sp < ( ( !'`' Nonspacechar )+ | !Ticks2 '`'+ | !( Sp Ticks2 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks2
-;;        | Ticks3 Sp < ( ( !'`' Nonspacechar )+ | !Ticks3 '`'+ | !( Sp Ticks3 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks3
-;;        | Ticks4 Sp < ( ( !'`' Nonspacechar )+ | !Ticks4 '`'+ | !( Sp Ticks4 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks4
-;;        | Ticks5 Sp < ( ( !'`' Nonspacechar )+ | !Ticks5 '`'+ | !( Sp Ticks5 ) ( Spacechar | Newline !BlankLine ) )+ > Sp Ticks5
-;;        )
-;;        { $$ = mk_str(yytext); $$->key = CODE; }
-
 (define code
   (sequence* ((ticks (-> (is #\`)
                          (repeated min: 1 max: 5 (none-of (is #\`)))
     (result code)))
 
 (define alphanumeric-ascii
-  (satisfies #[A-Za-z0-9]))
-
-;; HexEntity =     < '&' '#' [Xx] [0-9a-fA-F]+ ';' >
-;; DecEntity =     < '&' '#' [0-9]+ > ';' >
-;; CharEntity =    < '&' [A-Za-z0-9]+ ';' >
-
-;; Entity =    ( HexEntity | DecEntity | CharEntity )
-;;             { $$ = mk_str(yytext); $$->key = HTML; }
+  (satisfies #[a-za-z0-9]))
 
 (define entity
   (bind (-> (sequence (is #\&)
                 (_ (is delimiter)))
       (result text))))
 
-;; HtmlAttribute = (AlphanumericAscii | '-')+ Spnl ('=' Spnl (Quoted | (!'>' Nonspacechar)+))? Spnl
-
 (define html-attribute-value
   (preceded-by (is #\=)
                space-new-line
           (result (list name value))
           (result name)))))
 
-;; HtmlComment =   "<!--" (!"-->" .)* "-->"
-
 (define html-comment
   (sequence* ((_ (char-seq "<!--"))
               (text (->> item
       (->> (preceded-by (none-of close) inline)
            (zero-or-more))))))
 
-;; RawHtml =   < (HtmlComment | HtmlBlockScript | HtmlTag) >
-
 (define raw-html
   (any-of html-comment (html-inline-element)))
 
            (followed-by line-end
                         inline-without-line-end))))
 
-;; RefTitleParens = Spnl '(' < ( !(')' Sp Newline | Newline) . )* > ')'
-
 (define reference-title
   (let ((delimiters '((#\( . #\)))))
     (sequence* ((delimiter (->> (satisfies (char-set #\( #\' #\"))
                         (href ,href)
                         (title ,title)))))
 
-;; Line =  RawLine
-;;         { $$ = mk_str(yytext); }
-;; RawLine = ( < (!'\r' !'\n' .)* Newline > | < .+ > Eof )
-
 (define raw-line
   (any-of (-> (none-of (is #\return) (is #\newline))
               (preceded-by item)
   (sequence* ((line (as-string raw-line)))
     (result (tabs->spaces line))))
 
-;; Indent =            "\t" | "    "
-
 (define indent
   (any-of (is #\tab) (char-seq "    ")))
 
-;; IndentedLine =      Indent Line
-
 (define indented-line
   (preceded-by indent line))
 
-;; NonblankIndentedLine = !BlankLine IndentedLine
-
 (define non-blank-indented-line
   (preceded-by (none-of blank-line) indented-line))
 
-;; OptionallyIndentedLine = Indent? Line
-
 (define optionally-indented-line
   (preceded-by (maybe indent) line))
 
-
-;; This is only to make Markdown Test happy
 (define (crazy-trim line)
   (if (equal? line "> \n")
       line
       (string-append (string-trim-right line) "\n")))
 
-;; VerbatimChunk = a:StartList
-;;                 ( BlankLine { a = cons(mk_str("\n"), a); } )*
-;;                 ( NonblankIndentedLine { a = cons($$, a); } )+
-;;                 { $$ = mk_str_from_list(a, false); }
-
 (define verbatim-chunk
   (sequence* ((blank-lines (-> blank-line 
                                (preceded-by (result #\newline))
               (text (one-or-more non-blank-indented-line)))
     (result (append blank-lines (map crazy-trim text)))))
 
-
-;; Verbatim =     a:StartList ( VerbatimChunk { a = cons($$, a); } )+
-;;                { $$ = mk_str_from_list(a, false);
-;;                  $$->key = VERBATIM; }
-
 (define verbatim
   (sequence* ((chunks (one-or-more verbatim-chunk)))
     (result `(verbatim . ,chunks))))
 (define horizontal-rule-char
   (satisfies horizontal-rule-chars))
 
-;; HorizontalRule = NonindentSpace
-;;                  ( '*' Sp '*' Sp '*' (Sp '*')*
-;;                  | '-' Sp '-' Sp '-' (Sp '-')*
-;;                  | '_' Sp '_' Sp '_' (Sp '_')*)
-;;                  Sp Newline BlankLine+
-;;                  { $$ = mk_element(HRULE); }
-
 (define horizontal-rule
   (sequence* ((_ non-indent-space)
               (char horizontal-rule-char)
               (_ (one-or-more blank-line)))
     (result '(hr))))
 
-
-;; Enumerator = NonindentSpace [0-9]+ '.' Spacechar+
-
 (define enumerator
   (preceded-by non-indent-space
                (one-or-more (satisfies char-set:digit))
                (is #\.) space+))
 
-;; Bullet = !HorizontalRule NonindentSpace ('+' | '*' | '-') Spacechar+
-
 (define bullet-chars
   (char-set #\+ #\* #\-))
 
 (define list-item-start
   (any-of bullet enumerator))
 
-;; ListItem =  ( Bullet | Enumerator )
-;;             a:StartList
-;;             ListBlock { a = cons($$, a); }
-;;             ( ListContinuationBlock { a = cons($$, a); } )*
-;;             {  element *raw;
-;;                raw = mk_str_from_list(a, false);
-;;                raw->key = RAW;
-;;                $$ = mk_element(LISTITEM);
-;;                $$->children = raw;
-;;             }
-
-;; OrderedList = &Enumerator (ListTight | ListLoose)
-;;               { $$->key = ORDEREDLIST; }
-
-;; ListBlockLine = !BlankLine
-;;                 !( Indent? (Bullet | Enumerator) )
-;;                 !HorizontalRule
-;;                 OptionallyIndentedLine
-
 (define list-block-line
   (preceded-by (none-of blank-line
                         (preceded-by (maybe indent) list-item-start)
                         horizontal-rule)
                optionally-indented-line))
 
-;; ListBlock = a:StartList
-;;             !BlankLine Line { a = cons($$, a); }
-;;             ( ListBlockLine { a = cons($$, a); } )*
-;;             { $$ = mk_str_from_list(a, false); }
-
 (define list-block
   (sequence (preceded-by (none-of blank-line) line)
             (zero-or-more list-block-line)))
 
-;; ListContinuationBlock = a:StartList
-;;                         ( < BlankLine* >
-;;                           {   if (strlen(yytext) == 0)
-;;                                    a = cons(mk_str("\001"), a); /* block separator */
-;;                               else
-;;                                    a = cons(mk_str(yytext), a); } )
-;;                         ( Indent ListBlock { a = cons($$, a); } )+
-;;                         {  $$ = mk_str_from_list(a, false); }
-
-(use extras)
-(define ((debug x) input)
-  (pp x)
-  (pp input)
-  (cons #t input))
-
 (define list-continuation-block
   (sequence (zero-or-more blank-line)
             (one-or-more (preceded-by indent list-block))))
        (result)
        (node 'item)))
 
-;; ListItemTight =
-;;             ( Bullet | Enumerator )
-;;             a:StartList
-;;             ListBlock { a = cons($$, a); }
-;;             ( !BlankLine
-;;               ListContinuationBlock { a = cons($$, a); } )*
-;;             !ListContinuationBlock
-;;             {  element *raw;
-;;                raw = mk_str_from_list(a, false);
-;;                raw->key = RAW;
-;;                $$ = mk_element(LISTITEM);
-;;                $$->children = raw;
-;;             }
-
 (define list-item-tight
   (mutually-recursive-parser
    (sequence* ((_ list-item-start)
                (_ (none-of list-continuation-block)))
      (list-item-node inlines first-block more-blocks))))
 
-;; ListTight = a:StartList
-;;             ( ListItemTight { a = cons($$, a); } )+
-;;             BlankLine* !(Bullet | Enumerator)
-;;             { $$ = mk_list(LIST, a); }
-
 (define list-tight
   (sequence* ((items (one-or-more (list-item-tight)))
               (_ (followed-by (zero-or-more blank-line)
                               (none-of list-item-start))))
     (result items)))
 
-
-;; ListItem =  ( Bullet | Enumerator )
-;;             a:StartList
-;;             ListBlock { a = cons($$, a); }
-;;             ( ListContinuationBlock { a = cons($$, a); } )*
-;;             {  element *raw;
-;;                raw = mk_str_from_list(a, false);
-;;                raw->key = RAW;
-;;                $$ = mk_element(LISTITEM);
-;;                $$->children = raw;
-;;             }
-
-
 (define list-item-loose
   (mutually-recursive-parser
    (sequence* ((_ list-item-start)
                                 (as-string))))
      (list-item-node block first-block more-blocks))))
 
-;; ListLoose = a:StartList
-;;             ( b:ListItem BlankLine*
-;;               {   element *li;
-;;                   li = b->children;
-;;                   li->contents.str = realloc(li->contents.str, strlen(li->contents.str) + 3);
-;;                   strcat(li->contents.str, "\n\n");  /* In loose list, \n\n added to end of each element */
-;;                   a = cons(b, a);
-;;               } )+
-;;             { $$ = mk_list(LIST, a); }
-
 (define list-loose
   (one-or-more
    (sequence* ((item (list-item-loose))
                (_ (zero-or-more blank-line)))
      (result item))))
 
-
-;; BulletList = &Bullet (ListTight | ListLoose)
-;;              { $$->key = BULLETLIST; }
-
-;; OrderedList = &Enumerator (ListTight | ListLoose)
-;;               { $$->key = ORDEREDLIST; }
-
 (define (list* start node-type)
   (->> (any-of list-tight list-loose)
        (node node-type)
 (define ordered-list
   (list* enumerator 'ordered-list))
 
-;; AtxInline = !Newline !(Sp? '#'* Sp Newline) Inline
-
 (define atx-inline
   (-> (none-of new-line (sequence space* (zero-or-more (is #\#)) space* new-line))
       (preceded-by inline)))
 
-;; AtxStart =  < ( "######" | "#####" | "####" | "###" | "##" | "#" ) >
-;;             { $$ = mk_element(H1 + (strlen(yytext) - 1)); }
-
 (define atx-start
   (sequence* ((level (repeated (is #\#) min: 1 max: 6)))
     (result (length level))))
 
-;; AtxHeading = s:AtxStart Sp? a:StartList ( AtxInline { a = cons($$, a); } )+ (Sp? '#'* Sp)?  Newline
-;;             { $$ = mk_list(s->key, a);
-;;               free(s); }
-
 (define atx-heading
   (sequence* ((level atx-start)
               (_ space*)
               (_ new-line))
     (result `(heading ,level ,text))))
 
-;; SetextBottom1 = "===" '='* Newline
-
-;; SetextBottom2 = "---" '-'* Newline
-
 (define (setext-bottom char)
   (preceded-by (char-seq (make-string 3 char))
                (zero-or-more (is char))
                new-line))
 
-;; SetextHeading1 =  &(RawLine SetextBottom1)
-;;                   a:StartList ( !Endline Inline { a = cons($$, a); } )+ Sp? Newline
-;;                   SetextBottom1 { $$ = mk_list(H1, a); }
-
 (define (setext-heading* level bottom-char)
   (let ((bottom (setext-bottom bottom-char)))
     (sequence* ((text (-> (preceded-by (none-of line-end) inline)
   (any-of (setext-heading* 1 #\=)
           (setext-heading* 2 #\-)))
 
-;; Heading = SetextHeading | AtxHeading
 (define heading
   (any-of atx-heading setext-heading))
 
-
 (define paragraph
   (enclosed-by non-indent-space
                (node 'paragraph inlines)
 (define plain
   (node 'paragraph inlines))
 
-
-;; BlockQuoteRaw =  a:StartList
-;;                  (( '>' ' '? Line { a = cons($$, a); } )
-;;                   ( !'>' !BlankLine Line { a = cons($$, a); } )*
-;;                   ( BlankLine { a = cons(mk_str("\n"), a); } )*
-;;                  )+
-;;                  {   $$ = mk_str_from_list(a, true);
-;;                      $$->key = RAW;
-;;                  }
-
 (define blockquote
   (sequence*
       ((text (->> (sequence
           (list (char-seq el)
                 (char-seq (string-upcase el)))))))
 
-
-;; HtmlBlockOpenAddress = '<' Spnl ("address" | "ADDRESS") Spnl HtmlAttribute* '>'
-;; HtmlBlockCloseAddress = '<' Spnl '/' ("address" | "ADDRESS") Spnl '>'
-;; HtmlBlockAddress = HtmlBlockOpenAddress (HtmlBlockAddress | !HtmlBlockCloseAddress .)* HtmlBlockCloseAddress
-
 (define (html-block-in-tags* element-parser)
   (html-element-parser
    element-parser
 (define html-block-in-tags
   (html-block-in-tags* html-block-elements))
 
-;; HtmlBlockSelfClosing = '<' Spnl HtmlBlockType Spnl HtmlAttribute* '/' Spnl '>'
-
 (define html-block-self-closing
   (sequence* ((_ (preceded-by (is #\<) space-new-line))
               (el (any-of html-block-elements))
               (_ (preceded-by (maybe (is #\/)) space-new-line (is #\>))))
     (result (html-element el attrs))))
 
-;; HtmlBlock = < ( HtmlBlockInTags | HtmlComment | HtmlBlockSelfClosing ) >
-;;             BlankLine+
-;;             {   if (extension(EXT_FILTER_HTML)) {
-;;                     $$ = mk_list(LIST, NULL);
-;;                 } else {
-;;                     $$ = mk_str(yytext);
-;;                     $$->key = HTMLBLOCK;
-;;                 }
-;;             }
-
 (define html-block
   (any-of html-block-in-tags
           html-comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.