Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.theory > #40760 > unrolled thread

I finally completed my lexical analyzer generator (needed by my halt decider)

Started byolcott <NoOne@NoWhere.com>
First post2021-10-23 20:27 -0500
Last post2021-10-26 23:47 +0100
Articles 5 on this page of 25 — 4 participants

Back to article view | Back to comp.theory


Contents

  I finally completed my lexical analyzer generator (needed by my halt decider) olcott <NoOne@NoWhere.com> - 2021-10-23 20:27 -0500
    Re: I finally completed my lexical analyzer generator (needed by my halt decider) Richard Damon <Richard@Damon-Family.org> - 2021-10-23 21:49 -0400
      Re: I finally completed my lexical analyzer generator (needed by my halt decider) olcott <NoOne@NoWhere.com> - 2021-10-23 21:16 -0500
        Re: I finally completed my lexical analyzer generator (needed by my halt decider) Richard Damon <Richard@Damon-Family.org> - 2021-10-23 23:19 -0400
          Re: I finally completed my lexical analyzer generator ( axiomatic basis ) olcott <NoOne@NoWhere.com> - 2021-10-23 22:29 -0500
            Re: I finally completed my lexical analyzer generator ( axiomatic basis ) Richard Damon <Richard@Damon-Family.org> - 2021-10-24 06:40 -0400
              Re: I finally completed my lexical analyzer generator ( axiomatic basis ) olcott <NoOne@NoWhere.com> - 2021-10-24 09:04 -0500
                Re: I finally completed my lexical analyzer generator ( axiomatic basis ) Richard Damon <Richard@Damon-Family.org> - 2021-10-24 13:37 -0400
                  Re: I finally completed my lexical analyzer generator ( semantic tautology ) olcott <NoOne@NoWhere.com> - 2021-10-25 10:02 -0500
                    Re: I finally completed my lexical analyzer generator ( semantic tautology ) Richard Damon <Richard@Damon-Family.org> - 2021-10-25 19:40 -0400
    Re: I finally completed my lexical analyzer generator (needed by my halt decider) Richard Damon <Richard@Damon-Family.org> - 2021-10-24 07:59 -0400
      Re: I finally completed my lexical analyzer generator (needed by my halt decider) olcott <NoOne@NoWhere.com> - 2021-10-24 09:07 -0500
        Re: I finally completed my lexical analyzer generator (needed by my halt decider) Richard Damon <Richard@Damon-Family.org> - 2021-10-24 13:41 -0400
    Re: I finally completed my lexical analyzer generator (needed by my halt decider) update olcott <NoOne@NoWhere.com> - 2021-10-24 13:37 -0500
      Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Richard Damon <Richard@Damon-Family.org> - 2021-10-24 15:55 -0400
      Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-25 02:08 +0100
        Re: I finally completed my lexical analyzer generator (needed by my halt decider) update olcott <NoOne@NoWhere.com> - 2021-10-24 20:45 -0500
          Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-26 00:26 +0100
            Re: I finally completed my lexical analyzer generator (needed by my halt decider) update olcott <NoOne@NoWhere.com> - 2021-10-25 19:08 -0500
              Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-26 02:09 +0100
                Re: I finally completed my lexical analyzer generator (needed by my halt decider) update olcott <NoOne@NoWhere.com> - 2021-10-25 20:54 -0500
                  Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Richard Damon <news.x.richarddamon@xoxy.net> - 2021-10-26 07:00 -0400
                  Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-26 14:56 +0100
                    Re: I finally completed my lexical analyzer generator (needed by my halt decider) update olcott <NoOne@NoWhere.com> - 2021-10-26 09:43 -0500
                      Re: I finally completed my lexical analyzer generator (needed by my halt decider) update Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-26 23:47 +0100

Page 2 of 2 — ← Prev page 1 [2]


#40838 — Re: I finally completed my lexical analyzer generator (needed by my halt decider) update

