%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Listings test with hansl

\author{Sven Schreiber}
\documentclass{scrbook} 
\usepackage{xcolor}

\usepackage{listings}
\lstset{language = hansl, %
	showstringspaces = false, % 
	basicstyle = \footnotesize\ttfamily,
	keywordstyle = \color{red},
	keywordstyle = [2]\color{blue},
	keywordstyle = [3]\color{green},
	commentstyle = \color{darkgray}\sffamily,	% 
	stringstyle = \color{orange},
	% backgroundcolor=\color{lightgray},
	% These commands partly sorted by meaning:
	morekeywords = {list, bundle, %
		matrices, strings, bundles, lists, %
		funcerr, hfplot, launch, midasreg, %
		pkg, plot, setopt, % 
		deriv, params, %
		for, foreach, while, 
		},
	morekeywords = [2]{array, defarray, null, %
		BFGSmin, BFGScmax, BFGScmin, %
		bread, bwrite, cdummify, cnumber, %
		cnameget, cnameset, dropcoll, %
		easterday, ecdf, exists, fevd, genseries, %
		getinfo, getkeys, GSSmax, GSSmin, %
		hfdiff, hfldiff, hflags, hflist, instring, %
		isdiscrete, isdummy, isoconv, isodate, %
		jsonget, jsongetb, juldate, kdsmooth, %
		kmeier, kpsscrit, ksetup, linearize, %
		lrcovar, mgradient, mlincomb, mweights, %
		naalen, nlines, NMmax, NMmin, %
		normtest, npcorr, NRmin, numhess, %
		pexpand, pxnobs, qlrpval, %		
		rnameget, rnameset, %
		seasonals, sleep, smplspan, sprintf, %
		square, stringify, strvals, substr, %
		typeof, varnames, xmlget},
	% the following for the double-dash options:
	moredelim	= [l][\color{green}]{--},
	% obsolete former functions:
	deletekeywords = [2]{isnull, rowname, rownames, %
		colname, colnames, xpx },
	% and obsolete former commands:
	deletekeywords = {kalman, shell, sscanf},
	% try to redefine / override the $-accessors (not as group-1-keywords)
	keywordsprefix = {\$\$}, % anything which isn't a single $
	morekeywords = [3]{\$coeff, \$uhat, % to be completed
		\$ahat, \$aic, \$bic, \$chisq, \$coeff, 
		\$command, \$compan, \$datatype, \$depvar, \$df,
		\$diagpval, \$diagtest, \$dw, \$dwpval, \$ec,
		\$error, \$ess , \$evals, \$fcast, \$fcse,
		\$fevd, \$Fstat, \$gmmcrit, \$h, \$hausman,
		\$hqc, \$huge, \$jalpha, \$jbeta, \$jvbeta,
		\$lang, \$llt, \$lnl, \$macheps, \$mnlprobs,
		\$model, \$ncoeff, \$nobs, \$nvars, \$obsdate,
		\$obsmajor, \$obsmicro, \$obsminor, \$pd , \$pi,
		\$pvalue, \$qlrbreak, \$rho, \$rsq, \$sample,
		\$sargan, \$sigma, \$stderr, \$stopwatch, \$sysA,
		\$sysB, \$sysGamma, \$sysinfo, \$system, \$T,
		\$t1, \$t2, \$test, \$tmax, \$trsq,
		\$uhat, \$unit, \$vcv, \$vecGamma, \$version,
		\$vma, \$windows, \$xlist, \$xtxinv, \$yhat,
		\$ylist},
}

\begin{document}

\begin{lstlisting}
series x = log(y)
list L = null
bundle b = null
strings S = array(1)
S[1] = "hello"
matrices b.x = defarray(3) 
mle <whatever>
  deriv x = 0.5
end mle --auxiliary
# check if really not used anymore:
kalman
end kalman
if isnull(x)
  x = $coeff(y)
endif
# function or command?
sscanf()
# check the $i syntax
loop foreach i L
  series y = 2 * $i
endloop
loop while 1 > 2
endloop
loop for (i=1; i<j; i++)
endloop
\end{lstlisting}
	
\end{document}
