[Home]
[
prev
] [
up
] [
next
] ((test/grammar.as))
30.1
Test Grammar
732
⟨
test Grammar
732
⟩
≡
(
728
)
testGrammar1():
()
==
{
import
from
LabelSpecies
,
List
LabelSpecies
,
Integer
,
Array
Integer
,
String
,
List
ExpressionTree
,
MyParser
,
InterpretingTools
;
s:
String
==
"
Plus
(
SingletonSpecies
,
Times
(Self,
Self))";
S:
LabelSpecies
==
first
interpret
[parse
s];
checkExpOrd(coerce
S,
[0,
1,
2,
12,
120,
1680,
30240],
[0,
1,
1,
2,
5,
14,
42]);
}
testGrammar2():
()
==
{
import
from
LabelSpecies
,
List
LabelSpecies
,
Integer
,
Array
Integer
,
String
,
List
ExpressionTree
,
MyParser
,
InterpretingTools
;
T23:
List
LabelSpecies
==
interpret
[parse
"
Plus
(
SingletonSpecies
,
Times
(Self(2),
Self(2)))",
parse
"
Plus
(
SingletonSpecies
,
Times
(Self,
Times
(Self,Self)))"];
checkExpOrd(coerce
first
T23,
[0,
1,
2,
0,
48,
720,
5040,
100800,
3024000],
[0,
1,
1,
0,
2,
6,
7,
20,
75]);
checkExpOrd(coerce
first
rest
T23,
[0,
1,
0,
6,
72,
360,
5040,
151200,
2540160],
[0,
1,
0,
1,
3,
3,
7,
30,
63]);
}
Uses
Array
599
,
ExpressionTree
624a
,
Integer
66
,
InterpretingTools
453
,
LabelSpecies
452
,
MyParser
445
,
Plus
166a
,
SingletonSpecies
84
,
String
65
,
and
Times
175a
.
[Home]
[
prev
] [
up
] [
next
] ((test/grammar.as))