🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by "John E. Davis" Wed, 11 Nov 1992 13:52
Re: Procedure to matchup (){}[] ???
#78
Author: "John E. Davis"
Date: Wed, 11 Nov 1992 13:52
20 lines
1172 bytes
While these procedures that have been posted may work fine for most purposes,
I do not think they will as expected work for:

if ((ch == ')') || (ch == '('))
  {...}

Does anyone have one that works properly for this case?  If so, does it also
work for this:

if ((ch == '\'') || (ch == '\\'))
  {...}

--
     _____________
#___/John E. Davis\_________________________________________________________
#
# internet: davis@amy.tch.harvard.edu
#   bitnet: davis@ohstpy
#   office: 617-735-6746
#
Re: Procedure to matchup (){}[] ???
#80
Author: fairfield
Date: Wed, 11 Nov 1992 18:31
37 lines
2420 bytes
In article <DAVIS.92Nov11085239@pacific.mps.ohio-state.edu>, davis@pacific.mps.ohio-state.edu ("John E. Davis") writes:
> While these procedures that have been posted may work fine for most purposes,
> I do not think they will as expected work for:
>
> if ((ch == ')') || (ch == '('))
>   {...}
>
> Does anyone have one that works properly for this case?  If so, does it also
> work for this:
>
> if ((ch == '\'') || (ch == '\\'))
>   {...}

    The EVE_MATCH_DELIMITORS I posted early last week works correctly in
matching the parentheses (you didn't say WHAT you thought the unexpected
behaviour to be) for the _second_ case (perhaps you ought to _try_ the
procedures rather than just guessing :-), but the first case is tougher
because there's an "extra" copy of the delimiter you're trying to match
within a quoted string.

    I believe you're be asking the MATCH procedure to know a given
language's syntax for "quoting" a string, and to ignore  delimiters
embedded within those strings.  I can think of ways to do that, but I can
imagine more cases of it making the _wrong_ choice rather than the right
one... You basically have to search the WHOLE buffer to see if you're
within a (language-specific-syntax) quoted string.  I wouldn't want to
attempt that, I'd rather let the compiler catch _those_ cases...  "Operator
intervention" in the relatively infrequent cases, like your first example,
shouldn't be to ask :-)

    		-Ken
--
 Dr. Kenneth H. Fairfield    |  Internet: Fairfield@Slac.Stanford.Edu
 SLAC, P.O.Box 4349, MS 98   |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
 Stanford, CA   94309        |  BITNET    Fairfield@Slacvx
 ----------------------------------------------------------------------------
 These opinions are mine, not SLAC's, Stanford's, nor the DOE's...
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads