reverse scanner

2013-08-10 Thread Boyd Collier
I'm dealing with a situation in which I have to scan strings that are separated 
by tabs, and for each string, I have to extract two numerical values, with 
these values being separated by a non-numerical character or not being 
separated by any character at all.  I know the maximum number of characters 
used to represent each number, but unfortunately, the first character in the 
group of characters used to represent the first number can, quite arbitrarily, 
be either a 0 or missing.  For example, with the number of characters used to 
represent each number known to be 2, the strings 607, 0607, 06;07 (note the 
semicolon between 06 and 07) should all result in 6 and 7 being extracted as 
the two numerical values. Of course, I'd like to do something simple, and were 
it not for the arbitrary inclusion of a leading 0, it would be quite simple to 
use an instance of NSScanner.  Or, if there were such a beast as 
NSReverseScanner, it would also be relatively straight forward, but so far as 
I'm aware, no such beast exists. I can think of a couple of ways do accomplish 
this task, but if someone has already come up with a clean way of scanning in 
reverse, I'd appreciate hearing from them.

Boyd
___

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

Issues with NSTextView Attachments

2013-08-10 Thread Gordon Apple
Using NSTextView¹s native ability to embed image attachments, we have
successfully implemented resizing of the image by using a resizable frame
with a drag handle, and using setSize on the NSImage.  Works great.  Only
one problem, re-archiving the NSAttributableString loses the image size
change.  Any way to fix this?  Internally, in a CoreData auxiliary file
folder, we archive NSAttributableString.  Would we be better off storing it
as RTFD?

I also see allusions to subclasses of NSTextAttachment, but I see no way to
tell NSTextView, or its associates, to use such a subclass.
NSTextAttachmentCell is a protocol.  But who adopts this protocol?  For an
image, is this really a NSImageCell adopting this protocol?  Or is it the
NSTextAttachment?  Confusion here.  Documentation on attachments is sparse.

We would also like to have the ability to set the baseline when an image is
inserted, and change it when the image is resized.  Certain NSPDFImageReps
contain baseline info in private dictionaries, which we would like to use,
when available. In view of the above, should we abandon NSTextView¹s
paste/drag-in capabilities for images and override all the relevant methods
to do our own attachment inserts using a custom NSAttachment class?

Related question about NSImage.  I¹ve never understood setSize in NSImage.
Does this just affect the cached image, or does it have any impact on the
underlying imageRep, such as resizing and remapping a bitmap?

One more:  I¹ve never found a straightforward way to make a textView
re-layout all or a portion of the text.  The best way I¹ve found is to call
textContainerChangedGeometry.  Works, but seems rather obtuse.

Inquiring minds need to know.

___

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

Re: reverse scanner

2013-08-10 Thread Gary L. Wade
Is there a problem with using a character set of all digits except 0 when 
recognizing digits?
--
Gary L. Wade (Sent from my iPad)
http://www.garywade.com/

On Aug 10, 2013, at 10:07 AM, Boyd Collier bcolli...@cox.net wrote:

 I'm dealing with a situation in which I have to scan strings that are 
 separated by tabs, and for each string, I have to extract two numerical 
 values, with these values being separated by a non-numerical character or not 
 being separated by any character at all.  I know the maximum number of 
 characters used to represent each number, but unfortunately, the first 
 character in the group of characters used to represent the first number can, 
 quite arbitrarily, be either a 0 or missing.  For example, with the number of 
 characters used to represent each number known to be 2, the strings 607, 
 0607, 06;07 (note the semicolon between 06 and 07) should all result in 6 and 
 7 being extracted as the two numerical values. Of course, I'd like to do 
 something simple, and were it not for the arbitrary inclusion of a leading 0, 
 it would be quite simple to use an instance of NSScanner.  Or, if there were 
 such a beast as NSReverseScanner, it would also be relatively straight 
 forward, but so far as I'm aware, no such beast exists. I can think of a 
 couple of ways do accomplish this task, but if someone has already come up 
 with a clean way of scanning in reverse, I'd appreciate hearing from them.
 
 Boyd

___

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

Re: reverse scanner

