From: waltbrad on
I'm trying to read a GREP program written in C for windows. This is
written by Alan R. Feuer. Tried to find it on the web, but couldn't.

In a function called patternMatch he uses the instructions Top: and
Again:

I haven't been coding long and have never run into this. Nor can I
seem to find much information on the web about them.

But here is how it is used in this snippet:

BOOL
patternMatch (char *pattern, char *string)
/* Return TRUE if pattern matches string. */
{
register char pc, sc;
char *pat;
BOOL anchored;

if (anchored = (*pattern == ANCHOR))
++pattern;

Top: /* Once per char in string. */
pat = pattern;

Again:
pc = *pat;
sc = *string;

Can anyone tell me about these or point me to a page on it?

TIA
From: waltbrad on
On Dec 26, 12:05 pm, waltbrad <waltb...(a)hotmail.com> wrote:
> I'm trying to read a GREP program written in C for windows. This is
> written by Alan R. Feuer. Tried to find it on the web, but couldn't.
>
> In a function called patternMatch he uses the instructions Top: and
> Again:
>
> I haven't been coding long and have never run into this. Nor can I
> seem to find much information on the web about them.
>
> But here is how it is used in this snippet:
>
> BOOL
> patternMatch (char *pattern, char *string)
> /* Return TRUE if pattern matches string. */
> {
> register char pc, sc;
> char *pat;
> BOOL anchored;
>
> if (anchored = (*pattern == ANCHOR))
> ++pattern;
>
> Top: /* Once per char in string. */
> pat = pattern;
>
> Again:
> pc = *pat;
> sc = *string;
>
> Can anyone tell me about these or point me to a page on it?
>
> TIA

Sorry. He also concludes with a Success: instruction. So I'm actually
looking for Top: Again: Success:
From: waltbrad on
On Dec 26, 12:08 pm, waltbrad <waltb...(a)hotmail.com> wrote:
> On Dec 26, 12:05 pm, waltbrad <waltb...(a)hotmail.com> wrote:
>
>
>
> > I'm trying to read a GREP program written in C for windows. This is
> > written by Alan R. Feuer. Tried to find it on the web, but couldn't.
>
> > In a function called patternMatch he uses the instructions Top: and
> > Again:
>
> > I haven't been coding long and have never run into this. Nor can I
> > seem to find much information on the web about them.
>
> > But here is how it is used in this snippet:
>
> > BOOL
> > patternMatch (char *pattern, char *string)
> > /* Return TRUE if pattern matches string. */
> > {
> > register char pc, sc;
> > char *pat;
> > BOOL anchored;
>
> > if (anchored = (*pattern == ANCHOR))
> > ++pattern;
>
> > Top: /* Once per char in string. */
> > pat = pattern;
>
> > Again:
> > pc = *pat;
> > sc = *string;
>
> > Can anyone tell me about these or point me to a page on it?
>
> > TIA
>
> Sorry. He also concludes with a Success: instruction. So I'm actually
> looking for Top: Again: Success:

Okay, I see. First time I've ever had to deal with "go to" branching.
So, you can use just anything as a label? so long as it's followed by
a colon?
From: Ivan Novick on
On Dec 26, 10:21 am, waltbrad <waltb...(a)hotmail.com> wrote:
> On Dec 26, 12:08 pm, waltbrad <waltb...(a)hotmail.com> wrote:
>
>
>
> > On Dec 26, 12:05 pm, waltbrad <waltb...(a)hotmail.com> wrote:
>
> > > I'm trying to read a GREP program written in C for windows. This is
> > > written by Alan R. Feuer. Tried to find it on the web, but couldn't.
>
> > > In a function called patternMatch he uses the instructions Top: and
> > > Again:
>
> > > I haven't been coding long and have never run into this. Nor can I
> > > seem to find much information on the web about them.
>
> > > But here is how it is used in this snippet:
>
> > > BOOL
> > > patternMatch (char *pattern, char *string)
> > > /* Return TRUE if pattern matches string. */
> > > {
> > > register char pc, sc;
> > > char *pat;
> > > BOOL anchored;
>
> > > if (anchored = (*pattern == ANCHOR))
> > > ++pattern;
>
> > > Top: /* Once per char in string. */
> > > pat = pattern;
>
> > > Again:
> > > pc = *pat;
> > > sc = *string;
>
> > > Can anyone tell me about these or point me to a page on it?
>
> > > TIA
>
> > Sorry. He also concludes with a Success: instruction. So I'm actually
> > looking for Top: Again: Success:
>
> Okay, I see. First time I've ever had to deal with "go to" branching.
> So, you can use just anything as a label? so long as it's followed by
> a colon?

Ummm... yes ... i guess it can't be another reserved word like?:

for:

but otherwise yeah, those are just labels.

Regards,
Ivan Novick
http://www.0x4849.net
From: Bart van Ingen Schenau on
waltbrad wrote:

> I'm trying to read a GREP program written in C for windows. This is
> written by Alan R. Feuer. Tried to find it on the web, but couldn't.
>
> In a function called patternMatch he uses the instructions Top: and
> Again:
>
> I haven't been coding long and have never run into this. Nor can I
> seem to find much information on the web about them.
>
> But here is how it is used in this snippet:
>
> BOOL
> patternMatch (char *pattern, char *string)
> /* Return TRUE if pattern matches string. */
> {
> register char pc, sc;
> char *pat;
> BOOL anchored;
>
> if (anchored = (*pattern == ANCHOR))
> ++pattern;
>
> Top: /* Once per char in string. */
> pat = pattern;
>
> Again:
> pc = *pat;
> sc = *string;
>
> Can anyone tell me about these or point me to a page on it?

These are not actually instructions in the C and C++ languages, but they
are markers (labels) in the source code that you can jump to with a
goto statement.
In some other part of the patternMatch() function, you will likely see
an instruction
goto Top;
or
goto Again;

Lookup 'goto' and 'label' in your favourite reference book, and remember
that it usually makes the code a lot harder to digest when goto is
being used.

>
> TIA

Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://c-faq.com/
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/