Exemplo n.º 1
0
  public String play() {

    class ConstraintChecker {

      String result;

      public void checkPreconditions() {

        check_precondition();
      }

      public void checkPostconditions() {}

      public void check_precondition() {

        Player playerProponent = DialogueGame.this.getProponent();
        CommitmentStore commitmentStoreStore = playerProponent.getStore();
        Set setContent = commitmentStoreStore.getContent();
        Proposition propositionThesis = DialogueGame.this.thesis;
        MoveContent moveContentGetNegation = propositionThesis.getNegation();
        boolean bExcludes = CollectionUtilities.excludes(setContent, moveContentGetNegation);
        Player playerOpponent = DialogueGame.this.getOpponent();
        CommitmentStore commitmentStoreStore0 = playerOpponent.getStore();
        Set setContent0 = commitmentStoreStore0.getContent();
        Proposition propositionThesis0 = DialogueGame.this.thesis;
        boolean bExcludes0 = CollectionUtilities.excludes(setContent0, propositionThesis0);
        boolean bAnd = bExcludes && bExcludes0;
        if (!bAnd) {
          System.err.println("precondition 'precondition' failed for object " + DialogueGame.this);
        }
      }
    }
    ConstraintChecker checker = new ConstraintChecker();
    checker.checkPreconditions();
    checker.result = internal_play();

    checker.checkPostconditions();
    return checker.result;
  }
Exemplo n.º 2
0
 @Override
 public List<Object[]> execute() {
   List<Object[]> tuples = delegate().execute();
   if (!tuples.isEmpty()) {
     // Iterate through the tuples, removing any that do not satisfy the constraint ...
     Iterator<Object[]> iter = tuples.iterator();
     while (iter.hasNext()) {
       if (!checker.satisfiesConstraints(iter.next())) {
         iter.remove();
       }
     }
   }
   return tuples;
 }
Exemplo n.º 3
0
  public String start() {

    class ConstraintChecker {

      String result;

      public void checkPreconditions() {}

      public void checkPostconditions() {

        check_postcondition();
      }

      public void check_postcondition() {

        Player playerProponent = DialogueGame.this.getProponent();
        CommitmentStore commitmentStoreStore = playerProponent.getStore();
        Set setContent = commitmentStoreStore.getContent();
        boolean bIsEmpty = CollectionUtilities.isEmpty(setContent);
        Player playerOpponent = DialogueGame.this.getOpponent();
        CommitmentStore commitmentStoreStore0 = playerOpponent.getStore();
        Set setContent0 = commitmentStoreStore0.getContent();
        boolean bIsEmpty0 = CollectionUtilities.isEmpty(setContent0);
        boolean bAnd = bIsEmpty && bIsEmpty0;
        if (!bAnd) {
          System.err.println(
              "postcondition 'postcondition' failed for object " + DialogueGame.this);
        }
      }
    }
    ConstraintChecker checker = new ConstraintChecker();
    checker.checkPreconditions();
    checker.result = internal_start();

    checker.checkPostconditions();
    return checker.result;
  }
Exemplo n.º 4
0
 public static void main(String[] args) throws Exception {
   // Display help screen.
   if (args.length == 0 || args[0].compareToIgnoreCase("-h") == 0) {
     System.out.println("Protoc Embedded C Compiler for Protocol Buffers");
     System.out.println("Version " + VERSION);
     System.out.println(
         "Copyright (c) 2009-2011, Technische Universitaet Muenchen, http://www4.in.tum.de/");
     System.out.println(
         "Use: Protoc [-I=<source-directory>][--c_out=<output-directory>] <proto-file>");
     System.out.println();
     System.exit(0);
   }
   // Parse command-line arguments.
   File sourceDirectory = null;
   File outputDirectory = null;
   for (String arg : args) {
     if (arg.startsWith("-I=")) {
       sourceDirectory = new File(arg.substring(3));
       if (!sourceDirectory.exists() || !sourceDirectory.isDirectory()) {
         System.out.println(
             "Source directory '" + sourceDirectory + "' does not exist or is not a directory");
         System.exit(1);
       }
     }
     if (arg.startsWith("--c_out=")) {
       outputDirectory = new File(arg.substring(8));
       if (!outputDirectory.exists() || !outputDirectory.isDirectory()) {
         System.out.println(
             "Output directory '" + outputDirectory + "' does not exist or is not a directory");
         System.exit(1);
       }
     }
     if (arg.equals("--debug")) {
       debug = true;
     }
   }
   if (sourceDirectory == null) {
     sourceDirectory = new File(System.getProperty("user.dir"));
   }
   if (outputDirectory == null) {
     outputDirectory = new File(System.getProperty("user.dir"));
   }
   File protoFile = new File(sourceDirectory, args[args.length - 1]);
   if (!protoFile.exists() || !protoFile.isFile()) {
     System.out.println("Proto file '" + protoFile + "' does not exist or is not a file");
     System.exit(1);
   }
   // Parse input and build AST.
   final ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(protoFile));
   final ProtoLexer lexer = new ProtoLexer(input);
   final CommonTokenStream tokens = new CommonTokenStream(lexer);
   final ProtoParser parser = new ProtoParser(tokens);
   final ProtoParser.proto_return proto = parser.proto();
   final CommonTree tree = proto.tree;
   if (debug) {
     TreePrintUtils.printTree(tree);
   }
   // Walk AST to check constraints.
   final CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
   nodes.setTokenStream(tokens);
   final ConstraintChecker checker = new ConstraintChecker(nodes);
   checker.proto();
   if (checker.constraintErrors > 0) {
     System.err.println(
         "ERROR(s): " + checker.constraintErrors + " constraint violation(s), no files generated");
     System.exit(-1);
   }
   String name = protoFile.getName();
   if (name.contains(".")) {
     name = name.substring(0, name.lastIndexOf("."));
   }
   generate(
       "embedded-h-file.stg",
       new File(outputDirectory, name + ".h"),
       tokens,
       tree,
       name,
       checker.topologicalOrder);
   generate(
       "embedded-c-file.stg",
       new File(outputDirectory, name + ".c"),
       tokens,
       tree,
       name,
       checker.topologicalOrder);
 }