[antlr-interest] Using ANTLR generated Parser and Lexer for an interactive shell

rradh rradh at yahoo.com
Tue Feb 26 13:07:11 PST 2002


Hi,

I have the following procedure:

1. The shell lexer takes a line of text returned by 'readline()' and
generates tokens.
2. The shell parser takes the tokens generated by the lexer and
performs the actions. 


   for ( ; shellExit == false; )
   {
      line = readline(prompt);
      
      if (!line)
         break;

      istrstream inputLine(line);
      
      ShellLexer inputLineLexer( inputLine  );
      ShellParser inputLineParser(inputLineLexer);

      inputLineParser.parse_command();
   }

I know this sounds lousy, but the only working solution I have. A
script file that contains commands understood by the shell can be
input. 

A single shell parser and lexer is what I am shooting for as the
parser is decoupled from the input stream by lexer and i want the
lexer to just read consecutive input lines of text. The problem I am
having with that is that only the first command gets understood and I
can't flush the previous input stream to the lexer.

Any suggestions?
Thanks
Rajesh


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list