Ejemplo n.º 1
0
 @Override
 public Syntax syntax() {
   int left = Syntax.NumberType();
   int[] right = {Syntax.NumberType()};
   return Syntax.reporterSyntax(
       left, right, Syntax.NumberType(), org.nlogo.api.Syntax.NormalPrecedence() - 2);
 }
Ejemplo n.º 2
0
  @Override
  public Syntax syntax() {
    int[] right;
    right = new int[] {Syntax.NumberType(), Syntax.NumberType()};

    return Syntax.reporterSyntax(right, Syntax.PatchType() | Syntax.NobodyType());
  }
Ejemplo n.º 3
0
  @Override
  public Syntax getSyntax() {
    int[] input = new int[] {Syntax.StringType() | Syntax.TurtleType(), Syntax.StringType()};
    int output = Syntax.BooleanType();

    return Syntax.reporterSyntax(input, output);
  }
Ejemplo n.º 4
0
 @Override
 public Syntax syntax() {
   return Syntax.reporterSyntax(
       new int[] {Syntax.AgentsetType(), Syntax.BooleanBlockType()},
       Syntax.NumberType(),
       "OTPL",
       "?");
 }
Ejemplo n.º 5
0
 @Override
 public Syntax getSyntax() {
   return Syntax.reporterSyntax(
       new int[] {
         Syntax.WildcardType(), Syntax.NumberType(),
       },
       Syntax.WildcardType());
 }
Ejemplo n.º 6
0
 @Override
 public Syntax syntax() {
   return Syntax.commandSyntax(
       new int[] {Syntax.NumberType(), Syntax.CommandBlockType() | Syntax.OptionalType()},
       "O---",
       "-T--",
       true);
 }
Ejemplo n.º 7
0
 @Override
 public Object report(final org.nlogo.nvm.Context context) throws LogoException {
   Object obj = args[1].report(context);
   if (obj instanceof LogoList) {
     Object value = args[0].report(context);
     LogoList list = (LogoList) obj;
     for (Iterator<Object> it = list.iterator(); it.hasNext(); ) {
       if (Equality.equals(value, it.next())) {
         return Boolean.TRUE;
       }
     }
     return Boolean.FALSE;
   } else if (obj instanceof String) {
     return ((String) obj).indexOf(argEvalString(context, 0)) != -1 ? Boolean.TRUE : Boolean.FALSE;
   } else if (obj instanceof AgentSet) {
     Agent agent = argEvalAgent(context, 0);
     AgentSet agentset = (AgentSet) obj;
     if (agent instanceof Turtle) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Turtle.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.turtles()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Turtle) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     }
     if (agent instanceof Link) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Link.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.links()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Link) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     } else if (agent instanceof Patch) {
       if (agentset.type() != Patch.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.patches()) {
         return Boolean.TRUE;
       }
     }
     return agentset.contains(agent) ? Boolean.TRUE : Boolean.FALSE;
   } else {
     throw new ArgumentTypeException(
         context, this, 1, Syntax.ListType() | Syntax.StringType() | Syntax.AgentsetType(), obj);
   }
 }
 public Syntax getSyntax() {
   return Syntax.commandSyntax(
       new int[] {
         Syntax.StringType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType()
       });
 }
Ejemplo n.º 9
0
 @Override
 public Object report(final org.nlogo.nvm.Context context) throws LogoException {
   int index = argEvalIntValue(context, 0);
   Object obj = args[1].report(context);
   if (index < 0) {
     throw new EngineException(
         context, this, I18N.errorsJ().getN("org.nlogo.prim.etc.$common.negativeIndex", index));
   }
   if (obj instanceof LogoList) {
     LogoList list = (LogoList) obj;
     if (index >= list.size()) {
       throw new EngineException(
           context,
           this,
           I18N.errorsJ()
               .getN(
                   "org.nlogo.prim.etc.$common.indexExceedsListSize",
                   index,
                   Dump.logoObject(list),
                   list.size()));
     }
     return list.get(index);
   } else if (obj instanceof String) {
     String string = (String) obj;
     if (index >= string.length()) {
       throw new EngineException(
           context,
           this,
           I18N.errorsJ()
               .getN(
                   "org.nlogo.prim.etc.$common.indexExceedsListSize",
                   index,
                   Dump.logoObject(string),
                   string.length()));
     }
     return string.substring(index, index + 1);
   } else {
     throw new ArgumentTypeException(
         context, this, 1, Syntax.ListType() | Syntax.StringType(), obj);
   }
 }
