public void EmitANDOR() { var n1 = new PhysicalValue() { Number = 51 }; var n2 = new PhysicalValue() { Number = 52 }; var sc1 = new SelectionCriteria() { BinaryRelation = ">", FirstArgument = n1, SecondArgument = n2 }; var n3 = new PhysicalValue() { Number = 53 }; var n4 = new PhysicalValue() { Number = 54 }; var sc2 = new SelectionCriteria() { BinaryRelation = "<", FirstArgument = n3, SecondArgument = n4 }; var andor = new ANDOR() { AOType = ANDORType.kAnd }; andor.Arguments.Add(sc1); andor.Arguments.Add(sc2); var ms = new StringWriter(); andor.Emit(ms); var text = ms.ToString().Split('\r').Select(l => l.Trim()).ToArray(); Assert.AreEqual("atlas:number0 rdf:type qudt:QuantityValue ;", text[0]); Assert.AreEqual("qudt:numericValue \"51\"^^xsd:decimal .", text[1]); Assert.AreEqual("", text[2]); Assert.AreEqual("atlas:number1 rdf:type qudt:QuantityValue ;", text[3]); Assert.AreEqual("qudt:numericValue \"52\"^^xsd:decimal .", text[4]); Assert.AreEqual("", text[5]); Assert.AreEqual("atlas:selectionCriteria2 rdf:type dfs:SelectionCriteria ;", text[6]); Assert.AreEqual("dfs:usesBinaryRelation dfs:greaterThan ;", text[7]); Assert.AreEqual("dfs:hasFirstArgument atlas:number0 ;", text[8]); Assert.AreEqual("dfs:hasSecondArgument atlas:number1 .", text[9]); Assert.AreEqual("", text[10]); Assert.AreEqual("atlas:number3 rdf:type qudt:QuantityValue ;", text[11]); Assert.AreEqual("qudt:numericValue \"53\"^^xsd:decimal .", text[12]); Assert.AreEqual("", text[13]); Assert.AreEqual("atlas:number4 rdf:type qudt:QuantityValue ;", text[14]); Assert.AreEqual("qudt:numericValue \"54\"^^xsd:decimal .", text[15]); Assert.AreEqual("", text[16]); Assert.AreEqual("atlas:selectionCriteria5 rdf:type dfs:SelectionCriteria ;", text[17]); Assert.AreEqual("dfs:usesBinaryRelation dfs:lessThan ;", text[18]); Assert.AreEqual("dfs:hasFirstArgument atlas:number3 ;", text[19]); Assert.AreEqual("dfs:hasSecondArgument atlas:number4 .", text[20]); Assert.AreEqual("", text[21]); Assert.AreEqual("atlas:andor6 rdf:type dfs:And ;", text[22]); Assert.AreEqual("dfs:hasOperand atlas:selectionCriteria2 , atlas:selectionCriteria5 .", text[23]); }
private SelectionCriteria Convert(FinalStatePatternParser.CutBinaryContext context) { var c = new SelectionCriteria(); c.BinaryRelation = context.BINARY_OP().GetText(); c.FirstArgument = Convert(context.cut_arg()[0]); c.SecondArgument = Convert(context.cut_arg()[1]); return c; }
public void EmitSelectionCriteria() { var n1 = new PhysicalValue() { Number = 51 }; var n2 = new PhysicalValue() { Number = 52 }; var sc = new SelectionCriteria() { BinaryRelation = ">", FirstArgument = n1, SecondArgument = n2 }; var ms = new StringWriter(); sc.Emit(ms); var text = ms.ToString().Split('\r').Select(l => l.Trim()).ToArray(); Assert.AreEqual("atlas:number0 rdf:type qudt:QuantityValue ;", text[0]); Assert.AreEqual("qudt:numericValue \"51\"^^xsd:decimal .", text[1]); Assert.AreEqual("", text[2]); Assert.AreEqual("atlas:number1 rdf:type qudt:QuantityValue ;", text[3]); Assert.AreEqual("qudt:numericValue \"52\"^^xsd:decimal .", text[4]); Assert.AreEqual("", text[5]); Assert.AreEqual("atlas:selectionCriteria2 rdf:type dfs:SelectionCriteria ;", text[6]); Assert.AreEqual("dfs:usesBinaryRelation dfs:greaterThan ;", text[7]); Assert.AreEqual("dfs:hasFirstArgument atlas:number0 ;", text[8]); Assert.AreEqual("dfs:hasSecondArgument atlas:number1 .", text[9]); }
/// <summary> /// The user has given us a range cut /// </summary> /// <param name="context"></param> public override void ExitCutRange(FinalStatePatternParser.CutRangeContext context) { var c1 = new SelectionCriteria(); var c2 = new SelectionCriteria(); c1.BinaryRelation = context.BINARY_OP(0).GetText(); c2.BinaryRelation = context.BINARY_OP(1).GetText(); c1.FirstArgument = Convert(context.cut_number(0)); c1.SecondArgument = Convert(context.cut_name()); c2.FirstArgument = Convert(context.cut_name()); c2.SecondArgument = Convert(context.cut_number(1)); _current_criteria.Peek().Add(c1); _current_criteria.Peek().Add(c2); base.ExitCutRange(context); }