public void RegisterEntities(ILibrary library) { if(library == null) throw new ArgumentNullException("library"); library.AddEntity(new ArbitraryGenericEntity("|", "Transition", "PetriNet")); }
public void RegisterEntities(ILibrary library) { if (library == null) { throw new ArgumentNullException("library"); } library.AddEntity(new ArbitraryGenericEntity("|", "Transition", "PetriNet")); }
public IEntity PublishToLibrary(string domain, string architectureLabel, string entityLabel, string entitySymbol) { IEntity entity = BuildEntity(new MathIdentifier(entityLabel, domain), entitySymbol); IArchitectureFactory factory = BuildArchitectureFactory(new MathIdentifier(architectureLabel, domain), entity.EntityId); ILibrary lib = Service <ILibrary> .Instance; lib.AddEntity(entity); lib.AddArchitecture(factory); return(entity); }
public static IEntity PublishToLibrary(string xml, ILibrary library, string domain, string architectureLabel, string entityLabel, string entitySymbol) { if (library == null) { throw new ArgumentNullException("library"); } IEntity entity = ReadXmlEntity(xml, new MathIdentifier(entityLabel, domain), entitySymbol); IArchitectureFactory factory = BuildArchitectureFactory(xml, new MathIdentifier(architectureLabel, domain), entity.EntityId, entity.InputSignals.Length, entity.OutputSignals.Length, entity.Buses.Length); library.AddEntity(entity); library.AddArchitecture(factory); return(entity); }
private IEntity ScanDefineEntity() { tokenizer.Match(TokenTypes.TextIdentifier, "entity"); MathIdentifier entityId = ScanEntityMathIdentifierOrLabel(true); string symbol = ScanLiteral(); InfixNotation notation; switch (tokenizer.MatchGet(TokenTypes.TextIdentifier).Text) { case "pre": notation = InfixNotation.PreOperator; break; case "post": notation = InfixNotation.PostOperator; break; case "left": notation = InfixNotation.LeftAssociativeInnerOperator; break; case "right": notation = InfixNotation.RightAssociativeInnerOperator; break; default: notation = InfixNotation.None; break; } int precedence = -1; if (tokenizer.LookaheadFistToken.IsType(TokenTypes.Integer)) { precedence = (int)ScanInteger(); } string[] inputs, outputs, buses; if (tokenizer.LookaheadFistToken.Text == "in") { tokenizer.Match(TokenTypes.TextIdentifier, "in"); inputs = ScanTextIdentifierList().ToArray(); } else { inputs = new string[0]; } if (tokenizer.LookaheadFistToken.Text == "out") { tokenizer.Match(TokenTypes.TextIdentifier, "out"); outputs = ScanTextIdentifierList().ToArray(); } else { outputs = new string[0]; } if (tokenizer.LookaheadFistToken.Text == "bus") { tokenizer.Match(TokenTypes.TextIdentifier, "bus"); buses = ScanTextIdentifierList().ToArray(); } else { buses = new string[0]; } IEntity entity = new EntityBase(symbol, entityId, notation, precedence, inputs, outputs, buses); library.AddEntity(entity); return(entity); }
public void RegisterEntities(ILibrary library) { if(library == null) throw new ArgumentNullException("library"); #region Arithmetics library.AddEntity(new NaryToOneGenericEntity("+", "Add", "Std", InfixNotation.LeftAssociativeInnerOperator, 60)); library.AddEntity(new NaryToOneGenericEntity("-", "Subtract", "Std", InfixNotation.LeftAssociativeInnerOperator, 60)); library.AddEntity(new NaryToOneGenericEntity("*", "Multiply", "Std", InfixNotation.LeftAssociativeInnerOperator, 50)); library.AddEntity(new NaryToOneGenericEntity("/", "Divide", "Std", InfixNotation.LeftAssociativeInnerOperator, 50)); library.AddEntity(new SymmetricGenericEntity("-", "Negate", "Std", InfixNotation.PreOperator, 20)); library.AddEntity(new SymmetricGenericEntity("inv", "Invert", "Std")); library.AddEntity(new SymmetricGenericEntity("abs", "Absolute", "Std")); library.AddEntity(new SymmetricGenericEntity("exp", "Exponential", "Std")); library.AddEntity(new SymmetricGenericEntity("ln", "NaturalLogarithm", "Std")); library.AddEntity(new SymmetricGenericEntity("sqr", "Square", "Std")); library.AddEntity(new EntityBase("^", "Power", "Std", InfixNotation.RightAssociativeInnerOperator, 19, new string[] { "Power_base", "Power_radix" }, new string[] { "Power_out" })); library.AddEntity(new EntityBase("!", "Factorial", "Std", InfixNotation.PostOperator, 45, new string[] { "Factorial_in" }, new string[] { "Factorial_out" })); #endregion #region Trigonometry library.AddEntity(new SymmetricGenericEntity("sin", "Sine", "Std")); library.AddEntity(new SymmetricGenericEntity("cos", "Cosine", "Std")); library.AddEntity(new SymmetricGenericEntity("tan", "Tangent", "Std")); library.AddEntity(new SymmetricGenericEntity("cot", "Cotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("sec", "Secant", "Std")); library.AddEntity(new SymmetricGenericEntity("csc", "Cosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("asin", "InverseSine", "Std")); library.AddEntity(new SymmetricGenericEntity("acos", "InverseCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("atan", "InverseTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("acot", "InverseCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("asec", "InverseSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("acsc", "InverseCosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("sinh", "HyperbolicSine", "Std")); library.AddEntity(new SymmetricGenericEntity("cosh", "HyperbolicCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("tanh", "HyperbolicTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("coth", "HyperbolicCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("sech", "HyperbolicSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("csch", "HyperbolicCosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("asinh", "InverseHyperbolicSine", "Std")); library.AddEntity(new SymmetricGenericEntity("acosh", "InverseHyperbolicCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("atanh", "InverseHyperbolicTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("acoth", "InverseHyperbolicCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("asech", "InverseHyperbolicSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("acsch", "InverseHyperbolicCosecant", "Std")); #endregion #region Logic library.AddEntity(new NaryToOneGenericEntity("and", "And", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("nand", "Nand", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("or", "Or", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("nor", "Nor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("xor", "Xor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("xnor", "Xnor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("imp", "Imply", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new SymmetricGenericEntity("not", "Not", "Std", InfixNotation.PreOperator, 250)); #endregion #region Algebra & Analysis library.AddEntity(new NearlySymmetricGenericEntity("diff", "Derive", "Std", 1, 0)); library.AddEntity(new SymmetricGenericEntity("asimplify", "AutoSimplify", "Std")); #endregion #region Flow library.AddEntity(new SymmetricGenericEntity("<-", "Transport", "Std")); library.AddEntity(new NearlySymmetricGenericEntity("$", "Sync", "Std", 1, 0)); library.AddEntity(new SymmetricGenericEntity("clk", "Clock", "Std")); #endregion }
public void RegisterEntities(ILibrary library) { if (library == null) { throw new ArgumentNullException("library"); } #region Arithmetics library.AddEntity(new NaryToOneGenericEntity("+", "Add", "Std", InfixNotation.LeftAssociativeInnerOperator, 60)); library.AddEntity(new NaryToOneGenericEntity("-", "Subtract", "Std", InfixNotation.LeftAssociativeInnerOperator, 60)); library.AddEntity(new NaryToOneGenericEntity("*", "Multiply", "Std", InfixNotation.LeftAssociativeInnerOperator, 50)); library.AddEntity(new NaryToOneGenericEntity("/", "Divide", "Std", InfixNotation.LeftAssociativeInnerOperator, 50)); library.AddEntity(new SymmetricGenericEntity("-", "Negate", "Std", InfixNotation.PreOperator, 20)); library.AddEntity(new SymmetricGenericEntity("inv", "Invert", "Std")); library.AddEntity(new SymmetricGenericEntity("abs", "Absolute", "Std")); library.AddEntity(new SymmetricGenericEntity("exp", "Exponential", "Std")); library.AddEntity(new SymmetricGenericEntity("ln", "NaturalLogarithm", "Std")); library.AddEntity(new SymmetricGenericEntity("sqr", "Square", "Std")); library.AddEntity(new EntityBase("^", "Power", "Std", InfixNotation.RightAssociativeInnerOperator, 19, new string[] { "Power_base", "Power_radix" }, new string[] { "Power_out" })); library.AddEntity(new EntityBase("!", "Factorial", "Std", InfixNotation.PostOperator, 45, new string[] { "Factorial_in" }, new string[] { "Factorial_out" })); #endregion #region Trigonometry library.AddEntity(new SymmetricGenericEntity("sin", "Sine", "Std")); library.AddEntity(new SymmetricGenericEntity("cos", "Cosine", "Std")); library.AddEntity(new SymmetricGenericEntity("tan", "Tangent", "Std")); library.AddEntity(new SymmetricGenericEntity("cot", "Cotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("sec", "Secant", "Std")); library.AddEntity(new SymmetricGenericEntity("csc", "Cosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("asin", "InverseSine", "Std")); library.AddEntity(new SymmetricGenericEntity("acos", "InverseCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("atan", "InverseTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("acot", "InverseCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("asec", "InverseSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("acsc", "InverseCosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("sinh", "HyperbolicSine", "Std")); library.AddEntity(new SymmetricGenericEntity("cosh", "HyperbolicCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("tanh", "HyperbolicTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("coth", "HyperbolicCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("sech", "HyperbolicSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("csch", "HyperbolicCosecant", "Std")); library.AddEntity(new SymmetricGenericEntity("asinh", "InverseHyperbolicSine", "Std")); library.AddEntity(new SymmetricGenericEntity("acosh", "InverseHyperbolicCosine", "Std")); library.AddEntity(new SymmetricGenericEntity("atanh", "InverseHyperbolicTangent", "Std")); library.AddEntity(new SymmetricGenericEntity("acoth", "InverseHyperbolicCotangent", "Std")); library.AddEntity(new SymmetricGenericEntity("asech", "InverseHyperbolicSecant", "Std")); library.AddEntity(new SymmetricGenericEntity("acsch", "InverseHyperbolicCosecant", "Std")); #endregion #region Logic library.AddEntity(new NaryToOneGenericEntity("and", "And", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("nand", "Nand", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("or", "Or", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("nor", "Nor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("xor", "Xor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("xnor", "Xnor", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new NaryToOneGenericEntity("imp", "Imply", "Std", InfixNotation.LeftAssociativeInnerOperator, 250)); library.AddEntity(new SymmetricGenericEntity("not", "Not", "Std", InfixNotation.PreOperator, 250)); #endregion #region Algebra & Analysis library.AddEntity(new NearlySymmetricGenericEntity("diff", "Derive", "Std", 1, 0)); library.AddEntity(new SymmetricGenericEntity("asimplify", "AutoSimplify", "Std")); #endregion #region Flow library.AddEntity(new SymmetricGenericEntity("<-", "Transport", "Std")); library.AddEntity(new NearlySymmetricGenericEntity("$", "Sync", "Std", 1, 0)); library.AddEntity(new SymmetricGenericEntity("clk", "Clock", "Std")); #endregion }
public static IEntity PublishToLibrary(string xml, ILibrary library, string domain, string architectureLabel, string entityLabel, string entitySymbol) { if(library == null) throw new ArgumentNullException("library"); IEntity entity = ReadXmlEntity(xml, new MathIdentifier(entityLabel, domain), entitySymbol); IArchitectureFactory factory = BuildArchitectureFactory(xml, new MathIdentifier(architectureLabel, domain), entity.EntityId, entity.InputSignals.Length, entity.OutputSignals.Length, entity.Buses.Length); library.AddEntity(entity); library.AddArchitecture(factory); return entity; }