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

Re: small pascal

Hi Ali,

Ali Muhammad wrote:
It fails on first semicolon complaing that the semicolon expected, whereas
it is there. Grammar looks fine. I regenerated the lexer.dat file. Still
giving the same problem.

You should try looking at the tokens that the parser receives. Often, such problems are due to a faulty lexer that "eats" too many characters (e.g. if the lexer includes the semicolon within a TIdentifier).

You can try looking up a simple custom Lexer which prints all scanned tokens (type & value) in the mailing list archive. It goes something like:

public class MyLexer extends Lexer
  protected ... filter(Token t)
    System.out.println("Token: " + t.getClass() + " " + t.text());

I am writing this off my head, so the exact signature and names might be different.

I debugged the program and noticed that in method
public Start parse() throws ParserException, LexerException, IOException
(parser.java) when it switch on the action[0] it leads to the exception.
Now, I cannot view the action table. Is there any way to view and modify
this table.

You can view the table in the comments at the end of Parser.java. You cannot easily modify it, as the values are loaded from parser.dat, so you would have to modify this file (not easy).

It is quite unlikely that this would be a parse table problem. Of course, it could be, but I would really investigate the grammar/lexer first.

I hope this helps.


Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/