Fromolcott <NoOne@NoWhere.com>
Date2021-10-25 20:54 -0500
SubjectRe: I finally completed my lexical analyzer generator (needed by my halt decider) update
Message-ID<GMydnZtvI8x8wur8nZ2dnUU7-avNnZ2d@giganews.com>
In reply to#40835
On 10/25/2021 8:09 PM, Ben Bacarisse wrote:
> olcott <NoOne@NoWhere.com> writes:
> 
>> On 10/25/2021 6:26 PM, Ben Bacarisse wrote:
>>> olcott <NoOne@NoWhere.com> writes:
>>>
>>>> On 10/24/2021 8:08 PM, Ben Bacarisse wrote:
>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>
>>>>>> Enhancements: (Assumes that the C source code compiles)
>>>>>> (a) Ignores /* */ comments
>>>>>> (b) Ignores #define lines
>>>>>> (c) Correctly handles trailing space in: int Function_Name(void   )
>>>>>>
>>>>>> //
>>>>>> //  Deterministic Finite Automaton (DFA) recognizer
>>>>>> //  of C function headers.
>>>>>>
>>>>>> // Character Classes
>>>>>> //
>>>>>>        EMPTY [0]
>>>>>>        ALPHA [ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz]
>>>>>>      NUMERIC [0123456789]
>>>>>>           WS [0x09,0x0A,0x0D,0x20]
>>>>>>       LPAREN [(]
>>>>>>       RPAREN [)]
>>>>>>        POUND [#]
>>>>>>     ASTERISK [*]     // 0x2a
>>>>>>        COMMA [,]
>>>>>>        SLASH [0x2f]  // "/"
>>>>>>      NEWLINE [0x0A]
>>>>>
>>>>> Why don't you use these last seven?
>>>>
>>>> I do use them.
>>> I meant why not use them in the code you posted.
>>
>> They are used in the DFA shown below.
> 
> No they are not.

Here is LPAREN: [(]{fn}(06)
 >>>>>> <04> WS{fn}(05) ALPHA(04) NUMERIC(04) [*](00) [(]{fn}(06)

Here is RPAREN: [)]{fh}(00)
 >>>>>> <06> WS    (06) ALPHA(07) NUMERIC(00) [*](00) [)]{fh}(00)

Here is POUND: [#](13)
Here is SLASH: [/](12)
 >>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)

Here is ASTERISK: [*](02)
 >>>>>> <01> WS{ft}(03) ALPHA(01) NUMERIC(01) [*](02)

Here is COMMA:  [,]{vn}(06)
 >>>>>> <10> WS{vn}(11) ALPHA(10) NUMERIC(10) [,]{vn}(06) [)]{vn}(00)

Here is NEWLINE: [0x0A] (00)
 >>>>>> <13> ASCII_MINUS_NEWLINE(13)  [0x0A] (00)

>>>> I can refer to either the name or the definition of the character class.
>>>> ASCII and CONTROL may be used in the future.
>>>>
>>>>>>        ASCII [0x20-0x7e]
>>>>>>         ASCII_MINUS_NEWLINE [0x00-0x09,0x0b-0x7f]
>>>>>>        ASCII_MINUS_ASTERISK [0x00-0x29,0x2b-0x7f]
>>>>>>           ASCII_MINUS_SLASH [0x00-0x2e,0x30-0x7f]
>>>>>>      CONTROL [0x00-0x09,0x0b-0x1f,0x7f]
>>>>>>
>>>>>> // Recognized Patterns
>>>>>> //
>>>>>> {et} Empty
>>>>>> {ft} Function_Type
>>>>>> {fn} Function_Name
>>>>>> {vt} Variable_Type
>>>>>> {vn} Variable_Name
>>>>>> {fh} Function_Header
>>>>>>
>>>>>> // DFA Definition to recognize C function headers
>>>>>
>>>>> No DFA can do that in general.  You mean "recognise a very restricted
>>>>> subset of C function headers".
>>>>
>>>> It recognizes everything that I will ever write.
>>>
>>> Ah.  That simplifies things, and alerts the reader not to check the DFA
>>> since you can just say "I'd never write that!".  However...
>>>
>> If I wanted a more robust function header recognizer I would adapt the
>> lex/yacc spec for C.
> 
> Your DFA does not even recognise the one example you gave!
> 

Why did you delete it? Here is is being correctly recognized:
int* M(int* N);

  [i]  State(00)        NextState(01)  LineNumber(0006)
  [n]  State(01)        NextState(01)  LineNumber(0006)
  [t]  State(01)        NextState(01)  LineNumber(0006)
  [*]  State(01)        NextState(02)  LineNumber(0006)
  [ ]  State(02)  {ft}  NextState(03)  LineNumber(0006)
  [M]  State(03)        NextState(04)  LineNumber(0006)
  [(]  State(04)  {fn}  NextState(06)  LineNumber(0006)
  [i]  State(06)        NextState(07)  LineNumber(0006)
  [n]  State(07)        NextState(07)  LineNumber(0006)
  [t]  State(07)        NextState(07)  LineNumber(0006)
  [*]  State(07)        NextState(08)  LineNumber(0006)
  [ ]  State(08)  {vt}  NextState(09)  LineNumber(0006)
  [N]  State(09)        NextState(10)  LineNumber(0006)
  [)]  State(10)  {vn}  NextState(00)  LineNumber(0006)
   insert("M", 1);


>>>>>> // begin of function type
>>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)
>>>>>
>>>>> What does that [*] mean?  Judging by the other uses of []s, you seem to
>>>>> be accepting *s and digits at the start of a C function header even
>>>>> though they won't be taken to be one of your named matches.  Why single
>>>>> out *s and digits?
>>>>
>>>> int* M(int* N);
>>>
>>> This does not recognise the {fh} pattern.  Putting the named
>>> patterns into the string at the point the action would be triggered I
>>> get
>>

