by Hanford Carr <"hwcarr<no spam>"@[EMAIL PROTECTED]
>
Mar 30, 2005 at 10:53 AM
Profetas wrote:
>
> I have a simple menu program that loops and ask the user to type a
command,
>
> but after the first command is typed the readln
> doesn't read it properly
>
> That doesn't affect much, but it is driving me mad.
>
> has anybode had the same problem?
>
> I am using freepascal BTW.
>
> Thanks (the code is below)
>
> PROGRAM LexDemo;
>
> USES Scanner,Parser;
>
> {VAR}
>
> { PRE TRUE }
> { POST Menu printed out }
> PROCEDURE Menu();
>
> BEGIN
> WRITELN(' Logical calculator by Lucas S Silvs ');
> WRITELN('+------------------------------------------+');
> WRITELN('+ Main Menu +');
> WRITELN('+------------------------------------------+');
> WRITELN('| D -=> Display menu |');
> WRITELN('| L -=> Lex keyboard input |');
> WRITELN('| P -=> Parser the tokens into parse tree |');
> WRITELN('| E -=> Ealuate the parser tree |');
> WRITELN('| B -=> Bind an identifier to a value |');
> WRITELN('| S -=> Show the values of all identifiers |');
> WRITELN('| Q -=> Quit |');
> WRITELN('| Print (m)enu |');
> WRITELN('| (l)ex token from standard input |');
> WRITELN('| lex token(s) from standard input |');
> WRITELN('| (r)ead string |');
> WRITELN('| lex tokens from s(t)ring |');
> WRITELN('+------------------------------------------+');
> END {Menu};
>
> PROCEDURE Main_Loop();
> VAR
> Option : CHAR;
>
> BEGIN
> Option := 'd';
> WHILE Option <> 'q' DO
> BEGIN
> CASE Option OF
> 'L' : yylex();
> 'P' : yyparser(Tokens);
> 'l' : Menu();
> 's' : Menu();
> 'r' : Menu();
> 'd' : Menu();
> ELSE
> Menu();
> END;
>
> WRITE('Type your command: ==> ');
> READLN(Option);
> END
> END {Main_Loop};
>
> BEGIN
> Main_Loop();
> END. {LexDemo}
How do you enter your first command? Do you type say an 's' and wait
for something to happen or do you type 's'+<Enter>?
Hanford