Package org.jbehave.core.story.codegen.parser

Source Code of org.jbehave.core.story.codegen.parser.TextStoryParser

package org.jbehave.core.story.codegen.parser;

import java.io.IOException;
import java.io.PushbackReader;
import java.io.Reader;

import org.jbehave.core.story.codegen.domain.StoryDetails;
import org.jbehave.core.story.codegen.sablecc.lexer.Lexer;
import org.jbehave.core.story.codegen.sablecc.lexer.LexerException;
import org.jbehave.core.story.codegen.sablecc.node.Start;
import org.jbehave.core.story.codegen.sablecc.parser.Parser;
import org.jbehave.core.story.codegen.sablecc.parser.ParserException;



public class TextStoryParser implements StoryParser {
  public StoryDetails parseStory(Reader in) {
    try {
      Lexer lexer = new Lexer(new PushbackReader(in, 1024));
      Parser parser = new Parser(lexer);
      Start root = parser.parse();
      StoryDetailsBuilder builder = new StoryDetailsBuilder();
      root.apply(builder);
      return builder.getStoryDetails();
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage());
    } catch (LexerException e) {
      throw new RuntimeException(e.getMessage());
    } catch (ParserException e) {
      throw new RuntimeException(e.getMessage());
    }
   
  }

}
TOP

Related Classes of org.jbehave.core.story.codegen.parser.TextStoryParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.