[問題] 想請教各位大大一題演算法~
看板Prob_Solve (計算數學 Problem Solving)作者crazybeagle (☆瘋狂米格魯☆)時間20年前 (2004/04/16 17:01)推噓0(0推 0噓 0→)留言0則, 0人參與討論串1/1
我的題目是下列演算法~要修改它使它能連接運算子: 我有想到說打算在 else if OPCODE = 'MARCO' then
DEFINE
下面再加個判斷式,不然它會沒辦法判斷我所設定的巨集符號..但是對我這初級者來說@@真
目前我只知道有個方向,要在那家個判斷式~但我不知道如何去修改它>.< 或者我的方向錯?
導致寫不出來~但寫程式真是一大挑戰呀~所以想麻煩各位程式高手幫幫小弟的忙~感激不盡
begin {macro processor}
EXPANDING := FALSE
while OPCODE ≠ 'END' do
begin
GETLINE
PROCESSLINE
end{while}
end {marco processor}
procedure PROCESSLINE
begin
search NAMTAB for OPCODE
if found then
EXPAND
else if OPCODE = 'MARCO' then
DEFINE ←←打算在此加入一個判斷式,讓它能處理運算子..
else write source line to expanded file
end {PROCESSLINE}
procedure DEFINE
begin
enter macro name into NAMTAB
enter marco prototype into DEFTAB
LEVEL : = 1
while LEVEL > 0 do
begin
GETLINE
if this is not a comment line then
begin
substitute positional notation for parameters
enter line into DEFTAB
if OPCODE = 'MARCO' then
LEVEL :=LEVEL + 1 ←
else if OPCODE = 'MEND' then
LEVEL := LEVEL - 1 ←
end {if not comment}
end {while}
procedure EXPAND
begin
EXPANDING := TRUE
get first line of marco definition {prototype} from DEFTAB
set up arguments from marco invocation in ARGTAB
write marco invocation to expanded file as a comment
while not end of macro definition do
begin
GETLINE
PROCESSLINE
end {while}
EXPANDING :=FALSE
end {EXPAND}
procedure GETLINE
begin
if EXPANDING then
begin
get next line of macro definition from DEFTAB
substitute arguments from ARGTAB for positional notation
end {if}
else
read next line from input file
end {GETLINE}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.59.134.188
Prob_Solve 近期熱門文章
PTT數位生活區 即時熱門文章