So I know these basic dict commands in Postscript:
i dict
creates a dictionary with i
entries
d begin
moves dictionary d
to the dictionary stack
end
removes the topmost dictionary from the dictionary stack
d n w put
store value w
under name n
in dictionary d
d n get
get the value of name n
in dictionary d
, and put it on the stack
What I would like to do is create a dictionary that represents the associativity of differend operands. The +
operand and the -
operand share the same priority, therefor they are both set to 0, the *
and /
operands also share the same priority, but have higher priority than +
and -
and are therefor set to 1 and so on...
The Problem is, that I am not able to set the dictionary key to /
as it is treated as some kind of "delimiter". Is there any way around this, since i cannot change the keys, and I cannot create a dict like this:
/prioritydict 5 dict def
prioritydict /(-) 0 put
prioritydict /(+) 0 put
prioritydict /(*) 1 put
prioritydict /(/) 1 put
prioritydict /(^) 2 put
nor like this:
/prioritydict 5 dict def
prioritydict /- 0 put
prioritydict /+ 0 put
prioritydict /* 1 put
prioritydict // 1 put
prioritydict /^ 2 put
Any help is greatly appreciated
You could use the cvn (convert to name) operator to turn a string of any form you want into a literal name. These should all be equivalent:
prioritydict <2f> cvn 1 put
prioritydict (\/) cvn 1 put
prioritydict (\057) cvn 1 put