Interactive toplevel parsing

May 31, 2012 at 12:49 PM


I was wondering if it is possible to use GPPG in an Interactive toplevel enviroment.

If yes are there any example or any guidelines to follow?

Jun 6, 2012 at 9:10 AM

Hi baucez.  Well, gppg parsers can work with any scanner, interactive or not.  However building interactive *scanners* is sometimes tricky.

If you have an incremental scanner, one that returns symbols as they are typed in, then the parser may behave a little unexpectedly.

gppg parsers can sometimes make a parsing decision without needing a lookahead symbol, but in other circumstances will not make a move until it has seen the next symbol.  This sometimes appears a little odd.

Writing interactive scanners is likewise tricky, because a scanner needs one character of lookahead before it can declare that it has recognized *any* regular expression. For example if you have a C# scanner that has just read f,o,r, then it cannot return the token "keyword-for" without checking if the following characters are "each".  Usually it can work if input is read line-by-line and no regular expression contains a line-separator.

Other than this I can't give any general guidelines.