亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tutor10.doc

?? 計算機編譯原理教材
?? DOC
?? 第 1 頁 / 共 5 頁
字號:
       {--------------------------------------------------------------}


       Also, we're going to need some more code generation routines:


       {---------------------------------------------------------------}
       { Complement the Primary Register }

       procedure NotIt;
       begin
          EmitLn('NOT D0');
       end;
       {---------------------------------------------------------------}
       .
       .
       .
       {---------------------------------------------------------------}
       { AND Top of Stack with Primary }

       procedure PopAnd;
       begin
          EmitLn('AND (SP)+,D0');
       end;


       {---------------------------------------------------------------}
       { OR Top of Stack with Primary }

       procedure PopOr;
       begin
          EmitLn('OR (SP)+,D0');
       end;


       {---------------------------------------------------------------}
       { XOR Top of Stack with Primary }

       procedure PopXor;
       begin
          EmitLn('EOR (SP)+,D0');A*2A*
                                    - 22 -

PA2A





       end;


       {---------------------------------------------------------------}
       { Compare Top of Stack with Primary }

       procedure PopCompare;
       begin
          EmitLn('CMP (SP)+,D0');
       end;


       {---------------------------------------------------------------}
       { Set D0 If Compare was = }

       procedure SetEqual;
       begin
          EmitLn('SEQ D0');
          EmitLn('EXT D0');
       end;


       {---------------------------------------------------------------}
       { Set D0 If Compare was != }

       procedure SetNEqual;
       begin
          EmitLn('SNE D0');
          EmitLn('EXT D0');
       end;


       {---------------------------------------------------------------}
       { Set D0 If Compare was > }

       procedure SetGreater;
       begin
          EmitLn('SLT D0');
          EmitLn('EXT D0');
       end;


       {---------------------------------------------------------------}
       { Set D0 If Compare was < }

       procedure SetLess;
       begin
          EmitLn('SGT D0');
          EmitLn('EXT D0');
       end;
       {---------------------------------------------------------------}AN2AN
                                    - 23 -A*2A*

PA2A





       All of this  gives us the tools we need.  The BNF for the Boolean
       expressions is:


            <bool-expr> ::= <bool-term> ( <orop> <bool-term> )*

            <bool-term> ::= <not-factor> ( <andop> <not-factor> )*

            <not-factor> ::= [ '!' ] <relation>

            <relation> ::= <expression> [ <relop> <expression> ]


       Sharp-eyed readers might  note  that this syntax does not include
       the non-terminal  "bool-factor" used in earlier versions.  It was
       needed then because I also allowed for the Boolean constants TRUE
       and FALSE.   But  remember  that  in TINY there is no distinction
       made between Boolean and arithmetic  types ... they can be freely
       intermixed.   So there is really no  need  for  these  predefined
       values ... we can just use -1 and 0, respectively.

       In C terminology, we could always use the defines:


            #define TRUE -1
            #define FALSE 0


       (That is, if TINY had a  preprocessor.)   Later on, when we allow
       for  declarations  of  constants,  these  two   values   will  be
       predefined by the language.

       The reason that I'm harping on this is that  I've  already  tried
       the alternative, which is to  include TRUE and FALSE as keywords.
       The problem with that approach is that it  then  requires lexical
       scanning for EVERY variable name  in every expression.  If you'll
       recall,  I pointed out in Installment VII  that  this  slows  the
       compiler  down considerably.  As long as  keywords  can't  be  in
       expressions, we need to do the scanning only at the  beginning of
       every  new  statement  ...  quite  an improvement.  So using  the
       syntax above not only simplifies the parsing, but  speeds  up the
       scanning as well.

       OK, given that we're  all  satisfied  with  the syntax above, the
       corresponding code is shown below:


       {---------------------------------------------------------------}
       { Recognize and Translate a Relational "Equals" }

       procedure Equals;
       begin
          Match('=');
          Expression;A*2A*
                                    - 24 -

