Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

other slides about XTS

  • Loading branch information...
commit 6775b9edf9d146414222a34209f3e1b90878f754 1 parent 70d8b10
@LorenzoBettini LorenzoBettini authored
Showing with 247 additions and 37 deletions.
  1. +8 −1 EclipseDayFlorence-presentation/listings/Makefile
  2. +2 −1  EclipseDayFlorence-presentation/listings/ts.lang
  3. +1 −0  EclipseDayFlorence-presentation/listings/xts-attributeref.ts
  4. +5 −0 EclipseDayFlorence-presentation/listings/xts-attributeref.ts.tex
  5. +6 −0 EclipseDayFlorence-presentation/listings/xts-characteristics.ts
  6. +10 −0 EclipseDayFlorence-presentation/listings/xts-characteristics.ts.tex
  7. +4 −0 EclipseDayFlorence-presentation/listings/xts-literals.ts
  8. +8 −0 EclipseDayFlorence-presentation/listings/xts-literals.ts.tex
  9. +3 −0  EclipseDayFlorence-presentation/listings/xts-settingup.ts
  10. +8 −0 EclipseDayFlorence-presentation/listings/xts-settingup.ts.tex
  11. +3 −0  EclipseDayFlorence-presentation/listings/xts-types.ts
  12. +7 −0 EclipseDayFlorence-presentation/listings/xts-types.ts.tex
  13. +10 −0 EclipseDayFlorence-presentation/listings/xts-types2.ts
  14. +14 −0 EclipseDayFlorence-presentation/listings/xts-types2.ts.tex
  15. +12 −0 EclipseDayFlorence-presentation/listings/xts-types3.ts
  16. +16 −0 EclipseDayFlorence-presentation/listings/xts-types3.ts.tex
  17. +23 −0 EclipseDayFlorence-presentation/src-gen/org/typesys/xts/guidsl/typesys/GuiDlsTypesystemGenerated.java
  18. +105 −33 EclipseDayFlorence-presentation/xts.tex
  19. +1 −1  tsarticle/6-xts.tex
  20. +1 −1  tsarticle/lstlang0.sty
View
9 EclipseDayFlorence-presentation/listings/Makefile
@@ -5,7 +5,14 @@ TOPROCESS = SimpleRules.xsemantics SimpleRules2.xsemantics \
intro.gui \
xbase-gettype.xtend \
xts-typecoerce.java \
- xts-plus.ts
+ xts-plus.ts \
+ xts-settingup.ts \
+ xts-literals.ts \
+ xts-types.ts \
+ xts-types2.ts \
+ xts-types3.ts \
+ xts-attributeref.ts \
+ xts-characteristics.ts
# plain-typeconf.xtend \
# plain-gettype.xtend
View
3  EclipseDayFlorence-presentation/listings/ts.lang
@@ -1,4 +1,5 @@
include "java.lang"
keyword = "subtype|base|characteristic|common",
- "ensureType|ensureCompatibility|char|as|typeof|def|override|dispatch"
+ "ensureType|ensureCompatibility|char|as|typeof|def|override|dispatch",
+ "typesystem|ecore|file|language|package|section|javacode|clone|feature|ancestor"
View
1  EclipseDayFlorence-presentation/listings/xts-attributeref.ts
@@ -0,0 +1 @@
+typeof AttributeRef -> feature attr
View
5 EclipseDayFlorence-presentation/listings/xts-attributeref.ts.tex
@@ -0,0 +1,5 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{typeof}}\ AttributeRef\ -$>$\ \textbf{\textcolor{Plum}{feature}}\ attr
+\end{tabular}
View
6 EclipseDayFlorence-presentation/listings/xts-characteristics.ts
@@ -0,0 +1,6 @@
+characteristic COMPARABLE {
+ IntType, FloatType, BooleanType, StringType
+}
+characteristic NUMERIC {
+ IntType, FloatType
+}
View
10 EclipseDayFlorence-presentation/listings/xts-characteristics.ts.tex
@@ -0,0 +1,10 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{characteristic}}\ COMPARABLE\ \{ \\
+\mbox{}\ \ \ \ IntType,\ FloatType,\ BooleanType,\ StringType \\
+\mbox{}\}\ \ \\
+\mbox{}\textbf{\textcolor{Plum}{characteristic}}\ NUMERIC\ \{ \\
+\mbox{}\ \ \ \ IntType,\ FloatType \\
+\mbox{}\}\
+\end{tabular}
View
4 EclipseDayFlorence-presentation/listings/xts-literals.ts
@@ -0,0 +1,4 @@
+section "Literals"
+ typeof StringLiteral -> StringType
+ typeof BooleanLiteral -> BooleanType
+ typeof NumberLiteral -> javacode
View
8 EclipseDayFlorence-presentation/listings/xts-literals.ts.tex
@@ -0,0 +1,8 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{section}}\ \textcolor{RoyalBlue}{"{}Literals"{}} \\
+\mbox{}\ \ \ \ \ \ \textbf{\textcolor{Plum}{typeof}}\ StringLiteral\ -$>$\ StringType \\
+\mbox{}\ \ \ \ \ \ \textbf{\textcolor{Plum}{typeof}}\ BooleanLiteral\ -$>$\ BooleanType \\
+\mbox{}\ \ \ \ \ \ \textbf{\textcolor{Plum}{typeof}}\ NumberLiteral\ -$>$\ \textbf{\textcolor{Plum}{javacode}}
+\end{tabular}
View
3  EclipseDayFlorence-presentation/listings/xts-settingup.ts
@@ -0,0 +1,3 @@
+typesystem org.typesys.xts.guidsl.typesys.GuiDlsTypesystem
+ ecore file "platform:/.../GuiDsl.ecore"
+ language package org.typesys.xts.guidsl.guiDsl.GuiDslPackage
View
8 EclipseDayFlorence-presentation/listings/xts-settingup.ts.tex
@@ -0,0 +1,8 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{typesystem}}\ org.typesys.xts.guidsl.typesys.GuiDlsTypesystem\ \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ecore}}\ \textbf{\textcolor{Plum}{file}}\ \textcolor{RoyalBlue}{"{}platform:/.../GuiDsl.ecore"{}} \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{language}}\ \textbf{\textcolor{Plum}{package}}\ org.typesys.xts.guidsl.guiDsl.GuiDslPackage\ \\
+\mbox{}
+\end{tabular}
View
3  EclipseDayFlorence-presentation/listings/xts-types.ts
@@ -0,0 +1,3 @@
+section "Types"
+ typeof Type+ -> clone
+ subtype IntType base FloatType
View
7 EclipseDayFlorence-presentation/listings/xts-types.ts.tex
@@ -0,0 +1,7 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{section}}\ \textcolor{RoyalBlue}{"{}Types"{}} \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{typeof}}\ Type+\ -$>$\ \textbf{\textcolor{Plum}{clone}} \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{subtype}}\ IntType\ \textbf{\textcolor{Plum}{base}}\ FloatType
+\end{tabular}
View
10 EclipseDayFlorence-presentation/listings/xts-types2.ts
@@ -0,0 +1,10 @@
+typeof Comparison -> BooleanType {
+ ensureType left :<=: char(COMPARABLE)
+ ensureType right :<=: char(COMPARABLE)
+ ensureCompatibility left :<=>: right
+}
+typeof Minus -> common left right {
+ ensureType left :<=: char(NUMERIC)
+ ensureType right :<=: char(NUMERIC)
+ ensureCompatibility left :<=>: right
+}
View
14 EclipseDayFlorence-presentation/listings/xts-types2.ts.tex
@@ -0,0 +1,14 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textbf{\textcolor{Plum}{typeof}}\ Comparison\ -$>$\ BooleanType\ \{ \\
+\mbox{}\ \ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ left\ :$<$=:\ \textbf{\textcolor{Plum}{char}}(COMPARABLE) \\
+\mbox{}\ \ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ right\ :$<$=:\ \textbf{\textcolor{Plum}{char}}(COMPARABLE) \\
+\mbox{}\ \ \ \ \ \textbf{\textcolor{Plum}{ensureCompatibility}}\ left\ :$<$=$>$:\ right \\
+\mbox{}\} \\
+\mbox{}\textbf{\textcolor{Plum}{typeof}}\ Minus\ -$>$\ \textbf{\textcolor{Plum}{common}}\ left\ right\ \{ \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ left\ :$<$=:\ \textbf{\textcolor{Plum}{char}}(NUMERIC) \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ right\ :$<$=:\ \textbf{\textcolor{Plum}{char}}(NUMERIC) \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureCompatibility}}\ left\ :$<$=$>$:\ right \\
+\mbox{}\}
+\end{tabular}
View
12 EclipseDayFlorence-presentation/listings/xts-types3.ts
@@ -0,0 +1,12 @@
+// text widgets may only refer to non-boolean attributes
+typeof TextWidget -> feature attr {
+ ensureType length :<=: IntType
+ ensureType attr :<=: StringType, IntType, FloatType
+ ensureType validate :<=: BooleanType
+}
+
+// checkbox widgets may only refer to boolean attributes
+typeof CheckBoxWidget -> feature attr {
+ ensureType attr :<=: BooleanType
+ ensureType validate :<=: BooleanType
+}
View
16 EclipseDayFlorence-presentation/listings/xts-types3.ts.tex
@@ -0,0 +1,16 @@
+% Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
+\begin{tabular}[t]{l}
+\noindent
+\mbox{}\textcolor{Green}{//\ text\ widgets\ may\ only\ refer\ to\ non-boolean\ attributes\ } \\
+\mbox{}\textbf{\textcolor{Plum}{typeof}}\ TextWidget\ -$>$\ \textbf{\textcolor{Plum}{feature}}\ attr\ \{ \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ length\ :$<$=:\ IntType \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ attr\ :$<$=:\ StringType,\ IntType,\ FloatType \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ validate\ :$<$=:\ BooleanType \\
+\mbox{}\}\ \ \\
+\mbox{} \\
+\mbox{}\textcolor{Green}{//\ checkbox\ widgets\ may\ only\ refer\ to\ boolean\ attributes} \\
+\mbox{}\textbf{\textcolor{Plum}{typeof}}\ CheckBoxWidget\ -$>$\ \textbf{\textcolor{Plum}{feature}}\ attr\ \{ \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ attr\ :$<$=:\ BooleanType \\
+\mbox{}\ \ \ \ \textbf{\textcolor{Plum}{ensureType}}\ validate\ :$<$=:\ BooleanType \\
+\mbox{}\}
+\end{tabular}
View
23 ...orence-presentation/src-gen/org/typesys/xts/guidsl/typesys/GuiDlsTypesystemGenerated.java
@@ -0,0 +1,23 @@
+package org.typesys.xts.guidsl.typesys;
+
+import org.eclipse.emf.ecore.EObject;
+import de.itemis.xtext.typesystem.exceptions.TypesystemConfigurationException;
+import de.itemis.xtext.typesystem.trace.TypeCalculationTrace;
+import de.itemis.xtext.typesystem.characteristics.TypeCharacteristic;
+
+public class GuiDlsTypesystemGenerated extends de.itemis.xtext.typesystem.DefaultTypesystem {
+
+ protected org.typesys.xts.guidsl.guiDsl.GuiDslPackage p = org.typesys.xts.guidsl.guiDsl.GuiDslPackage.eINSTANCE;
+
+
+ protected void initialize() {
+
+ try {
+
+ } catch ( TypesystemConfigurationException ex ) {
+ ex.printStackTrace();
+ }
+ }
+
+
+}
View
138 EclipseDayFlorence-presentation/xts.tex
@@ -8,52 +8,124 @@
\begin{frame}
\frametitle{Xtext Typesystem (XTS)}
\begin{itemize}
- \item Typesystem DSL written in Xtext
- \item Additional uses: interpreter, testing
- \item Recursive type computation
+ \item Originally developed as a framework with a Java API to declaratively
+ specify type system rules;
+ \item DSL to generate the Java code that had to be written before;
+ \item If no suitable declarative abstraction is available,
+ Java code can still be added manually.
+ \item \texttt{ITypesystem} interface with methods for
+ \begin{itemize}
+ \item calculating the type of model elements
+ \item for comparing types for
+ compatibility and subtyping relationships
+ \end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
- \frametitle{The Plus Operator with XTS}
+ \frametitle{Setting up}
\begin{footnotesize}
- \input{listings/xts-plus.ts.tex}
+ \input{listings/xts-settingup.ts.tex}
\end{footnotesize}
- \note{
- \begin{itemize}
- \item Commonly used language elements
- \end{itemize}
- \begin{itemize}
- \item subtype relationships
- \item grouping of types
- \item type computation, \emph{ensure}\ldots clauses
- \end{itemize}}
+
+the platform URI for the Ecore file (the metaclasses for
+which we want to specify the type system rules)
+
\end{frame}
-\note{
\begin{frame}[fragile]
- \frametitle{The Plus Operator with XTS}
- \begin{itemize}
- \item Coercion of a number to a String
- \end{itemize}
+ \frametitle{Specifying types}
\begin{footnotesize}
- \input{listings/xts-typecoerce.java.tex}
+ \input{listings/xts-types.ts.tex}
\end{footnotesize}
- \begin{itemize}
- \item XTS will try custom coercion methods before throwing a type error
- \item coercion methods use polymorphic dispatch
- \end{itemize}
- public EObject typeCoerce( EObject candidateElement, FloatType candidate,
- StringType expected, TypeCalculationTrace trace ) {
- if ( candidateElement instanceof NumberLiteral ) {
- trace.add( candidateElement, "Number coerced to string.");
- return create(lang.getStringType());
- }
- return null;
-}
-\end{frame}}
+\onslide<2->
+
+ \begin{footnotesize}
+ \input{listings/xts-literals.ts.tex}
+ \end{footnotesize}
+
+\onslide<3->
+
+\medskip
+
+ Recursive computation
+
+ \begin{footnotesize}
+ \input{listings/xts-attributeref.ts.tex}
+ \end{footnotesize}
+
+
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Specifying types}
+
+ \begin{footnotesize}
+ \input{listings/xts-characteristics.ts.tex}
+ \end{footnotesize}
+
+\onslide<2->
+
+ \begin{footnotesize}
+ \input{listings/xts-types2.ts.tex}
+ \end{footnotesize}
+
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{Specifying types}
+
+ \begin{footnotesize}
+ \input{listings/xts-types3.ts.tex}
+ \end{footnotesize}
+
+\end{frame}
+
+% \begin{frame}[fragile]
+% \frametitle{The Plus Operator with XTS}
+%
+%
+% \begin{footnotesize}
+% \input{listings/xts-plus.ts.tex}
+% \end{footnotesize}
+%
+% \note{
+% \begin{itemize}
+% \item Commonly used language elements
+% \end{itemize}
+% \begin{itemize}
+% \item subtype relationships
+% \item grouping of types
+% \item type computation, \emph{ensure}\ldots clauses
+% \end{itemize}}
+% \end{frame}
+%
+% \note{
+% \begin{frame}[fragile]
+% \frametitle{The Plus Operator with XTS}
+% \begin{itemize}
+% \item Coercion of a number to a String
+% \end{itemize}
+%
+% \begin{footnotesize}
+% \input{listings/xts-typecoerce.java.tex}
+% \end{footnotesize}
+%
+% \begin{itemize}
+% \item XTS will try custom coercion methods before throwing a type error
+% \item coercion methods use polymorphic dispatch
+% \end{itemize}
+% public EObject typeCoerce( EObject candidateElement, FloatType candidate,
+% StringType expected, TypeCalculationTrace trace ) {
+% if ( candidateElement instanceof NumberLiteral ) {
+% trace.add( candidateElement, "Number coerced to string.");
+% return create(lang.getStringType());
+% }
+% return null;
+% }
+% \end{frame}}
View
2  tsarticle/6-xts.tex
@@ -67,7 +67,7 @@ \subsection{The type of types}
\begin{lstlisting}[language=xts]
section "Types"
typeof Type+ -> clone
- subtype IntType base FloatTyoe
+ subtype IntType base FloatType
\end{lstlisting}
We also specify the subtyping relationship between \ic{FloatType} and \ic{IntType}. This
View
2  tsarticle/lstlang0.sty
@@ -49,7 +49,7 @@
\lst@definelanguage{xts}%
{morekeywords={typesystem,ecore,file,language,package,%
section,typeof,subtype,base,clone,javacode,characteristic,%
- abstract,ensureType,ensureCompatibility,char,common},%
+ abstract,ensureType,ensureCompatibility,char,common,feature,ancestor},%
sensitive,%
morecomment=[l]//,%
morecomment=[s]{/*}{*/},%
Please sign in to comment.
Something went wrong with that request. Please try again.