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

Re: getting [1,1] expecting: EOF no matter what



Hi there
I know I'm missing a | at the end of the file but that's not my problem,
evey grammar I have tried I awlays get
[1,1] expecting: EOF, if I move the first caracter of the example file
to the 3rd line I get
[3,1] expecting: EOF
the point is it always expects a EOF to start reading a token
thanks in advance



On 10/27/06, Jorge Mario G. Mazo <vadersolo@xxxxxxxxx> wrote:
Hi there
I'm very new to sablecc, but no matter what I try I alwats get the same error
here is my grammar

Package org.sablecc.baba;

Helpers
    digitos     = ['0'..'9'];
    letras      = ['A'..'Z']|['a'..'z'];
    caracteres  = ' '|digitos|letras;
    lf          = 10;
    cr          = 13;
    eol         = cr lf | cr | lf;
    blank       = 10 | 10 13 | 9 | ' ';

Tokens

    if          = 'if';
    then        = 'then';
    else        = 'else';
    while       = 'while';
    for         = 'for';
    end         = 'end';
    do          = 'do';

    numero      = digitos+;
    variable    = letras(letras|digitos)*;

    endofline   = eol;
    blanktoken  = blank+;

Ignored Tokens
    endofline,
    blanktoken;

Productions
    programa =
        lista_decl;

    lista_decl =
        decl*;

    decl =
        variable;

    lista_instr =
        instr*;

    instr =
        {declaracion} decl |

        {if} if variable then lista_instr end |

        {while} while variable do lista_instr end

        {for}  for variable do lista_instr end;
==========================================
and here is the java code I'm using
==========================================
import java.io.FileReader;
import java.io.PushbackReader;
import org.sablecc.baba.lexer.*;
import org.sablecc.baba.node.*;
import org.sablecc.baba.parser.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
    if (args.length < 1) {
        System.out.println("Usage:");
        System.out.println("java Main <filename>");
    }

    try {
        Lexer lexer = new Lexer(new PushbackReader(new
BufferedReader(new FileReader(args[0])),1024));

        Parser parser = new Parser(lexer);

        Start ast = parser.parse();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    }
}

-------------
I dont know what I'm doing wrong
any help would be apreciated