Package anvil.script.statements

Examples of anvil.script.statements.DefinitionStatement


  }

  final public void Namespace() throws ParseException {
  Token t;
  Statement stmt = flowPeek();
  DefinitionStatement scope = stmt.getScopeStatement();
    try {
      t = jj_consume_token(NAMESPACE);
        Location location = toLocation(t);
      scope = NamespacePart(location, scope);
      label_3:
View Full Code Here


  Token href;
  Token as = null;
  Name entity = null;
  Name[] decls;
  boolean added = false;
    DefinitionStatement scope = flowPeek().getDefinitionStatement();
    try {
      t = jj_consume_token(IMPORT);
      Location location = toLocation(t);
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case STRING_LITERAL:
        href = jj_consume_token(STRING_LITERAL);
        String pathinfo = Conversions.unescape(href.image, true);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case AS:
        case COLON:
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case AS:
            jj_consume_token(AS);
            as = jj_consume_token(SYMBOL);
            scope.addHrefImport(this, location, pathinfo, as.image, null, false);
            added = true;
            break;
          case COLON:
            jj_consume_token(COLON);
            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
            case MODULE:
            case SYMBOL:
              decls = RequestedDeclarations();
              scope.addHrefImport(this, location, pathinfo, null, decls, false);
              added = true;
              break;
            case STAR:
              jj_consume_token(STAR);
              scope.addHrefImport(this, location, pathinfo, null, null, true);
              added = true;
              break;
            default:
              jj_la1[13] = jj_gen;
              jj_consume_token(-1);
              throw new ParseException();
            }
            break;
          default:
            jj_la1[14] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
          break;
        default:
          jj_la1[15] = jj_gen;
          ;
        }
        if (!added) {
          scope.addHrefImport(this, location, pathinfo, null, null, false);
        }
        break;
      case MODULE:
      case SYMBOL:
        entity = Name(null);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case DOT:
        case AS:
        case COLON:
          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
          case DOT:
            jj_consume_token(DOT);
            jj_consume_token(STAR);
            scope.addEntityImport(this, location, entity, null, true);
            added = true;
            break;
          case AS:
            jj_consume_token(AS);
            as = jj_consume_token(SYMBOL);
            entity.setAs(as.image);
            scope.addEntityImport(this, location, entity, null, false);
            added = true;
            break;
          case COLON:
            jj_consume_token(COLON);
            switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
            case MODULE:
            case SYMBOL:
              decls = RequestedDeclarations();
              scope.addEntityImport(this, location, entity, decls, false);
              added = true;
              break;
            case STAR:
              jj_consume_token(STAR);
              scope.addEntityImport(this, location, entity, null, true);
              added = true;
              break;
            default:
              jj_la1[16] = jj_gen;
              jj_consume_token(-1);
              throw new ParseException();
            }
            break;
          default:
            jj_la1[17] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
          break;
        default:
          jj_la1[18] = jj_gen;
          ;
        }
        if (!added) {
          scope.addEntityImport(this, location, entity, null, false);
        }
        break;
      default:
        jj_la1[19] = jj_gen;
        jj_consume_token(-1);
