first pass
This commit is contained in:
parent
0e6e0b8d18
commit
e1881b6f64
14 changed files with 970 additions and 0 deletions
272
parsec.html
Normal file
272
parsec.html
Normal file
|
@ -0,0 +1,272 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=1024, user-scalable=no">
|
||||
|
||||
<title>Parsec</title>
|
||||
|
||||
<!-- Required stylesheet -->
|
||||
<link rel="stylesheet" href="core/deck.core.css">
|
||||
|
||||
<!-- Extension CSS files go here. Remove or add as needed. -->
|
||||
<link rel="stylesheet" href="extensions/goto/deck.goto.css">
|
||||
<link rel="stylesheet" href="extensions/menu/deck.menu.css">
|
||||
<link rel="stylesheet" href="extensions/navigation/deck.navigation.css">
|
||||
<link rel="stylesheet" href="extensions/status/deck.status.css">
|
||||
<link rel="stylesheet" href="extensions/hash/deck.hash.css">
|
||||
<!-- <link rel="stylesheet" href="extensions/scale/deck.scale.css"> -->
|
||||
|
||||
<!-- Transition theme. More available in /themes/transition/ or create your own. -->
|
||||
|
||||
<!-- <link rel="stylesheet" href="themes/transition/fade.css"> -->
|
||||
<!-- Style theme. More available in /themes/style/ or create your own. -->
|
||||
<!-- <link rel="stylesheet" href="themes/style/web-2.0.css"> -->
|
||||
<link rel="stylesheet" href="themes/style/y/main.css" />
|
||||
<link rel="stylesheet" href="themes/style/y/solarized.css" />
|
||||
<!-- Required Modernizr file -->
|
||||
<script src="modernizr.custom.js"></script>
|
||||
<script>
|
||||
function gofullscreen(){
|
||||
var body=document.getElementById('body');
|
||||
try {
|
||||
body.requestFullScreen();
|
||||
} catch(err) {
|
||||
try {
|
||||
body.webkitRequestFullScreen();
|
||||
} catch(err) {
|
||||
body.mozRequestFullScreen();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body id="body" class="deck-container">
|
||||
|
||||
<div style="display:none">
|
||||
\(\newcommand{\F}{\mathbf{F}}\)
|
||||
\(\newcommand{\E}{\mathbf{E}}\)
|
||||
\(\newcommand{\C}{\mathcal{C}}\)
|
||||
\(\newcommand{\D}{\mathcal{D}}\)
|
||||
\(\newcommand{\id}{\mathrm{id}}\)
|
||||
\(\newcommand{\ob}[1]{\mathrm{ob}(#1)}\)
|
||||
\(\newcommand{\hom}[1]{\mathrm{hom}(#1)}\)
|
||||
\(\newcommand{\Set}{\mathbf{Set}}\)
|
||||
\(\newcommand{\Mon}{\mathbf{Mon}}\)
|
||||
\(\newcommand{\Vec}{\mathbf{Vec}}\)
|
||||
\(\newcommand{\Grp}{\mathbf{Grp}}\)
|
||||
\(\newcommand{\Rng}{\mathbf{Rng}}\)
|
||||
\(\newcommand{\ML}{\mathbf{ML}}\)
|
||||
\(\newcommand{\Hask}{\mathbf{Hask}}\)
|
||||
\(\newcommand{\Cat}{\mathbf{Cat}}\)
|
||||
\(\newcommand{\fmap}{\mathtt{fmap}}\)
|
||||
</div>
|
||||
|
||||
<!-- Begin slides. Just make elements with a class of slide. -->
|
||||
|
||||
<section class="slide">
|
||||
<div style="text-align:center; position:absolute; top: 2em; font-size: .9em; width: 100%">
|
||||
<h1 style="position: relative;">Parsec</h1>
|
||||
<author><em class="base01">by</em> Yann Esposito</author>
|
||||
<div style="font-size:.5em">
|
||||
<twitter>
|
||||
<a href="http://twitter.com/yogsototh">@yogsototh</a>,
|
||||
</twitter>
|
||||
<googleplus>
|
||||
<a href="https://plus.google.com/117858550730178181663">+yogsototh</a>
|
||||
</googleplus>
|
||||
</div>
|
||||
<div class="base01" style="font-size: .5em; font-weight: 400; font-variant:italic">
|
||||
<div class="button" style="margin: .5em auto;border: solid 2px; padding: 5px; width: 8em; border-radius: 1em; background:rgba(255,255,255,0.05);" onclick="javascript:gofullscreen();">ENTER FULLSCREEN</div>
|
||||
HTML presentation: use arrows, space to navigate.
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="slide">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=1024, user-scalable=no">
|
||||
|
||||
<title>Parsec</title>
|
||||
|
||||
<!-- Required stylesheet -->
|
||||
<link rel="stylesheet" href="core/deck.core.css">
|
||||
|
||||
<!-- Extension CSS files go here. Remove or add as needed. -->
|
||||
<link rel="stylesheet" href="extensions/goto/deck.goto.css">
|
||||
<link rel="stylesheet" href="extensions/menu/deck.menu.css">
|
||||
<link rel="stylesheet" href="extensions/navigation/deck.navigation.css">
|
||||
<link rel="stylesheet" href="extensions/status/deck.status.css">
|
||||
<link rel="stylesheet" href="extensions/hash/deck.hash.css">
|
||||
<!-- <link rel="stylesheet" href="extensions/scale/deck.scale.css"> -->
|
||||
|
||||
<!-- Transition theme. More available in /themes/transition/ or create your own. -->
|
||||
|
||||
<!-- <link rel="stylesheet" href="themes/transition/fade.css"> -->
|
||||
<!-- Style theme. More available in /themes/style/ or create your own. -->
|
||||
<!-- <link rel="stylesheet" href="themes/style/web-2.0.css"> -->
|
||||
<link rel="stylesheet" href="themes/style/y/main.css" />
|
||||
<link rel="stylesheet" href="themes/style/y/solarized.css" />
|
||||
<!-- Required Modernizr file -->
|
||||
<script src="modernizr.custom.js"></script>
|
||||
<script>
|
||||
function gofullscreen(){
|
||||
var body=document.getElementById('body');
|
||||
try {
|
||||
body.requestFullScreen();
|
||||
} catch(err) {
|
||||
try {
|
||||
body.webkitRequestFullScreen();
|
||||
} catch(err) {
|
||||
body.mozRequestFullScreen();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body id="body" class="deck-container">
|
||||
|
||||
<div style="display:none">
|
||||
\(\newcommand{\F}{\mathbf{F}}\)
|
||||
\(\newcommand{\E}{\mathbf{E}}\)
|
||||
\(\newcommand{\C}{\mathcal{C}}\)
|
||||
\(\newcommand{\D}{\mathcal{D}}\)
|
||||
\(\newcommand{\id}{\mathrm{id}}\)
|
||||
\(\newcommand{\ob}[1]{\mathrm{ob}(#1)}\)
|
||||
\(\newcommand{\hom}[1]{\mathrm{hom}(#1)}\)
|
||||
\(\newcommand{\Set}{\mathbf{Set}}\)
|
||||
\(\newcommand{\Mon}{\mathbf{Mon}}\)
|
||||
\(\newcommand{\Vec}{\mathbf{Vec}}\)
|
||||
\(\newcommand{\Grp}{\mathbf{Grp}}\)
|
||||
\(\newcommand{\Rng}{\mathbf{Rng}}\)
|
||||
\(\newcommand{\ML}{\mathbf{ML}}\)
|
||||
\(\newcommand{\Hask}{\mathbf{Hask}}\)
|
||||
\(\newcommand{\Cat}{\mathbf{Cat}}\)
|
||||
\(\newcommand{\fmap}{\mathtt{fmap}}\)
|
||||
</div>
|
||||
|
||||
<!-- Begin slides. Just make elements with a class of slide. -->
|
||||
|
||||
</section>
|
||||
<section class="slide">
|
||||
<!-- End slides. -->
|
||||
|
||||
|
||||
<!-- Begin extension snippets. Add or remove as needed. -->
|
||||
|
||||
<!-- deck.navigation snippet -->
|
||||
<a href="#" class="deck-prev-link" title="Previous">←</a>
|
||||
<a href="#" class="deck-next-link" title="Next">→</a>
|
||||
|
||||
<!-- deck.status snippet -->
|
||||
<p class="deck-status">
|
||||
<span class="deck-status-current"></span>
|
||||
/
|
||||
<span class="deck-status-total"></span>
|
||||
</p>
|
||||
|
||||
<!-- deck.goto snippet -->
|
||||
<form action="." method="get" class="goto-form">
|
||||
<label for="goto-slide">Go to slide:</label>
|
||||
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
|
||||
<datalist id="goto-datalist"></datalist>
|
||||
<input type="submit" value="Go">
|
||||
</form>
|
||||
|
||||
<!-- deck.hash snippet -->
|
||||
<a href="." title="Permalink to this slide" class="deck-permalink">#</a>
|
||||
|
||||
<!-- End extension snippets. -->
|
||||
|
||||
|
||||
<!-- Required JS files. -->
|
||||
<script src="jquery-1.7.2.min.js"></script>
|
||||
<script src="core/deck.core.js"></script>
|
||||
|
||||
<!-- Extension JS files. Add or remove as needed. -->
|
||||
<script src="core/deck.core.js"></script>
|
||||
<script src="extensions/hash/deck.hash.js"></script>
|
||||
<script src="extensions/menu/deck.menu.js"></script>
|
||||
<script src="extensions/goto/deck.goto.js"></script>
|
||||
<script src="extensions/status/deck.status.js"></script>
|
||||
<script src="extensions/navigation/deck.navigation.js"></script>
|
||||
<!-- <script src="extensions/scale/deck.scale.js"></script> -->
|
||||
|
||||
<!-- Initialize the deck. You can put this in an external file if desired. -->
|
||||
<script>
|
||||
$(function() {
|
||||
$.deck('.slide');
|
||||
});
|
||||
</script>
|
||||
<!-- Y theme -->
|
||||
<script src="js/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script src="js/highlight/highlight.pack.js"></script>
|
||||
<script>
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</section>
|
||||
<!-- End slides. -->
|
||||
|
||||
|
||||
<!-- Begin extension snippets. Add or remove as needed. -->
|
||||
|
||||
<!-- deck.navigation snippet -->
|
||||
<a href="#" class="deck-prev-link" title="Previous">←</a>
|
||||
<a href="#" class="deck-next-link" title="Next">→</a>
|
||||
|
||||
<!-- deck.status snippet -->
|
||||
<p class="deck-status">
|
||||
<span class="deck-status-current"></span>
|
||||
/
|
||||
<span class="deck-status-total"></span>
|
||||
</p>
|
||||
|
||||
<!-- deck.goto snippet -->
|
||||
<form action="." method="get" class="goto-form">
|
||||
<label for="goto-slide">Go to slide:</label>
|
||||
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
|
||||
<datalist id="goto-datalist"></datalist>
|
||||
<input type="submit" value="Go">
|
||||
</form>
|
||||
|
||||
<!-- deck.hash snippet -->
|
||||
<a href="." title="Permalink to this slide" class="deck-permalink">#</a>
|
||||
|
||||
<!-- End extension snippets. -->
|
||||
|
||||
|
||||
<!-- Required JS files. -->
|
||||
<script src="jquery-1.7.2.min.js"></script>
|
||||
<script src="core/deck.core.js"></script>
|
||||
|
||||
<!-- Extension JS files. Add or remove as needed. -->
|
||||
<script src="core/deck.core.js"></script>
|
||||
<script src="extensions/hash/deck.hash.js"></script>
|
||||
<script src="extensions/menu/deck.menu.js"></script>
|
||||
<script src="extensions/goto/deck.goto.js"></script>
|
||||
<script src="extensions/status/deck.status.js"></script>
|
||||
<script src="extensions/navigation/deck.navigation.js"></script>
|
||||
<!-- <script src="extensions/scale/deck.scale.js"></script> -->
|
||||
|
||||
<!-- Initialize the deck. You can put this in an external file if desired. -->
|
||||
<script>
|
||||
$(function() {
|
||||
$.deck('.slide');
|
||||
});
|
||||
</script>
|
||||
<!-- Y theme -->
|
||||
<script src="js/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script src="js/highlight/highlight.pack.js"></script>
|
||||
<script>
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
1
parsec/.gitignore
vendored
Normal file
1
parsec/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
_html
|
16
parsec/10_Introduction/010_.html
Normal file
16
parsec/10_Introduction/010_.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<div style="text-align:center; position:absolute; top: 2em; font-size: .9em; width: 100%">
|
||||
<h1 style="position: relative;">Parsec</h1>
|
||||
<author><em class="base01">by</em> Yann Esposito</author>
|
||||
<div style="font-size:.5em">
|
||||
<twitter>
|
||||
<a href="http://twitter.com/yogsototh">@yogsototh</a>,
|
||||
</twitter>
|
||||
<googleplus>
|
||||
<a href="https://plus.google.com/117858550730178181663">+yogsototh</a>
|
||||
</googleplus>
|
||||
</div>
|
||||
<div class="base01" style="font-size: .5em; font-weight: 400; font-variant:italic">
|
||||
<div class="button" style="margin: .5em auto;border: solid 2px; padding: 5px; width: 8em; border-radius: 1em; background:rgba(255,255,255,0.05);" onclick="javascript:gofullscreen();">ENTER FULLSCREEN</div>
|
||||
HTML presentation: use arrows, space to navigate.
|
||||
</div>
|
||||
</div>
|
7
parsec/10_Introduction/020_Origine.md
Normal file
7
parsec/10_Introduction/020_Origine.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
## Parsing
|
||||
|
||||
|
||||
Latin pars (ōrātiōnis), meaning part (of speech).
|
||||
|
||||
- **analysing a string of symbols**
|
||||
- **formal grammar**.
|
11
parsec/10_Introduction/030_Example.md
Normal file
11
parsec/10_Introduction/030_Example.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
## Parsing Example (1)
|
||||
|
||||
From String:
|
||||
|
||||
~~~
|
||||
(1+3)*(1+5+9)
|
||||
~~~
|
||||
|
||||
To data structure:
|
||||
|
||||
![AST](parsec/img/mp/AST.png)\
|
19
parsec/10_Introduction/050_Base.md
Normal file
19
parsec/10_Introduction/050_Base.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
## [Write Yourself a Scheme in 48 Hours](https://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/First_Steps)
|
||||
|
||||
|
||||
~~~ {.haskell}
|
||||
import Text.Parsec
|
||||
type Parser a = Parsec String () a
|
||||
~~~
|
||||
|
||||
~~~ {.haskell}
|
||||
symbol :: Parser Char
|
||||
symbol = oneOf "!#$%&|*+-/:<=>?@^_~"
|
||||
~~~
|
||||
|
||||
~~~ {.haskell}
|
||||
readExpr :: String -> String
|
||||
readExpr input = case parse symbol "lisp" input of
|
||||
Left err -> "No match: " ++ show err
|
||||
Right val -> "Found: " ++ show val
|
||||
~~~
|
37
parsec/gen
Executable file
37
parsec/gen
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# get script directory
|
||||
if [[ ${0[0]} = '/' ]]; then
|
||||
scriptdir="${0:h}"
|
||||
else
|
||||
scriptdir="$PWD/${0:h}"
|
||||
fi
|
||||
|
||||
cd $scriptdir
|
||||
|
||||
htmldir="_html"
|
||||
[[ ! -e $htmldir ]] && mkdir $htmldir
|
||||
# Convert all slides from markdown
|
||||
for slide in **/*.{mp,html}(.N); do
|
||||
dst="$htmldir/${slide:r}.html"
|
||||
[[ ! -e ${dst:h} ]] && mkdir -p ${dst:h}
|
||||
case ${slide:e} in
|
||||
md) pandoc -f markdown -t html $slide > $dst;;
|
||||
html) cp $slide $dst;;
|
||||
esac
|
||||
done
|
||||
|
||||
name=${PWD:t}
|
||||
|
||||
{
|
||||
cat head.html
|
||||
for slide in $htmldir/**/*.html(.N); do
|
||||
case $slide in
|
||||
head.html|tail.html) continue
|
||||
esac
|
||||
print -- '<section class="slide">'
|
||||
cat $slide | sed 's#&#<span class="and">&</span>#g'
|
||||
print -- '</section>'
|
||||
done
|
||||
cat tail.html
|
||||
} > ../$name.html
|
68
parsec/head.html
Normal file
68
parsec/head.html
Normal file
|
@ -0,0 +1,68 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=1024, user-scalable=no">
|
||||
|
||||
<title>Parsec</title>
|
||||
|
||||
<!-- Required stylesheet -->
|
||||
<link rel="stylesheet" href="core/deck.core.css">
|
||||
|
||||
<!-- Extension CSS files go here. Remove or add as needed. -->
|
||||
<link rel="stylesheet" href="extensions/goto/deck.goto.css">
|
||||
<link rel="stylesheet" href="extensions/menu/deck.menu.css">
|
||||
<link rel="stylesheet" href="extensions/navigation/deck.navigation.css">
|
||||
<link rel="stylesheet" href="extensions/status/deck.status.css">
|
||||
<link rel="stylesheet" href="extensions/hash/deck.hash.css">
|
||||
<!-- <link rel="stylesheet" href="extensions/scale/deck.scale.css"> -->
|
||||
|
||||
<!-- Transition theme. More available in /themes/transition/ or create your own. -->
|
||||
|
||||
<!-- <link rel="stylesheet" href="themes/transition/fade.css"> -->
|
||||
<!-- Style theme. More available in /themes/style/ or create your own. -->
|
||||
<!-- <link rel="stylesheet" href="themes/style/web-2.0.css"> -->
|
||||
<link rel="stylesheet" href="themes/style/y/main.css" />
|
||||
<link rel="stylesheet" href="themes/style/y/solarized.css" />
|
||||
<!-- Required Modernizr file -->
|
||||
<script src="modernizr.custom.js"></script>
|
||||
<script>
|
||||
function gofullscreen(){
|
||||
var body=document.getElementById('body');
|
||||
try {
|
||||
body.requestFullScreen();
|
||||
} catch(err) {
|
||||
try {
|
||||
body.webkitRequestFullScreen();
|
||||
} catch(err) {
|
||||
body.mozRequestFullScreen();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body id="body" class="deck-container">
|
||||
|
||||
<div style="display:none">
|
||||
\(\newcommand{\F}{\mathbf{F}}\)
|
||||
\(\newcommand{\E}{\mathbf{E}}\)
|
||||
\(\newcommand{\C}{\mathcal{C}}\)
|
||||
\(\newcommand{\D}{\mathcal{D}}\)
|
||||
\(\newcommand{\id}{\mathrm{id}}\)
|
||||
\(\newcommand{\ob}[1]{\mathrm{ob}(#1)}\)
|
||||
\(\newcommand{\hom}[1]{\mathrm{hom}(#1)}\)
|
||||
\(\newcommand{\Set}{\mathbf{Set}}\)
|
||||
\(\newcommand{\Mon}{\mathbf{Mon}}\)
|
||||
\(\newcommand{\Vec}{\mathbf{Vec}}\)
|
||||
\(\newcommand{\Grp}{\mathbf{Grp}}\)
|
||||
\(\newcommand{\Rng}{\mathbf{Rng}}\)
|
||||
\(\newcommand{\ML}{\mathbf{ML}}\)
|
||||
\(\newcommand{\Hask}{\mathbf{Hask}}\)
|
||||
\(\newcommand{\Cat}{\mathbf{Cat}}\)
|
||||
\(\newcommand{\fmap}{\mathtt{fmap}}\)
|
||||
</div>
|
||||
|
||||
<!-- Begin slides. Just make elements with a class of slide. -->
|
||||
|
28
parsec/img/mp/AST.mp
Normal file
28
parsec/img/mp/AST.mp
Normal file
|
@ -0,0 +1,28 @@
|
|||
% DPI 200
|
||||
pair A,B,C,D,E,F,G,H;
|
||||
d:=1.5u;
|
||||
A=(0,0);
|
||||
B=A shifted (-1.5d,-d);
|
||||
C=B shifted (-d/2,-d);
|
||||
D=C shifted (d,0);
|
||||
E=B shifted (3d,0);
|
||||
F=E shifted (-d,-d);
|
||||
G=F shifted (d,0);
|
||||
H=G shifted (d,0);
|
||||
|
||||
drawState(A, "\times");
|
||||
drawState(B, "+");
|
||||
drawState(C, "1");
|
||||
drawState(D, "3");
|
||||
drawState(E, "+");
|
||||
drawState(F, "5");
|
||||
drawState(G, "7");
|
||||
drawState(H, "9");
|
||||
|
||||
drawEdge(A,B,"");
|
||||
drawEdge(B,C,"");
|
||||
drawEdge(B,D,"");
|
||||
drawEdge(A,E,"");
|
||||
drawEdge(E,F,"");
|
||||
drawEdge(E,G,"");
|
||||
drawEdge(E,H,"");
|
BIN
parsec/img/mp/AST.png
Normal file
BIN
parsec/img/mp/AST.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
79
parsec/img/mp/gen
Executable file
79
parsec/img/mp/gen
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
if [[ ${0[0]} = '/' ]]; then
|
||||
scriptdir="${0:h}"
|
||||
else
|
||||
scriptdir="$PWD/${0:h}"
|
||||
fi
|
||||
|
||||
tmpdir=/tmp/mp
|
||||
[[ ! -d $tmpdir ]] && mkdir $tmpdir
|
||||
|
||||
typeset -a fics
|
||||
if (($#<1)); then
|
||||
fics=( $scriptdir/*.mp(N) )
|
||||
else
|
||||
for f in $@; do
|
||||
fics=( $fics $scriptdir/$f )
|
||||
done
|
||||
fi
|
||||
|
||||
(( ${#fics} == 0 )) && {
|
||||
print -- "No .mp files indo $scriptdir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
(( ${#fics} == 1 )) && [[ ${fics[1]} = "$scriptdir/graph.mp" ]] && {
|
||||
print -- "Only graph.mp files indo $scriptdir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (($#==0)); then
|
||||
listfic=( $fics )
|
||||
else
|
||||
listfic=( $* )
|
||||
fi
|
||||
|
||||
\cp -f $listfic $tmpdir
|
||||
cd $tmpdir
|
||||
for fpfic in $listfic; do
|
||||
fic=${fpfic:t}
|
||||
tmp=${fic:r}-tmp.mp
|
||||
eps=${fic:r}-tmp.1
|
||||
png=${fic:r}.png
|
||||
old=${fic:r}.old
|
||||
[[ $fic = "graph.mp" ]] && continue
|
||||
{
|
||||
echo -n >&2 "MPOST [$fic]"
|
||||
cat $scriptdir/graph.mp
|
||||
echo 'beginfig(1)'
|
||||
echo ' drawoptions (withcolor base1);'
|
||||
cat $fic
|
||||
echo 'endfig;'
|
||||
echo 'bye;'
|
||||
} | sed 's/base00/baseZeroZero/g' \
|
||||
| sed 's/base01/baseZeroOne/g' \
|
||||
| sed 's/base02/baseZeroTwo/g' \
|
||||
| sed 's/base03/baseZeroThree/g' \
|
||||
| sed 's/base0/baseZero/g' \
|
||||
| sed 's/base1/baseOne/g' \
|
||||
| sed 's/base2/baseTwo/g' \
|
||||
| sed 's/base3/baseThree/g' \
|
||||
| sed 's/red/s_red/g' \
|
||||
| sed 's/blue/s_blue/g' \
|
||||
| sed 's/green/s_green/g' > $tmp
|
||||
[[ -e $old ]] && diff $tmp $old >/dev/null && { echo " identical"; continue }
|
||||
|
||||
dpi=$(grep '% DPI' $tmp | awk '{print $3}')
|
||||
[[ $dpi = "" ]] && dpi=600
|
||||
|
||||
print
|
||||
print "[DPI]: $dpi"
|
||||
|
||||
print -- "[$PWD]: mpost $tmp && convert -density $dpi $tmp.1 $png"
|
||||
mpost --tex=latex $tmp && \
|
||||
convert -colorspace rgb -density $dpi $eps '(' +clone -background black -shadow 90x4+0+1 ')' +swap -background none -layers merge +repage $png && \
|
||||
\cp -f $png $scriptdir && \
|
||||
\cp -f $tmp $old && \
|
||||
echo "updated"
|
||||
done
|
339
parsec/img/mp/graph.mp
Normal file
339
parsec/img/mp/graph.mp
Normal file
|
@ -0,0 +1,339 @@
|
|||
% solarized color scheme
|
||||
color baseZeroThree, baseZeroTwo, baseZeroOne, baseZeroZero
|
||||
, baseZero, baseOne, baseTwo, baseThree, yellow, orange
|
||||
, red, magenta, violet, blue, cyan, green;
|
||||
baseZeroThree :=(0.0 ,0.168627450980392,0.211764705882353);
|
||||
baseZeroTwo :=(0.0274509803921569,0.211764705882353,0.258823529411765);
|
||||
baseZeroOne :=(0.345098039215686 ,0.431372549019608,0.458823529411765);
|
||||
baseZeroZero :=(0.396078431372549 ,0.482352941176471,0.513725490196078);
|
||||
baseZero :=(0.513725490196078 ,0.580392156862745,0.588235294117647);
|
||||
baseOne :=(0.576470588235294 ,0.631372549019608,0.631372549019608);
|
||||
baseTwo :=(0.933333333333333 ,0.909803921568627,0.835294117647059);
|
||||
baseThree :=(0.992156862745098 ,0.964705882352941,0.890196078431372);
|
||||
yellow :=(0.709803921568627 ,0.537254901960784,0.0);
|
||||
orange :=(0.796078431372549 ,0.294117647058824,0.0862745098039216);
|
||||
red :=(0.862745098039216 ,0.196078431372549,0.184313725490196);
|
||||
magenta :=(0.827450980392157 ,0.211764705882353,0.509803921568627);
|
||||
violet :=(0.423529411764706 ,0.443137254901961,0.768627450980392);
|
||||
blue :=(0.149019607843137 ,0.545098039215686,0.823529411764706);
|
||||
cyan :=(0.164705882352941 ,0.631372549019608,0.596078431372549);
|
||||
green :=(0.52156862745098 ,0.6 ,0.0);
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%
|
||||
% Automata drawing %
|
||||
%%%%%%%%%%%%%%%%%%%%
|
||||
u:=.5cm; % unity
|
||||
gu:=5u; % distance between states
|
||||
nodesize := u; %size of a node
|
||||
nodespace := u+.1cm; %size of a node
|
||||
|
||||
def resize(expr nu)=
|
||||
u:=nu;
|
||||
gu:=5u; % distance between states
|
||||
nodesize := u; %size of a node
|
||||
nodespace := u+.1cm; %size of a node
|
||||
enddef;
|
||||
|
||||
% return the middle of a path
|
||||
vardef midpoint(expr p)=
|
||||
save r; pair r;
|
||||
r:=point 1/2length(p) of p;
|
||||
r
|
||||
enddef;
|
||||
|
||||
% shorten a path of length d at the beginning and the end
|
||||
vardef shorten(expr p,d) =
|
||||
save q,bcirc,ecirc;
|
||||
path q,bcirc,ecirc;
|
||||
bcirc := fullcircle scaled d shifted point 0 of p;
|
||||
ecirc := fullcircle scaled d shifted point length(p) of p;
|
||||
q := p cutbefore bcirc cutafter ecirc;
|
||||
q
|
||||
enddef;
|
||||
|
||||
% Return a rounded box around top left and bottom right point.
|
||||
vardef block(expr tl,br) =
|
||||
save p;
|
||||
save d,shift;
|
||||
save topleft,bottomright;
|
||||
save tll,tlt,trt,trr,brr,brb,blb,bll;
|
||||
path p;
|
||||
numeric d,shift;
|
||||
d := 1/3u;
|
||||
shift := 1.2u;
|
||||
pair topleft,bottomright;
|
||||
topleft := tl shifted (-shift,2shift);
|
||||
bottomright := br shifted (shift,-.5shift);
|
||||
pair tll,tlt,trt,trr,brr,brb,blb,bll;
|
||||
tll := topleft shifted (-d,0);
|
||||
tlt := topleft shifted (0,d);
|
||||
trt := (xpart bottomright, ypart topleft) shifted (0,d);
|
||||
trr := (xpart bottomright, ypart topleft) shifted (d,0);
|
||||
brr := bottomright shifted (d,0);
|
||||
brb := bottomright shifted (0,-d);
|
||||
blb := (xpart topleft, ypart bottomright) shifted (0,-d);
|
||||
bll := (xpart topleft, ypart bottomright) shifted (-d,0);
|
||||
p:=tlt---trt..trr---brr..brb---blb..bll---tll..cycle;
|
||||
p
|
||||
enddef;
|
||||
|
||||
% b being the path of the block
|
||||
vardef blockLabelPosition(expr b)=
|
||||
save pos;
|
||||
pair pos;
|
||||
pos := point 0.5 of b;
|
||||
pos
|
||||
enddef;
|
||||
|
||||
% draw a block with the right math-mode tex label on top of it
|
||||
def drawblock(expr topleftpoint, bottomrightpoint, l)=
|
||||
save b,pos;
|
||||
path b;
|
||||
b:=block(topleftpoint,bottomrightpoint);
|
||||
pair pos;
|
||||
pos := blockLabelPosition(b);
|
||||
draw b withcolor base01;
|
||||
label.top(TEX("$"&l&"$"),pos);
|
||||
enddef;
|
||||
|
||||
% -- Generic private functions
|
||||
|
||||
% return the edge between points A and B.
|
||||
% out angle from A is inan
|
||||
% in angle to B is outan
|
||||
% nodesize is the size of the node
|
||||
vardef edgeFull(expr posA,posB,inan,outan) =
|
||||
save sub,s;
|
||||
path sub,s;
|
||||
s := posA {dir inan} .. {dir outan} posB ;
|
||||
sub := shorten(s,nodespace);
|
||||
sub
|
||||
enddef;
|
||||
|
||||
% return a picture of the label l for edge e
|
||||
vardef edgeLabel(expr e,l) =
|
||||
save ret,mid,an,lab,height,width;
|
||||
picture ret;
|
||||
pair mid;
|
||||
mid := midpoint(e);
|
||||
numeric an;
|
||||
an := angle (direction 1/2length(e) of e);
|
||||
picture lab;
|
||||
pair height,width;
|
||||
lab:=thelabel(TEX("$"&l&"$"),origin);
|
||||
height:=(0,ypart (ulcorner lab - llcorner lab));
|
||||
width:=(xpart (urcorner lab - ulcorner lab),0);
|
||||
if (an>-35) and (an<35):
|
||||
ret:=lab shifted height rotated an shifted mid;
|
||||
elseif (an>145) or (an<-145):
|
||||
ret:=lab shifted height rotated (an+180) shifted mid;
|
||||
elseif (an>75) and (an<120):
|
||||
ret:=lab shifted mid shifted -width;
|
||||
elseif (an>-120) and (an<-75):
|
||||
ret:=lab shifted mid shifted width;
|
||||
else:
|
||||
ret:=lab shifted mid shifted height;
|
||||
fi;
|
||||
ret
|
||||
enddef;
|
||||
|
||||
|
||||
|
||||
% --- LABELED GRAPHS ---
|
||||
% return the edge between points A and B.
|
||||
% out angle from A is an + angle from A to B
|
||||
vardef edgeAngle(expr posA,posB,an) =
|
||||
save res,d;
|
||||
path res;
|
||||
numeric d;
|
||||
d := angle(posB-posA);
|
||||
res := edgeFull(posA,posB,d+an,d-an);
|
||||
res
|
||||
enddef;
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% %%
|
||||
%% LOOPS %%
|
||||
%% %%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
vardef dist(expr a,b)=
|
||||
save width,height,res;
|
||||
numeric width,height,res;
|
||||
width:=xpart b - xpart a;
|
||||
height:=ypart b - ypart a;
|
||||
res:=sqrt(width*width + height*height);
|
||||
enddef;
|
||||
% return a loop
|
||||
vardef loopFull(expr a,b,an) =
|
||||
save ba,ea;
|
||||
save circ,p,s;
|
||||
pair ba,ea;
|
||||
path circ,p,s;
|
||||
p:=a{1,1}..b..{1,-1}cycle;
|
||||
circ:= fullcircle scaled nodespace shifted a;
|
||||
ba = circ intersectionpoint (subpath (0,1) of p);
|
||||
ea = circ intersectionpoint (subpath (1,2) of p);
|
||||
s:= ba{1,1}..b..{1,-1}ea;
|
||||
s shifted -a rotated an shifted a
|
||||
enddef;
|
||||
|
||||
vardef loopPoint(expr a,b) =
|
||||
loopFull(a,b,0)
|
||||
enddef;
|
||||
|
||||
vardef loopAngle(expr a,an) =
|
||||
loopFull(a,a shifted (0,nodesize),an)
|
||||
enddef;
|
||||
|
||||
vardef loop(expr a) =
|
||||
loopFull(a,a shifted (0,nodesize),0)
|
||||
enddef;
|
||||
|
||||
% return the direct edge between A and B
|
||||
vardef edge(expr posA,posB) =
|
||||
save an;
|
||||
save sub;
|
||||
numeric an;
|
||||
path sub;
|
||||
if (posA = posB):
|
||||
sub := loop(posA);
|
||||
else:
|
||||
an := angle(posB-posA);
|
||||
sub := edgeFull(posA,posB,an,an);
|
||||
fi
|
||||
sub
|
||||
enddef;
|
||||
|
||||
def drawLoopPoint(expr a,b,l) =
|
||||
begingroup;
|
||||
save s;
|
||||
path s;
|
||||
s:=loopPoint(a,b);
|
||||
drawarrow s;
|
||||
label.top(TEX("$"&l&"$"),midpoint(s));
|
||||
endgroup;
|
||||
enddef;
|
||||
def drawLoop(expr a,l) =
|
||||
begingroup;
|
||||
save s;
|
||||
path s;
|
||||
s:=loop(a);
|
||||
drawarrow s;
|
||||
label.top(TEX("$"&l&"$"),midpoint(s));
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
def drawstate(expr pos) =
|
||||
draw pos withpen pencircle scaled 4bp;
|
||||
enddef;
|
||||
|
||||
% draw some state with some label insize
|
||||
def drawState(expr pos,l) =
|
||||
begingroup;
|
||||
save lab,reslab;
|
||||
save height,width;
|
||||
save size;
|
||||
% Draw the circle
|
||||
draw fullcircle scaled nodesize shifted pos;
|
||||
|
||||
% Draw the label with the right size
|
||||
picture lab,reslab;
|
||||
numeric height,width;
|
||||
numeric size;
|
||||
lab=thelabel(TEX("$"&l&"$"),origin);
|
||||
height:=ypart (ulcorner lab - llcorner lab);
|
||||
width :=xpart (urcorner lab - ulcorner lab);
|
||||
size := sqrt(height*height + width*width);
|
||||
if size>.9nodesize:
|
||||
reslab:=lab scaled (.9nodesize/size) shifted pos;
|
||||
else:
|
||||
reslab:=lab shifted pos;
|
||||
fi
|
||||
% help for debug to draw boundaries
|
||||
% draw ulcorner reslab -- urcorner reslab -- lrcorner reslab -- llcorner reslab -- cycle;
|
||||
draw reslab;
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
% draw an edge
|
||||
def drawEdgeFull(expr posA,posB,l,inan,outan) =
|
||||
begingroup;
|
||||
save sub;
|
||||
path sub;
|
||||
sub := edgeFull(posA,posB,inan,outan);
|
||||
drawarrow sub;
|
||||
draw edgeLabel(sub,l);
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
def drawEdgeAngle(expr posA,posB,l,inan) =
|
||||
begingroup;
|
||||
save sub;
|
||||
path sub;
|
||||
sub := edgeAngle(posA,posB,inan);
|
||||
drawarrow sub;
|
||||
draw edgeLabel(sub,l);
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
def drawEdge(expr posA,posB,l) =
|
||||
begingroup;
|
||||
save sub;
|
||||
path sub;
|
||||
sub := edge(posA,posB);
|
||||
drawarrow sub;
|
||||
draw edgeLabel(sub,l);
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
vardef box(expr posA) =
|
||||
save b,size;
|
||||
path b;
|
||||
numeric size;
|
||||
size:=2nodesize;
|
||||
b := unitsquare scaled size shifted posA shifted (-.5size,-.5size);
|
||||
b
|
||||
enddef;
|
||||
|
||||
def drawbox(expr posA,l) =
|
||||
begingroup;
|
||||
save b,pos;
|
||||
path b;
|
||||
pair pos;
|
||||
b:=box(posA);
|
||||
draw b;
|
||||
pos=point 3 of b;
|
||||
label.lrt(TEX("$"&l&"$"),pos);
|
||||
endgroup;
|
||||
enddef;
|
||||
|
||||
prologues:=3;
|
||||
|
||||
verbatimtex
|
||||
%&latex
|
||||
\documentclass{minimal}
|
||||
\begin{document}
|
||||
etex
|
||||
|
||||
% TEX macro is short enough to be copied
|
||||
string preverbatimtex_, postverbatimtex_;
|
||||
|
||||
vardef TEXPRE text s = preverbatimtex_ := s; enddef;
|
||||
|
||||
vardef TEXPOST text s = postverbatimtex_ := s; enddef;
|
||||
|
||||
vardef TEX primary s =
|
||||
if known preverbatimtex_:
|
||||
write "verbatimtex "&preverbatimtex_&" etex" to "mptextmp.mp";
|
||||
fi
|
||||
write "btex "&s&" etex" to "mptextmp.mp";
|
||||
if known postverbatimtex_:
|
||||
write "verbatimtex "&postverbatimtex_&" etex" to "mptextmp.mp";
|
||||
fi
|
||||
write EOF to "mptextmp.mp";
|
||||
scantokens "input mptextmp"
|
||||
enddef;
|
||||
|
||||
TEXPRE("\documentclass{minimal}\begin{document}");
|
||||
TEXPOST("\end{document}");
|
36
parsec/renameSlideFic.sh
Executable file
36
parsec/renameSlideFic.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
# get script directory
|
||||
if [[ ${0[0]} = '/' ]]; then
|
||||
scriptdir="${0:h}"
|
||||
else
|
||||
scriptdir="$PWD/${0:h}"
|
||||
fi
|
||||
|
||||
cd $scriptdir
|
||||
|
||||
for rep in **/{??,???}_*(N/); do
|
||||
print "renaming html of $rep"
|
||||
cd $rep
|
||||
i=10
|
||||
for fic in *.html(.N); do
|
||||
title=$( <$fic grep h2 | sed 's/<[^>]*>//g;s/&[^;]*;//g;s/[^a-zA-Z0-9]/_/g;s/__*/_/g;s/^_//;s/_$//;')
|
||||
if ((i<100)); then
|
||||
num="0$i"
|
||||
else
|
||||
num="$i"
|
||||
fi
|
||||
((i+=10))
|
||||
newfic=${num}_$title.${fic:e}
|
||||
[[ $fic == $newfic ]] && { continue }
|
||||
[[ -e $newfic ]] && {
|
||||
print -- "$newfic already exists!" >&2
|
||||
continue
|
||||
}
|
||||
mv $fic $newfic
|
||||
mdfic=${fic:r}.md
|
||||
newmdfic=${newfic:r}.md
|
||||
[[ -e $mdfic ]] && mv $mdfic $newmdfic
|
||||
done
|
||||
cd $scriptdir
|
||||
done
|
57
parsec/tail.html
Normal file
57
parsec/tail.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
<!-- End slides. -->
|
||||
|
||||
|
||||
<!-- Begin extension snippets. Add or remove as needed. -->
|
||||
|
||||
<!-- deck.navigation snippet -->
|
||||
<a href="#" class="deck-prev-link" title="Previous">←</a>
|
||||
<a href="#" class="deck-next-link" title="Next">→</a>
|
||||
|
||||
<!-- deck.status snippet -->
|
||||
<p class="deck-status">
|
||||
<span class="deck-status-current"></span>
|
||||
/
|
||||
<span class="deck-status-total"></span>
|
||||
</p>
|
||||
|
||||
<!-- deck.goto snippet -->
|
||||
<form action="." method="get" class="goto-form">
|
||||
<label for="goto-slide">Go to slide:</label>
|
||||
<input type="text" name="slidenum" id="goto-slide" list="goto-datalist">
|
||||
<datalist id="goto-datalist"></datalist>
|
||||
<input type="submit" value="Go">
|
||||
</form>
|
||||
|
||||
<!-- deck.hash snippet -->
|
||||
<a href="." title="Permalink to this slide" class="deck-permalink">#</a>
|
||||
|
||||
<!-- End extension snippets. -->
|
||||
|
||||
|
||||
<!-- Required JS files. -->
|
||||
<script src="jquery-1.7.2.min.js"></script>
|
||||
<script src="core/deck.core.js"></script>
|
||||
|
||||
<!-- Extension JS files. Add or remove as needed. -->
|
||||
<script src="core/deck.core.js"></script>
|
||||
<script src="extensions/hash/deck.hash.js"></script>
|
||||
<script src="extensions/menu/deck.menu.js"></script>
|
||||
<script src="extensions/goto/deck.goto.js"></script>
|
||||
<script src="extensions/status/deck.status.js"></script>
|
||||
<script src="extensions/navigation/deck.navigation.js"></script>
|
||||
<!-- <script src="extensions/scale/deck.scale.js"></script> -->
|
||||
|
||||
<!-- Initialize the deck. You can put this in an external file if desired. -->
|
||||
<script>
|
||||
$(function() {
|
||||
$.deck('.slide');
|
||||
});
|
||||
</script>
|
||||
<!-- Y theme -->
|
||||
<script src="js/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<script src="js/highlight/highlight.pack.js"></script>
|
||||
<script>
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue