-
Notifications
You must be signed in to change notification settings - Fork 0
/
00_Terms_Primatives_and_Association.olly
84 lines (70 loc) · 3.25 KB
/
00_Terms_Primatives_and_Association.olly
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
###############################################################
All data in Oliver is represented either as a term, an
expression, or as an abstraction. All expressions are
defined by a bounding pair of characters that define the
start and the end of the expression. All terms and
abstractions are considered expressions.
###############################################################
# Shibang lines configure the runtime of the program.
# Here we are allowing for exceptions to be thrown.
#! NO_EXCEPT = false
# mishtype
# Numerical expressions are bound by apostrophes.
'1', '2', '14.125', '9 + 3i'
# Text string expressions are bound by quotations.
"a", "b", "Hello", "Welcome to Oliver Lang!"
# Primative 'expression' expressions are all bound by parenthesis.
(), ('1'), ('1', '2', "cat", "dog")
# They can also be bound by colons & semicolans. This is
# to help reading and organizing written code strings.
:;, :'1';, :'1', '2', "cat", "dog";
# List expressions are bound by brackets.
[], ['1'], ['1', '2', "cat", "dog"]
# Keyword terms and operators, all have a predefined expression
# associatations. All expressions are all evaluated and placed
# on the back of the deque.
"The deque = " # Set a text string to the end of the deque.
<< # Print a text representation of the top deque element.
deque # Set a copy of the deque on top of the deque.
<< # Note the emit '<<' operator removes the term from the stack.
endl # End the current output line.
endl # Add extra line between next output.
# Specification at runtime repalces all terms with the associated
# expression assigned to them. Terms without associattion will
# alway specify to the value of nothing, and not placed on to the
# deque.
# Programer defined terms only have an association if
# and only if an association is defined. The postfix
# 'assign' operator defines that association.
+deque [] assign
+string_1 "Text string 1." assign
+string_2 "Text string 2." assign
+x '42' assign
+y '18' assign
# Notice the unary operator '+' was used. A unary '+' is
# the identy function. Unary '+' accepts any single argument
# and returns it as the result. It is useful in preventing
# symbol evaluation at runtime. Else the specified term would
# be placed on the deque. The unary '+' must have no space
# between it and the term it identifies.
# Once a term is symbolicly associated, any instance of
# the term will be replaced by its associated expression.
"x = " << x << endl
"y = " << y << endl
"string_1 = " << string_1 << endl
"string_2 = " << string_2 << endl
endl
# We can also define new expressions to evaluate using
# the identiy function to associate expressions to terms.
# Here we emit a copy of the deque before assignment to
# see the value being assigned to the symbol 'sum'.
+sum +(x + y) (deque << endl) assign
"sum = " << sum << endl
endl
# All expressions are also evaluated explicitatly at
# runtime, unless passed to the deque through the unary '+'
# operator. Here the expression '((x + (x / y)) * x)' is
# evaluated, the result assigned to the symbol 'f'.
+f ((x + (x / y)) * x) (deque << endl) assign
"f = " << f << endl
endl