PA2A





          PopCompare;
          SetEqual;
       end;


       {---------------------------------------------------------------}
       { Recognize and Translate a Relational "Not Equals" }

       procedure NotEquals;
       begin
          Match('#');
          Expression;
          PopCompare;
          SetNEqual;
       end;


       {---------------------------------------------------------------}
       { Recognize and Translate a Relational "Less Than" }

       procedure Less;
       begin
          Match('<');
          Expression;
          PopCompare;
          SetLess;
       end;


       {---------------------------------------------------------------}
       { Recognize and Translate a Relational "Greater Than" }

       procedure Greater;
       begin
          Match('>');
          Expression;
          PopCompare;
          SetGreater;
       end;


       {---------------------------------------------------------------}
       { Parse and Translate a Relation }


       procedure Relation;
       begin
          Expression;
          if IsRelop(Look) then begin
             Push;
             case Look of
              '=': Equals;
              '#': NotEquals;
              '<': Less;A*2A*
                                    - 25 -

PA2A





              '>': Greater;
             end;
          end;
       end;


       {---------------------------------------------------------------}
       { Parse and Translate a Boolean Factor with Leading NOT }

       procedure NotFactor;
       begin
          if Look = '!' then begin
             Match('!');
             Relation;
             NotIt;
             end
          else
             Relation;
       end;


       {---------------------------------------------------------------}
       { Parse and Translate a Boolean Term }

       procedure BoolTerm;
       begin
          NotFactor;
          while Look = '&' do begin
             Push;
             Match('&');
             NotFactor;
             PopAnd;
          end;
       end;


       {--------------------------------------------------------------}
       { Recognize and Translate a Boolean OR }

       procedure BoolOr;
       begin
          Match('|');
          BoolTerm;
          PopOr;
       end;


       {--------------------------------------------------------------}
       { Recognize and Translate an Exclusive Or }

       procedure BoolXor;
       begin
          Match('~');
          BoolTerm;A*2A*
                                    - 26 -

PA2A





          PopXor;
       end;


       {---------------------------------------------------------------}
       { Parse and Translate a Boolean Expression }

       procedure BoolExpression;
       begin
          BoolTerm;
          while IsOrOp(Look) do begin
             Push;
             case Look of
              '|': BoolOr;
              '~': BoolXor;
             end;
          end;
       end;
       {--------------------------------------------------------------}


       To tie it all together, don't forget to change the  references to
       Expression in  procedures Factor and Assignment so that they call
       BoolExpression instead.

       OK, if  you've  got  all  that typed in, compile it and give it a
       whirl.    First,  make  sure  you  can  still parse  an  ordinary
       arithmetic expression.  Then, try a Boolean one.    Finally, make
       sure  that you can assign the results of  relations.    Try,  for
       example:

            pvx,y,zbx=z>ye.

       which stands for:

            PROGRAM
            VAR X,Y,Z
            BEGIN
            X = Z > Y
            END.


       See how this assigns a Boolean value to X?

       CONTROL STRUCTURES

       We're almost home.   With  Boolean  expressions  in place, it's a
       simple  matter  to  add control structures.  For TINY, we'll only
       allow two kinds of them, the IF and the WHILE:


            <if> ::= IF <bool-expression> <block> [ ELSE <block>] ENDIF

            <while> ::= WHILE <bool-expression> <block> ENDWHILEA*2A*
                                    - 27 -

