Search in sources :

Example 1 with Start

use of de.prob.core.sablecc.node.Start in project probparsers by bendisposto.

the class AnswerTest method testOperation3.

@Test
public void testOperation3() throws ResultParserException {
    final String testString = "yes('.'(=('PLOps','.'(op(initialise_machine,1,[],root),[])),[]))";
    final Start rootNode = ProBResultParser.parse(testString);
    /* Review: Using System.out.println is ok, this is a test only */
    // NOPMD by fabian on 8/13/07 12:48 PM
    System.out.println(testString);
    // new RootNode(new SableAST(rootNode),
    // new HashMap<SetElementItem, String>());
    assertNotNull(PARSETREE_WAS_NULL, rootNode);
}
Also used : Start(de.prob.core.sablecc.node.Start) Test(org.junit.Test)

Example 2 with Start

use of de.prob.core.sablecc.node.Start in project probparsers by bendisposto.

the class AnswerTest method testNo.

// executeOperation(1).
// no
@Test
public void testNo() throws ResultParserException {
    final String testString = "no";
    final Start rootNode = ProBResultParser.parse(testString);
    assertNotNull(PARSETREE_WAS_NULL, rootNode);
}
Also used : Start(de.prob.core.sablecc.node.Start) Test(org.junit.Test)

Example 3 with Start

use of de.prob.core.sablecc.node.Start in project probparsers by bendisposto.

the class AnswerTest method testOperation2.

// computeOperationsForState(7,X).
// yes('.'(=('X','.'(op(add(fd(3,'Name'),fd(1,'Code')),11,[]),'.'(op(add(fd(3,'Name'),fd(2,'Code')),12,[]),'.'(op(lookup(fd(1,'Name')),7,'.'(fd(1,'Code'),[])),'.'(op(lookup(fd(2,'Name')),7,'.'(fd(1,'Code'),[])),'.'(op(update(fd(1,'Name'),fd(1,'Code')),7,[]),'.'(op(update(fd(1,'Name'),fd(2,'Code')),13,[]),'.'(op(update(fd(2,'Name'),fd(1,'Code')),7,[]),'.'(op(update(fd(2,'Name'),fd(2,'Code')),8,[]),[]))))))))),[]))
@Test
public void testOperation2() throws ResultParserException {
    final String testString = "yes('.'(=('X','.'(op(add(fd(3,'Name'),fd(1,'Code')),11,[],0),'.'(op(add(fd(3,'Name'),fd(2,'Code')),12,[],0),'.'(op(lookup(fd(1,'Name')),7,'.'(fd(1,'Code'),[]),0),'.'(op(lookup(fd(2,'Name')),7,'.'(fd(1,'Code'),[]),0),'.'(op(update(fd(1,'Name'),fd(1,'Code')),7,[],0),'.'(op(update(fd(1,'Name'),fd(2,'Code')),13,[],0),'.'(op(update(fd(2,'Name'),fd(1,'Code')),7,[],0),'.'(op(update(fd(2,'Name'),fd(2,'Code')),8,[],0),[]))))))))),[]))";
    final Start rootNode = ProBResultParser.parse(testString);
    /* Review: Using System.out.println is ok, this is a test only */
    // NOPMD by fabian on 8/13/07 12:48 PM
    System.out.println(testString);
    // new RootNode(new SableAST(rootNode),
    // new HashMap<SetElementItem, String>());
    assertNotNull(PARSETREE_WAS_NULL, rootNode);
}
Also used : Start(de.prob.core.sablecc.node.Start) Test(org.junit.Test)

Example 4 with Start

use of de.prob.core.sablecc.node.Start in project probparsers by bendisposto.

the class ProBResultParser method parse.

public static Start parse(final String prologAnswer) throws ResultParserException {
    if (prologAnswer.length() == 0)
        throw new ResultParserException("Received empty Result", null);
    final PushbackReader codeReader = new PushbackReader(new StringReader(prologAnswer), prologAnswer.length());
    final Lexer lexer = new Lexer(codeReader);
    final Parser parser = new Parser(lexer);
    Start parseResult = null;
    try {
        parseResult = parser.parse();
    } catch (final ParserException e) {
        String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser. String was: '" + prologAnswer + "'. Last Token was '" + e.getToken() + "': " + e.getLocalizedMessage();
        throw new ResultParserException(message, e);
    } catch (final LexerException e) {
        String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser String was: '" + prologAnswer + "': " + e.getLocalizedMessage();
        throw new ResultParserException(message, e);
    } catch (final IOException e) {
        String message = "Internal Error while parsing ProB answer. This ist most likely a bug in the Result-Parser String was: " + prologAnswer + "': " + e.getLocalizedMessage();
        throw new ResultParserException(message, e);
    }
    return parseResult;
}
Also used : ParserException(de.prob.core.sablecc.parser.ParserException) Lexer(de.prob.core.sablecc.lexer.Lexer) Start(de.prob.core.sablecc.node.Start) StringReader(java.io.StringReader) IOException(java.io.IOException) LexerException(de.prob.core.sablecc.lexer.LexerException) PushbackReader(java.io.PushbackReader) Parser(de.prob.core.sablecc.parser.Parser)

Example 5 with Start

use of de.prob.core.sablecc.node.Start in project probparsers by bendisposto.

the class AnswerTest method testGetNegativeNumber.

// yes('.'(=('CurID',-1),[]))
@Test
public void testGetNegativeNumber() throws ResultParserException {
    final String testString = "yes('.'(=('CurId',-1),[]))";
    final Start rootNode = ProBResultParser.parse(testString);
    assertNotNull(PARSETREE_WAS_NULL, rootNode);
}
Also used : Start(de.prob.core.sablecc.node.Start) Test(org.junit.Test)

Aggregations

Start (de.prob.core.sablecc.node.Start)13 Test (org.junit.Test)11 IRawCommand (de.prob.animator.command.IRawCommand)1 Lexer (de.prob.core.sablecc.lexer.Lexer)1 LexerException (de.prob.core.sablecc.lexer.LexerException)1 Parser (de.prob.core.sablecc.parser.Parser)1 ParserException (de.prob.core.sablecc.parser.ParserException)1 PrologTermStringOutput (de.prob.prolog.output.PrologTermStringOutput)1 IOException (java.io.IOException)1 PushbackReader (java.io.PushbackReader)1 StringReader (java.io.StringReader)1