From: Joseph M. Newcomer on
Duh! The usual way to write this is

#define MAKESTATE(state, ch) MAKELONG(state, _T(ch))
typedef enum {S0, ...} states;

states state = S0;

while(*p != _T('\0'))
{
swtich(MAKESTATE(state, *p)
{
case MAKESTATE(S0, '0'):
case MAKESTATE(S0, '1'):
....
case MAKESTATE(S0, '9'):
state = STATE_NUMBER;
p++;
continue;
case MAKESTATE(S0, '(')
state = STATE_OPEN_PAREN;
p++;
continue;

THis is first-semester intro-to-C stuff.
joe

On Thu, 20 May 2010 12:43:09 -0500, Peter Olcott <NoSpam(a)OCR4Screen.com> wrote:

>On 5/20/2010 12:14 PM, Joseph M. Newcomer wrote:
>> Oh. A techhique that has been known to me for about 40 years. And one which I pointed
>> out.
>> joe
>
>You only mentioned a case statement not a set of case statements nested
>within a case statement. Since I was already using a case statement in
>my own table driven code it was not immediately obvious what you were
>referring to because you failed to provide this extra missing detail.
>
>I would guess that this case within case design would tend to be
>somewhat slower, but, it is too close to call without direct measurement.
>
>>
>> On Thu, 20 May 2010 11:29:51 -0500, Peter Olcott<NoSpam(a)OCR4Screen.com> wrote:
>>
>>> I got this answer from comp.theory. It was completely obvious once it
>>> was explained. It is trivially simple to create a DFA based recognizer
>>> without a state transition matrix data table. Simply encode case
>>> statements corresponding to inputs within the case elements of a case
>>> statement corresponding to states.
>>>
>>> In at least some cases the (case within case) method might be faster
>>> depending upon whether or not memory is reduced enough to more than
>>> offset the higher case statement overhead to increase cache locality of
>>> reference.
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
That was not rude, that was what we call "wishful thinking".
joe

On Thu, 20 May 2010 12:19:47 -0500, Peter Olcott <NoSpam(a)OCR4Screen.com> wrote:

>On 5/20/2010 12:16 PM, Joseph M. Newcomer wrote:
>> There is nothing rude about stating that there is nearly always more than one way to
>> achieve something, or suggesting a google search string.
>>
>> Could you point out PRECISELY where this person was "rude"?
>>
>
>This
> >>>and then go away.
>
>> My career prospects never suffered from my being outspoken. On the contrary, I have been
>> very successful.
>> joe
>>
>> On Thu, 20 May 2010 12:03:48 -0500, Peter Olcott<NoSpam(a)OCR4Screen.com> wrote:
>>
>>> On 5/20/2010 11:46 AM, Leigh Johnston wrote:
>>>> "Peter Olcott"<NoSpam(a)OCR4Screen.com> wrote in message
>>>> news:wtadnXb96NPj_mjWnZ2dnUVZ_r4AAAAA(a)giganews.com...
>>>>> I got this answer from comp.theory. It was completely obvious once it
>>>>> was explained. It is trivially simple to create a DFA based recognizer
>>>>> without a state transition matrix data table. Simply encode case
>>>>> statements corresponding to inputs within the case elements of a case
>>>>> statement corresponding to states.
>>>>>
>>>>> In at least some cases the (case within case) method might be faster
>>>>> depending upon whether or not memory is reduced enough to more than
>>>>> offset the higher case statement overhead to increase cache locality
>>>>> of reference.
>>>>
>>>> There is nearly always more than one way of achieving the same goal and
>>>> whether or not one way is faster than another can only be definitively
>>>> determined through profiling.
>>>>
>>>> Google for "premature optimization" and then go away.
>>>>
>>>> /Leigh
>>>
>>> Rudeness can quickly kill your career prospects in ways that you may not
>>> even be aware of.
>>>
>>> If you don't like what I am saying then simply do not respond to my posts.
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm