private void CreateTypesTable() { TypesTable = new TypesTable.TypesTable(); TypesTable.StandardLibraryCreator sLC = new TypesTable.StandardLibraryCreator(); sLC.CreateStandardLibrary(TypesTable); // Docasna podpora pro typy v Tournaments.eXo Class date = new Class(TypesTable, TypesTable.Library.RootNamespace, "Date"); date.Operations.Add(new Operation("after", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("before", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("equals", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("trunc", true, date, new Parameter[] { })); date.Operations.Add(new Operation("=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation("<=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation("<", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation(">", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation(">=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); // TypesTable.Library.RootNamespace.NestedClassifier.Add(date); TypesTable.RegisterType(date); Class matchesStatus = new Class(TypesTable, TypesTable.Library.RootNamespace, "MatchStatus"); // TypesTable.Library.RootNamespace.NestedClassifier.Add(matchesStatus); TypesTable.RegisterType(matchesStatus); TranslateSchema(Schema); }
public OclCompilerResult CompileEvolutionScript(string text, Bridge.IBridgeToOCL bridge) { TypesTable.TypesTable tt = bridge.TypesTable; ErrorCollection errColl = new ErrorCollection(); // lexer ANTLRStringStream stringStream = new ANTLRStringStream(text); OCLSyntaxLexer lexer = new OCLSyntaxLexer(stringStream, errColl); // syntax CommonTokenStream tokenStream = new CommonTokenStream(lexer); OCLSyntaxParser parser = new OCLSyntaxParser(tokenStream, errColl); var output = parser.evolutionDeclarationList(); // semantic Antlr.Runtime.Tree.CommonTreeNodeStream treeStream = new CommonTreeNodeStream(output.Tree); OCLAst semantic = new OCLAst(treeStream, errColl); semantic.TypesTable = tt; semantic.Bridge = bridge; semantic.EnvironmentStack.Push(new NamespaceEnvironment(tt.Library.RootNamespace)); AST.Constraints constraints; AST.PropertyInitializations initializations; // try { OCLAst.evolutionDeclarationList_return evolutionDeclarationListReturn = semantic.evolutionDeclarationList(); constraints = evolutionDeclarationListReturn.Constraints; initializations = evolutionDeclarationListReturn.PropertyInitializations; // } //catch{ // constraints = new AST.Constraints(); // errColl.AddError(new ErrorItem("Fatal error.")); // } return(new OclCompilerResult(constraints, initializations, errColl, tt.Library, bridge)); }
/// <summary> /// Compile stand-alone expression. /// </summary> /// <example> /// Example shows how to parse stand-alone invariant. /// <code> /// <![CDATA[ /// // ... /// Environment nsEnv = new NamespaceEnvironment(tt.Library.RootNamespace); /// VariableDeclaration varSelf = new VariableDeclaration(selfName, contextClassifier, null); /// Environment classifierEnv = nsEnv.CreateFromClassifier(contextClassifier, varSelf); /// Environment selfEnv = Environment.AddElement(selfName, contextClassifier, varSelf, true); /// /// Compiler.Compiler compiler = new Compiler.Compiler(); /// var result = compiler.CompileStandAloneExpression(expressionText, tt, selfEnv); /// ]]> /// </code> /// </example> public ExpressionCompilerResult CompileStandAloneExpression(string text, TypesTable.TypesTable tt, Environment env) { ErrorCollection errColl = new ErrorCollection(); // lexer ANTLRStringStream stringStream = new ANTLRStringStream(text); OCLSyntaxLexer lexer = new OCLSyntaxLexer(stringStream, errColl); // syntax CommonTokenStream tokenStream = new CommonTokenStream(lexer); OCLSyntaxParser parser = new OCLSyntaxParser(tokenStream, errColl); var output = parser.oclExpression(); // semantic Antlr.Runtime.Tree.CommonTreeNodeStream treeStream = new CommonTreeNodeStream(output.Tree); OCLAst semantic = new OCLAst(treeStream, errColl); semantic.TypesTable = tt; semantic.EnvironmentStack.Push(env); AST.OclExpression expression; // try { expression = semantic.oclExpression(); // } //catch{ // constraints = new AST.Constraints(); // errColl.AddError(new ErrorItem("Fatal error.")); // } return(new ExpressionCompilerResult(expression, errColl, tt.Library)); }
/// <summary> /// Creates instance which represents <paramref name="sourceClass"/> in OCL type system. /// </summary> /// <param name="tt">Destination OCL type system.</param> /// <param name="sourceClass">Source class</param> /// <param name="parent">Parent of <paramref name="sourceClass"/> in inheritance hierarchy (if it has any)</param> /// <param name="nameOverride">Use this parameter when the class in the OCL should be registered under a /// different name than <paramref name="sourceClass"/>.<see cref="PIMClass.Name"/></param> public PIMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PIMClass sourceClass, PIMBridgeClass parent = null, string nameOverride = null) : base(tt, ns, nameOverride ?? sourceClass.Name, parent ?? tt.Library.Any) { this.SourceClass = sourceClass; PIMAttribute = new Dictionary <PIMAttribute, PIMBridgeAttribute>(); PIMAssociations = new Dictionary <PIMAssociationEnd, PIMBridgeAssociation>(); PIMOperations = new Dictionary <ModelOperation, Operation>(); }
public TupleType(TypesTable.TypesTable tt, IEnumerable <Property> tupleParts) : base(tt, new Namespace("isolatedNS"), GetName(tupleParts), null) { // this.TupleParts = new PropertyCollection(this); foreach (var p in tupleParts) { this.TupleParts.Add(p); } }
partial void OnCreated() { TypesTable = new TypesTable.TypesTable(); Errors = new ErrorCollection(); EnvironmentStack = new Stack <OCL.Environment>(); //EnvironmentStack.Push(new NamespaceEnvironment(new Namespace(""))); if (Errors == null) { Errors = new ErrorCollection(); } }
static public Classifier GetTypeByCardinality(TypesTable.TypesTable tt, IHasCardinality card, Classifier baseType) { if (card.Upper > 1) { return(tt.Library.CreateCollection(CollectionKind.Set, baseType)); } else { return(baseType); } }
public Classifier(TypesTable.TypesTable tt, Namespace ns, string name) { this.TypeTable = tt; Properties = new PropertyCollection(this); Operations = new OperationCollection(this); NestedClassifier = new NestedElemetCollection <Classifier, IModelElement>(this); this.Name = name; ns.NestedClassifier.Add(this); _QualifiedName = new Lazy <string>(() => GetQualifiedName(), true); }
public InvalidType(TypesTable.TypesTable tt, string name) : base(tt, tt.Library.RootNamespace, name) { }
protected CollectionType(TypesTable.TypesTable tt, CollectionKind collectionKind, Classifier elemetnType, Classifier superClassifier) : base(tt, new Namespace("isolatedNS"), GetName(collectionKind, elemetnType), superClassifier) { this.CollectionKind = collectionKind; this.ElementType = elemetnType; }
public CollectionType(TypesTable.TypesTable tt, Classifier elemetnType, Classifier superClassifier) : this(tt, CollectionKind.Collection, elemetnType, superClassifier) { }
public SetType(TypesTable.TypesTable tt, Classifier elemetnType, Classifier superClassifier) : base(tt, CollectionKind.Set, elemetnType, superClassifier) { }
private void CreateTypesTable() { Library.StandardTypeName naming = new OCL.TypesTable.Library.StandardTypeName(); naming.Any = "any"; naming.Boolean = "boolean"; naming.Integer = "integer"; naming.Invalid = "invalid"; naming.Message = "message"; naming.Real = "double"; naming.String = "string"; naming.Type = "type"; naming.UnlimitedNatural = "unlimitedNatural"; naming.Void = "void"; TypesTable = new TypesTable.TypesTable(naming); TypesTable.StandardLibraryCreator sLC = new TypesTable.StandardLibraryCreator(); sLC.CreateStandardLibrary(TypesTable); #region XML schema additional primitive types var @decimal = new Classifier(TypesTable, TypesTable.Library.RootNamespace, "decimal", TypesTable.Library.Integer); TypesTable.RegisterType(@decimal); var date = new Classifier(TypesTable, TypesTable.Library.RootNamespace, "date"); TypesTable.RegisterType(date); #endregion // Docasna podpora pro typy v Tournaments.eXo date.Operations.Add(new Operation("after", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("before", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("equals", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", date) })); date.Operations.Add(new Operation("trunc", true, date, new Parameter[] { })); date.Operations.Add(new Operation("=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation("<=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation("<", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation(">", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); date.Operations.Add(new Operation(">=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", date) })); TypesTable.RegisterType(date); // TypesTable.Library.RootNamespace.NestedClassifier.Add(date); Class dateTime = new Class(TypesTable, TypesTable.Library.RootNamespace, "dateTime"); dateTime.Operations.Add(new Operation("after", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", dateTime) })); dateTime.Operations.Add(new Operation("before", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", dateTime) })); dateTime.Operations.Add(new Operation("equals", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("time", dateTime) })); dateTime.Operations.Add(new Operation("trunc", true, dateTime, new Parameter[] { })); dateTime.Operations.Add(new Operation("getDate", true, dateTime, new Parameter[] { })); dateTime.Operations.Add(new Operation("=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", dateTime) })); dateTime.Operations.Add(new Operation("<=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", dateTime) })); dateTime.Operations.Add(new Operation("<", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", dateTime) })); dateTime.Operations.Add(new Operation(">", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", dateTime) })); dateTime.Operations.Add(new Operation(">=", true, TypesTable.Library.Boolean, new Parameter[] { new Parameter("other", dateTime) })); TypesTable.RegisterType(dateTime); // TypesTable.Library.RootNamespace.NestedClassifier.Add(dateTime); Class matchesStatus = new Class(TypesTable, TypesTable.Library.RootNamespace, "MatchStatus"); // TypesTable.Library.RootNamespace.NestedClassifier.Add(matchesStatus); TypesTable.RegisterType(matchesStatus); TranslateSchema(Schema, false); TypesTable.PerformDeferredInitializations(); }
public PSMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PSMContentModel sourceContentModel, string registerName) : this(tt, ns, GetContentModelOCLName(sourceContentModel)) { this.PSMSource = sourceContentModel; this.PSMSourceType = SourceType.PSMContentModel; }
public PSMBridgeClass(TypesTable.TypesTable tt, Namespace ns, PSMClass sourceClass, PSMBridgeClass parent = null, string nameOverride = null) : this(tt, ns, nameOverride ?? sourceClass.Name, parent) { this.PSMSource = sourceClass; this.PSMSourceType = SourceType.PSMClass; }
private PSMBridgeClass(TypesTable.TypesTable tt, Namespace ns, string name, Classifier parent = null) : base(tt, ns, name, parent ?? tt.Library.Any) { PSMChildMembers = new Dictionary <PSMAssociation, PSMBridgeAssociation>(); PSMAttribute = new Dictionary <PSMAttribute, PSMBridgeAttribute>(); }
public TemplateParameterType(TypesTable.TypesTable tt, Namespace ns) : base(tt, ns, "") { throw new NotImplementedException(); }
public Class(TypesTable.TypesTable tt, Namespace ns, string name) : base(tt, ns, name, tt.Library.Any) { SuperClass = new List <Classifier>(); }
public Classifier(TypesTable.TypesTable tt, Namespace ns, string name, Classifier superClassifier) : this(tt, ns, name) { this.SuperClassifier = superClassifier; }
public DataType(TypesTable.TypesTable tt, Namespace ns, string name, Classifier superClassifier) : base(tt, ns, name, superClassifier) { }
/// <summary> /// /// </summary> /// <param name="sourceType"></param> /// <param name="_bodyType"></param> /// <param name="tt"></param> /// <returns></returns> public Classifier BodyType(CollectionType sourceType, Classifier _bodyType, TypesTable.TypesTable tt) { return(bodyType(sourceType, _bodyType, tt)); }