Package org.ggp.base.util.symbol.grammar

Examples of org.ggp.base.util.symbol.grammar.SymbolAtom


  public Request create(Gamer gamer, String source) throws RequestFormatException
  {
    try
    {
      SymbolList list = (SymbolList) SymbolFactory.create(source);
      SymbolAtom head = (SymbolAtom) list.get(0);

      String type = head.getValue().toLowerCase();
      if (type.equals("play"))
      {
        return createPlay(gamer, list);
      }
      else if (type.equals("start"))
View Full Code Here


    if (list.size() != 3)
    {
      throw new IllegalArgumentException("Expected exactly 2 arguments!");
    }

    SymbolAtom arg1 = (SymbolAtom) list.get(1);
    Symbol arg2 = list.get(2);

    String matchId = arg1.getValue();
    List<GdlTerm> moves = parseMoves(arg2);

    return new PlayRequest(gamer, matchId, moves);
  }
View Full Code Here

    if (list.size() < 6)
    {
      throw new IllegalArgumentException("Expected at least 5 arguments!");
    }

    SymbolAtom arg1 = (SymbolAtom) list.get(1);
    SymbolAtom arg2 = (SymbolAtom) list.get(2);
    SymbolList arg3 = (SymbolList) list.get(3);
    SymbolAtom arg4 = (SymbolAtom) list.get(4);
    SymbolAtom arg5 = (SymbolAtom) list.get(5);

    String matchId = arg1.getValue();
    GdlConstant roleName = (GdlConstant) GdlFactory.createTerm(arg2);
    String theRulesheet = arg3.toString();
    int startClock = Integer.valueOf(arg4.getValue());
    int playClock = Integer.valueOf(arg5.getValue());

    // For now, there are only five standard arguments. If there are any
    // new standard arguments added to START, they should be added here.

    Game theReceivedGame = Game.createEphemeralGame(theRulesheet);
View Full Code Here

    if (list.size() != 3)
    {
      throw new IllegalArgumentException("Expected exactly 2 arguments!");
    }

    SymbolAtom arg1 = (SymbolAtom) list.get(1);
    Symbol arg2 = list.get(2);

    String matchId = arg1.getValue();
    List<GdlTerm> moves = parseMoves(arg2);

    return new StopRequest(gamer, matchId, moves);
  }
View Full Code Here

        if (list.size() != 2)
        {
            throw new IllegalArgumentException("Expected exactly 1 argument!");
        }

        SymbolAtom arg1 = (SymbolAtom) list.get(1);
        String matchId = arg1.getValue();

        return new AbortRequest(gamer, matchId);
    }
View Full Code Here

    if (list.size() != 3)
    {
      throw new IllegalArgumentException("Expected exactly 2 arguments!");
    }

    SymbolAtom arg1 = (SymbolAtom) list.get(1);
    SymbolAtom arg2 = (SymbolAtom) list.get(2);

    String theRulesheet = arg1.toString();
    int previewClock = Integer.valueOf(arg2.getValue());

    Game theReceivedGame = Game.createEphemeralGame(theRulesheet);
    return new PreviewRequest(gamer, theReceivedGame, previewClock);
    }
View Full Code Here

  private static Gdl createGdl(Symbol symbol)
  {
    if (symbol instanceof SymbolList)
    {
      SymbolList list = (SymbolList) symbol;
      SymbolAtom type = (SymbolAtom) list.get(0);

      if (type.getValue().equals("<="))
      {
        return createRule(list);
      }
    }
View Full Code Here

  private static GdlLiteral createLiteral(Symbol symbol)
  {
    if (symbol instanceof SymbolList)
    {
      SymbolList list = (SymbolList) symbol;
      SymbolAtom type = (SymbolAtom) list.get(0);

      if (type.getValue().toLowerCase().equals("distinct"))
      {
        return createDistinct(list);
      }
      else if (type.getValue().toLowerCase().equals("not"))
      {
        return createNot(list);
      }
      else if (type.getValue().toLowerCase().equals("or"))
      {
        return createOr(list);
      }
    }
View Full Code Here

  public static GdlTerm createTerm(Symbol symbol)
  {
    if (symbol instanceof SymbolAtom)
    {
      SymbolAtom atom = (SymbolAtom) symbol;
      if (atom.getValue().charAt(0) == '?')
      {
        return createVariable(atom);
      }
      else
      {
View Full Code Here

TOP

Related Classes of org.ggp.base.util.symbol.grammar.SymbolAtom

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.