Re: Interactive stamtment execution (goon)
Thu, 30 Jul 1992 13:40:20 GMT

          From comp.compilers

Related articles
Interactive stamtment execution (Elliot H. Mednick) (1992-07-29)
Re: Interactive stamtment execution (1992-07-30)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (goon)
Organization: St. Olaf College, Northfield, MN USA
Date: Thu, 30 Jul 1992 13:40:20 GMT
Keywords: interpreter, yacc
References: 92-07-088 (Elliot H. Mednick) writes:
  [how can I use one parser for both interactive and batch parsing?]

  The language that is to be parsed includes header and declarative
  information that YACC needs to know about, as well as the procedural
  statements. In "interactive mode", entering declarations would be
  illegal; only the statements would be allowed. At the top level, a common
  YACC description might look something like this:

        : program
        | statement

        : header declaration statment_list

Just modify the productions.

        : ... { if (interactive) YYERROR; ...}

        : ... { if (interactive) YYERROR; ...}

Or if you want to get really fancy, then make the lexer

PS: Whenever designing a language that is supposed to be interactive _and_
batch, I think long and hard about doing anything dependent on the output
of isatty(). It's awful confusing for the user, especially when something
typed in interactively gives errors when cut-and-pasted into a file, or
conversely If you can manage to get along without the headers and
declarations in interactive mode, why bother? If you allow headers and
declarations in batch mode, why bother making them illegal in interactive

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.