A <- B{C} Cardinality Stop Expression behavior question for XTreams-Parsing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

A <- B{C} Cardinality Stop Expression behavior question for XTreams-Parsing

Squeak - Dev mailing list
Hi Folks,

I am getting some unexpected behaviour from  XTreams-Parsing Stop Expression.


From my notes, I am expecting:
{E}    
Cardinality:  Stop Expression
A <- B{C}
to accept A,  means, accept any number of B up until E comes.
Consume E too, but don't yield it.
So, such expression accepts: BE, BBE, BBBE, BBBBE, etc, and yields B, BB, BBB, BBBB, etc.

I am parsing Wikimedia Free Links...some text enclosed in brackets that I transform into an anchor on the rule callback.

[[this is a free link]]

This rule works.... 

LinkFreeUnCaptioned <- OPEN_BRACKET{2} [^\]\|]+ "]]"
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.

works great.

However....

LinkFreeUnCaptioned <- OPEN_BRACKET{2} [^\]\|]{"]]"}
works great too...EXCEPT


It also works when there is NO pair of closing brackets.


i.e.

[[this is a free link]]
is correctly parsed, but

[[this is a free link
is ALSO parsed, even though there are not closing "]]"'



I am not sure if my expectation is incorrect or if this is a bug.

Thank you for your time.

Below is a (debugging version) of the callback for the above rule:


LinkFreeUnCaptioned:  anOrderedCollection

<action: 'LinkFreeUnCaptioned' >
      | link caption url xml|
      url := caption := anOrderedCollection joinSeparatedBy:''.
      self break.
      link := (WikitextLink default  linkFree: url caption: caption).
      xml := self
      newElementTag: Anchor
            attributes:
            (Array with: Href -> ((link baseurl), (link url)) with: Classs -> (link claass joinSeparatedBy:'') with: Title -> (link title))
            elements: (Array with: (self newText: (link title))).
      transcripton ifTrue:[Transcript show:'LinkFreeUnCaptioned';cr. ].
^xml