<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>Hi Folks,<br></div><div><br></div><div>I am getting some unexpected behaviour from  XTreams-Parsing Stop Expression.<br></div><div><br></div><div><br></div><div>From my notes, I am expecting:<br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div><div>{E}     <br></div><div>Cardinality:  Stop Expression<br></div><div>A <- B{C}<br></div><div>to accept A,  means, accept any number of B up until E comes.<br></div><div>Consume E too, but don't yield it.<br></div><div>So, such expression accepts: BE, BBE, BBBE, BBBBE, etc, and yields B, BB, BBB, BBBB, etc.<br></div></div></blockquote><div><br></div><div>I am parsing Wikimedia Free Links...some text enclosed in brackets that I transform into an anchor on the rule callback.<br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>[[this is a free link]]<br></div></blockquote><div><br></div><div>This rule works.... <br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>LinkFreeUnCaptioned                 <- OPEN_BRACKET{2} [^\]\|]+ "]]"<br></div></blockquote><div>It invokes the callback when encountering two open brackets then eat any text except the pipe and the close bracket and continue until you hit two close brackets.<br></div><div><br></div><div>works great.<br></div><div><br></div><div>However....<br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>LinkFreeUnCaptioned                       <- OPEN_BRACKET{2} [^\]\|]{"]]"}<br></div></blockquote><div>works great too...EXCEPT<br></div><div><br></div><div><br></div><div>It also works when there is NO pair of closing brackets.<br></div><div><br></div><div><br></div><div>i.e.<br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>[[this is a free link]]<br></div></blockquote><div>is correctly parsed, but<br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div>[[this is a free link<br></div></blockquote><div>is ALSO parsed, even though there are not closing "]]"'<br></div><div><br></div><div><br></div><div><br></div><div>I am not sure if my expectation is incorrect or if this is a bug.<br></div><div><br></div><div>Thank you for your time.<br></div><div><br></div><div>Below is a (debugging version) of the callback for the above rule:<br></div><div><br></div><div><br></div><div>LinkFreeUnCaptioned:  anOrderedCollection<br></div><div><br></div><blockquote style="border: 1px solid rgb(204, 204, 204); padding: 7px; background-color: rgb(245, 245, 245);"><div><div><action: 'LinkFreeUnCaptioned' ><br></div><div>      "<a href="https://en.wikipedia.org/wiki/Help:Wikitext#Free_links" target="_blank">https://en.wikipedia.org/wiki/Help:Wikitext#Free_links</a>"<br></div><div>      | link caption url xml|<br></div><div>      url := caption := anOrderedCollection joinSeparatedBy:''.<br></div><div>      self break.<br></div><div>      link := (WikitextLink default  linkFree: url caption: caption).<br></div><div>      xml := self<br></div><div>      newElementTag: Anchor<br></div><div>            attributes:<br></div><div>            (Array with: Href -> ((link baseurl), (link url)) with: Classs -> (link claass joinSeparatedBy:'') with: Title -> (link title))<br></div><div>            elements: (Array with: (self newText: (link title))).<br></div><div>      transcripton ifTrue:[Transcript show:'LinkFreeUnCaptioned';cr.    ].<br></div><div>^xml<br></div></div></blockquote><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br></body></html>