Your:
*1*x x(*x x()
was rejected by the C compiler.

-- 
Copyright 2021 Pete Olcott

"Great spirits have always encountered violent opposition from mediocre 
minds." Einstein

[toc] | [prev] | [next] | [standalone]


#40848 — Re: I finally completed my lexical analyzer generator (needed by my halt decider) update

FromRichard Damon <news.x.richarddamon@xoxy.net>
Date2021-10-26 07:00 -0400
SubjectRe: I finally completed my lexical analyzer generator (needed by my halt decider) update
Message-ID<sl8n3r$j10$1@dont-email.me>
In reply to#40838
On 10/25/21 9:54 PM, olcott wrote:
> On 10/25/2021 8:09 PM, Ben Bacarisse wrote:
>> olcott <NoOne@NoWhere.com> writes:
>>
>>> On 10/25/2021 6:26 PM, Ben Bacarisse wrote:
>>>> olcott <NoOne@NoWhere.com> writes:
>>>>
>>>>> On 10/24/2021 8:08 PM, Ben Bacarisse wrote:
>>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>>
>>>>>>> Enhancements: (Assumes that the C source code compiles)
>>>>>>> (a) Ignores /* */ comments
>>>>>>> (b) Ignores #define lines
>>>>>>> (c) Correctly handles trailing space in: int Function_Name(void   )
>>>>>>>
>>>>>>> //
>>>>>>> //  Deterministic Finite Automaton (DFA) recognizer
>>>>>>> //  of C function headers.
>>>>>>>
>>>>>>> // Character Classes
>>>>>>> //
>>>>>>>        EMPTY [0]
>>>>>>>        ALPHA [ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz]
>>>>>>>      NUMERIC [0123456789]
>>>>>>>           WS [0x09,0x0A,0x0D,0x20]
>>>>>>>       LPAREN [(]
>>>>>>>       RPAREN [)]
>>>>>>>        POUND [#]
>>>>>>>     ASTERISK [*]     // 0x2a
>>>>>>>        COMMA [,]
>>>>>>>        SLASH [0x2f]  // "/"
>>>>>>>      NEWLINE [0x0A]
>>>>>>
>>>>>> Why don't you use these last seven?
>>>>>
>>>>> I do use them.
>>>> I meant why not use them in the code you posted.
>>>
>>> They are used in the DFA shown below.
>>
>> No they are not.
> 
> Here is LPAREN: [(]{fn}(06)
>  >>>>>> <04> WS{fn}(05) ALPHA(04) NUMERIC(04) [*](00) [(]{fn}(06)
> 
> Here is RPAREN: [)]{fh}(00)
>  >>>>>> <06> WS    (06) ALPHA(07) NUMERIC(00) [*](00) [)]{fh}(00)
> 
> Here is POUND: [#](13)
> Here is SLASH: [/](12)
>  >>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)
> 
> Here is ASTERISK: [*](02)
>  >>>>>> <01> WS{ft}(03) ALPHA(01) NUMERIC(01) [*](02)
> 
> Here is COMMA:  [,]{vn}(06)
>  >>>>>> <10> WS{vn}(11) ALPHA(10) NUMERIC(10) [,]{vn}(06) [)]{vn}(00)
> 
> Here is NEWLINE: [0x0A] (00)
>  >>>>>> <13> ASCII_MINUS_NEWLINE(13)  [0x0A] (00)

You do understand that NONE of these cases are using the class 
definitions you are talking about, just reference the same set of 
characters that the class uses.
> 
>>>>> I can refer to either the name or the definition of the character 
>>>>> class.
>>>>> ASCII and CONTROL may be used in the future.
>>>>>
>>>>>>>        ASCII [0x20-0x7e]
>>>>>>>         ASCII_MINUS_NEWLINE [0x00-0x09,0x0b-0x7f]
>>>>>>>        ASCII_MINUS_ASTERISK [0x00-0x29,0x2b-0x7f]
>>>>>>>           ASCII_MINUS_SLASH [0x00-0x2e,0x30-0x7f]
>>>>>>>      CONTROL [0x00-0x09,0x0b-0x1f,0x7f]
>>>>>>>
>>>>>>> // Recognized Patterns
>>>>>>> //
>>>>>>> {et} Empty
>>>>>>> {ft} Function_Type
>>>>>>> {fn} Function_Name
>>>>>>> {vt} Variable_Type
>>>>>>> {vn} Variable_Name
>>>>>>> {fh} Function_Header
>>>>>>>
>>>>>>> // DFA Definition to recognize C function headers
>>>>>>
>>>>>> No DFA can do that in general.  You mean "recognise a very restricted
>>>>>> subset of C function headers".
>>>>>
>>>>> It recognizes everything that I will ever write.
>>>>
>>>> Ah.  That simplifies things, and alerts the reader not to check the DFA
>>>> since you can just say "I'd never write that!".  However...
>>>>
>>> If I wanted a more robust function header recognizer I would adapt the
>>> lex/yacc spec for C.
>>
>> Your DFA does not even recognise the one example you gave!
>>
> 
> Why did you delete it? Here is is being correctly recognized:
> int* M(int* N);
> 
>   [i]  State(00)        NextState(01)  LineNumber(0006)
>   [n]  State(01)        NextState(01)  LineNumber(0006)
>   [t]  State(01)        NextState(01)  LineNumber(0006)
>   [*]  State(01)        NextState(02)  LineNumber(0006)
>   [ ]  State(02)  {ft}  NextState(03)  LineNumber(0006)
>   [M]  State(03)        NextState(04)  LineNumber(0006)
>   [(]  State(04)  {fn}  NextState(06)  LineNumber(0006)
>   [i]  State(06)        NextState(07)  LineNumber(0006)
>   [n]  State(07)        NextState(07)  LineNumber(0006)
>   [t]  State(07)        NextState(07)  LineNumber(0006)
>   [*]  State(07)        NextState(08)  LineNumber(0006)
>   [ ]  State(08)  {vt}  NextState(09)  LineNumber(0006)
>   [N]  State(09)        NextState(10)  LineNumber(0006)
>   [)]  State(10)  {vn}  NextState(00)  LineNumber(0006)
>    insert("M", 1);
> 
> 
>>>>>>> // begin of function type
>>>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)
>>>>>>
>>>>>> What does that [*] mean?  Judging by the other uses of []s, you 
>>>>>> seem to
>>>>>> be accepting *s and digits at the start of a C function header even
>>>>>> though they won't be taken to be one of your named matches.  Why 
>>>>>> single
>>>>>> out *s and digits?
>>>>>
>>>>> int* M(int* N);
>>>>
>>>> This does not recognise the {fh} pattern.  Putting the named
>>>> patterns into the string at the point the action would be triggered I
>>>> get
>>>
> 
> Your:
> *1*x x(*x x()
> was rejected by the C compiler.
> 

[toc] | [prev] | [next] | [standalone]


#40851 — Re: I finally completed my lexical analyzer generator (needed by my halt decider) update

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-10-26 14:56 +0100
SubjectRe: I finally completed my lexical analyzer generator (needed by my halt decider) update
Message-ID<87pmrrzy74.fsf@bsb.me.uk>
In reply to#40838
olcott <NoOne@NoWhere.com> writes:

> On 10/25/2021 8:09 PM, Ben Bacarisse wrote:
>> olcott <NoOne@NoWhere.com> writes:
>> 
>>> On 10/25/2021 6:26 PM, Ben Bacarisse wrote:
>>>> olcott <NoOne@NoWhere.com> writes:
>>>>
>>>>> On 10/24/2021 8:08 PM, Ben Bacarisse wrote:
>>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>>
>>>>>>> Enhancements: (Assumes that the C source code compiles)
>>>>>>> (a) Ignores /* */ comments
>>>>>>> (b) Ignores #define lines
>>>>>>> (c) Correctly handles trailing space in: int Function_Name(void   )
>>>>>>>
>>>>>>> //
>>>>>>> //  Deterministic Finite Automaton (DFA) recognizer
>>>>>>> //  of C function headers.
>>>>>>>
>>>>>>> // Character Classes
>>>>>>> //
>>>>>>>        EMPTY [0]
>>>>>>>        ALPHA [ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz]
>>>>>>>      NUMERIC [0123456789]
>>>>>>>           WS [0x09,0x0A,0x0D,0x20]
>>>>>>>       LPAREN [(]
>>>>>>>       RPAREN [)]
>>>>>>>        POUND [#]
>>>>>>>     ASTERISK [*]     // 0x2a
>>>>>>>        COMMA [,]
>>>>>>>        SLASH [0x2f]  // "/"
>>>>>>>      NEWLINE [0x0A]
>>>>>>
>>>>>> Why don't you use these last seven?
>>>>>
>>>>> I do use them.
>>>>
>>>> I meant why not use them in the code you posted.
>>>
>>> They are used in the DFA shown below.
>>
>> No they are not.
>
> Here is LPAREN: [(]{fn}(06)
>>>>>>> <04> WS{fn}(05) ALPHA(04) NUMERIC(04) [*](00) [(]{fn}(06)

No.  That state uses the definitions ALPHA and NUMERIC but it does not
use the definition LPAREN.  The point, since I seem t have to spell it
out, is why name the class is you are not going to use the named
versions?  It makes the read think you don't know how the notation
works.

>>>>> I can refer to either the name or the definition of the character class.
>>>>> ASCII and CONTROL may be used in the future.
>>>>>
>>>>>>>        ASCII [0x20-0x7e]
>>>>>>>         ASCII_MINUS_NEWLINE [0x00-0x09,0x0b-0x7f]
>>>>>>>        ASCII_MINUS_ASTERISK [0x00-0x29,0x2b-0x7f]
>>>>>>>           ASCII_MINUS_SLASH [0x00-0x2e,0x30-0x7f]
>>>>>>>      CONTROL [0x00-0x09,0x0b-0x1f,0x7f]
>>>>>>>
>>>>>>> // Recognized Patterns
>>>>>>> //
>>>>>>> {et} Empty
>>>>>>> {ft} Function_Type
>>>>>>> {fn} Function_Name
>>>>>>> {vt} Variable_Type
>>>>>>> {vn} Variable_Name
>>>>>>> {fh} Function_Header
>>>>>>>
>>>>>>> // DFA Definition to recognize C function headers
>>>>>>
>>>>>> No DFA can do that in general.  You mean "recognise a very restricted
>>>>>> subset of C function headers".
>>>>>
>>>>> It recognizes everything that I will ever write.
>>>>
>>>> Ah.  That simplifies things, and alerts the reader not to check the DFA
>>>> since you can just say "I'd never write that!".  However...
>>>>
>>> If I wanted a more robust function header recognizer I would adapt the
>>> lex/yacc spec for C.
>>
>> Your DFA does not even recognise the one example you gave! 
>
> Why did you delete it?

I didn't.  It is still quoted in the post you are replying to here and
you have kept in your reply and it is still there in this post.

> Here is is being correctly recognized:
> int* M(int* N);
>
>  [i]  State(00)        NextState(01)  LineNumber(0006)
>  [n]  State(01)        NextState(01)  LineNumber(0006)
>  [t]  State(01)        NextState(01)  LineNumber(0006)
>  [*]  State(01)        NextState(02)  LineNumber(0006)
>  [ ]  State(02)  {ft}  NextState(03)  LineNumber(0006)
>  [M]  State(03)        NextState(04)  LineNumber(0006)
>  [(]  State(04)  {fn}  NextState(06)  LineNumber(0006)
>  [i]  State(06)        NextState(07)  LineNumber(0006)
>  [n]  State(07)        NextState(07)  LineNumber(0006)
>  [t]  State(07)        NextState(07)  LineNumber(0006)
>  [*]  State(07)        NextState(08)  LineNumber(0006)
>  [ ]  State(08)  {vt}  NextState(09)  LineNumber(0006)
>  [N]  State(09)        NextState(10)  LineNumber(0006)
>  [)]  State(10)  {vn}  NextState(00)  LineNumber(0006)
>   insert("M", 1);

It is not recognised as matching the {fh} pattern.  That's (apparently)
the pattern for a function header.  Some things do match the {fh}
pattern.  For example "int M(void)".

Now you may have fudged things by making the action associated with the
{vn} action trigger whatever it is you want to with a function header,
but that's a hack.  Or maybe you've hacked it to work in some other way,
but some function headers do match the correct named pattern, but most
don't.

>>>>>>> // begin of function type
>>>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)
>>>>>>
>>>>>> What does that [*] mean?  Judging by the other uses of []s, you seem to
>>>>>> be accepting *s and digits at the start of a C function header even
>>>>>> though they won't be taken to be one of your named matches.  Why single
>>>>>> out *s and digits?
>>>>>
>>>>> int* M(int* N);
>>>>
>>>> This does not recognise the {fh} pattern.  Putting the named
>>>> patterns into the string at the point the action would be triggered I
>>>> get

This is where you should have show that example not being recognised and
then you would not accused me of deleting the example!

> Your:
> *1*x x(*x x()
> was rejected by the C compiler.

Yes.  But right after I complained about your "int* M(int* N);" example
not matching as a header you said

  "The above string would be rejected by the C compiler"

which is obviously not the case.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#40854 — Re: I finally completed my lexical analyzer generator (needed by my halt decider) update

Fromolcott <NoOne@NoWhere.com>
Date2021-10-26 09:43 -0500
SubjectRe: I finally completed my lexical analyzer generator (needed by my halt decider) update
Message-ID<ubudnamzFLZhjuX8nZ2dnUU7-WfNnZ2d@giganews.com>
In reply to#40851
On 10/26/2021 8:56 AM, Ben Bacarisse wrote:
> olcott <NoOne@NoWhere.com> writes:
> 
>> On 10/25/2021 8:09 PM, Ben Bacarisse wrote:
>>> olcott <NoOne@NoWhere.com> writes:
>>>
>>>> On 10/25/2021 6:26 PM, Ben Bacarisse wrote:
>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>
>>>>>> On 10/24/2021 8:08 PM, Ben Bacarisse wrote:
>>>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>>>
>>>>>>>> Enhancements: (Assumes that the C source code compiles)
>>>>>>>> (a) Ignores /* */ comments
>>>>>>>> (b) Ignores #define lines
>>>>>>>> (c) Correctly handles trailing space in: int Function_Name(void   )
>>>>>>>>
>>>>>>>> //
>>>>>>>> //  Deterministic Finite Automaton (DFA) recognizer
>>>>>>>> //  of C function headers.
>>>>>>>>
>>>>>>>> // Character Classes
>>>>>>>> //
>>>>>>>>         EMPTY [0]
>>>>>>>>         ALPHA [ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz]
>>>>>>>>       NUMERIC [0123456789]
>>>>>>>>            WS [0x09,0x0A,0x0D,0x20]
>>>>>>>>        LPAREN [(]
>>>>>>>>        RPAREN [)]
>>>>>>>>         POUND [#]
>>>>>>>>      ASTERISK [*]     // 0x2a
>>>>>>>>         COMMA [,]
>>>>>>>>         SLASH [0x2f]  // "/"
>>>>>>>>       NEWLINE [0x0A]
>>>>>>>
>>>>>>> Why don't you use these last seven?
>>>>>>
>>>>>> I do use them.
>>>>>
>>>>> I meant why not use them in the code you posted.
>>>>
>>>> They are used in the DFA shown below.
>>>
>>> No they are not.
>>
>> Here is LPAREN: [(]{fn}(06)
>>>>>>>> <04> WS{fn}(05) ALPHA(04) NUMERIC(04) [*](00) [(]{fn}(06)
> 
> No.  That state uses the definitions ALPHA and NUMERIC but it does not
> use the definition LPAREN.  

I told you this before yet you did not notice because your entire focus 
is on rebuttal with no weight what-so-ever to understand.

A character class can be referred to in the DFA by its name of by its 
definition. Because [(] is more concise than LPAREN I used the 
definition instead of the name.

> The point, since I seem t have to spell it
> out, is why name the class is you are not going to use the named
> versions?  It makes the read think you don't know how the notation
> works.
> 
>>>>>> I can refer to either the name or the definition of the character class.
>>>>>> ASCII and CONTROL may be used in the future.
>>>>>>
>>>>>>>>         ASCII [0x20-0x7e]
>>>>>>>>          ASCII_MINUS_NEWLINE [0x00-0x09,0x0b-0x7f]
>>>>>>>>         ASCII_MINUS_ASTERISK [0x00-0x29,0x2b-0x7f]
>>>>>>>>            ASCII_MINUS_SLASH [0x00-0x2e,0x30-0x7f]
>>>>>>>>       CONTROL [0x00-0x09,0x0b-0x1f,0x7f]
>>>>>>>>
>>>>>>>> // Recognized Patterns
>>>>>>>> //
>>>>>>>> {et} Empty
>>>>>>>> {ft} Function_Type
>>>>>>>> {fn} Function_Name
>>>>>>>> {vt} Variable_Type
>>>>>>>> {vn} Variable_Name
>>>>>>>> {fh} Function_Header
>>>>>>>>
>>>>>>>> // DFA Definition to recognize C function headers
>>>>>>>
>>>>>>> No DFA can do that in general.  You mean "recognise a very restricted
>>>>>>> subset of C function headers".
>>>>>>
>>>>>> It recognizes everything that I will ever write.
>>>>>
>>>>> Ah.  That simplifies things, and alerts the reader not to check the DFA
>>>>> since you can just say "I'd never write that!".  However...
>>>>>
>>>> If I wanted a more robust function header recognizer I would adapt the
>>>> lex/yacc spec for C.
>>>
>>> Your DFA does not even recognise the one example you gave!
>>
>> Why did you delete it?
> 
> I didn't.  It is still quoted in the post you are replying to here and
> you have kept in your reply and it is still there in this post.
> 
>> Here is is being correctly recognized:
>> int* M(int* N);
>>
>>   [i]  State(00)        NextState(01)  LineNumber(0006)
>>   [n]  State(01)        NextState(01)  LineNumber(0006)
>>   [t]  State(01)        NextState(01)  LineNumber(0006)
>>   [*]  State(01)        NextState(02)  LineNumber(0006)
>>   [ ]  State(02)  {ft}  NextState(03)  LineNumber(0006)
>>   [M]  State(03)        NextState(04)  LineNumber(0006)
>>   [(]  State(04)  {fn}  NextState(06)  LineNumber(0006)
>>   [i]  State(06)        NextState(07)  LineNumber(0006)
>>   [n]  State(07)        NextState(07)  LineNumber(0006)
>>   [t]  State(07)        NextState(07)  LineNumber(0006)
>>   [*]  State(07)        NextState(08)  LineNumber(0006)
>>   [ ]  State(08)  {vt}  NextState(09)  LineNumber(0006)
>>   [N]  State(09)        NextState(10)  LineNumber(0006)
>>   [)]  State(10)  {vn}  NextState(00)  LineNumber(0006)
>>    insert("M", 1);
> 
> It is not recognised as matching the {fh} pattern.  That's (apparently)

I already told you this before but because you only want to provide a 
rebuttal and don't give a rat's ass about understanding what I say you 
missed the explanition.

Because each state can only recognize a single pattern and state (10) 
must recognize {vn} I use a separate semantic action to recognize {fh}.

> the pattern for a function header.  Some things do match the {fh}
> pattern.  For example "int M(void)".
> 
> Now you may have fudged things by making the action associated with the
> {vn} action trigger whatever it is you want to with a function header,
> but that's a hack.  Or maybe you've hacked it to work in some other way,
> but some function headers do match the correct named pattern, but most
> don't.
> 
>>>>>>>> // begin of function type
>>>>>>>> <00> WS    (00) ALPHA(01) NUMERIC(00) [*](00) [/](12) [#](13)
>>>>>>>
>>>>>>> What does that [*] mean?  Judging by the other uses of []s, you seem to
>>>>>>> be accepting *s and digits at the start of a C function header even
>>>>>>> though they won't be taken to be one of your named matches.  Why single
>>>>>>> out *s and digits?
>>>>>>
>>>>>> int* M(int* N);
>>>>>
>>>>> This does not recognise the {fh} pattern.  Putting the named
>>>>> patterns into the string at the point the action would be triggered I
>>>>> get
> 
> This is where you should have show that example not being recognised and
> then you would not accused me of deleting the example!
> 
>> Your:
>> *1*x x(*x x()
>> was rejected by the C compiler.
> 
> Yes.  But right after I complained about your "int* M(int* N);" example
> not matching as a header you said
> 

I already said that I have separate semantic actions that augment the 
recognizer and you simply ignored that part because it was not useful 
for your rebuttal.

This is the semantic action that recognizes Function Headers

bool RecognizedFunctionHeader(u8 OneByte, int State)
{
   return (OneByte == ')' && (State == 6 || State == 7 || State == 9 || 
State == 10 || State == 11));
}

*1*x x(*x x()

>    "The above string would be rejected by the C compiler"
> 
> which is obviously not the case.
> 

Why say something so foolish as that?


-- 
Copyright 2021 Pete Olcott

"Great spirits have always encountered violent opposition from mediocre 
minds." Einstein

[toc] | [prev] | [next] | [standalone]


#40870 — Re: I finally completed my lexical analyzer generator (needed by my halt decider) update

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-10-26 23:47 +0100
SubjectRe: I finally completed my lexical analyzer generator (needed by my halt decider) update
Message-ID<87ee87z9mm.fsf@bsb.me.uk>
In reply to#40854
olcott <NoOne@NoWhere.com> writes:

> On 10/26/2021 8:56 AM, Ben Bacarisse wrote:
>> olcott <NoOne@NoWhere.com> writes:
>> 
>>> On 10/25/2021 8:09 PM, Ben Bacarisse wrote:
>>>> olcott <NoOne@NoWhere.com> writes:
>>>>
>>>>> On 10/25/2021 6:26 PM, Ben Bacarisse wrote:
>>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>>
>>>>>>> On 10/24/2021 8:08 PM, Ben Bacarisse wrote:
>>>>>>>> olcott <NoOne@NoWhere.com> writes:
>>>>>>>>
>>>>>>>>> Enhancements: (Assumes that the C source code compiles)
>>>>>>>>> (a) Ignores /* */ comments
>>>>>>>>> (b) Ignores #define lines
>>>>>>>>> (c) Correctly handles trailing space in: int Function_Name(void   )
>>>>>>>>>
>>>>>>>>> //
>>>>>>>>> //  Deterministic Finite Automaton (DFA) recognizer
>>>>>>>>> //  of C function headers.
>>>>>>>>>
>>>>>>>>> // Character Classes
>>>>>>>>> //
>>>>>>>>>         EMPTY [0]
>>>>>>>>>         ALPHA [ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz]
>>>>>>>>>       NUMERIC [0123456789]
>>>>>>>>>            WS [0x09,0x0A,0x0D,0x20]
>>>>>>>>>        LPAREN [(]
>>>>>>>>>        RPAREN [)]
>>>>>>>>>         POUND [#]
>>>>>>>>>      ASTERISK [*]     // 0x2a
>>>>>>>>>         COMMA [,]
>>>>>>>>>         SLASH [0x2f]  // "/"
>>>>>>>>>       NEWLINE [0x0A]
>>>>>>>>
>>>>>>>> Why don't you use these last seven?
>>>>>>>
>>>>>>> I do use them.
>>>>>>
>>>>>> I meant why not use them in the code you posted.
>>>>>
>>>>> They are used in the DFA shown below.
>>>>
>>>> No they are not.
>>>
>>> Here is LPAREN: [(]{fn}(06)
>>>>>>>>> <04> WS{fn}(05) ALPHA(04) NUMERIC(04) [*](00) [(]{fn}(06)
>>
>> No.  That state uses the definitions ALPHA and NUMERIC but it does not
>> use the definition LPAREN.  
>
> I told you this before yet you did not notice because your entire
> focus is on rebuttal with no weight what-so-ever to understand.
>
> A character class can be referred to in the DFA by its name of by its
> definition. Because [(] is more concise than LPAREN I used the
> definition instead of the name.

Obviously.  That's not the issue.  You don't use the named definitions.
It looks sloppy to give definitions that you don't use.  Just like it
looks sloppy to include "NUMERIC(00)" in state 0 when digits are invalid
at that point.  Why single them out?  It looks like writing code by
rote, rather than with careful consideration.

>>> Here is is being correctly recognized:
>>> int* M(int* N);
>>>
>>>   [i]  State(00)        NextState(01)  LineNumber(0006)
>>>   [n]  State(01)        NextState(01)  LineNumber(0006)
>>>   [t]  State(01)        NextState(01)  LineNumber(0006)
>>>   [*]  State(01)        NextState(02)  LineNumber(0006)
>>>   [ ]  State(02)  {ft}  NextState(03)  LineNumber(0006)
>>>   [M]  State(03)        NextState(04)  LineNumber(0006)
>>>   [(]  State(04)  {fn}  NextState(06)  LineNumber(0006)
>>>   [i]  State(06)        NextState(07)  LineNumber(0006)
>>>   [n]  State(07)        NextState(07)  LineNumber(0006)
>>>   [t]  State(07)        NextState(07)  LineNumber(0006)
>>>   [*]  State(07)        NextState(08)  LineNumber(0006)
>>>   [ ]  State(08)  {vt}  NextState(09)  LineNumber(0006)
>>>   [N]  State(09)        NextState(10)  LineNumber(0006)
>>>   [)]  State(10)  {vn}  NextState(00)  LineNumber(0006)
>>>    insert("M", 1);
>>
>> It is not recognised as matching the {fh} pattern.  That's (apparently)
>
> I already told you this before but because you only want to provide a
> rebuttal and don't give a rat's ass about understanding what I say you
> missed the explanition.
>
> Because each state can only recognize a single pattern and state (10)
> must recognize {vn} I use a separate semantic action to recognize
> {fh}.

The string you gave does not match the function header pattern.  Your
"explanation" explains nothing.  You just confirm confirming that the
DFA does not recognise "int* M(int* N)" as a function header.  The DFA
stops after recognising a "vn" (variable name?).

>> Yes.  But right after I complained about your "int* M(int* N);" example
>> not matching as a header you said
>
> I already said that I have separate semantic actions that augment the
> recognizer and you simply ignored that part because it was not useful
> for your rebuttal.
>
> This is the semantic action that recognizes Function Headers
>
> bool RecognizedFunctionHeader(u8 OneByte, int State)
> {
>   return (OneByte == ')' && (State == 6 || State == 7 || State == 9 || State == 10 || State == 11));
> }
>
> *1*x x(*x x()
>
>>    "The above string would be rejected by the C compiler"
>> which is obviously not the case.
>
> Why say something so foolish as that?

I know you are not above lying.  I know you persist in dishonestly
omitting key parts of Linz's argument about halting.  But I never
thought you'd edit and re-order a reply to score a cheap point.  For
some reason it seems particularly shameful that you'd do this.

Here is the exchange:

|>> int* M(int* N);
|> 
|> This does not recognise the {fh} pattern.  Putting the named
|> patterns into the string at the point the action would be triggered I
|> get
| 
|The above string would be rejected by the C compiler this never reach 
|the DFA reogonizer.
| 
|>    int* {ft}M({fn}int* {vt}N){vn}

Just look at how you have re-edited that simple exchange.

You gave an example.  I told you your DFA does not recognise it as a
function header.  You say "the above string would be rejected by the C
compiler".

The string you dishonestly re-inserted into the exchange "*1*x x(*x x()"
does not even appear, quoted or otherwise, in your post so you don't
even have the excuse that "the above string" was supposed to refer to
something further above than the obvious candidate.

You rarely shock me anymore, but I'm shocked by this behaviour.

-- 
Ben.

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.theory


csiph-web