langs.sty
changeset 336 3cb200fa6d6a
parent 164 08a6e035223e
child 345 7f0ac1355f0b
--- a/langs.sty	Wed Nov 26 10:15:43 2014 +0000
+++ b/langs.sty	Thu Nov 27 17:52:17 2014 +0000
@@ -8,28 +8,10 @@
 \definecolor{codepurple}{rgb}{0.5,0,0.35}      % keywords
 \definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % doc
 \definecolor{codeblue}{rgb}{0.25,0.35,0.75}    % types
-\definecolor{darkgray}{rgb}{.4,.4,.4}
 
 \BeforeBeginEnvironment{lstlisting}{\par\noindent\begin{minipage}{\linewidth}}
 \AfterEndEnvironment{lstlisting}{\end{minipage}\par}
 
-\lstdefinelanguage{JavaScript}{
-  keywords={break,case,catch,continue,debugger,default,% 
-    delete,do,else,false,finally,for,function,if,in,instanceof,% 
-    new,null,return,switch,this,throw,true,try,typeof,var,void,while,with},
-  morecomment=[l]{//},
-  morecomment=[s]{/*}{*/},
-  morestring=[b]',
-  morestring=[b]",
-  ndkeywords={class,export,boolean,throw,implements,import,this},
-  keywordstyle=\color{codepurple}\bfseries,
-  ndkeywordstyle=\color{darkgray}\bfseries,
-  identifierstyle=\color{black},
-  commentstyle=\color{codegreen}\ttfamily,
-  stringstyle=\color{codegreen}\ttfamily,
-  sensitive=true
-}
-
 \lstdefinelanguage{Scala}{
   morekeywords={abstract,case,catch,class,def,%
     do,else,extends,false,final,finally,%
@@ -38,28 +20,28 @@
     private,protected,requires,return,sealed,%
     super,this,throw,trait,true,try,%
     type,val,var,while,with,yield},%
-  otherkeywords={=>,<-,<\%,<:,>:,\#,@},%
+  otherkeywords={=>,<-,<\%,<:,>:,\#},%
   sensitive=true,%
   %directives={Int,Char,Rexp,String,Boolean,BigInt,Unit,List,Set},%
   %moredelim=*[directive]:,%
   morecomment=[l]{//},%
   morecomment=[n]{/*}{*/},
+  morestring=[s]{"""}{"""},
   morestring=[b]",
   morestring=[b]',
-  morestring=[b]"""
 }[keywords,comments,strings]
 
 \lstdefinelanguage{While}{
-  morekeywords={if,then,else,while,do,true,false,write,upto,for,skip},
-  otherkeywords={=,!=,:=,<,>,;},
-  sensitive=true,
+  morekeywords={if,then,else,while,do,true,false,write,upto,read,for,skip},
+  morecomment=[l]{//},
   morecomment=[n]{/*}{*/},
-}
+  morestring=[b]",
+  otherkeywords={=,!=,:=,<,>,\%;*,/},
+}[keywords,comments,strings]
 
 \lstdefinestyle{mystyle}
        {basicstyle=\ttfamily,
 	keywordstyle=\color{codepurple}\bfseries,
-        %directivestyle=\color{codeblue}\bfseries,
 	stringstyle=\color{codegreen},
 	commentstyle=\color{codegreen},
 	morecomment=[s][\color{codedocblue}]{/**}{*/},
@@ -72,7 +54,8 @@
 	showstringspaces=false,
         xleftmargin=8mm,
         emphstyle=\color{codeblue}\bfseries,
-        keepspaces}
+        keepspaces
+}
 
 \lstset{language=Scala,
         style=mystyle}
@@ -80,4 +63,5 @@
 
 \newcommand{\code}[1]{{\lstinline{#1}}}
 \newcommand{\pcode}[1]{\mbox{\lstset{language={},keywordstyle=\color{black}}\lstinline!#1!}}
+\newcommand{\scode}[1]{\mbox{\lstset{language={},basicstyle=\ttfamily\color{codegreen}}\lstinline!#1!}}
 \makeatother