-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
123 lines (116 loc) · 3.64 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport'>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="inheritence.js"></script>
<script type="text/javascript" src="jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="lexer.js"></script>
<script type="text/javascript" src="classes.js"></script>
<script type="text/javascript" src="operation.js"></script>
<script type="text/javascript" src="ast.js"></script>
<script type="text/javascript" src="parser.js"></script>
<script type="text/javascript" src="vm.js"></script>
<script type="text/javascript" src="pwidget.js"></script>
<script type="text/javascript" src="page.js"></script>
<link rel="stylesheet" href="page.css">
<style>
.one-fifth {
width: 150px;
float: left;
}
.two-fifths {
width: 300px;
float: left;
}
h1 {
padding-bottom: 0px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>Reversible</h1>
<strong>A simple language for learning to program</strong>
<script type="text/javascript">
function $_GET(q,s) {
s = s ? s : window.location.search;
var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i');
return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
}
$(function() {
var program = $_GET("program");
var run_on_start = $_GET("runonstart");
var programming_widget = new ProgrammingWidget("#assignment", "assignment", program, run_on_start).activate();
});
</script>
<div id="assignment">
</div>
<div class="info">
<a href="reversible-slides.html">Slides for programmers</a>
<a href="teaching-reversible-slides.html">Slides for learners</a>
<a href="https://github.com/boberetezeke/reversible-lang-js">Get the Code</a>
<a href="SpecRunner.html">Run the Tests</a>
</div>
<div class="two-fifths">
<h1>Examples</h1>
<h3>Input a name and display it</h3>
<pre>
name = input_string ( "enter name" )
output ( "your name is" )
output ( name )
</pre>
<h3>Get a list of food bills, total and average them</h3>
<pre>
sum = 0
num_people = 0
value = 1
while value != 0
value = input_number ( "enter food amount" )
if value != 0
sum = sum + value
num_people = num_people + 1
end
end
output ( "total bill is" )
output ( sum )
output ( "the average bill is" )
output ( sum / num_people )
</pre>
</div>
<div class="two-fifths">
<h1>Syntax</h1>
<ul>
<li>Assignment: identifier '=' Expression</li>
<li>Expression: (Literal | Identifier) operand (Literal | Identifier)</li>
<li>FunctionCall: Identifier '(' Argument* ')'
<li>If Statement:
<ul>
<li>'if' Expression</li>
<li>Statements*</li>
<li>'else' (else clause optional)</li>
<li>Statements*</li>
<li>'end'</li>
</ul>
</li>
<li>While Statement:
<ul>
<li>'while' Expression</li>
<li>Statements*</li>
<li>'end'</li>
</ul>
</li>
<li>Literal: \d+ | "[^"]*"</li>
<li>Identifier: [\w_]+
</ul>
</div>
<div class="one-fifth">
<h1>Functions</h1>
<ul>
<li>Input a number - input_number ( "a string prompt" )</li>
<li>Input a string - input_string ( "a string prompt" )</li>
<li>Output a value - output ( literal_or_variable_name )</li>
</ul>
</div>
</body>
</html>