Ejemplo n.º 10
0
 @Override
 public Syntax syntax() {
   int[] right = {
     Syntax.WildcardType(), Syntax.ListType() | Syntax.StringType() | Syntax.AgentsetType()
   };
   int ret = Syntax.BooleanType();
   return Syntax.reporterSyntax(right, ret);
 }
Ejemplo n.º 11
0
 @Override
 public Syntax getSyntax() {
   return Syntax.commandSyntax(
       new int[] {
         Syntax.StringType(),
         Syntax.StringType(),
         Syntax.NumberType(),
         Syntax.StringType() | Syntax.RepeatableType()
       },
       3);
 }
Ejemplo n.º 12
0
 @Override
 public Syntax syntax() {
   return Syntax.commandSyntax(
       new int[] {
         Syntax.TurtlesetType(),
         Syntax.LinksetType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType()
       },
       true);
 }
Ejemplo n.º 13
0
 public org.nlogo.api.Syntax getSyntax() {
   int[] right = {
     org.nlogo.api.Syntax.TYPE_STRING,
   };
   return org.nlogo.api.Syntax.commandSyntax(right);
 }
Ejemplo n.º 14
0
 @Override
 public Syntax getSyntax() {
   return Syntax.commandSyntax(new int[] {Syntax.StringType()});
 }
Ejemplo n.º 15
0
 @Override
 public Syntax syntax() {
   int[] right = {Syntax.NumberType(), Syntax.NumberType()};
   return Syntax.reporterSyntax(right, Syntax.NumberType(), "-TP-");
 }
Ejemplo n.º 16
0
 @Override
 public Syntax syntax() {
   int[] right = {Syntax.WildcardType(), Syntax.ListType()};
   int ret = Syntax.ListType();
   return Syntax.reporterSyntax(right, ret);
 }
Ejemplo n.º 17
0
 @Override
 public Syntax syntax() {
   return Syntax.commandSyntax(new int[] {Syntax.ReferenceType()}, "-T--", true);
 }
Ejemplo n.º 18
0
 @Override
 public Syntax syntax() {
   int[] right = {Syntax.NumberType(), Syntax.NumberType()};
   int ret = Syntax.BooleanType();
   return Syntax.reporterSyntax(right, ret);
 }
Ejemplo n.º 19
0
 @Override
 public Syntax syntax() {
   return Syntax.reporterSyntax(Syntax.NumberType(), "-TP-");
 }
 public Syntax getSyntax() {
   return Syntax.commandSyntax(new int[] {});
 }
Ejemplo n.º 21
0
 @Override
 public Syntax syntax() {
   return Syntax.commandSyntax();
 }
Ejemplo n.º 22
0
 @Override
 public Syntax syntax() {
   return Syntax.reporterSyntax(new int[] {Syntax.NumberType()}, Syntax.NumberType());
 }
Ejemplo n.º 23
0
 @Override
 public Syntax syntax() {
   return Syntax.commandSyntax("-T--", true);
 }
Ejemplo n.º 24
0
 @Override
 public Syntax syntax() {
   int[] right = {Syntax.AgentsetType(), Syntax.NumberBlockType()};
   int ret = Syntax.AgentType();
   return Syntax.reporterSyntax(right, ret, "OTPL", "?");
 }
Ejemplo n.º 25
0
 public Syntax getSyntax() {
   return Syntax.reporterSyntax(new int[] {Syntax.NumberType()}, Syntax.ListType());
 }