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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tutor11.doc

?? 計(jì)算機(jī)編譯原理教材
?? DOC
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):





       { Scan the Current Identifier for Keywords }

       procedure Scan;
       begin
          if Token = 'x' then
             Token := KWcode[Lookup(Addr(KWlist), Value, NKW) + 1];
       end;
       {--------------------------------------------------------------}


       There is one last detail.  In the compiler there are a few places
       that we must  actually  check  the  string  value  of  the token.
       Mainly, this  is done to distinguish between the different END's,
       but there are a couple  of  other  places.    (I  should  note in
       passing that we could always  eliminate the need for matching END
       characters by encoding each one  to a different character.  Right
       now we are definitely taking the lazy man's route.)

       The  following  version  of MatchString takes the  place  of  the
       character-oriented Match.  Note that, like Match, it DOES advance
       the input stream.


       {--------------------------------------------------------------}
       { Match a Specific Input String }

       procedure MatchString(x: string);
       begin
          if Value <> x then Expected('''' + x + '''');
          Next;
       end;
       {--------------------------------------------------------------}


       FIXING UP THE COMPILER

       Armed with these new scanner procedures, we can now begin  to fix
       the compiler to  use  them  properly.   The changes are all quite
       minor,  but  there  are quite a  few  places  where  changes  are
       necessary.  Rather than  showing  you each place, I will give you
       the general idea and then just give the finished product.


       First of all, the code for procedure Block doesn't change, though
       its function does:


       {--------------------------------------------------------------}
       { Parse and Translate a Block of Statements }

       procedure Block;
       begin
          Scan;
          while not(Token in ['e', 'l']) do beginA*2A*
                                     - 9 -

PA2A





             case Token of
              'i': DoIf;
              'w': DoWhile;
              'R': DoRead;
              'W': DoWrite;
             else Assignment;
             end;
             Scan;
          end;
       end;
       {--------------------------------------------------------------}


       Remember that the new version of Scan doesn't  advance  the input
       stream, it only  scans  for  keywords.   The input stream must be
       advanced by each procedure that Block calls.

       In general, we have to replace every test on Look with  a similar
       test on Token.  For example:


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

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


       In procedures like Add, we don't  have  to use Match anymore.  We
       need only call Next to advance the input stream:


       {--------------------------------------------------------------}
       { Recognize and Translate an Add }

       procedure Add;
       begin
          Next;
          Term;
          PopAdd;
       end;
       {-------------------------------------------------------------}AB2AB
                                    - 10 -A*2A*

PA2A





       Control  structures  are  actually simpler.  We just call Next to
       advance over the control keywords:


       {---------------------------------------------------------------}
       { Recognize and Translate an IF Construct }

       procedure Block; Forward;

       procedure DoIf;
       var L1, L2: string;
       begin
          Next;
          BoolExpression;
          L1 := NewLabel;
          L2 := L1;
          BranchFalse(L1);
          Block;
          if Token = 'l' then begin
             Next;
             L2 := NewLabel;
             Branch(L2);
             PostLabel(L1);
             Block;
          end;
          PostLabel(L2);
          MatchString('ENDIF');
       end;
       {--------------------------------------------------------------}


       That's about the extent of the REQUIRED changes.  In  the listing
       of TINY  Version  1.1  below,  I've  also  made a number of other
       "improvements" that  aren't really required.  Let me explain them
       briefly:

        (1)  I've deleted the two procedures Prog and Main, and combined
             their functions into the main program.  They didn't seem to
             add  to program clarity ... in fact  they  seemed  to  just
             muddy things up a little.

        (2)  I've  deleted  the  keywords  PROGRAM  and  BEGIN  from the
             keyword list.  Each  one  only occurs in one place, so it's
             not necessary to search for it.

        (3)  Having been  bitten  by  an  overdose  of  cleverness, I've
             reminded myself that TINY  is  supposed  to be a minimalist
             program.  Therefore I've  replaced  the  fancy  handling of
             unary minus with the dumbest one I could think of.  A giant
             step backwards in code quality, but a  great simplification
             of the compiler.  KISS is the right place to use  the other
             version.AB2AB
                                    - 11 -A*2A*

PA2A





        (4)  I've added some  error-checking routines such as CheckTable
             and CheckDup, and  replaced  in-line code by calls to them.
             This cleans up a number of routines.

        (5)  I've  taken  the  error  checking  out  of  code generation
             routines  like Store, and put it in  the  parser  where  it
             belongs.  See Assignment, for example.

        (6)  There was an error in InTable and Locate  that  caused them
             to search all locations  instead  of  only those with valid
             data  in them.  They now search only  valid  cells.    This
             allows us to eliminate  the  initialization  of  the symbol
             table, which was done in Init.

        (7)  Procedure AddEntry now has two  arguments,  which  helps to
             make things a bit more modular.

        (8)  I've cleaned up the  code  for  the relational operators by
             the addition of the  new  procedures  CompareExpression and
             NextExpression.

        (9)  I fixed an error in the Read routine ... the  earlier value
             did not check for a valid variable name.


        CONCLUSION

       The resulting compiler for  TINY  is given below.  Other than the
       removal  of  the  keyword PROGRAM, it parses the same language as
       before.    It's  just  a  bit cleaner, and more importantly  it's
       considerably more robust.  I feel good about it.

       The next installment will be another  digression:  the discussion
       of  semicolons  and  such that got me into this mess in the first
       place.  THEN we'll press on  into  procedures and types.  Hang in
       there with me.  The addition of those features will go a long way
       towards removing KISS from  the  "toy  language" category.  We're
       getting very close to being able to write a serious compiler.


       TINY VERSION 1.1


       {--------------------------------------------------------------}
       program Tiny11;

       {--------------------------------------------------------------}
       { Constant Declarations }

       const TAB = ^I;
             CR  = ^M;
             LF  = ^J;

             LCount: integer = 0;A*2A*
                                    - 12 -

PA2A





             NEntry: integer = 0;


       {--------------------------------------------------------------}
       { Type Declarations }

       type Symbol = string[8];

            SymTab = array[1..1000] of Symbol;

            TabPtr = ^SymTab;


       {--------------------------------------------------------------}
       { Variable Declarations }

       var Look : char;             { Lookahead Character }
           Token: char;             { Encoded Token       }
           Value: string[16];       { Unencoded Token     }


       const MaxEntry = 100;

       var ST   : array[1..MaxEntry] of Symbol;
           SType: array[1..MaxEntry] of char;


       {--------------------------------------------------------------}
       { Definition of Keywords and Token Types }

       const NKW =   9;
             NKW1 = 10;

       const KWlist: array[1..NKW] of Symbol =
                     ('IF', 'ELSE', 'ENDIF', 'WHILE', 'ENDWHILE',
                      'READ', 'WRITE', 'VAR', 'END');

       const KWcode: string[NKW1] = 'xileweRWve';


       {--------------------------------------------------------------}
       { Read New Character From Input Stream }

       procedure GetChar;
       begin
          Read(Look);
       end;

       {--------------------------------------------------------------}
       { Report an Error }

       procedure Error(s: string);
       begin
          WriteLn;A*2A*
                                    - 13 -

PA2A





          WriteLn(^G, 'Error: ', s, '.');
       end;


       {--------------------------------------------------------------}
       { Report Error and Halt }

       procedure Abort(s: string);
       begin
          Error(s);
          Halt;
       end;


       {--------------------------------------------------------------}
       { Report What Was Expected }

       procedure Expected(s: string);
       begin
          Abort(s + ' Expected');
       end;

       {--------------------------------------------------------------}
       { Report an Undefined Identifier }

       procedure Undefined(n: string);
       begin
          Abort('Undefined Identifier ' + n);
       end;


       {--------------------------------------------------------------}
       { Report a Duplicate Identifier }

       procedure Duplicate(n: string);
       begin
          Abort('Duplicate Identifier ' + n);
       end;


       {--------------------------------------------------------------}
       { Check to Make Sure the Current Token is an Identifier }

       procedure CheckIdent;
       begin
          if Token <> 'x' then Expected('Identifier');
       end;


       {--------------------------------------------------------------}
       { Recognize an Alpha Character }

       function IsAlpha(c: char): boolean;
       beginA*2A*
                                    - 14 -

PA2A





          IsAlpha := UpCase(c) in ['A'..'Z'];
       end;


       {--------------------------------------------------------------}
       { Recognize a Decimal Digit }

       function IsDigit(c: char): boolean;
       begin
          IsDigit := c in ['0'..'9'];
       end;


       {--------------------------------------------------------------}
       { Recognize an AlphaNumeric Character }

       function IsAlNum(c: char): boolean;
       begin
          IsAlNum := IsAlpha(c) or IsDigit(c);
       end;


       {--------------------------------------------------------------}
       { Recognize an Addop }

       function IsAddop(c: char): boolean;
       begin
          IsAddop := c in ['+', '-'];
       end;


       {--------------------------------------------------------------}
       { Recognize a Mulop }

       function IsMulop(c: char): boolean;
       begin
          IsMulop := c in ['*', '/'];
       end;


       {--------------------------------------------------------------}
       { Recognize a Boolean Orop }

       function IsOrop(c: char): boolean;
       begin
          IsOrop := c in ['|', '~'];
       end;


       {--------------------------------------------------------------}
       { Recognize a Relop }

       function IsRelop(c: char): boolean;
       beginA*2A*
                                    - 15 -

PA2A





          IsRelop := c in ['=', '#', '<', '>'];
       end;


       {--------------------------------------------------------------}
       { Recognize White Space }

       function IsWhite(c: char): boolean;
       begin
          IsWhite := c in [' ', TAB, CR, LF];
       end;


       {--------------------------------------------------------------}
       { Skip Over Leading White Space }

       procedure SkipWhite;
       begin
          while IsWhite(Look) do
             GetChar;
       end;


       {--------------------------------------------------------------}
       { Table Lookup }

       function Lookup(T: TabPtr; s: string; n: integer): integer;
       var i: integer;
           found: Boolean;
       begin
          found := false;
          i := n;
          while (i > 0) and not found do
             if s = T^[i] then
                found := true
             else
                dec(i);
          Lookup := i;
       end;


       {--------------------------------------------------------------}
       { Locate a Symbol in Table }
       { Returns the index of the entry.  Zero if not present. }

       function Locate(N: Symbol): integer;
       begin
          Locate := Lookup(@ST, n, NEntry);
       end;


       {--------------------------------------------------------------}
       { Look for Symbol in Table }A62A6
                                    - 16 -A*2A*

PA2A





       function InTable(n: Symbol): Boolean;
       begin
          InTable := Lookup(@ST, n, NEntry) <> 0;
       end;


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区成人在线视频| 亚洲超丰满肉感bbw| 91麻豆精品国产综合久久久久久 | 一区二区日韩电影| 日韩三级电影网址| 一本大道久久a久久综合婷婷 | 日日欢夜夜爽一区| 国产精品国产三级国产aⅴ原创| 欧美日韩国产123区| 91在线视频网址| 国产一区二区三区四区五区美女 | 国产精品久久久久久久久久久免费看 | 99热国产精品| 久久99热99| 午夜精品福利一区二区蜜股av| 国产精品天干天干在观线| 日韩免费一区二区三区在线播放| 欧美在线免费视屏| 99re亚洲国产精品| 粉嫩av一区二区三区| 韩国毛片一区二区三区| 日韩高清不卡一区| 午夜电影一区二区| 亚洲国产欧美在线人成| 亚洲欧美福利一区二区| 国产女主播视频一区二区| 久久久影视传媒| 亚洲精品一区二区在线观看| 欧美一区二区免费视频| 欧美另类videos死尸| 欧美日韩国产一区| 欧美图区在线视频| 欧美日韩极品在线观看一区| 精品视频色一区| 欧美性一区二区| 在线免费一区三区| 欧美在线观看一二区| 欧美在线综合视频| 欧美日韩国产小视频| 欧美日韩你懂的| 88在线观看91蜜桃国自产| 欧美日韩色一区| 欧美老女人第四色| 欧美一区二区精品在线| 日韩欧美一区二区视频| 欧美精品一区二区三区很污很色的| 欧美videofree性高清杂交| 精品三级av在线| 久久久五月婷婷| 国产精品久久毛片av大全日韩| 91蝌蚪porny九色| 美美哒免费高清在线观看视频一区二区| 日韩二区在线观看| 久久疯狂做爰流白浆xx| 国产精品一区久久久久| 99久久婷婷国产综合精品电影| 色综合久久综合网97色综合| 欧美日韩专区在线| 欧美本精品男人aⅴ天堂| 国产午夜精品美女毛片视频| 亚洲欧洲av另类| 亚洲韩国一区二区三区| 蜜桃免费网站一区二区三区| 国产又黄又大久久| a亚洲天堂av| 欧美日韩国产成人在线免费| 精品久久久久99| 亚洲欧美综合在线精品| 天堂久久久久va久久久久| 极品少妇xxxx精品少妇偷拍| 9l国产精品久久久久麻豆| 欧美人妇做爰xxxⅹ性高电影| 日韩免费成人网| 亚洲日本一区二区| 蜜桃视频一区二区三区| 99久久精品久久久久久清纯| 欧美久久久影院| 国产精品麻豆久久久| 亚洲成人免费视| 国产成人亚洲精品青草天美| 色94色欧美sute亚洲13| 日韩精品一区二区三区在线| 中文字幕日韩一区二区| 日本欧美久久久久免费播放网| 国产成人免费在线| 欧美日韩在线播放三区四区| 久久久久久久久久久久久夜| 亚洲一区免费在线观看| 高清shemale亚洲人妖| 欧美日韩电影在线| 中文字幕一区二区三| 日韩视频中午一区| 中文字幕日韩一区二区| 久久99精品国产.久久久久久 | 另类调教123区| 欧洲一区二区av| 中文字幕精品三区| 日本欧美久久久久免费播放网| 99久久99久久免费精品蜜臀| 日韩一级欧美一级| 亚洲一区二区黄色| 99视频在线精品| 国产亚洲一区二区三区四区| 午夜精品久久久久久久蜜桃app| 国产成人精品三级| 欧美一区二区三区四区久久| 亚洲激情网站免费观看| 国产一区二区精品久久91| 欧美一区二区三区电影| 一区二区三区 在线观看视频| 成人av在线一区二区| 久久久一区二区| 六月丁香综合在线视频| 精品视频全国免费看| 亚洲素人一区二区| 成人h动漫精品一区二| 欧美精品一区二区三区在线| 三级欧美在线一区| 欧美色涩在线第一页| 亚洲欧美日本韩国| 7777精品伊人久久久大香线蕉最新版| 亚洲蜜桃精久久久久久久| 国产成人精品综合在线观看 | 日韩高清电影一区| 欧美日韩一区小说| 亚洲欧美乱综合| 91视频免费观看| 亚洲欧洲av色图| 91美女在线视频| 伊人婷婷欧美激情| 91国产丝袜在线播放| 亚洲精品美国一| 一本高清dvd不卡在线观看| 最新日韩在线视频| 色综合久久久久| 亚洲精品中文在线影院| 91久久国产最好的精华液| 一区二区成人在线| 欧美精品123区| 视频一区国产视频| 欧美一级片在线看| 久久成人久久鬼色| 久久久精品影视| www.亚洲人| 一区二区三区精品| 91精品在线免费观看| 久久99热这里只有精品| 国产日韩欧美电影| 不卡的av网站| 亚洲综合小说图片| 777亚洲妇女| 国产尤物一区二区| 中文字幕在线一区免费| 色狠狠综合天天综合综合| 亚洲图片有声小说| 欧美成人乱码一区二区三区| 国产综合久久久久久鬼色| 日本一区二区三区国色天香 | 蜜桃av一区二区三区电影| 精品国产一二三区| 成人精品免费视频| 一区二区三区精密机械公司| 91精品国产一区二区| 国产麻豆精品在线| 亚洲伦理在线免费看| 欧美日韩二区三区| 国产精品亚洲午夜一区二区三区| 国产精品福利影院| 欧美精品99久久久**| 国产成人h网站| 亚洲成人第一页| 久久综合久久久久88| 99久久亚洲一区二区三区青草 | 开心九九激情九九欧美日韩精美视频电影 | 免费成人在线视频观看| 欧美激情一二三区| 欧美日韩成人综合在线一区二区 | 不卡影院免费观看| 午夜精品福利久久久| 欧美激情中文字幕| 欧美日韩国产高清一区二区| 国产成人在线视频免费播放| 亚洲国产精品一区二区久久 | 亚洲欧美国产高清| 久久综合色之久久综合| 欧美性猛交xxxx乱大交退制版| 国产一区二区三区最好精华液| 亚洲午夜一区二区三区| 亚洲国产成人私人影院tom| 91精品中文字幕一区二区三区| 99久久er热在这里只有精品15 | 蜜臀av一区二区三区| 国产精品视频一区二区三区不卡| 欧美少妇一区二区| 成人深夜视频在线观看| 美美哒免费高清在线观看视频一区二区| 17c精品麻豆一区二区免费| 日韩女同互慰一区二区| 在线观看成人免费视频| www.亚洲国产|