-
Notifications
You must be signed in to change notification settings - Fork 2
/
SYNTAX
66 lines (44 loc) · 1.53 KB
/
SYNTAX
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
Expression syntax
-----------------
1. Operators
In decreasing priority:
^ (exponentiation)
- (negative sign)
* /
+ -
= (rule-equation)
Exponentiation is right-associative, while all the other
arithmetic operators are left-associative.
Example: 1 + 2 * 3
2. Parentheses
Example: (1 + 2) * 3
3. Variable names / symbols
Example: bob
4. Functions
Example: cos(x * x)
Example: foo(A * (B + 1), asdf, clown, qwerty - fjds(bob * log(derp)))
Rule syntax
-----------
Rules are written as equations. Variable in the left-hand-side get matched
to expressions which are subsituted into the right-hand-side.
For example, the rule 'x + x = 2 * x' will turn the expression
'cos(x) + cos(x)' into '2 * cos(x)'.
There are some "special" syntaxes:
e|x matches any expression e without any occurence of x in it
e:x matches any expression e with an occurence of x in it,
including x itself.
e::x matches any expression e with an occurence of x in it,
but not x itself.
e|'x matches anything that isn't literally the symbol x
[ Issue: x has to have been defined before (to the left) of the ]
[ syntax for these syntaxes to work :( ]
[ ]
[ So for example, expressions like "D(e|x, x)" are a problem ]
[ but "D(x, e|x)" will work. There might be a way to fix this... ]
?x matches a direct variable symbol x
#n matches a number n
$f matches a function f
@e matches an expression e which isn't a number
'e matches literally the symbol e
In the preloaded rule files ("rules" directory, comment-lines start
with '%' characters).