[squeak-dev] A <- B{C} Cardinality Stop Expression behavior question for XTreams-Parsing
gettimothy
gettimothy at zoho.com
Mon Mar 15 17:24:29 UTC 2021
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' >
"https://en.wikipedia.org/wiki/Help:Wikitext#Free_links"
| 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210315/29ae3864/attachment-0001.html>
More information about the Squeak-dev
mailing list
|