示例#1
0
  public IParseNode parse(IParseState parseState) throws Exception {
    String source = new String(parseState.getSource());
    RubyScript root =
        new RubyScript(
            parseState.getStartingOffset(), parseState.getStartingOffset() + source.length());
    RubyStructureBuilder builder = new RubyStructureBuilder(root);
    SourceElementVisitor visitor = new SourceElementVisitor(builder);
    visitor.acceptNode(getSourceParser().parse(source).getAST());
    parseState.setParseResult(root);

    return root;
  }
示例#2
0
  public IParseRootNode parse(IParseState parseState) throws Exception {
    String source = new String(parseState.getSource());
    GrammarScanner scanner = new GrammarScanner(new StringReader(source));
    GrammarParser parser = new GrammarParser();
    IParseRootNode result = null;

    Object parseResult = parser.parse(scanner);

    if (parseResult instanceof GrammarTreeRoot) {
      GrammarTreeRoot grammarRoot = (GrammarTreeRoot) parseResult;

      result = new BeaverParseRootNode(grammarRoot);

      parseState.setParseResult(result);
    }

    return result;
  }