[ANN] MEPS (Regular Expressions)

Alan Reider squeak at ajr.e4ward.com
Fri Feb 11 21:12:42 UTC 2005


In release .3 I've added a lightweight Regular Expression parser. It was 
designed to be used with MEPS or standalone. It currently passes around 100 
of the tests in Henry Spencer's regex package.

It should be fairly easy to extend with features like counted repetitions 
(eg {3,1})

One novel feature is the way it implements retrieving submatches. You can 
navigate to any part of the expression (no parens needed) and then ask what 
it matched. eg,

| rx | 
| rx := '[\w-\.]+@[\w-\.]+' regex. 
rx << 'alnr at example.com'.  "alnr at example.com"
rx getMatch.      "alnr at example.com"
rx pieces third.     " [\w-\.]+"
rx  pieces third getMatch.     "example.com"
rx branch1 piece1 getMatch   "alnr"
rx matchedBranch piece2 getMatch. "@"

Regular expressions can be mixed with other MEPS Class or block parsers, eg

'   <  alnr at example.com   >' readStream
  match: '\s*<\s*' regex
  and:   EmailAddress
  and:   '\s*>\s*' regex
 action:  [ : result | result second]  " 'alnr at example.com' "

(Incidently I've done a fair amount of the RFC2822 spec used by SMTP commands 
in MEPS).

On Sunday 06 February 2005 21:15, Alan Reider wrote:
> Hi,
>
> MEPS is available at SqueakMap.
> http://map1.squeakfoundation.org/sm/package/1e518e4f-119f-4a39-80eb-04bcbec
>6fc01
>
> Description:
>
> MEPS stands for Matching Extensions for PositionalStream. You can use this
> package to translate a BNF grammar into an equivalent recursive descent
> parser or scanner.
>
> MEPS is simple enough for one-liners yet capable enough for complete
> parsers or scanners. See http://squeak.reider.net/MEPS/meps.html for
> details.
>
> Cheers,
> Alan



More information about the Squeak-dev mailing list