public Node ExpSimple() { Node nodo = null; switch (CurrentToken) { case TokenCategory.FLOTANTE: nodo = new Flotante() { GetToken = Expect(TokenCategory.FLOTANTE) }; break; case TokenCategory.DUP: nodo = new Dup() { GetToken = Expect(TokenCategory.DUP) }; nodo.Add(ExpSimple()); break; case TokenCategory.BRACKET_OPEN: nodo = ExpSum(); break; default: Console.WriteLine("Switch"); throw new SyntaxError(); } return(nodo); }
public Node Simple() { Console.WriteLine(CurrentToken); switch (CurrentToken) { case Token.SLEFT: Expect(Token.SLEFT); var exp = Sum(); Expect(Token.SRIGHT); return(exp); case Token.FLOAT: Expect(Token.FLOAT); return(new Float()); case Token.DUP: Expect(Token.DUP); var exp2 = new Dup() { Simple() }; return(exp2); default: throw new SyntaxError(); } }
private static RemoteOperator createOperatorType(String operatorType, Boolean isFullLog, String routing, String[] inputSources, String[] outputSources, String[] output_op, String[] replicas_op, String[] operatorParams) { RemoteOperator remoteOperator; switch (operatorType) { case "COUNT": remoteOperator = new Count(inputSources, outputSources, routing, isFullLog, output_op, replicas_op); break; case "CUSTOM": remoteOperator = new Custom(inputSources, outputSources, routing, isFullLog, output_op, replicas_op, operatorParams); break; case "DUP": remoteOperator = new Dup(inputSources, outputSources, routing, isFullLog, output_op, replicas_op); break; case "FILTER": remoteOperator = new Filter(inputSources, outputSources, routing, isFullLog, output_op, replicas_op, operatorParams); break; case "UNIQ": remoteOperator = new Uniq(inputSources, outputSources, routing, isFullLog, output_op, replicas_op, operatorParams); break; default: throw new Exception("Unknown Operator Type"); } return(remoteOperator); }
/// <summary> /// 写入固定报头首字节 /// </summary> /// <returns></returns> private void WriteFixedHeaderByte(IByteBuffer buf) { var ret = (byte)PacketType << 4; ret |= Dup.ToByte() << 3; ret |= (byte)Qos << 1; ret |= Retain.ToByte(); buf.WriteByte(ret); }
public void DuplicateAutomata() { var bin = MessagePackSerializer.Serialize(new Dup { ABCDEFGH = 10, ABCDEFGHIJKL = 99 }, Resolvers.ContractlessStandardResolver.Options); Dup v = MessagePackSerializer.Deserialize <Dup>(bin, Resolvers.ContractlessStandardResolver.Options); v.ABCDEFGH.Is(10); v.ABCDEFGHIJKL.Is(99); }
public string Visit(Dup node) { var stringBuilder = new StringBuilder(); var first = Visit((dynamic)node[0]); stringBuilder.Append(first); stringBuilder.Append("\t\tdup\n"); stringBuilder.Append("\t\tadd\n"); return(stringBuilder.ToString()); }
public void WriteTo(Stream stream) { var flags = (byte)MessageType << 4; flags |= Dup.ToByte() << 3; flags |= (byte)Qos << 1; flags |= Retain.ToByte(); stream.WriteByte((byte)flags); stream.Write(EncodeLength(RemaingLength)); }
public void WriteTo(IByteBuffer buffer) { var flags = (byte)PacketType << 4; flags |= Dup.ToByte() << 3; flags |= (byte)Qos << 1; flags |= Retain.ToByte(); buffer.WriteByte((byte)flags); buffer.WriteBytes(EncodeLength(RemaingLength)); }
public void Dup(int sequenceIndex) { Dup dup = new Dup(); var topEnumerator = sequences[sequenceIndex].GetEnumerator(); dup.TopInput = () => { while (topEnumerator.MoveNext()) { return(topEnumerator.Current); } return(Value.Finished); }; var topresult = ReadOutput(dup.Top).ToArray(); var bottomresult = ReadOutput(dup.Bottom).ToArray(); Assert.AreEqual(sequences[sequenceIndex].Count() + 1, topresult.Length); //all inputs plus one finished EqualEnumerables(sequences[sequenceIndex].Select(x => x.Get <int>()), topresult.TakeWhile(x => !x.Done).Select(x => x.Get <int>())); Assert.AreEqual(sequences[sequenceIndex].Count() + 1, bottomresult.Length); //all inputs plus one finished EqualEnumerables(sequences[sequenceIndex].Select(x => x.Get <int>()), bottomresult.TakeWhile(x => !x.Done).Select(x => x.Get <int>())); }
public Node Simple() { if (CurrentToken == Token.FLOAT) { var floa = new Float(); floa.lexeme = lex.curlex; //floa.lexeme = CurrentToken.lexeme; Console.WriteLine(floa.lexeme); //Console.WriteLine(floa.lexeme); //floa.AnchorToken = //Console.WriteLine("aqui4"); Expect(Token.FLOAT); //var exp1 = MaxList(); ////console.writeLine(CurrentToken); return(floa); } if (CurrentToken == Token.DUP) { var dup = new Dup(); //dup.AnchorToken = //Console.WriteLine("aqui5"); Expect(Token.DUP); var exp1 = Simple(); dup.Add(exp1); return(dup); } else if (CurrentToken == Token.OPEN) { Expect(Token.OPEN); var dup = MaxList(); //dup.AnchorToken = //Console.WriteLine("aqui6"); //xpect(Token.DUP); Expect(Token.CLOSE); return(dup); } //console.writeLine("aqui"); throw new SyntaxError(); return(null); }
/// <summary> /// processaCOBR /// </summary> /// <param name="nodeinfNFe"></param> private void processaCOBR(XmlNode nodeinfNFe) { foreach (XmlNode noder in nodeinfNFe.ChildNodes) { if (noder.LocalName.Equals("fat")) { nfe.Cobr.Fat.nFat = this.readValue(noder, TpcnResources.nFat); nfe.Cobr.Fat.vOrig = this.readDouble(noder, TpcnResources.vOrig); nfe.Cobr.Fat.vDesc = this.readDouble(noder, TpcnResources.vDesc); nfe.Cobr.Fat.vLiq = this.readDouble(noder, TpcnResources.vLiq); } if (noder.LocalName.Equals("dup")) { Dup dupInfo = new Dup(); dupInfo.dVenc = this.readDate(noder, TpcnResources.dVenc); dupInfo.nDup = this.readValue(noder, TpcnResources.nDup); dupInfo.vDup = this.readDouble(noder, TpcnResources.vDup); nfe.Cobr.Dup.Add(dupInfo); } } }
public string Visit(Dup node) { return(Visit((dynamic)node[0]) + Visit((dynamic)node[0]) + "\t\tadd\n"); }
public string Visit(Dup node) { Console.WriteLine($"visit node"); return(Visit((dynamic)node[0]) + "\t\tdup\n\t\tadd\n"); }
//This function actually creates the object associated with each Instruction by using a long switch statement. The object //created is polymorphed up to an IInstruction and then returned from the function to be stored in the encodedInstrs list. //Ugly? Very. Effective? Extremely. private IInstruction createObject(string comm, int valToUse, int currentInstruc) { IInstruction retVal = null; switch (comm) { case "exit": retVal = new Exit(valToUse) as IInstruction; break; case "swap": retVal = new Swap() as IInstruction; break; case "inpt": retVal = new Inpt() as IInstruction; break; case "nop": retVal = new Nop() as IInstruction; break; case "pop": retVal = new Pop() as IInstruction; break; case "add": retVal = new Add() as IInstruction; break; case "sub": retVal = new Sub() as IInstruction; break; case "mul": retVal = new Mul() as IInstruction; break; case "div": retVal = new Div() as IInstruction; break; case "rem": retVal = new Rem() as IInstruction; break; case "and": retVal = new And() as IInstruction; break; case "or": retVal = new Or() as IInstruction; break; case "xor": retVal = new Xor() as IInstruction; break; case "neg": retVal = new Neg() as IInstruction; break; case "not": retVal = new Not() as IInstruction; break; case "goto": retVal = new Goto(valToUse) as IInstruction; break; case "ifeq": retVal = new If1(0, valToUse, currentInstruc) as IInstruction; break; case "ifne": retVal = new If1(1, valToUse, currentInstruc) as IInstruction; break; case "iflt": retVal = new If1(2, valToUse, currentInstruc) as IInstruction; break; case "ifgt": retVal = new If1(3, valToUse, currentInstruc) as IInstruction; break; case "ifle": retVal = new If1(4, valToUse, currentInstruc) as IInstruction; break; case "ifge": retVal = new If1(5, valToUse, currentInstruc) as IInstruction; break; case "ifez": retVal = new If2(0, valToUse, currentInstruc) as IInstruction; break; case "ifnz": retVal = new If2(1, valToUse, currentInstruc) as IInstruction; break; case "ifmi": retVal = new If2(2, valToUse, currentInstruc) as IInstruction; break; case "ifpl": retVal = new If2(3, valToUse, currentInstruc) as IInstruction; break; case "dup": retVal = new Dup(valToUse) as IInstruction; break; case "print": retVal = new Print() as IInstruction; break; case "dump": retVal = new Dump() as IInstruction; break; case "push": retVal = new Push(valToUse) as IInstruction; break; } return(retVal); }