2013-08-10 Thread Jerry Krinock

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.


___

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

Re: reverse scanner

2013-08-10 Thread Tom Davie
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.

Tom Davie

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.
 
 
 ___
 
 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/tom.davie%40gmail.com
 
 This email sent to tom.da...@gmail.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

Re: reverse scanner

2013-08-10 Thread Sandor Szatmari
If one number has a leading leading zero will the other number have one, if 
applicable?  For instance, is 60 followed by 7 distinguishable from 6 followed 
by 07?

Sandor Szatmari

On Aug 10, 2013, at 13:07, Boyd Collier bcolli...@cox.net wrote:

 I'm dealing with a situation in which I have to scan strings that are 
 separated by tabs, and for each string, I have to extract two numerical 
 values, with these values being separated by a non-numerical character or not 
 being separated by any character at all.  I know the maximum number of 
 characters used to represent each number, but unfortunately, the first 
 character in the group of characters used to represent the first number can, 
 quite arbitrarily, be either a 0 or missing.  For example, with the number of 
 characters used to represent each number known to be 2, the strings 607, 
 0607, 06;07 (note the semicolon between 06 and 07) should all result in 6 and 
 7 being extracted as the two numerical values. Of course, I'd like to do 
 something simple, and were it not for the arbitrary inclusion of a leading 0, 
 it would be quite simple to use an instance of NSScanner.  Or, if there were 
 such a beast as NSReverseScanner, it would also be relatively straight 
 forward, but so far as I'm aware, no such beast exists. I can think of a 
 couple of ways do accomplish this task, but if someone has already come up 
 with a clean way of scanning in reverse, I'd appreciate hearing from them.
 
 Boyd
 ___
 
 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/admin.szatmari.net%40gmail.com
 
 This email sent to admin.szatmari@gmail.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

Re: Issues with NSTextView Attachments

2013-08-10 Thread Kyle Sluder
On Sat, Aug 10, 2013, at 10:31 AM, Gordon Apple wrote:
 Using NSTextView¹s native ability to embed image attachments, we have
 successfully implemented resizing of the image by using a resizable frame
 with a drag handle, and using setSize on the NSImage.  Works great.  Only
 one problem, re-archiving the NSAttributableString loses the image size
 change.  Any way to fix this?  Internally, in a CoreData auxiliary file
 folder, we archive NSAttributableString.  Would we be better off storing
 it
 as RTFD?

You could store it as a custom attribute on the attachment character.

 
 I also see allusions to subclasses of NSTextAttachment, but I see no way
 to
 tell NSTextView, or its associates, to use such a subclass.

You will need to create the attachment object yourself and assign it as
the value of the NSTextAttachmentAttributeName for the attachment
character.

You could do this in an implementation of -[NSTextDelegate
didChangeText:] so that user drag-and-drop of images still results in
your custom attachment class being created.

 NSTextAttachmentCell is a protocol.  But who adopts this protocol?  For
 an
 image, is this really a NSImageCell adopting this protocol?  Or is it the
 NSTextAttachment?  Confusion here.  Documentation on attachments is
 sparse.

The current architecture dates back to when NSCell was a useful class to
instantiate directly. I believe NSCell still implements
NSTextAttachmentCell, but it might actually be NSImageCell. But yes,
that's the gist of the design.

 
 We would also like to have the ability to set the baseline when an image
 is
 inserted, and change it when the image is resized.  Certain
 NSPDFImageReps
 contain baseline info in private dictionaries, which we would like to
 use,
 when available. In view of the above, should we abandon NSTextView¹s
 paste/drag-in capabilities for images and override all the relevant
 methods
 to do our own attachment inserts using a custom NSAttachment class?

Maybe. See above for one idea of how to continue using NSTextView's drag
and drop support.

 
 Related question about NSImage.  I¹ve never understood setSize in
 NSImage.
 Does this just affect the cached image, or does it have any impact on the
 underlying imageRep, such as resizing and remapping a bitmap?

