Compiler construction 附言标志

Compiler construction 附言标志,compiler-construction,postscript,logo-lang,Compiler Construction,Postscript,Logo Lang,我试图在PostScript中为我的徽标程序找到等效代码: PROC FRACTAL( SIZE ) IF SIZE < 1 THEN FORWARD 5 ELSE LEFT 90 RIGHT 90 RIGHT 90 RIGHT 90 RIGHT 90 RIGHT 90 FORWARD 60 ENDIF PROC MAIN( VOID ) FRACTAL( 5 ) 此解决方案基于以下问题: 这段代码对我来说很好,但是由于某些原因PS不想显示图片 后记的翻译是正确的。问题是Logo程序

我试图在PostScript中为我的徽标程序找到等效代码:

PROC FRACTAL( SIZE )
IF SIZE < 1 THEN
FORWARD 5
ELSE 
LEFT 90
RIGHT 90
RIGHT 90
RIGHT 90
RIGHT 90
RIGHT 90
FORWARD 60
ENDIF

PROC MAIN( VOID )
FRACTAL( 5 )
此解决方案基于以下问题:


这段代码对我来说很好,但是由于某些原因PS不想显示图片

后记的翻译是正确的。问题是Logo程序没有做任何有趣的事情。

是否直接将其发送到打印机?你在ghostscript中试过吗?@Luis,我创建了一个.ps文件,并试图在OSX中使用预览打开它。你确定徽标程序按照你的想法运行吗?看起来它只是画了一条短的垂直线,这与ghostscript为PS程序提供的输出相同。顺便说一句,“LEFT 90 RIGHT 90”和“RIGHT 90 RIGHT 90 RIGHT 90 RIGHT 90 RIGHT 90”一样都是不可操作的。顺便说一句,我使用的调试器(在源代码的注释中提到)在这里可用:
%!
%(debug.ps/db5.ps)run traceon stepon currentfile cvx debug
/Xpos { 300 } def
/Ypos { 500 } def
/Heading { 0 } def
/Arg { 0 } def
/RIGHT {
Heading exch add Trueheading
/Heading exch store
} def
/LEFT {
Heading exch sub Trueheading
/Heading exch store
} def
/Trueheading {
360 mod dup
0 lt { 360 add } if
} def
/FORWARD {
dup Heading sin mul
exch Heading cos mul
2 copy Newposition
rlineto
} def
/Newposition {
Heading 180 gt Heading 360 lt
and { neg } if exch
Heading 90 gt Heading 270 lt
and { neg } if exch
Ypos add /Ypos exch def
Xpos add /Xpos exch def
} def
/SIZE { 5 } def
/FRACTAL{
1 dict begin
/SIZE exch def
SIZE
1
lt
{
5
FORWARD
}{
90
LEFT
90
RIGHT
90
RIGHT
90
RIGHT
90
RIGHT
90
RIGHT
60
FORWARD
} ifelse 
end
} def
/MAIN{
5
FRACTAL
} def
Xpos Ypos moveto
MAIN
stroke
showpage