Changeset 21
- Timestamp:
- Nov 23, 2007, 1:30:19 AM (18 years ago)
- Author:
- neil.c.c.brown
- Message:
-
Defined an occam syntax highlighting mode, and changed the colour of the comments to save my eyes.
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/200711-tock-seminars/200711-tock-slides.tex
r20 r21 4 4 %{{{ header 5 5 %include polycode.fmt 6 (追記) (追記ここまで) 6 7 7 8 \usepackage{pifont} … … 68 69 % package does allow us to escape to maths mode, so perhaps we should try that... 69 70 70 \begin{document} 71 \lstdefinelanguage[21]{occam} 72 {morekeywords={BYTE,FOR,FROM,INT,INT32,IS,PROC,RESHAPES,RETYPES,SEQ,SIZE,VAL}, 73 otherkeywords={:,:=}, 74 morecomment=[l]{--} 75 } 76 77 \definecolor{ForestGreen}{cmyk}{0.91,0,0.88,0.12} 78 79 \def\haskellsettings{ 71 80 \lstset{ 72 81 language={[improved]Haskell}, … … 75 84 keywordstyle=\color{blue}\bfseries, 76 85 identifierstyle=, 77 commentstyle=\color{ (削除) g (削除ここまで)reen}\itshape,86 commentstyle=\color{(追記) ForestG (追記ここまで)reen}\itshape, 78 87 stringstyle=, 79 88 showstringspaces=false} 89 (追記) } (追記ここまで) 90 (追記) (追記ここまで) 91 (追記) \def\occamsettings{ (追記ここまで) 92 (追記) \lstset{ (追記ここまで) 93 (追記) language={[21]occam}, (追記ここまで) 94 (追記) columns=fixed, (追記ここまで) 95 (追記) basicstyle=\small\ttfamily, (追記ここまで) 96 (追記) keywordstyle=\color{blue}\bfseries, (追記ここまで) 97 (追記) identifierstyle=, (追記ここまで) 98 (追記) commentstyle=\color{ForestGreen}\itshape, (追記ここまで) 99 (追記) stringstyle=, (追記ここまで) 100 (追記) showstringspaces=false} (追記ここまで) 101 (追記) } (追記ここまで) 102 (追記) (追記ここまで) 103 (追記) \begin{document} (追記ここまで) 104 (追記) (追記ここまで) 105 (追記) \haskellsettings (追記ここまで) 80 106 81 107 \begin{frame} … … 475 501 \begin{frame}[fragile] 476 502 \frametitle{Matching elements} 477 \begin{verbatim} 503 \occamsettings 504 \begin{lstlisting} 478 505 x, y := y, x 479 506 480 507 t := y 481 508 y := x 482 x := t\end{verbatim} 509 x := t 510 \end{lstlisting} 511 \haskellsettings 483 512 \begin{lstlisting} 484 513 Assign p0 (VarList p0 ["x", "y"]) (ExprList p0 [JustVar "x", JustVar "y"]) … … 995 1024 \section{Language features} 996 1025 997 %TODO define a syntax-highlighting mode for occam, and change the occam 998 %code fragments to use it 1026 \occamsettings 999 1027 1000 1028 \begin{frame}[fragile] … … 1004 1032 \item Instead, it has a very powerful reference (``abbreviation'') system 1005 1033 \end{itemize} 1006 \begin{verbatim} 1007 INT x: -- declares variable 1008 INT y IS x: -- declares reference to variable 1009 VAL INT y2 IS y: -- declares read-only reference to variable 1010 1011 PROC foo (INT z) -- procedure that takes a reference 1034 \begin{lstlisting} 1035 INT x: -- declares variable 1036 INT y IS x: -- declares reference to variable 1037 VAL INT y2 IS y: 1038 -- declares read-only reference to variable 1039 1040 PROC foo (INT z) -- procedure that takes a reference 1012 1041 z := 42 1013 1042 : 1014 \end{ (削除) verbatim (削除ここまで)}1043 \end{(追記) lstlisting (追記ここまで)} 1015 1044 \end{frame} 1016 1045 … … 1024 1053 \end{itemize} 1025 1054 \end{itemize} 1026 \begin{ (削除) verbatim (削除ここまで)}1027 [10]INT xs: (削除) (削除ここまで)-- declares an array1055 \begin{(追記) lstlisting (追記ここまで)} 1056 [10]INT xs: (追記) (追記ここまで)-- declares an array 1028 1057 SEQ 1029 xs[15] := 42 (削除) (削除ここまで)-- would fail at compile time1030 xs[n] := 42 (削除) (削除ここまで)-- would fail at runtime if n >= 101031 1032 n := SIZE xs (削除) (削除ここまで)-- get size of the array1033 1034 INT y IS xs[4]: (削除) (削除ここまで)-- abbreviate a member of the array1058 xs[15] := 42 (追記) (追記ここまで)-- would fail at compile time 1059 xs[n] := 42 (追記) (追記ここまで)-- would fail at runtime if n >= 10 1060 1061 n := SIZE xs (追記) (追記ここまで)-- get size of the array 1062 1063 INT y IS xs[4]: (追記) (追記ここまで)-- abbreviate a member of the array 1035 1064 y := 42 1036 1065 1037 [4]INT ys IS [xs FROM 4 FOR 5]: -- abbreviate a slice of the array 1066 [4]INT ys IS [xs FROM 4 FOR 5]: 1067 -- abbreviate a slice of the array 1038 1068 ys[2] := 42 1039 \end{ (削除) verbatim (削除ここまで)}1069 \end{(追記) lstlisting (追記ここまで)} 1040 1070 \end{frame} 1041 1071 … … 1072 1102 \begin{frame}[fragile] 1073 1103 \frametitle{Retyping} 1074 \begin{ (削除) verbatim (削除ここまで)}1104 \begin{(追記) lstlisting (追記ここまで)} 1075 1105 INT32 i: 1076 1106 [4]BYTE bs RETYPES i: 1077 \end{ (削除) verbatim (削除ここまで)}1107 \end{(追記) lstlisting (追記ここまで)} 1078 1108 \begin{itemize} 1079 1109 \item Data retyping … … 1090 1120 \item Arrays can be reshaped! 1091 1121 \end{itemize} 1092 \begin{ (削除) verbatim (削除ここまで)}1122 \begin{(追記) lstlisting (追記ここまで)} 1093 1123 [4][3]INT xs: 1094 1124 [2][6]INT ys RESHAPES xs: 1095 \end{ (削除) verbatim (削除ここまで)}1125 \end{(追記) lstlisting (追記ここまで)} 1096 1126 \end{frame} 1097 1127 … … 1111 1141 \end{itemize} 1112 1142 \end{frame} 1143 (追記) (追記ここまで) 1144 (追記) \haskellsettings (追記ここまで) 1145 (追記) (追記ここまで) 1113 1146 %}}} 1114 1147 … … 1127 1160 \begin{itemize} 1128 1161 \item Nothing uses infinite data structures 1129 \item Really want strict evaluation in most p (削除) al (削除ここまで)ces1162 \item Really want strict evaluation in most p(追記) la (追記ここまで)ces 1130 1163 \begin{itemize} 1131 1164 \item Force errors sooner!
Note:
See TracChangeset
for help on using the changeset viewer.