Common definitions of graphical items in Modelica - modelica

I could see there are some common definitions of the graphical items in Modelica language, but I can't find the definitions in Modelica Standard Library, so these definitions are built-in types?

Those types, and the records in that chapter, are internal to the specification.
Additionally having unit="mm" as for DrawingUnit is not recommended for normal types, as the idea is to use SI-types without any prefix.

Related

Domain-Specific Languages in Racket compared to Model-Driven frameworks such as Xtext

Racket and Xtext are both considered as language workbenches, but they are based on different concepts and workflows.
As an experienced Xtext user, I find it difficult to adapt my thought process to Racket.
In Xtext, the grammar of a language is converted into, or mapped to, a set of classes (also called a metamodel).
Xtext also generates a parser that converts a source file into a set of instances of those classes. A scoping API allows to resolve named references, so that the result is an object graph (also called a model) rather than an abstract syntax tree (AST).
Such a model can be queried, transformed, or fed into a template engine to generate code.
In Racket, the reader produces an AST in the form of a syntax object. However, most examples that I have found seem to make an ad-hoc use of this syntax object. Either they are toy languages that do not need a complete object graph, or they are too complex and it is difficult to infer a general methodology.
For my current language project, after struggling with syntax objects, I have created the equivalent of a metamodel using Racket structs. Then it was fairly easy to convert a syntax object into an object graph that I could manipulate as if it were a model in EMF. However, I feel like I am not using syntax objects the way they are intended to be.
Here are my questions:
What tools or APIs are available to work on syntax objects and achieve a similar ease-of-use as a model-driven framework?
Are there documents that describe a general language development methodology in Racket, that could be applied to non-trivial languages?
Are there documents that explain the Racket way, compared to Xtext or any other model-driven language framework?
EDIT:
Based on the documentation for Metaprogramming helpers, syntax classes can be used to specify and compose syntax patterns, and attach attributes to their elements. They can achieve a similar purpose as the classes of a metamodel.
However, as far as I can see, syntax classes are not classes, and syntax objects are not linked to syntax classes in a class-instance relationship.
This has the following consequences:
Syntax classes do not support inheritance directly, but we can achieve a similar effect with ~or* and attribute declarations for subclasses.
Syntax classes do not come with accessors for their attributes: you have to call syntax-parse every time you want to read an attribute.
At this point, there are still two missing features that are not addressed in the documentation that I have found:
Traversing a syntax tree from child to parent: how can I get a reference to the syntax object enclosing a given syntax object?
Scoping: how can I define specific scoping rules for my language?

Using OCL for Date attributes

I have some models with date attributes and I want to include ocl for validation and derivation.
Searching on the internet I found some articles and papers referring to date.isBefore(date) or date.before(date) methods but these methods are not recognized in OCL.
Additionally I would like to define derivation such as derivation: endDate + 10;.
Do I have to redefine a Date class with all methods I need ?
Any material or link related to it is welcome.
Given that OCL does not define Date, the authors' should have gone the long way round in order to formally define isBefore (and pages are a scarce resource in academic writing ;)
A few “primitive types” including numbers and strings are predefined
in UML [RJB98*, p. 394]. The availability of other types like date and
money is “system-dependent”. In any case, the semantics of primitive
types has to be defined outside UML.
(Richters Mark. A Precise Approach to Validating UML Models and OCL Constraints, Universität Bremen, p. 33, 86)
[RJB98] Rumbaugh, Jacobson, and Booch. The Unified Modeling
Language Reference Manual. Addison-Wesley, 1998.
While I'm not proficient in EMF, According to this link any Java datatype can be used in your models by declaring it as
the instance type of an EDataType for your Ecore model. (See also this reference)

XText multiple file extensions

I'd like to define a language with different elements that shall be contained into different kind of files though linked (i.e. similarly to C++ with .cpp and .h files).
Is grammar mixin the right way to do that? If so how should I proceed?
Different elements in different file kinds sounds like a use case for Grammar Mixins. The base grammar should define the language concepts common for both languages, and the sub-languages would inherit from the base grammar.
Ideally create a manually written Ecore metamodel and map the concept to it (i.e. don't use 'generate').
Since 2.10, Xtext supports parser rule fragments. This means you can define certain reusable parts of rules with the 'fragment' keyword. See https://github.com/eclipse/xtext-core/blob/761ffeac7e62525be5a5473988d7f1d577298b67/org.eclipse.xtext.tests/src/org/eclipse/xtext/parser/fragments/FragmentTestLanguage.xtext.

Project visualization in Lisp

Is there a tool that can generate diagrams (similar to Doxygen using Graphviz) but in the formats described by this paper: Lisp Looks Different
Program Style Distribution: Determine which programming style (Functional, OO, Imperative or Macro) dominates a software package, also to determine the size of complexity in each package.
Class Method Relation View: Visualizes the relationships between classes and methods (in Lisp, classes and methods are separated). The goal is to identify possible independent or loosely coupled components of the system.
Generic Concer View: Helps to identify and locate cross-cutting concerns associated with generic functions.
Class Type View: Helps to identify different types of classes, based on their structure, more precisely on the attributes to methods ratio.
tio
For the meaning of the colors and shapes, please refer to the document. It would be nice if there are equivalent tools for other languages as well.
Have you looked at Mondrian, which the paper cites was what was used to generate those diagrams?
More generally, have you looked at Moose, of which Mondrian is but a part?
I'm not sure I've seen one that produces diagrams exactly like those above, but there are quite a few more software visualization tools around.
Obvous first step: contact the paper's authors and ask what tools they used, and do they have any code they can share.

Representing classes and interfaces in a language neutral way

I need to define simple classes and interfaces (Ex. IClassInterface) in a language neutral way and then use a variety of code generation tools to generate the code files in a variety of languages such as C#, Java, etc... Does anyone know of a standard; ratified or otherwise; that I can use for the neutral representation. I know UML is often used for creating diagrams, but I am actually looking for something that can easily be parsed, extended, and used to drive other automated processes. Maybe this is actually possible with UML, although I am not sure what the markup language might look like if one exists.
I could create my own definition using XML or something similar, but I would prefer to avoid reinventing the wheel if possible.
UML
I think you might be looking for XMI (XML Metadata Interchange)
There is IDL (for example, Google's protocol buffers), and WSDL, which can be used to produce interfaces and classes by many web service frameworks. (You typically do not have to use the generated code as an actual webservice.)
The wikipedia entry for IDL lists a number of implementations of IDL. Although IDL is mainly for describing interfaces, some implementations also use it to describe objects (e.g. Microsoft IDL.)