/Util/latex/dafny.sty

http://dafny.codeplex.com · TeX · 111 lines · 102 code · 2 blank · 7 comment · 0 complexity · 2b6222360f0b74bb08a949bc18cd8751 MD5 · raw file

  1. % dafny.sty
  2. % Dafny mode for the LaTeX listings package.
  3. % Rustan Leino, 22 June 2008.
  4. \usepackage{listings}
  5. \lstdefinelanguage{dafny}{
  6. morekeywords={class,datatype,codatatype,type,iterator,
  7. bool,nat,int,object,set,multiset,seq,array,array2,array3,map,
  8. function,predicate,copredicate,
  9. ghost,var,static,refines,
  10. method,constructor,comethod,
  11. returns,yields,abstract,module,import,default,opened,as,in,
  12. requires,modifies,ensures,reads,decreases,free,
  13. % expressions
  14. match,case,false,true,null,old,fresh,choose,this,
  15. % statements
  16. assert,assume,print,new,if,then,else,while,invariant,break,label,return,yield,
  17. parallel,where,calc
  18. },
  19. literate=%
  20. {:}{$\colon$}1
  21. {::}{$\bullet$}2
  22. {:=}{$:$$=$}2
  23. {!}{$\lnot$}1
  24. {!!}{$\not\cap$}1
  25. {==}{$=$}1
  26. {!=}{$\neq$}1
  27. {&&}{$\land$}1
  28. {||}{$\lor$}1
  29. {<=}{$\le$}1
  30. {>=}{$\ge$}1
  31. % the following isn't actually Dafny, but it gives the option to produce nicer latex
  32. {|=>}{$\Rightarrow$}2
  33. {<=set}{$\subseteq$}1
  34. {+set}{$\cup$}1
  35. {*set}{$\cap$}1
  36. {==>}{$\Longrightarrow$}3
  37. {=>}{$\Rightarrow$}2
  38. {<==>}{$\Longleftrightarrow$}4
  39. {forall}{$\forall$}1
  40. {exists}{$\exists$}1
  41. {!in}{$\not\in$}1
  42. {\\in}{$\in$}1
  43. % the following isn't actually Dafny, but it gives the option to produce nicer latex
  44. {<<}{$\langle$}1
  45. {>>}{$\rangle$}1
  46. {(==)}{${}^{(=)}$}2
  47. {...}{$\ldots$}1
  48. {\\alpha}{$\alpha$}1
  49. {\\beta}{$\beta$}1
  50. {\\gamma}{$\gamma$}1
  51. {\\delta}{$\delta$}1
  52. {\\epsilon}{$\epsilon$}1
  53. {\\zeta}{$\zeta$}1
  54. {\\eta}{$\eta$}1
  55. {\\theta}{$\theta$}1
  56. {\\iota}{$\iota$}1
  57. {\\kappa}{$\kappa$}1
  58. {\\lambda}{$\lambda$}1
  59. {\\mu}{$\mu$}1
  60. {\\nu}{$\nu$}1
  61. {\\xi}{$\xi$}1
  62. {\\pi}{$\pi$}1
  63. {\\rho}{$\rho$}1
  64. {\\sigma}{$\sigma$}1
  65. {\\tau}{$\tau$}1
  66. {\\upsilon}{$\upsilon$}1
  67. {\\phi}{$\phi$}1
  68. {\\chi}{$\chi$}1
  69. {\\psi}{$\psi$}1
  70. {\\omega}{$\omega$}1
  71. {\\Gamma}{$\Gamma$}1
  72. {\\Delta}{$\Delta$}1
  73. {\\Theta}{$\Theta$}1
  74. {\\Lambda}{$\Lambda$}1
  75. {\\Xi}{$\Xi$}1
  76. {\\Pi}{$\Pi$}1
  77. {\\Sigma}{$\Sigma$}1
  78. {\\Upsilon}{$\Upsilon$}1
  79. {\\Phi}{$\Phi$}1
  80. {\\Psi}{$\Psi$}1
  81. {\\Omega}{$\Omega$}1
  82. ,
  83. sensitive=true, % case sensitive
  84. morecomment=[l]{//},
  85. morecomment=[s]{/*}{*/},
  86. morestring=[b]",
  87. numbers=none,
  88. firstnumber=0,
  89. numberstyle=\tiny,
  90. stepnumber=5,
  91. basicstyle=\scriptsize\sffamily,
  92. commentstyle=\itshape,
  93. keywordstyle=\bfseries,
  94. ndkeywordstyle=\bfseries,
  95. }
  96. \lstnewenvironment{dafny}[1][]{%
  97. \lstset{language=dafny,
  98. floatplacement={tbp},captionpos=b,
  99. frame=lines,xleftmargin=8pt,xrightmargin=8pt,basicstyle=\ttfamily,#1}}{}
  100. \lstnewenvironment{dafnyNoLines}[1][]{%
  101. \lstset{language=dafny,
  102. floatplacement={tbp},captionpos=b,
  103. xleftmargin=8pt,xrightmargin=8pt,basicstyle=\ttfamily,#1}}{}
  104. \def\inlinedafny{%
  105. \lstinline[language=dafny,basicstyle=\ttfamily,columns=fixed]}
  106. \newcommand{\lstfile}[1]{
  107. \lstinputlisting[language=dafny,%
  108. frame=lines,xleftmargin=8pt,xrightmargin=8pt,basicstyle=\ttfamily,columns=fixed]{#1}
  109. }