-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrainfuck.xml
132 lines (117 loc) · 3.15 KB
/
brainfuck.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
[
<!ENTITY echo-program ",[.,]">
<!ENTITY echo-input "Echo this!">
<!ENTITY hello-world-program "<![CDATA[
++++++++++[>+++++++>++++++++++>+++
>+<<<<-]>++.>+.+++++++..+++.
>++.<<+++++++++++++++.>.+++.------.
--------.>+.>.]]>">
<!ENTITY rot13-program "<![CDATA[
-,+[ -[ >>++++[>++++++++<-] <+<-[ >+>+>-[>>>]
<[[>+<-]>>+>] <<<<<- ] ]>>>[-]+ >--[-[<->+++[-]]]<[
++++++++++++<[ >-[>+>>] >[+[<+>-]>+>>] <<<<<- ] >>[<+>-]
>[ -[ -<<[-]>> ]<<[<<->>-]>> ]<<[<<+>>-] ] <[-] <.[-] <-,+ ] ]]>">
<!ENTITY rot13-input "Uv!">
]>
<?xml-stylesheet type="text/xsl" href="brainfuck.xsl"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Brainfuck interpreter in xslt</title>
<style type="text/css">
body {
background: #798
}
div {
max-width: 35em;
margin: auto;
padding: 1em;
background: #fff;
border-radius: 1em;
}
h1, h2, h3 {
text-shadow: 0.1em 0.1em #bcbebd;
}
.code {
font-family: monospace;
margin: 0em;
padding: 0.5em;
background: #eee;
border-radius: 0.3em;
border: 1px solid #aaa;
}
a {
text-shadow: 0.1em 0.1em #bcbebd;
position: relative;
top: -0.1em;
left: -0.1em;
}
a:hover {
text-shadow: 0em 0em;
position: relative;
top: 0em;
left: 0em;
}
</style>
</head>
<body>
<div>
<h1>Brainfuck interpreter in xslt</h1>
<p>
Some one said this would be stupid, so I couldn't resist. It allows you to
embed brainfuck code in xhtml. It uses XSLT to evaluate the brainfuck code.
</p>
<h2>Examples</h2>
<h3>Echo</h3>
<p>
Echos input, code asumes EOF is 0. EOS is configurable.
</p>
<h4>Code:</h4>
<p class="code">&echo-program;</p>
<h4>Input:</h4>
<p class="code">&echo-input;</p>
<h4>Output:</h4>
<p class="code">
<bf:brainfuck xmlns:bf="https://github.com/mzeo/xslt-brainfuck">
<bf:input>&echo-input;</bf:input>
<bf:eof>0</bf:eof>
<bf:main>
&echo-program;
</bf:main>
</bf:brainfuck>
</p>
<h3>Hello world</h3>
<p>
Example code from <a href="http://en.wikipedia.org/wiki/Brainfuck#Examples">Wikipedia</a>.
Outputs "Hello world!".
</p>
<h4>Code:</h4>
<p class="code">&hello-world-program;</p>
<h4>Output:</h4>
<p class="code">
<bf:brainfuck xmlns:bf="https://github.com/mzeo/xslt-brainfuck">
<bf:main>&hello-world-program;</bf:main>
</bf:brainfuck>
</p>
<h3>Rot13</h3>
<p>
Example code from <a href="http://en.wikipedia.org/wiki/Brainfuck#Examples">Wikipedia</a>.
Applies rot13 chiffer to input. <em>Note:</em> this one is slow, ony using short input.
</p>
<h4>Code:</h4>
<p class="code">&rot13-program;</p>
<h4>Input:</h4>
<p class="code">&rot13-input;</p>
<h4>Output:</h4>
<p class="code">
<bf:brainfuck xmlns:bf="https://github.com/mzeo/xslt-brainfuck">
<bf:input>&rot13-input;</bf:input>
<bf:main>&rot13-program;</bf:main>
</bf:brainfuck>
</p>
</div>
</body>
</html>