Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: confusion about behavior |
| Date | 2011-08-15 12:36 -0700 |
| Organization | None to speak of |
| Message-ID | <lnvcty1n7k.fsf@nuthaus.mib.org> (permalink) |
| References | <cda0e503-482a-4075-b3fa-af3013819716@l11g2000prh.googlegroups.com> <ln1uwn4xuc.fsf@nuthaus.mib.org> <pan.2011.08.15.01.57.26@gmail.com> <slrnj4h5dl.28nb.usenet-nospam@guild.seebs.net> <rOudnTasA46G6dTTnZ2dnUVZ_vednZ2d@bestweb.net> |
Kenneth Brody <kenbrody@spamcop.net> writes:
> On 8/15/2011 12:28 AM, Seebs wrote:
> [...]
>> The "maximal munch" rule.
>>
>> "++" is a larger token than "+". Therefore, if you see two +, it *MUST*
>> be ++, and *CANNOT* be "+", even if that later results in a syntax error.
>>
>> So:
>> a+++b
>> a => start a token
>> + => there is no token starting "a+", so "a" was a token, and we now have "+"
>> + => there is a token starting "++", and that's complete
>> + => start a new token, consisting of "+", keep looking...
>
> Nit:
>
> The second '+' shouldn't really say "and that's complete".
>
> The third '+' should really be "there is no '+++' token, nor does any token
> start with it, so _now_ '++' is now complete, and we start a new token,
> consisting of '+', keep looking".
Counter-nit:
The second '+' could say "The *only* token starting with ++ is ++
itself; therefore, that's complete".
The lexical scanner could realize that "++" is the complete token either
when it sees the second '+', or when it sees the third one. The effect
is exactly the same either way.
>> b => "+b" can't be a token, so the "+" becomes a token.
>>
>> (Then we hit ";" and because "b;" can't be a token, "b" is a token and ";"
>> is a token.)
>>
>> Basically, in order for it to be "+ ++b", the compiler would have to look
>> at "++" and decide to split off the first part of it, and it can't.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
confusion about behavior LJ <djtheshowstopper@gmail.com> - 2011-08-14 11:56 -0700
Re: confusion about behavior China Blue Tip Wrench <chine.bleu@yahoo.com> - 2011-08-14 12:05 -0700
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-14 12:06 -0700
Re: confusion about behavior Todd Carnes <toddcarnes@gmail.com> - 2011-08-15 01:57 +0000
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-14 19:10 -0700
Re: confusion about behavior Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-08-15 03:44 +0100
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-14 20:27 -0700
Re: confusion about behavior Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-14 22:52 -0400
Re: confusion about behavior Seebs <usenet-nospam@seebs.net> - 2011-08-15 04:28 +0000
Re: confusion about behavior Kenneth Brody <kenbrody@spamcop.net> - 2011-08-15 15:31 -0400
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-15 12:36 -0700
Re: confusion about behavior Seebs <usenet-nospam@seebs.net> - 2011-08-15 20:33 +0000
Re: confusion about behavior Kenneth Brody <kenbrody@spamcop.net> - 2011-08-16 14:39 -0400
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-16 12:27 -0700
Re: confusion about behavior Willem <willem@toad.stack.nl> - 2011-08-16 19:47 +0000
Re: confusion about behavior Barry Schwarz <schwarz45@yahoo.com> - 2011-09-05 04:50 -0700
[OT] Re: confusion about behavior Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-05 09:07 -0400
Re: confusion about behavior Kenneth Brody <kenbrody@spamcop.net> - 2011-09-06 12:42 -0400
Re: confusion about behavior James Kuyper <jameskuyper@verizon.net> - 2011-08-14 15:10 -0400
Re: confusion about behavior Todd Carnes <toddcarnes@gmail.com> - 2011-08-15 02:04 +0000
Re: confusion about behavior Keith Thompson <kst-u@mib.org> - 2011-08-14 19:15 -0700
Re: confusion about behavior Todd Carnes <toddcarnes@gmail.com> - 2011-08-15 02:34 +0000
Re: confusion about behavior James Kuyper <jameskuyper@verizon.net> - 2011-08-14 22:37 -0400
Re: confusion about behavior Todd Carnes <toddcarnes@gmail.com> - 2011-08-15 02:26 +0000
csiph-web