changeset 14:dff5f09c28c7

use listings
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 01 May 2020 13:07:45 +0900
parents cce07a6da420
children 875bf4bc5059
files paper/Makefile paper/anatofuz-sigos.md paper/anatofuz-sigos.pdf paper/anatofuz-sigos.tex paper/md2tex.pl paper/md2tex/first.tex
diffstat 6 files changed, 98 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/paper/Makefile	Thu Apr 30 20:24:26 2020 +0900
+++ b/paper/Makefile	Fri May 01 13:07:45 2020 +0900
@@ -40,4 +40,4 @@
 
 
 clean:
-	rm -f *.dvi *.aux *.log  *.ps *.gz *.bbl *.blg *~ *.core
+	rm -f *.dvi *.aux *.log  *.ps *.gz *.bbl *.blg *~ *.core anatofuz-sigos.tex
--- a/paper/anatofuz-sigos.md	Thu Apr 30 20:24:26 2020 +0900
+++ b/paper/anatofuz-sigos.md	Fri May 01 13:07:45 2020 +0900
@@ -46,3 +46,18 @@
 この継続はSchemeなどの環境を持つ継続とは異なり、 スタックを持たず環境を保存しない継続である為に軽量である事から軽量継続と呼べる。
 またCbCではこの軽量継続を用いた再帰呼び出しを利用することで、 for文などのループ文を廃し関数型プログラミングに近いスタイルでプログラミングすることが可能である。
 現在CbCはGCC及びLLVM/clang上にそれぞれ実装されている。
+
+
+CbCの例題をCode \ref{src:cbc_example}に示す。
+
+
+
+``` src:cbc_example, c
+__code code_gear1(struct str* st) {
+    if (st->number) {
+        goto hoge(...);
+    }
+    goto code_gear2(foo);
+}
+
+```
Binary file paper/anatofuz-sigos.pdf has changed
--- a/paper/anatofuz-sigos.tex	Thu Apr 30 20:24:26 2020 +0900
+++ b/paper/anatofuz-sigos.tex	Fri May 01 13:07:45 2020 +0900
@@ -13,6 +13,30 @@
 
 \usepackage[dvips]{graphicx}
 \usepackage{latexsym}
+\usepackage{listings}
+\lstset{
+  language=C,
+  tabsize=2,
+  frame=single,
+  basicstyle={\tt\footnotesize}, %
+  identifierstyle={\footnotesize}, %
+  commentstyle={\footnotesize\itshape}, %
+  keywordstyle={\footnotesize\ttfamily}, %
+  ndkeywordstyle={\footnotesize\ttfamily}, %
+  stringstyle={\footnotesize\ttfamily},
+  breaklines=true,
+  captionpos=b,
+  columns=[l]{fullflexible}, %
+  xrightmargin=0zw, %
+  xleftmargin=1zw, %
+  aboveskip=1zw,
+  numberstyle={\scriptsize}, %
+  stepnumber=1,
+  numbersep=0.5zw, %
+  lineskip=-0.5ex,
+}
+\usepackage{caption}
+
 
 \def\Underline{\setbox0\hbox\bgroup\let\\\endUnderline}
 \def\endUnderline{\vphantom{y}\egroup\smash{\underline{\box0}}\\}
@@ -22,7 +46,7 @@
 %\setcounter{巻数}{59}%vol59=2018
 %\setcounter{号数}{10}
 %\setcounter{page}{1}
-
+\renewcommand{\lstlistingname}{Code}
 
 \begin{document}
 
@@ -99,6 +123,21 @@
 またCbCではこの軽量継続を用いた再帰呼び出しを利用することで、 for文などのループ文を廃し関数型プログラミングに近いスタイルでプログラミングすることが可能である。
 現在CbCはGCC及びLLVM/clang上にそれぞれ実装されている。
 
+
+CbCの例題をCode \ref{src:cbc_example}に示す。
+
+
+
+\begin{lstlisting}[frame=lrbt,label=src:cbc_example,caption={c}]
+__code code_gear1(struct str* st) {
+    if (st->number) {
+        goto hoge(...);
+    }
+    goto code_gear2(foo);
+}
+
+\end{lstlisting}
+
 \nocite{*}
 \bibliographystyle{ipsjunsrt}
 \bibliography{anatofuz-bib}
--- a/paper/md2tex.pl	Thu Apr 30 20:24:26 2020 +0900
+++ b/paper/md2tex.pl	Fri May 01 13:07:45 2020 +0900
@@ -17,10 +17,27 @@
 }
 
 open my $fh, '<', $source_md;
+
+my $in_codeblock = 0;
+
 while (my $line = <$fh>) {
   if ($line =~/^#/) {
     $line =~ s/# (.*)/\\section{$1}/;
   }
+
+  if ($line =~ /```/) {
+    $in_codeblock = !$in_codeblock;
+    if (!$in_codeblock) {
+      $line = '\end{lstlisting}' ."\n";
+    }
+    if ($line =~ /``` (.*),\s*(.*)/) {
+      $line = '\b'."egin{lstlisting}[frame=lrbt,label=$1,caption={$2}]\n";
+    }
+  }
+
+  if ($line =~ /^\[(.*),\s*(.*)\]\((.*)\)/) {
+      $line = '\l' ."stinputlisting[label=$1, caption={$2}]{$3}\n";
+  }
   print $texFH $line;
 }
 close $fh;
--- a/paper/md2tex/first.tex	Thu Apr 30 20:24:26 2020 +0900
+++ b/paper/md2tex/first.tex	Fri May 01 13:07:45 2020 +0900
@@ -13,6 +13,30 @@
 
 \usepackage[dvips]{graphicx}
 \usepackage{latexsym}
+\usepackage{listings}
+\lstset{
+  language=C,
+  tabsize=2,
+  frame=single,
+  basicstyle={\tt\footnotesize}, %
+  identifierstyle={\footnotesize}, %
+  commentstyle={\footnotesize\itshape}, %
+  keywordstyle={\footnotesize\ttfamily}, %
+  ndkeywordstyle={\footnotesize\ttfamily}, %
+  stringstyle={\footnotesize\ttfamily},
+  breaklines=true,
+  captionpos=b,
+  columns=[l]{fullflexible}, %
+  xrightmargin=0zw, %
+  xleftmargin=1zw, %
+  aboveskip=1zw,
+  numberstyle={\scriptsize}, %
+  stepnumber=1,
+  numbersep=0.5zw, %
+  lineskip=-0.5ex,
+}
+\usepackage{caption}
+
 
 \def\Underline{\setbox0\hbox\bgroup\let\\\endUnderline}
 \def\endUnderline{\vphantom{y}\egroup\smash{\underline{\box0}}\\}
@@ -22,7 +46,7 @@
 %\setcounter{巻数}{59}%vol59=2018
 %\setcounter{号数}{10}
 %\setcounter{page}{1}
-
+\renewcommand{\lstlistingname}{Code}
 
 \begin{document}