Examples of FPLParser


Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

  public void testNegTestEffect() throws ParseException {
    String string = "?!Foo(a, b):c";
    RelationsEnvironment env = new RelationsEnvironment();
    env.addRelation(new Relation("Foo", new String[] {"Bar", "Baz"}));
   
    FPLParser parser = new FPLParser(string, env, new StubIType());
    RelEffect effect = parser.relEffect();
   
    Assert.assertEquals("Effect type is wrong", RelEffect.EffectType.NEG_TEST, effect.getType());
    Assert.assertEquals("Effect relation is wrong", "Foo", effect.getRelation().getName());
   
    FreeVars vars = effect.getFreeVariables();
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

public class ParseSimplePredicate {
  @Test
  public void testTrueParses() throws ParseException {
    String string = "TRUE";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a TruePredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof TruePredicate);   
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

  }

  @Test
  public void testFalseParses() throws ParseException {
    String string = "FALSE";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a FalsePredicate, but is " + pred.getClass().getCanonicalName(), pred instanceof FalsePredicate);
   
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

  }

  @Test
  public void testBoolParses() throws ParseException {
    String string = "foo";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a BooleanValue, but is " + pred.getClass().getCanonicalName(), pred instanceof BooleanValue);
   
    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be positive", val.isPositive());
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

  }

  @Test
  public void testNegBoolParses() throws ParseException {
    String string = "!foo";
    FPLParser parser = new FPLParser(string, null, null);
    Predicate pred = parser.expression();
   
    Assert.assertTrue("Parsed predicate should be a BooleanValue, but is " + pred.getClass().getCanonicalName(), pred instanceof BooleanValue);
   
    BooleanValue val = (BooleanValue)pred;
    Assert.assertTrue("Parsed predicate should be negative", !val.isPositive());
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

  }
 
  @Test(expected=ParseException.class)
  public void badParse() throws ParseException {
    String string = "!";
    FPLParser parser = new FPLParser(string, null, null);
    parser.expression();
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

      parseConstraint(constraint, contextType);
    parsed.add(constraint);
  }

  private void parseConstraint(IAnnotation constraint, IType contextType) throws JavaModelException {
    FPLParser parser = new FPLParser(rels, contextType);
    Operation op = null;
    Predicate trigger = null, requires = null, restrict = null;
    List<Effect> effects = new LinkedList<Effect>();
   
    try {
      for (IMemberValuePair pair : constraint.getMemberValuePairs()) {
        String name = pair.getMemberName();
        if (name.equals("op")) {
          parser.reset((String)pair.getValue());
          op = parser.operation();
        }
        else if (name.equals("trigger")) {
          parser.reset((String)pair.getValue());
          trigger = parser.expression();
        }
        else if (name.equals("requires")) {
          parser.reset((String)pair.getValue());
          requires = parser.expression();
        }
        else if (name.equals("restrictTo")) {
          parser.reset((String)pair.getValue());
          restrict = parser.expression();
        }
        else if (name.equals("effects")) {     
          for (Object effect : (Object[])pair.getValue()) {
            parser.reset((String)effect);
            effects.add(parser.effect());
          }
        }
      }
     
      if (trigger == null)
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

    String[] effStrings = new String[effObj.length];
    for (int ndx = 0; ndx < effStrings.length; ndx++) {
      effStrings[ndx] = (String)effObj[ndx];
    }
   
    FPLParser parser = new FPLParser(rels, contextType);
    Predicate trigger;
    List<RelEffect> effects = new LinkedList<RelEffect>();
   
    try {     
      parser.reset(trgString);
      trigger = parser.expression();
      assert(trigger != null);
     
      for (String eString : effStrings) {
        parser.reset(eString);
        effects.add(parser.relEffect());
      }
     
      inferRules.add(new InferredRel(trigger, effects));
    } catch (ParseException e) {
      ReportingUtility.reportParseError(infer.getResource(), infer.getNameRange(), e.getMessage());
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

      NodeList consParts = item.getChildNodes();
      Operation op = null;
      Predicate trigger = null, restrict = null, requires = null;
      List<Effect> effects = new LinkedList<Effect>();
     
      FPLParser parser = new FPLParser(rels, context);
     
      for (int ndx = 0; ndx < consParts.getLength(); ndx++) {
        Node node = consParts.item(ndx);
        if (!(node instanceof Element))
          continue;
        String name = node.getNodeName();
       
        if (name.equals("op")) {
          assert op == null;
          parser.reset(node.getTextContent());
          op = parser.operation();
        }
        else if (name.equals("trg")) {
          assert trigger == null;
          parser.reset(node.getTextContent());
          trigger = parser.expression();
        }
        else if (name.equals("rst")) {
          assert restrict == null;
          parser.reset(node.getTextContent());
          restrict = parser.expression();
        }
        else if (name.equals("req")) {
          assert requires == null;
          parser.reset(node.getTextContent());
          requires = parser.expression();
        }
        else if (name.equals("eff")) {
          parser.reset(node.getTextContent());
          effects.add(parser.effect());
        }
      }
      if (trigger == null)
        trigger = new TruePredicate();
      if (restrict == null)
View Full Code Here

Examples of edu.cmu.cs.fusion.parsers.predicate.FPLParser

    try {
      NodeList consParts = item.getChildNodes();
      Predicate trigger = null;
      List<RelEffect> effects = new LinkedList<RelEffect>();
     
      FPLParser parser = new FPLParser(rels, context);
     
      for (int ndx = 0; ndx < consParts.getLength(); ndx++) {
        Node node = consParts.item(ndx);
        if (!(node instanceof Element))
          continue;
        String name = node.getNodeName();
       
        if (name.equals("trg")) {
          assert trigger == null;
          parser.reset(node.getTextContent());
          trigger = parser.expression();
        }
        else if (name.equals("eff")) {
          parser.reset(node.getTextContent());
          effects.add(parser.relEffect());
        }
      }
      assert (trigger != null);
      assert (!effects.isEmpty());
      inferRules.add(new InferredRel(trigger, effects));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.