9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] How to generate a "debuggable" lex.yy.c?
@ 2021-11-10 19:28 gomfy via 9fans
  2021-11-11 11:25 ` Charles Forsyth
  0 siblings, 1 reply; 3+ messages in thread
From: gomfy via 9fans @ 2021-11-10 19:28 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 4022 bytes --]

Hello,                                                                         
                                                                               
I would like to generate a lexer with debug functionality. I'm relying on a slightly modified versions of the sources:
https://9fans.github.io/plan9port/man/man3/bio.html                            
https://9fans.github.io/plan9port/man/man1/yacc.html                           
https://9fans.github.io/plan9port/man/man1/lex.html                            
                                                                               
As far as I can tell, my issues are not related to the fact that I'm working with a slightly modified version, but I thought I'll mention it just to be on the safe side.
                                                                                    
The first issue was that the debug information collected in fdebug was not flushed and as a result the **y.debug** file for the lexer kept showing up empty. I had to add Bterm(fdebug); at the end of the main() in **yacc.c** to get the **y.debug** file to be generated with content.
                                                                               
Now, my issue is that if I'm compiling the generated **lex.yy.c** with -DLEXDEBUG I get: 

undefined reference to `allprint(char)' 

because of sections like the one below:
                                                                               
# ifdef LEXDEBUG                                                               
            if(debug){                                                              
                fprintf(yyout,"char ");                                             
                allprint(yych);                                                     
                putchar('\n');                                                      
                }                                                                   
# endif                                                                             
                                                                                    
The allprint() function is defined in the Lex source **sub1.c**.  It seems I'd have to link against the Lex source to be able to compile **lex.yy.c** in debug mode, which would be a bit complicated as there are some clashes with my other application. Other complications are caused by the global variables that show up in allprint() and other functions that are listed in the DEBUG section of **sub1.c**.
                                                                               
Can someone point me in the right direction, or tell me what am I missing here?
                                                                                    
Thanks!                                                                        
Gyorgy    
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tdade85f2048629bd-M4b2d5c130fef22af9777cbbc
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 10096 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] How to generate a "debuggable" lex.yy.c?
  2021-11-10 19:28 [9fans] How to generate a "debuggable" lex.yy.c? gomfy via 9fans
@ 2021-11-11 11:25 ` Charles Forsyth
  2021-11-11 15:26   ` gomfy via 9fans
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Forsyth @ 2021-11-11 11:25 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 2860 bytes --]

Perhaps add a copy of allprint, without the character counting, to replace
the existing extern declaration in your ncform, still #ifdef'd with
LEXDEBUG.
The signature of allprint should also be static void allprint(Uchar) and
the exotic initial lines of sub1.c's allprint can be removed.
It needs a #include <ctype.h> inside the #ifdef to get isprint.

Originally on Unix there was a separate little lex library with its own
version of allprint.

On Wed, 10 Nov 2021 at 19:28, gomfy via 9fans <9fans@9fans.net> wrote:

>
> Hello,
>
>
> I would like to generate a lexer with debug functionality. I'm relying on
> a slightly modified versions of the sources:
> https://9fans.github.io/plan9port/man/man3/bio.html
>
> https://9fans.github.io/plan9port/man/man1/yacc.html
>
> https://9fans.github.io/plan9port/man/man1/lex.html
>
>
>
> As far as I can tell, my issues are not related to the fact that I'm
> working with a slightly modified version, but I thought I'll mention it
> just to be on the safe side.
>
>
> The first issue was that the debug information collected in fdebug was
> not flushed and as a result the *y.debug* file for the lexer kept showing
> up empty. I had to add Bterm(fdebug); at the end of the main() in *yacc.c*
> to get the *y.debug* file to be generated with content.
>
>
> Now, my issue is that if I'm compiling the generated *lex.yy.c* with
> -DLEXDEBUG I get:
>
> undefined reference to `allprint(char)'
>
> because of sections like the one below:
>
>
>
> # ifdef LEXDEBUG
>             if(debug){
>                 fprintf(yyout,"char ");
>                 allprint(yych);
>                 putchar('\n');
>                 }
> # endif
>
>
>
> The allprint() function is defined in the Lex source *sub1.c*.  It seems
> I'd have to link against the Lex source to be able to compile *lex.yy.c*
> in debug mode, which would be a bit complicated as there are some clashes
> with my other application. Other complications are caused by the global
> variables that show up in allprint() and other functions that are listed
> in the DEBUG section of *sub1.c*.
>
>
> Can someone point me in the right direction, or tell me what am I missing
> here?
>
>
>
> Thanks!
> Gyorgy
> *9fans <https://9fans.topicbox.com/latest>* / 9fans / see discussions
> <https://9fans.topicbox.com/groups/9fans> + participants
> <https://9fans.topicbox.com/groups/9fans/members> + delivery options
> <https://9fans.topicbox.com/groups/9fans/subscription> Permalink
> <https://9fans.topicbox.com/groups/9fans/Tdade85f2048629bd-M4b2d5c130fef22af9777cbbc>
>

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tdade85f2048629bd-Mb3af3d5e0cba2640853d9f74
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 11100 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] How to generate a "debuggable" lex.yy.c?
  2021-11-11 11:25 ` Charles Forsyth
@ 2021-11-11 15:26   ` gomfy via 9fans
  0 siblings, 0 replies; 3+ messages in thread
From: gomfy via 9fans @ 2021-11-11 15:26 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

Perfect, this worked. Thank you!
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tdade85f2048629bd-M7226e26d3cd8c13c50ce0dd9
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 754 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-11 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 19:28 [9fans] How to generate a "debuggable" lex.yy.c? gomfy via 9fans
2021-11-11 11:25 ` Charles Forsyth
2021-11-11 15:26   ` gomfy via 9fans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).