NSImage.size is a semantic property. It tells the caller how big the
image is in device-independent points. It is no longer related to
caching. See the App Kit release notes for 10.6, section titled NSImage
Behavior: Simplifying caching and related interfaces: 
https://developer.apple.com/library/mac/releasenotes/Cocoa/AppKitOlderNotes.html

 
 One more:  I¹ve never found a straightforward way to make a textView
 re-layout all or a portion of the text.  The best way I¹ve found is to
 call
 textContainerChangedGeometry.  Works, but seems rather obtuse.

NSLayoutManager has many invalidation methods.

--Kyle Sluder

___

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

Re: reverse scanner

2013-08-10 Thread Keary Suska
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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: reverse scanner

2013-08-10 Thread Tom Davie

On 10 Aug 2013, at 22: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.

No, some hacked on extensions to regular expressions can do this.  Because 
people keep repeatedly bumping into the problem that they’re not as powerful as 
CFGs, and most parsing problems aren’t regular.

Tom Davie
___

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

Re: reverse scanner

2013-08-10 Thread Fritz Anderson
On 10 Aug 2013, at 3:54 PM, Tom Davie tom.da...@gmail.com wrote:

 On 10 Aug 2013, at 22:44, Keary Suska cocoa-...@esoteritech.com wrote:
 
 No, some hacked on extensions to regular expressions can do this.  Because 
 people keep repeatedly bumping into the problem that they’re not as powerful 
 as CFGs, and most parsing problems aren’t regular.

See no true Scotsman. http://en.wikipedia.org/wiki/No_true_Scotsman

The point remains that there are quite powerful extensions to the formal 
regular-expression syntax that are reliable, in almost universal use, and 
helpful to the OP. In your heart of hearts, you will admit to knowing that.

In the '80s, I called myself a hacker, and even had a vanity license plate 
MAC HAKR. The battle over the popular meaning of hacker has been lost, and so 
it has been with regular expression.

— F


___

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

Re: reverse scanner

2013-08-10 Thread Philip Ershler
Are you numbers constrained to be from 1 to 9? How about 0677 (which is 
actually 6 and 7) or 0607 (which is actually 607) etc?

Phil

On Aug 10, 2013, at 2:54 PM, Tom Davie tom.da...@gmail.com wrote:

 
 On 10 Aug 2013, at 22: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.
 
 No, some hacked on extensions to regular expressions can do this.  Because 
 people keep repeatedly bumping into the problem that they’re not as powerful 
 as CFGs, and most parsing problems aren’t regular.
 
 Tom Davie
 ___
 
 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/ershler%40cvrti.utah.edu
 
 This email sent to ersh...@cvrti.utah.edu

Philip R. Ershler Ph.D.
University of Utah
Cardiovascular Research and Training Institute
95 South 2000 East
Salt Lake City, UT 84112-5000

phone: (801) 230-8771
alt ph: (801) 587-9528
fax: (801) 581-3128
e-mail: ersh...@cvrti.utah.edu


___

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

Re: reverse scanner

2013-08-10 Thread Philip Ershler
Whoops, I meant 

Are you numbers constrained to be from 1 to 9? How about 0677 (which is 
actually 6 and 77) or 0607 (which is actually 607) etc?

Phil

On Aug 10, 2013, at 2:54 PM, Tom Davie tom.da...@gmail.com wrote:

 
 On 10 Aug 2013, at 22: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.
 
 No, some hacked on extensions to regular expressions can do this.  Because 
 people keep repeatedly bumping into the problem that they’re not as powerful 
 as CFGs, and most parsing problems aren’t regular.
 
 Tom Davie
 ___
 
 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/ershler%40cvrti.utah.edu
 
 This email sent to ersh...@cvrti.utah.edu

Philip R. Ershler Ph.D.
University of Utah
Cardiovascular Research and Training Institute
95 South 2000 East
Salt Lake City, UT 84112-5000

phone: (801) 230-8771
alt ph: (801) 587-9528
fax: (801) 581-3128
e-mail: ersh...@cvrti.utah.edu


___

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/ershler%40cvrti.utah.edu

This email sent to ersh...@cvrti.utah.edu

___

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

Re: reverse scanner

2013-08-10 Thread Maxthon Chan
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