PA2A





       Once  again,  let  me  spell  out the decisions implicit in  this
       syntax, which departs strongly from that of C or Pascal.  In both
       of those languages, the "body" of an IF or WHILE is regarded as a
       single  statement.  If you intend to use a block of more than one
       statement, you have to build a compound statement using BEGIN-END
       (in Pascal) or  '{}' (in C).  In TINY (and KISS) there is no such
       thing as a compound statement  ... single or multiple they're all
       just blocks to these languages.

       In KISS, all the control structures will have explicit and unique
       keywords  bracketing  the  statement block, so there  can  be  no
       confusion as to where things begin  and  end.  This is the modern
       approach, used in such respected languages as Ada  and  Modula 2,
       and it completely eliminates the problem of the "dangling else."

       Note  that I could have chosen to use the same keyword END to end
       all  the constructs, as is done in Pascal.  (The closing '}' in C
       serves the same purpose.)  But this has always led  to confusion,
       which is why Pascal programmers tend to write things like


            end { loop }

       or   end { if }


       As I explained in  Part  V,  using  unique terminal keywords does
       increase  the  size  of the keyword list and therefore slows down
       the  scanning, but in this case it seems a small price to pay for
       the added insurance.   Better  to find the errors at compile time
       rather than run time.

       One last thought:  The two constructs above each  have  the  non-
       terminals


             <bool-expression> and <block>


       juxtaposed with no separating keyword.  In Pascal we would expect
       the keywords THEN and DO in these locations.

       I have no problem with leaving out these keywords, and the parser
       has no trouble either, ON CONDITION that we make no errors in the
       bool-expression part.  On  the  other hand, if we were to include
       these extra keywords we would get yet one more level of insurance
       at very little  cost,  and  I  have no problem with that, either.
       Use your best judgment as to which way to go.

       OK, with that bit of explanation let's proceed.  As  usual, we're
       going to need some new  code generation routines.  These generate
       the code for conditional and unconditional branches:AB2AB
                                    - 28 -A*2A*

