Ejemplo n.º 1
0
  /*
   *preamble
   *  : namespaceHeader? import*
   *  ;
   */
  private void parsePreamble(boolean imports) {
    /*
     * namespaceHeader
     *   : modifiers "namespace" SimpleName{"."} SEMI?
     *   ;
     */
    PsiBuilder.Marker namespaceHeader = mark();
    PsiBuilder.Marker firstEntry = mark();
    parseModifierList(MODIFIER_LIST, true);

    if (at(PACKAGE_KEYWORD)) {
      advance(); // PACKAGE_KEYWORD

      parseNamespaceName();

      if (at(LBRACE)) {
        // Because it's blocked namespace and it will be parsed as one of top level objects
        firstEntry.rollbackTo();
        namespaceHeader.done(NAMESPACE_HEADER);
        return;
      }

      firstEntry.drop();

      consumeIf(SEMICOLON);
    } else {
      firstEntry.rollbackTo();
    }
    namespaceHeader.done(NAMESPACE_HEADER);

    if (imports) parseImportDirectives();
  }
Ejemplo n.º 2
0
  void parseScript() {
    PsiBuilder.Marker fileMarker = mark();

    parsePreamble(false);

    PsiBuilder.Marker scriptMarker = mark();
    parseImportDirectives();

    PsiBuilder.Marker blockMarker = mark();

    myExpressionParsing.parseStatements();

    blockMarker.done(BLOCK);
    scriptMarker.done(SCRIPT);
    fileMarker.done(JET_FILE);
  }