From e5cc35f57783cc4e6bc26d0757b1de9b420f914d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Teichgr=C3=A4ber?= Date: Wed, 23 Jan 2013 22:35:43 +0100 Subject: [PATCH] Rewrote Emph/Strong parsers to avoid exponential blowup. [jgm/peg-markdown] See https://github.com/jgm/peg-markdown/commit/39dfc1c --- parser.leg | 28 ++++++++-------------------- portid | 2 +- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/parser.leg b/parser.leg index 59595e4..96d0b8e 100644 --- a/parser.leg +++ b/parser.leg @@ -529,27 +529,19 @@ UlOrStarLine = (UlLine | StarLine) { $$ = p.mkString(yytext) } StarLine = < "****" '*'* > | < Spacechar '*'+ &Spacechar > UlLine = < "____" '_'* > | < Spacechar '_'+ &Spacechar > -SpaceInline = a:StartList - ( (b:Space | b:Endline) { a = cons(b, a) } )+ - c:Inline { a = cons(c, a); $$ = p.mkList(LIST, a) } - -NonspaceInline = !Spacechar !Newline Inline - Emph = EmphStar | EmphUl -EmphStar = '*' +EmphStar = '*' &Nonspacechar a:StartList - ( !'*' b:NonspaceInline { a = cons(b, a) } - | b:SpaceInline { a = cons(b, a) } + ( !'*' b:Inline { a = cons(b, a) } | b:StrongStar { a = cons(b, a) } )+ '*' { $$ = p.mkList(EMPH, a) } -EmphUl = '_' +EmphUl = '_' &Nonspacechar a:StartList - ( !'_' b:NonspaceInline { a = cons(b, a) } - | b:SpaceInline { a = cons(b, a) } + ( !'_' b:Inline { a = cons(b, a) } | b:StrongUl { a = cons(b, a) } )+ '_' @@ -557,19 +549,15 @@ EmphUl = '_' Strong = StrongStar | StrongUl -StrongStar = "**" +StrongStar = "**" &Nonspacechar a:StartList - ( !"**" b:NonspaceInline { a = cons(b, a) } - | b:SpaceInline { a = cons(b, a) } - )+ + ( !"**" b:Inline { a = cons(b, a) })+ "**" { $$ = p.mkList(STRONG, a) } -StrongUl = "__" +StrongUl = "__" &Nonspacechar a:StartList - ( !"__" b:NonspaceInline { a = cons(b, a) } - | b:SpaceInline { a = cons(b, a) } - )+ + ( !"__" b:Inline { a = cons(b, a) })+ "__" { $$ = p.mkList(STRONG, a) } diff --git a/portid b/portid index 6bb2f98..0f11735 100644 --- a/portid +++ b/portid @@ -1 +1 @@ -195 +196