Beispiel #1
0
  @Override
  protected IParseNode processEmbeddedlanguage(IParseState parseState)
      throws Exception // $codepro.audit.disable
        // declaredExceptions
      {
    String source = parseState.getSource();
    int sourceLength = source.length();
    int startingOffset = parseState.getStartingOffset();
    IParseNode root = null;

    advance();
    short id = getCurrentSymbol().getId();
    while (id != PHTMLTokens.EOF) {
      // only cares about PHP tokens
      switch (id) {
        case PHTMLTokens.PHP:
          if (root == null) {
            root =
                new ParseRootNode(
                    IPHPConstants.CONTENT_TYPE_PHP,
                    PHPParser.NO_CHILDREN,
                    startingOffset,
                    startingOffset + sourceLength - 1);
          }
          processPHPBlock(root, sourceLength);
          break;
      }
      advance();
      id = getCurrentSymbol().getId();
    }
    return root;
  }
  protected void parse(IParseState parseState, WorkingParseResult working) throws Exception {
    Reader reader = new StringReader(parseState.getSource());
    Node root = getSourceParser().compose(reader);

    // Convert YAML nodes to our own!
    YAMLParseRootNode yamlRoot = new YAMLParseRootNode(root, parseState);

    working.setParseResult(yamlRoot);
  }
Beispiel #3
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;
  }
Beispiel #4
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;
  }