Yacc & Lex Question

Yacc & Lex Question

Post by Leung Leu » Sat, 02 Dec 1995 04:00:00



Hi all,

        I am writing a program which will use Yacc & Lex to get the user's
input. But while waiting for the user's input, I want the program to poll
the message queue at the same time. If there is a message, it will be
displayed on the screen. How to do that ?  Seems that I cannot do
anything while waiting for user's input  ( yyparse() ) ...

Thanks

Leung

 
 
 

Yacc & Lex Question

Post by Wendell G » Sat, 02 Dec 1995 04:00:00


an infinite number of monkeys calling themselves Leung Leung

RB>Hi all,

RB>  I am writing a program which will use Yacc & Lex to get the user's
RB>input. But while waiting for the user's input, I want the program to poll
RB>the message queue at the same time. If there is a message, it will be
RB>displayed on the screen. How to do that ?  Seems that I cannot do
RB>anything while waiting for user's input  ( yyparse() ) ...

You can probably use a timer-interrupt to wake your message-poller
every so often...

man alarm
man signal

--r
--
--------------------------------------------------------------------------
| "The density of the information         | Rick Bradley                 |
|  presented is near the theoretical      | Starving Graduate Student    |
|  minimum." --FreeBSD manual:  comsat(8) | CS Dept. -- SUNY Stony Brook |
--------------------------------------------------------------------------

 
 
 

Yacc & Lex Question

Post by Craig P. Forbe » Sat, 02 Dec 1995 04:00:00



>         I am writing a program which will use Yacc & Lex to get the user's
> input. But while waiting for the user's input, I want the program to poll
> the message queue at the same time. If there is a message, it will be
> displayed on the screen. How to do that ?  Seems that I cannot do
> anything while waiting for user's input  ( yyparse() ) ...

I can't recall the details off hand but I believe you can define the
input function for lex.  Then in your input function you can do whatever
you want.  

If you aren't already you may want to look into flex and bison.  I find
them much nicer (and more portable) then the AT&T lex/yacc.

--
Craig P. Forbes                      McCabe & Associates
                                     5501 Twin Knolls Road, Suite 111

 
 
 

Yacc & Lex Question

Post by Leung Leu » Sun, 03 Dec 1995 04:00:00


: an infinite number of monkeys calling themselves Leung Leung

: RB>Hi all,

: RB>        I am writing a program which will use Yacc & Lex to get the user's
: RB>input. But while waiting for the user's input, I want the program to poll
: RB>the message queue at the same time. If there is a message, it will be
: RB>displayed on the screen. How to do that ?  Seems that I cannot do
: RB>anything while waiting for user's input  ( yyparse() ) ...

: You can probably use a timer-interrupt to wake your message-poller
: every so often...

: man alarm
: man signal

        Um ... It is a very good idea.. Thanks ! :)
Any other suggestions are welcom.

 
 
 

Yacc & Lex Question

Post by Pete Roumeliot » Mon, 04 Dec 1995 04:00:00



>Hi all,
>    I am writing a program which will use Yacc & Lex to get the user's
>input. But while waiting for the user's input, I want the program to poll
>the message queue at the same time. If there is a message, it will be
>displayed on the screen. How to do that ?  Seems that I cannot do
>anything while waiting for user's input  ( yyparse() ) ...

OK I'll take a whack at it.   Why don't you fork off a process that
does a blocking msgrcv call.  The rest of the main program can process
the user input and the forked process will sit there listening to your
message queue.  

Sound feasibal????

Pete R.

 
 
 

Yacc & Lex Question

Post by Mark-Jason Domin » Mon, 04 Dec 1995 04:00:00




>    I am writing a program which will use Yacc & Lex to get the user's
>input. But while waiting for the user's input, I want the program to poll
>the message queue at the same time. If there is a message, it will be
>displayed on the screen. How to do that ?  Seems that I cannot do
>anything while waiting for user's input  ( yyparse() ) ...

yyparse calls yylex to get tokens, and yylex calls `input' to get
characters.  You can define your own `input 'routine, and yylex will
call this routine instead.  Your input routine call poll the message
queue and display the response before it returns control to yylex.

I think that `input' is a macro, so the way to do this is to include
        #undef input

in the header part of the .l file; then yylex will call your `input'
function instead of using the macro.

--

  The night is pleasing to us because, like memory, it erases idle details.

 
 
 

1. Followup YACC & LEX Question

Thanks to all who responded to my recent LEX question..  I managed to take
two of the 4 responses I got and merge them for a solution..  Another question
comes up, now:

I'm still having fun with preprocessors.  What I now need to do is to
implement a (YACC) grammar to preprocess hunks of code, disregarding
code that is the actual program body wherever necesary..

For example, Here is a possibility:

        ? (VAR debug_mode:boolean := TRUE,
               unhappy_mode:boolean := TRUE; );?
               .
        <lots of program body here #1>
               .
        ?IF (debug_mode)
            PROCEDURE [XREF] Moo (x:integer);
               .
               .
        <lots of program body here #2>
               .
            PROCEND Moo;
        ?ELSE
            PROCEDURE [XREF] Moo2 (x:real);
               .
               .
        ?IFEND

For clarification of my ambiguous comment above, what I need to do is to
take a YACC grammar that will accept preprocessor directives but that has
no clue about the programming language itself.  Thus, I will need to
disregard code that is in "<lots of program body here #1>".  I can deal
with program bodies #2 and #3 and their appropriate manipulation, but
can't comprehend how to disregard all that middle code.  Anyone have an
idea?  Thanks in advance!

        -Jeff

2. PICO manual?

3. Where can I get origianl AT&T lex & yacc source?

4. permission on cdroast?

5. Wanted - additional tutorials & documentation on Lex & Yacc

6. Source/Package for xadmin?

7. YACC & LEX under Microsoft Windows

8. Making SVGALIB use XF86 monitor settings?

9. The Lex & Yacc source code for C++

10. LEX/YACC & Imake

11. Copmiling w/gcc under Solaris 2.3 (w/lex & yacc)

12. Need smart makefile for lex&yacc

13. how to use lex&yacc?