PA2A





       {---------------------------------------------------------------}
       { Branch Unconditional  }

       procedure Branch(L: string);
       begin
          EmitLn('BRA ' + L);
       end;


       {---------------------------------------------------------------}
       { Branch False }

       procedure BranchFalse(L: string);
       begin
          EmitLn('TST D0');
          EmitLn('BEQ ' + L);
       end;
       {--------------------------------------------------------------}


       Except for the encapsulation of  the code generation, the code to
       parse the control constructs is the same as you've seen before:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线免费观看日韩欧美| 九色综合国产一区二区三区| 精品国产自在久精品国产| 欧美在线视频你懂得| 色系网站成人免费| 91免费在线看| 91老师片黄在线观看| 91美女在线视频| 欧洲中文字幕精品| 在线成人免费视频| 日韩女优av电影在线观看| 欧美xxxxx裸体时装秀| 亚洲精品在线免费播放| 久久精品视频免费| 国产精品免费视频网站| 亚洲三级电影网站| 五月婷婷综合在线| 麻豆精品一区二区av白丝在线| 日本中文在线一区| 久久精品国产在热久久| 国产精品亚洲午夜一区二区三区 | 激情综合网最新| 亚洲电影一区二区三区| 国产精品美女久久久久高潮| 国产精品电影一区二区| 夜夜嗨av一区二区三区中文字幕| 国产福利一区二区三区| 欧洲精品一区二区三区在线观看| 久久毛片高清国产| 亚洲高清一区二区三区| 色综合天天综合网国产成人综合天| 五月婷婷综合网| 国产精品家庭影院| 国产日韩影视精品| 国产乱码字幕精品高清av| av中文字幕一区| 欧美色图第一页| 欧美综合一区二区| 欧美xxxxxxxx| 色偷偷久久一区二区三区| 在线观看日韩电影| 国产精品看片你懂得| av亚洲产国偷v产偷v自拍| 欧美精品一区二区三区在线| 91精品国产免费久久综合| 国产精品成人免费精品自在线观看| 欧美伊人久久久久久午夜久久久久| 欧美图区在线视频| 精品国产乱码久久久久久久久| 亚洲第一成年网| 亚洲一区国产视频| 韩国成人精品a∨在线观看| 亚洲免费在线播放| 久久久久国产精品厨房| 日韩欧美成人激情| 久久九九99视频| 中文字幕一区二| 最好看的中文字幕久久| 日韩一级片网址| 大桥未久av一区二区三区中文| 麻豆一区二区99久久久久| 美女视频第一区二区三区免费观看网站| 日韩av电影免费观看高清完整版 | 风间由美一区二区av101| 亚洲精品午夜久久久| 国产午夜精品理论片a级大结局| 欧美三级中文字幕| 色狠狠桃花综合| 欧美三级电影精品| kk眼镜猥琐国模调教系列一区二区| 亚洲精品国产无天堂网2021| 国产精品亚洲第一| 精品粉嫩aⅴ一区二区三区四区| 亚洲欧美一区二区三区国产精品| 欧美性猛片aaaaaaa做受| 精品三级在线观看| 日韩欧美成人一区二区| 欧美色中文字幕| 日韩视频一区二区三区在线播放| 欧美一级国产精品| 精品国产乱码久久久久久老虎 | 日韩一区二区免费在线电影| 欧美一区二区三区视频在线| 精品人在线二区三区| 国产日韩欧美不卡| 亚洲欧美二区三区| 亚洲国产成人91porn| 九九在线精品视频| 欧美日韩你懂得| 欧美激情资源网| 国产精品99精品久久免费| 激情综合网最新| 中文字幕一区二区在线播放| 欧美不卡在线视频| 欧美亚洲综合另类| 色www精品视频在线观看| 99riav久久精品riav| 国v精品久久久网| 欧美丝袜自拍制服另类| 久久久777精品电影网影网| 亚洲三级在线观看| jizzjizzjizz欧美| 国产一区日韩二区欧美三区| 亚洲一区二区av在线| 亚洲欧美日韩一区| 免费看欧美女人艹b| 日本道精品一区二区三区| 91精品国产综合久久婷婷香蕉| 欧美三级日本三级少妇99| 日韩一区二区精品在线观看| 亚洲欧洲综合另类| 高清久久久久久| 国产精品卡一卡二| 国产乱码精品一品二品| 精品美女一区二区| 琪琪久久久久日韩精品| 欧美在线观看视频一区二区| 一区二区激情小说| 欧美喷水一区二区| 日本亚洲视频在线| 国产人妖乱国产精品人妖| 菠萝蜜视频在线观看一区| 亚洲色欲色欲www在线观看| 在线欧美日韩精品| 黄一区二区三区| 18欧美乱大交hd1984| 欧美巨大另类极品videosbest | 欧美日韩一级二级| 日韩精品三区四区| 亚洲天堂免费看| 538prom精品视频线放| 国产高清精品久久久久| 一区二区在线观看av| 久久精品这里都是精品| 91在线国产福利| 国产成人啪午夜精品网站男同| 亚洲国产欧美一区二区三区丁香婷| 欧美一区二区三区不卡| 国产精品2024| 狠狠色狠狠色综合| 日产精品久久久久久久性色| 中文字幕制服丝袜一区二区三区 | 婷婷久久综合九色综合绿巨人| 欧美一级理论片| 欧美午夜免费电影| 色香色香欲天天天影视综合网| 久久精品久久精品| 免费看欧美女人艹b| 污片在线观看一区二区| 亚洲美女电影在线| 亚洲免费av网站| 中文字幕日韩av资源站| 国产女同性恋一区二区| 国产日产精品一区| 国产精品久久久久天堂| 国产性做久久久久久| 国产欧美精品一区| 国产欧美日韩另类视频免费观看| 精品少妇一区二区三区在线视频| 欧美另类videos死尸| 精品国产凹凸成av人网站| 久久精品一区八戒影视| 国产网红主播福利一区二区| 国产亚洲一区字幕| 亚洲精品欧美在线| 日韩精品91亚洲二区在线观看| 国产一区二区三区免费在线观看| 国产精品中文欧美| 欧美一区二区在线免费播放 | 久久久综合激的五月天| 国产精品久久久久久亚洲伦| 亚洲一区在线视频观看| 经典三级在线一区| 欧美在线制服丝袜| 国产日韩欧美麻豆| 免费欧美日韩国产三级电影| 成人午夜在线视频| 欧美丰满少妇xxxxx高潮对白| 国产精品美女久久久久aⅴ| 日韩电影在线免费看| 欧美亚洲综合一区| 亚洲精品成人a在线观看| 波多野结衣在线一区| 精品国产人成亚洲区| 日韩av一区二区在线影视| 色综合天天综合色综合av| 中文字幕中文在线不卡住| 国产精品一色哟哟哟| 精品国产乱码久久久久久蜜臀| 三级欧美在线一区| 日韩一级片在线观看| 国产麻豆视频精品| 国产欧美日产一区| 在线观看www91| 免费看黄色91| 国产精品激情偷乱一区二区∴| 国产69精品久久久久777| 亚洲欧洲成人精品av97| 欧美在线视频日韩| 国产久卡久卡久卡久卡视频精品|