[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Line by Line Mode error messages



I have an application that needs to read line by line from a console... so I was using the approach described previously in http://lists.sablecc.org/pipermail/sablecc-discussion/msg00316.html 
in which Rowan suggested:
Rowan Worth wrote:
  I think I have a general solution for 3.2:
1) read one line
2) try and parse it
3) if you got an AST then you are done
4) if you got an exception and the lexer is at EOF, read another line
and go back to (2)
[...]
 
That approach has been working just fine, except for one problem... how to report errors?  If I get an error at the end of a line, it may be because of a "real" syntax error, or just because some construct (like an IF...ENDIF block) is incomplete.  I don't want to put out lots of "spurious" error messages to the user.  I was wondering if there is a reasonably easy way to know when I get an error building the AST what production it thought it was working on when it failed. ( For example, if I knew that it was an IF statement that was ill-formed, I could ignore the error message because I know that IF statements require multiple lines)
 
Has anyone encountered this sort of problem and figured out a solution?  I believe this will be solved when SableCC4 is ready for production, but in the meantime I need a way to do this in SableCC 3.2
 
Thanks!
 
 
 

Roger