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

Re: ParserException: [1,1] expecting: EOF



Thanks. It works for me as well from command prompt. i.e the parser and other files are generated.

However, when I try to parse an _expression_  (from netbeans or command prompt), I get the error:

[1,1] expecting: EOF
org.sablecc.sablecc.parser.ParserException: [1,1] expecting: EOF
        at org.sablecc.sablecc.parser.Parser.parse(Parser.java:1792)
        at org.sablecc.sablecc.login.callParser(login.java:83)
        at org.sablecc.sablecc.login.loginPlusXml(login.java:70)
        at org.sablecc.sablecc.login$2.actionPerformed(login.java:120)

Below is a snippet of my code:

import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.xml.sax.InputSource;
import javax.xml.xpath.XPath.*;
import org.sablecc.sablecc.node.*;
import org.sablecc.sablecc.analysis.*;
import org.sablecc.sablecc.lexer.*;
import org.sablecc.sablecc.parser.*;
.
.
.
 public String loginPlusXml() throws XPathExpressionException{
        String login = loginTextField.getText();
        String password = new String(passwordTextField.getPassword());
        XPathFactory factory = XPathFactory.newInstance();
        XPath xpath = factory.newXPath();
        String _expression_="//users[login/text()=' " + login + " ' and password/text()=' " + password + " ']/id/text()";
        System.out.println("verifying login...");
        XPathExpression  expr = xpath.compile(_expression_);
        callParser(_expression_);
        return _expression_;
    }
        public static void callParser(String _expression_) {
        try {
            // Create a Parser instance.
            StringReader stringReader = new StringReader(_expression_);
            Parser p = new Parser( new Lexer( new PushbackReader( stringReader, _expression_.length))));
           
// Parse the input.
         Start tree = p.parse();     (the error occurs here)
        } catch(Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.exit(-1);
        }
       
    }
.
.
.
Is there any thing I might be doing wrong?



----- Original Message ----
From: Etienne M. Gagnon <egagnon@xxxxxxxxx>
To: Discussion mailing list for the SableCC project <sablecc-discussion@xxxxxxxxxxxxxxxxx>
Sent: Sunday, August 3, 2008 1:45:26 AM
Subject: Re: ParserException: [1,1] expecting: EOF

Hi Lola,

It works for me (see below). There's probably something wrong in your NetBeans setup. You could try running SableCC from the command line, until you find the problem.

Call to all: Is there any NetBeans user that could help Lola?

Etienne
PS: Here's the execution trace:
$ sablecc grammar.sablecc

SableCC version 3.2
Copyright (C) 1997-2003 Etienne M. Gagnon <etienne.gagnon@xxxxxxx> and
others. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.

Type 'sablecc -license' to view
the complete copyright notice and license.


-- Generating parser for grammar.sablecc in /Users/egagnon/tmp/bug
Adding productions and alternative of section AST.
Verifying identifiers.
Verifying ast identifiers.
Adding empty productions and empty alternative transformation if necessary.
Adding productions and alternative transformation if necessary.
computing alternative symbol table identifiers.
Verifying production transform identifiers.
Verifying ast alternatives transform identifiers.
Generating token classes.
Generating production classes.
Generating alternative classes.
Generating analysis classes.
Generating utility classes.
Generating the lexer.
State: INITIAL
- Constructing NFA.
....................................................
- Constructing DFA.
.........................................................................................
....................................
- resolving ACCEPT states.
Generating the parser.
.......
.......
.......
..
.......

Lola Oluyomi wrote:
[...]
Find attached a sample grammar file.
[...]

-- 
Etienne M. Gagnon, Ph.D.
SableCC: http://sablecc.org
SableVM: http://sablevm.org