Skip to content

Commit

Permalink
other slides about XTS
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed May 2, 2012
1 parent 70d8b10 commit 6775b9e
Show file tree
Hide file tree
Showing 20 changed files with 247 additions and 37 deletions.
9 changes: 8 additions & 1 deletion EclipseDayFlorence-presentation/listings/Makefile
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion 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"
@@ -0,0 +1 @@
typeof AttributeRef -> feature attr
@@ -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}
@@ -0,0 +1,6 @@
characteristic COMPARABLE {
IntType, FloatType, BooleanType, StringType
}
characteristic NUMERIC {
IntType, FloatType
}
@@ -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}
4 changes: 4 additions & 0 deletions EclipseDayFlorence-presentation/listings/xts-literals.ts
@@ -0,0 +1,4 @@
section "Literals"
typeof StringLiteral -> StringType
typeof BooleanLiteral -> BooleanType
typeof NumberLiteral -> javacode
8 changes: 8 additions & 0 deletions 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}
3 changes: 3 additions & 0 deletions 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
8 changes: 8 additions & 0 deletions 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}
3 changes: 3 additions & 0 deletions EclipseDayFlorence-presentation/listings/xts-types.ts
@@ -0,0 +1,3 @@
section "Types"
typeof Type+ -> clone
subtype IntType base FloatType
7 changes: 7 additions & 0 deletions 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}
10 changes: 10 additions & 0 deletions 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
}
14 changes: 14 additions & 0 deletions 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}
12 changes: 12 additions & 0 deletions 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
}
16 changes: 16 additions & 0 deletions 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}
@@ -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();
}
}


}
138 changes: 105 additions & 33 deletions EclipseDayFlorence-presentation/xts.tex
Expand Up @@ -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}}
2 changes: 1 addition & 1 deletion tsarticle/6-xts.tex
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tsarticle/lstlang0.sty
Expand Up @@ -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]{/*}{*/},%
Expand Down

0 comments on commit 6775b9e

Please sign in to comment.