version 1.37, 2004/09/10 13:20:23 |
version 1.46, 2004/09/17 00:47:08 |
|
|
% $OpenXM: OpenXM/src/kan96xx/Kan/dr.sm1,v 1.36 2004/09/09 11:42:22 takayama Exp $ |
% $OpenXM: OpenXM/src/kan96xx/Kan/dr.sm1,v 1.45 2004/09/17 00:10:41 takayama Exp $ |
%% dr.sm1 (Define Ring) 1994/9/25, 26 |
%% dr.sm1 (Define Ring) 1994/9/25, 26 |
%% This file is error clean. |
%% This file is error clean. |
|
|
|
|
0 1 << set0 length 1 sub >> |
0 1 << set0 length 1 sub >> |
{ |
{ |
/i set |
/i set |
<< set0 i get >> a eq |
set0 i get tag , a tag , eq { |
{ |
<< set0 i get >> a eq |
/flag 1 def |
{ |
} |
/flag 1 def exit |
{ } |
} |
ifelse |
{ } |
|
ifelse |
|
} { } ifelse |
} for |
} for |
] pop |
] pop |
/arg1 flag def |
/arg1 flag def |
|
|
[( string .. universalNumber) |
[( string .. universalNumber) |
(Parse the << string >> as a universalNumber.) |
(Parse the << string >> as a universalNumber.) |
(Example: (123431232123123).. /n set) |
(Example: (123431232123123).. /n set) |
|
({ commands }.. executes the commands. << .. >> is equivalent to exec.) |
]] putUsages |
]] putUsages |
/.. { (universalNumber) data_conversion } def |
/.. { dup tag 3 eq { exec } { (universalNumber) data_conversion} ifelse } def |
|
|
[(dc) |
[(dc) |
[(Abbreviation of data_conversion.) |
[(Abbreviation of data_conversion.) |
Line 4151 $ [ff ff] fromVectors :: $ |
|
Line 4154 $ [ff ff] fromVectors :: $ |
|
/getNode { |
/getNode { |
/arg2 set |
/arg2 set |
/arg1 set |
/arg1 set |
[/in-getNode /ob /key /rr /rr /ii] pushVariables |
[/in-getNode /ob /key /rr /tt /ii] pushVariables |
[ |
[ |
/ob arg1 def |
/ob arg1 def |
/key arg2 def |
/key arg2 def |
/rr null def |
/rr null def |
{ |
{ |
|
ob isArray { |
|
ob length 1 gt { |
|
ob 0 get isString { |
|
ob 0 get , key eq { |
|
/rr ob 1 get def exit |
|
} { } ifelse |
|
} { } ifelse |
|
}{ } ifelse |
|
ob { key getNode , dup tag 0 eq {pop} { } ifelse } map /tt set |
|
tt length 0 gt { /rr tt 0 get def exit } |
|
{/rr null def exit } ifelse |
|
} { } ifelse |
|
|
ob isClass { |
ob isClass { |
ob (array) dc /ob set |
ob (array) dc /ob set |
} { exit } ifelse |
} { } ifelse |
|
ob isClass , ob isArray or { } { exit } ifelse |
ob 0 get key eq { |
ob 0 get key eq { |
/rr ob def |
/rr ob def |
exit |
exit |
Line 4178 $ [ff ff] fromVectors :: $ |
|
Line 4195 $ [ff ff] fromVectors :: $ |
|
arg1 |
arg1 |
} def |
} def |
[(getNode) |
[(getNode) |
[(ob key getNode) |
[(ob key getNode node-value) |
(ob is a class object.) |
(ob is a class object or an array.) |
(The operator getNode returns the node with the key in ob.) |
(The operator getNode returns the node with the key in ob.) |
(The node is an array of the format [key attr-list node-list]) |
(When ob is a class, the node is an array of the format [key attr-list node-list]) |
|
(When ob is an array, the node is a value of key-value pairs.) |
(Example:) |
(Example:) |
( /dog [(dog) [[(legs) 4] ] [ ]] [(class) (tree)] dc def) |
( /dog [(dog) [[(legs) 4] ] [ ]] [(class) (tree)] dc def) |
( /man [(man) [[(legs) 2] ] [ ]] [(class) (tree)] dc def) |
( /man [(man) [[(legs) 2] ] [ ]] [(class) (tree)] dc def) |
( /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def) |
( /ma [(mammal) [ ] [man dog]] [(class) (tree)] dc def) |
( ma (dog) getNode ) |
( ma (dog) getNode ) |
|
(Example 2:) |
|
( [ [1 ] [2 3] [[(dog) 2]]] (dog) getNode ::) |
]] putUsages |
]] putUsages |
|
|
/cons { |
/cons { |
Line 4202 $ [ff ff] fromVectors :: $ |
|
Line 4222 $ [ff ff] fromVectors :: $ |
|
[(cons) |
[(cons) |
[(obj list cons list) |
[(obj list cons list) |
]] putUsages |
]] putUsages |
|
/arrayToList { |
|
/arg1 set |
|
[/a /r] pushVariables |
|
[ |
|
/a arg1 def |
|
{ |
|
a isArray { |
|
a { arrayToList } map /a set |
|
a (list) dc /r set |
|
exit |
|
} { } ifelse |
|
/r a def |
|
exit |
|
} loop |
|
/arg1 r def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(arrayToList) |
|
[(a arrayToList list) |
|
]] putUsages |
|
|
|
/listToArray { |
|
/arg1 set |
|
[/a /r] pushVariables |
|
[ |
|
/a arg1 def |
|
{ |
|
a tag 12 eq { |
|
a (array) dc /a set |
|
a { listToArray } map /r set |
|
exit |
|
} { } ifelse |
|
a tag 0 eq { |
|
/r [ ] def |
|
exit |
|
} { } ifelse |
|
/r a def |
|
exit |
|
} loop |
|
/arg1 r def |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(listToArray) |
|
[(list listToArray a) |
|
]] putUsages |
|
|
|
% Body is moved to smacro.sm1 |
|
[(makeInfix) |
|
[(literal makeInfix) |
|
(Change literal to an infix operator.) |
|
(Example: /+ { add } def ) |
|
( /+ makeInfix) |
|
( /s 0 def 1 1 100 { /i set s + i /s set } for s message) |
|
( [ 1 2 3 ] { /i set i + 2 } map ::) |
|
]] putUsages |
|
|
/usages { |
/usages { |
/arg1 set |
/arg1 set |
[/name /flag /n /k /slist /m /i /sss] pushVariables |
[/name /flag /n /k /slist /m /i /sss /key /ukeys] pushVariables |
[ |
[ |
/name arg1 def |
/name arg1 def |
/flag true def |
/flag true def |
|
{ % begin loop |
|
|
%BUG: should use regular expression in a future. |
name isArray { |
|
/ukeys @.usages { 0 get } map shell def |
|
name { /key set [(regexec) key ukeys] extension |
|
{ 0 get } map } map /sss set |
|
exit |
|
} { } ifelse |
|
|
name tag 1 eq { |
name tag 1 eq { |
@.usages { 0 get } map shell { (, ) nl } map /sss set |
@.usages { 0 get } map shell { (, ) nl } map /sss set |
|
exit |
} { |
} { |
|
|
/sss [ ] def |
/sss [ ] def |
Line 4239 $ [ff ff] fromVectors :: $ |
|
Line 4326 $ [ff ff] fromVectors :: $ |
|
{name Usage /sss [(Usage of ) name ( could not obtained.) nl ] def} |
{name Usage /sss [(Usage of ) name ( could not obtained.) nl ] def} |
{ } |
{ } |
ifelse |
ifelse |
|
exit |
} ifelse |
} ifelse |
|
|
|
} loop |
/arg1 sss cat def |
/arg1 sss cat def |
] pop |
] pop |
popVariables |
popVariables |
Line 4248 $ [ff ff] fromVectors :: $ |
|
Line 4338 $ [ff ff] fromVectors :: $ |
|
[(usages) |
[(usages) |
[(key usages usages-as-a-string) |
[(key usages usages-as-a-string) |
(num usages list-of-key-words) |
(num usages list-of-key-words) |
|
([key1 key2 ... ] usages list-of-key-words : it accepts regular expressions.) |
]] putUsages |
]] putUsages |
|
|
|
/setMinus { |
|
/arg2 set /arg1 set |
|
[/aa /bb /i ] pushVariables |
|
[ |
|
/aa arg1 def /bb arg2 def |
|
[ |
|
0 1 aa length 1 sub { |
|
/i set |
|
aa i get bb memberQ { |
|
} { aa i get } ifelse |
|
} for |
|
] /arg1 set |
|
] pop |
|
popVariables |
|
arg1 |
|
} def |
|
[(setMinus) |
|
[(a b setMinus c) |
|
]] putUsages |
|
|
|
% Define some infix operators |
|
/~add~ { add } def /~add~ makeInfix |
|
/~sub~ { sub } def /~sub~ makeInfix |
|
/~mul~ { mul } def /~mul~ makeInfix |
|
/~div~ { div } def /~div~ makeInfix |
|
/~power~ { power } def /~power~ makeInfix |
|
/~put~ { |
|
dup tag 3 eq { exec } { } ifelse put |
|
} def |
|
/~put~ makeInfix |
|
|
|
|
; |
; |
|
|