NSScanner is *not* a parser - it is a lexical analyser and you are the one that is responsible of writing a parser on top of it. I have a project Subtitler (http://github.com/xcvista/Subtitler) that included 2 parsers that is built on top of NSScanner, and I vaguely remember that there is an Smalltalk compiler written in Objective-C using NSScanner extensively as its lexer and LLVM as code emitter somewhere...
On Aug 11, 2013, at 4:44, Keary Suska <cocoa-...@esoteritech.com> wrote: > 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 <je...@ieee.org> wrote: >> >>> >>> On 2013 Aug 10, at 10:07, Boyd Collier <bcolli...@cox.net> 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 (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com > > This email sent to xcvi...@me.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com