View Full Code Here

    jj_consume_token(CLOSE);
      boolean is_synchronized = (r != null);
      String name = s.image;
      String document = (r!=null) ? r.document : t.document;

      DefinitionStatement target = flowPeek().getDefinitionStatement();
      DefinitionStatement parent = flowPeek().getScopeStatement();
      FunctionStatement  context = flowPeek().getFunctionStatement();

      FunctionStatement function = new FunctionStatement(toLocation(t), parent, context, is_synchronized, name, document, parameters);
      function.setParentStatement(flowPeek());
      if (target.lookupDeclaration(name) == null) {
        parent.declare(function);
        if (context != null) {
          context.declare(name, function);
        }
      } else {
        error(toLocation(t), "Entity '" + name + "' is already declared");
View Full Code Here

      boolean is_constructor = false;
      Location location = toLocation(t);
      String document = t.document;
      String name = s.image;

      DefinitionStatement target = flowPeek().getDefinitionStatement();
      ClassStatement      parent = flowPeek().getClassStatement();
      FunctionStatement  context = flowPeek().getFunctionStatement();

      if (context != null) {
        if (context.getType() == Type.FUNCTION) {
          is_static = true;
        }
      }
      if (is_static) {
        if (name.equals(parent.getName())) {
          error(location, "Static methods may not used as constructors");
        }
        FunctionStatement function = new FunctionStatement(location, parent, context, is_synchronized, name, document, parameters);
        function.setParentStatement(flowPeek());
        if (target.lookupDeclaration(name) == null) {
          parent.declare(function);
          if (context != null) {
            context.declare(name, function);
          }
        } else {
          error(location, "Entity '" + name + "' is already declared");
        }
        flowPush(function);
        flowPush(function.getChildStatement());

      } else {
        MethodStatement method;
        if ((context == null) && name.equals(parent.getName())) {
          is_constructor = true;
          method = new ConstructorStatement(location, parent, is_synchronized, name, document, parameters);
          if (parent.getConstructor() != null) {
            error(location, "Constructor is already declared for class '"+parent+"'");
          }
        } else {
          method = new MethodStatement(location, parent, context, is_synchronized, name, document, parameters);
        }
        method.setParentStatement(flowPeek());
        if (target.lookupLocalDeclaration(name) == null) {
          parent.declare(method);
          if (context != null) {
            context.declare(name, method);
          }
        } else {
View Full Code Here

      jj_la1[33] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
      Statement stmt = flowPeek();
      DefinitionStatement parent = stmt.getScopeStatement();
      FunctionStatement context  = stmt.getFunctionStatement();
      FunctionStatement function;
      String name = "inline$" + parent.getNextInlined();
      if (parent.typeOf() == Statement.ST_CLASS) {
        function = new MethodStatement(toLocation(t), parent, context, false, name, null, parameters);
      } else {
        function = new FunctionStatement(toLocation(t), parent, context, false, name, null, parameters);
      }
      function.setParentStatement(flowPeek());
      parent.declare(function);
      flowPush(function);
      flowPush(function.getChildStatement());
      push(new InlinedFunctionNode(context, function));
    label_10:
    while (true) {
View Full Code Here

      jj_la1[36] = jj_gen;
      ;
    }
    jj_consume_token(BEGIN);
      String name = s.image;
      DefinitionStatement parent = flowPeek().getScopeStatement();
      InterfaceStatement decl = new InterfaceStatement(location, parent, name, t.document, interfaces);
      if (parent.lookupDeclaration(name) == null) {
        parent.declare(decl);
      } else {
        error(location, "Entity '"+name+"' is already declared");
      }
      flowPush(decl);
    label_12:
View Full Code Here

    default:
      jj_la1[40] = jj_gen;
      ;
    }
    jj_consume_token(BEGIN);
      DefinitionStatement parent = flowPeek().getDefinitionStatement();
      ClassStatement classtype = new ClassStatement(location, parent, name, t.document, base, interfaces);
      if (parent.lookupDeclaration(name) == null && !parent.isEntityReserved(name)) {
        parent.declare(classtype);
      } else {
        error(location, "Entity '"+name+"' is already declared");
      }
      flowPush(classtype);
    label_13:
View Full Code Here

  Token symbol;
  Expression expr = null;
    symbol = jj_consume_token(SYMBOL);
      Location location = toLocation(symbol);
      String name = symbol.image;
      DefinitionStatement target = flowPeek().getDefinitionStatement();
      VariableStatement var = null;
      if (target.lookupDeclaration(name) == null && !target.isEntityReserved(name)) {
        var = target.declare(location, name, expr, document, statik);
      } else {
        error(location, "Entity '" + name + "' is already declared");
      }
      if (var != null) {
        flowPush(var);
View Full Code Here

  Token symbol;
    symbol = jj_consume_token(SYMBOL);
    jj_consume_token(ASSIGN);
      Location location = toLocation(symbol);
      String name = symbol.image;
      DefinitionStatement target = flowPeek().getDefinitionStatement();
      ConstantVariableStatement constant = new ConstantVariableStatement(location, target, name, null, keyword.document);
      if (target.lookupDeclaration(name) == null && !target.isEntityReserved(name)) {
        target.declare(constant);
      } else {
        error(location, "Entity '" + name + "' is already declared");
      }
      flowPush(constant);
    ValueExpression();
View Full Code Here

    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case CARET:
      op = jj_consume_token(CARET);
      location = toLocation(op);
      Statement stmt = flowPeek();
      DefinitionStatement parent = stmt.getScopeStatement();
      context = stmt.getFunctionStatement();
      String name = "thunk$" + parent.getNextInlined();
      if (parent.typeOf() == Statement.ST_CLASS) {
        thunk = new MethodStatement(location, parent, context, false, name, null, ParameterListDeclaration.EMPTY);
      } else {
        thunk = new FunctionStatement(location, parent, context, false, name, null, ParameterListDeclaration.EMPTY);
      }
      thunk.setParentStatement(flowPeek());
      parent.declare(thunk);
      flowPush(thunk);
      flowPush(thunk.getChildStatement());
      break;
    default:
      jj_la1[124] = jj_gen;
View Full Code Here

TOP

Related Classes of anvil.script.statements.DefinitionStatement

Copyright © 2018 www.massapicom. 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.