• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: reverse scanner
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reverse scanner


  • Subject: Re: reverse scanner
  • From: Keary Suska <email@hidden>
  • Date: Sat, 10 Aug 2013 14:44:34 -0600

On Aug 10, 2013, at 12:17 PM, Tom Davie wrote:

> Heh, I’d actually argue that NSScanner is a much much better API to use here (and in fact nearly everywhere).  Regular expressions constrain you only to regular grammars, which are a pretty small set.  In my experience 99% of the use of them is actually trying to parse something that’s not *quite* a regular grammar, and uses a hack on top of regular expressions to do something not-quite-right.
>
> NSScanner by comparison makes the separation of what’s scanning/tokenisation, and what’s up to your (turing complete) program much more clear.  So basically, (at least in my opinion), if you want to parse something that’s regular, NSScanner is a great choice.  If you want to parse something that’s context free, look at CoreParse (Not tooting my own horn, honest).  And finally, if you want to parse something that’s more even than that, then you’re probably back to NSScanner and a turing complete program.
>
> About the only use for regular expressions I can think of is asking NSScanner to scan something that it doesn’t by default know about.

I would agree that NSScanner is a better API than NSRegularExpression, but I think that is Apple's fault because there are better regex API's, such as RegexKit.

I would argue, however, that it is NSScanner that only functions well with fixed and unvarying grammars and has no context, other than a specific, unvarying linear progression. Regular expressions have a huge grammar and when you consider conditionals and zero-width assertions you can parse information that would send NSScanner into dizzying fits.

Not to mention that NSScanner can't even touch the problem that the OP is experiencing, while regular expressions will handle it very nicely.

> On 10 Aug 2013, at 19:53, Jerry Krinock <email@hidden> wrote:
>
>>
>> On 2013 Aug 10, at 10:07, Boyd Collier <email@hidden> wrote:
>>
>>> but if someone has already come up with a clean way of scanning in reverse
>>
>> In Mac OS X 10.7+, we have NSRegularExpression.  In earlier systems, call out to Perl.  Regexes are fun.
>>


Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: reverse scanner
      • From: Maxthon Chan <email@hidden>
    • Re: reverse scanner
      • From: Tom Davie <email@hidden>
References: 
 >reverse scanner (From: Boyd Collier <email@hidden>)
 >Re: reverse scanner (From: Jerry Krinock <email@hidden>)
 >Re: reverse scanner (From: Tom Davie <email@hidden>)

  • Prev by Date: Re: Issues with NSTextView Attachments
  • Next by Date: Re: reverse scanner
  • Previous by thread: Re: reverse scanner
  • Next by thread: Re: reverse scanner
  • Index(es):
    • Date
    • Thread