[Ometa] Case-insensitive seq?
Jeff Moser
jeffreydmoser at gmail.com
Sat Dec 20 09:04:03 PST 2008
Hi Frank,
I think you're on to the right track. I haven't used the Smalltalk version,
but I'd imagine that another approach would be to override the "exactly"
rule to try the case insensitive comparison first, followed by the existing
implementation. This way, you could still leverage very helpful rules like
"token" which lets you define keywords in quotes like "integer"
Cheers,
Jeff
On Fri, Dec 19, 2008 at 6:44 AM, Frank Shearar <frank.shearar at angband.za.org
> wrote:
> "Frank Shearar" <frank.shearar at angband.za.org> writes:
>
> > I've been writing an Ometa parser for the Delphi language.
> >
> > Up to now, I've been using a copy of the OSqueakParser>>token production
> > (token :xs ::=3D <spaces> <seq xs>). Delphi is, however, a case insensi=
tive
> > kind've language. Thus, when I write <token 'integer'> in a production,
> what
> > I really want is to accept "Integer" or "INTEGER" or any other
> permutation
> > of case.
> >
> > I've tried a number of things but haven't found anything that works:
> > * hacked a seqNoCase starting from a duplicate of Ometa>>seq
> > * using something like <spaces> <char>+:s ?[(String withAll: s)
> asLowercase
> > =3D (String withAll: xs) asLowercase] =3D> [String withAll: s]
> >
> > I've run out of steam trying to figure out this problem, so I thought I=
'd
> > try here :) Any ideas on how to accept a sequence that matches some inp=
ut
> > (of character), without regard to case?
>
> Here's an ugly solution:
>
> exactlyNoCase :want ::=3D
> <anything>:got ?[want asLowercase =3D got asLowercase] =3D> [want]
>
> seqNoCase
> | xs |
> ^ self oAnd: {
> [xs :=3D self apply: #anything].
> [xs do: [:x |
> (self apply: #exactlyNoCase withArguments: {x}) =3D Fail
> ifTrue: [^ Fail]]].
> [xs]
> }
>
> If anyone has a better solution, I'm all ears!
>
> frank
>
>
> _______________________________________________
> OMeta mailing list
> OMeta at vpri.org
> http://vpri.org/mailman/listinfo/ometa
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://vpri.org/pipermail/ometa/attachments/20081220/03222270/attachme=
nt.htm
More information about the OMeta
mailing list