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

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

?? tutor12.doc

?? 計算機編譯原理教材
?? DOC
?? 第 1 頁 / 共 3 頁
字號:
       procedure GetChar;
       begin
          GetCharX;
          if Look = '{' then SkipComment;
       end;
       {--------------------------------------------------------------}


       Code this up  and  give  it  a  try.    You'll find that you can,
       indeed, bury comments anywhere you like.  The comments never even
       get into the parser proper ... every call to GetChar just returns
       any character that's NOT part of a comment.

       As a matter of fact, while  this  approach gets the job done, and
       may even be  perfectly  satisfactory  for  you, it does its job a
       little  TOO  well.    First  of all, most  programming  languages
       specify that a comment should be treated like a  space,  so  that
       comments aren't allowed  to  be embedded in, say, variable names.
       This current version doesn't care WHERE you put comments.

       Second, since the  rest  of  the  parser can't even receive a '{'
       character, you will not be allowed to put one in a quoted string.

       Before you turn up your nose at this simplistic solution, though,
       I should point out  that  as respected a compiler as Turbo Pascal
       also won't allow  a  '{' in a quoted string.  Try it.  And as for
       embedding a comment in an  identifier, I can't imagine why anyone
       would want to do such a  thing,  anyway, so the question is moot.
       For 99% of all  applications,  what I've just shown you will work
       just fine.

       But,  if  you  want  to  be  picky  about it  and  stick  to  the
       conventional treatment, then we  need  to  move  the interception
       point downstream a little further.

       To  do  this,  first change GetChar back to the way  it  was  and
       change the name called in SkipComment.  Then, let's add  the left
       brace as a possible whitespace character:


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

       function IsWhite(c: char): boolean;
       begin
          IsWhite := c in [' ', TAB, CR, LF, '{'];
       end;
       {--------------------------------------------------------------}AB2AB
                                    - 11 -A*2A*

PA2A





       Now, we can deal with comments in procedure SkipWhite:


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

       procedure SkipWhite;
       begin
          while IsWhite(Look) do begin
             if Look = '{' then
                SkipComment
             else
                GetChar;
          end;
       end;
       {--------------------------------------------------------------}


       Note  that SkipWhite is written so that we  will  skip  over  any
       combination of whitespace characters and comments, in one call.

       OK, give this one a try, too.   You'll  find  that  it will let a
       comment serve to delimit tokens.  It's worth mentioning that this
       approach also gives us the  ability to handle curly braces within
       quoted strings, since within such  strings we will not be testing
       for or skipping over whitespace.

       There's one last  item  to  deal  with:  Nested  comments.   Some
       programmers like the idea  of  nesting  comments, since it allows
       you to comment out code during debugging.  The  code  I've  given
       here won't allow that and, again, neither will Turbo Pascal.

       But the fix is incredibly easy.  All  we  need  to  do is to make
       SkipComment recursive:


       {--------------------------------------------------------------}
       { Skip A Comment Field }

       procedure SkipComment;
       begin
          while Look <> '}' do begin
             GetChar;
             if Look = '{' then SkipComment;
          end;
          GetChar;
       end;
       {--------------------------------------------------------------}


       That does it.  As  sophisticated a comment-handler as you'll ever
       need.AB2AB
                                    - 12 -A*2A*

PA2A





       MULTI-CHARACTER DELIMITERS

       That's all well and  good  for cases where a comment is delimited
       by single  characters,  but  what  about  the  cases such as C or
       standard Pascal, where two  characters  are  required?  Well, the
       principles are still the same, but we have to change our approach
       quite a bit.  I'm sure it won't surprise you to learn that things
       get harder in this case.

       For the multi-character situation, the  easiest thing to do is to
       intercept the left delimiter  back  at the GetChar stage.  We can
       "tokenize" it right there, replacing it by a single character.

       Let's assume we're using the C delimiters '/*' and '*/'.   First,
       we  need  to  go back to the "GetCharX' approach.  In yet another
       copy of your compiler, rename  GetChar to GetCharX and then enter
       the following new procedure GetChar:


       {--------------------------------------------------------------}
       { Read New Character.  Intercept '/*' }

       procedure GetChar;
       begin
          if TempChar <> ' ' then begin
             Look := TempChar;
             TempChar := ' ';
             end
          else begin
             GetCharX;
             if Look = '/' then begin
                Read(TempChar);
                if TempChar = '*' then begin
                   Look := '{';
                   TempChar := ' ';
                end;
             end;
          end;
       end;
       {--------------------------------------------------------------}


       As you can see, what this procedure does is  to  intercept  every
       occurrence of '/'.  It then examines the NEXT  character  in  the
       stream.  If the character  is  a  '*',  then  we  have  found the
       beginning  of  a  comment,  and  GetChar  will  return  a  single
       character replacement for it.   (For  simplicity,  I'm  using the
       same '{' character  as I did for Pascal.  If you were writing a C
       compiler, you'd no doubt want to pick some other character that's
       not  used  elsewhere  in C.  Pick anything you like ... even $FF,
       anything that's unique.)

       If the character  following  the  '/'  is NOT a '*', then GetChar
       tucks it away in the new global TempChar, and  returns  the  '/'.A*2A*
                                    - 13 -

PA2A





       Note that you need to declare this new variable and initialize it
       to ' '.  I like to do  things  like  that  using the Turbo "typed
       constant" construct:


            const TempChar: char = ' ';


       Now we need a new version of SkipComment:


       {--------------------------------------------------------------}
       { Skip A Comment Field }

       procedure SkipComment;
       begin
          repeat
             repeat
                GetCharX;
             until Look = '*';
             GetCharX;
          until Look = '/';
          GetChar;
       end;
       {--------------------------------------------------------------}


       A  few  things  to  note:  first  of  all, function  IsWhite  and
       procedure SkipWhite  don't  need  to  be  changed,  since GetChar
       returns the '{' token.  If you change that token  character, then
       of  course you also need to change the  character  in  those  two
       routines.

       Second, note that  SkipComment  doesn't call GetChar in its loop,
       but  GetCharX.    That  means   that  the  trailing  '/'  is  not
       intercepted and  is seen by SkipComment.  Third, although GetChar
       is the  procedure  doing  the  work,  we  can still deal with the
       comment  characters  embedded  in  a  quoted  string,  by calling
       GetCharX  instead  of  GetChar  while  we're  within  the string.
       Finally,  note  that  we can again provide for nested comments by
       adding a single statement to SkipComment, just as we did before.


       ONE-SIDED COMMENTS

       So far I've shown you  how  to  deal  with  any  kind  of comment
       delimited on the left and the  right.   That only leaves the one-
       sided comments like those in assembler language or  in  Ada, that
       are terminated by the end of the line.  In a  way,  that  case is
       easier.   The only procedure that would need  to  be  changed  is
       SkipComment, which must now terminate at the newline characters:


       {--------------------------------------------------------------}A*2A*
                                    - 14 -

PA2A





       { Skip A Comment Field }

       procedure SkipComment;
       begin
          repeat
             GetCharX;
          until Look = CR;
          GetChar;
       end;
       {--------------------------------------------------------------}


       If the leading character is  a  single  one,  as  in  the  ';' of
       assembly language, then we're essentially done.  If  it's  a two-
       character token, as in the '--'  of  Ada, we need only modify the
       tests  within  GetChar.   Either way, it's an easier problem than
       the balanced case.


       CONCLUSION

       At this point we now have the ability to deal with  both comments
       and semicolons, as well as other kinds of syntactic sugar.   I've
       shown  you several ways to deal with  each,  depending  upon  the
       convention  desired.    The  only  issue left is: which of  these
       conventions should we use in KISS/TINY?

       For the reasons that I've given as we went  along,  I'm  choosing
       the following:


        (1) Semicolons are TERMINATORS, not separators

        (2) Semicolons are OPTIONAL

        (3) Comments are delimited by curly braces

        (4) Comments MAY be nested


       Put the code corresponding to these cases into your copy of TINY.
       You now have TINY Version 1.2.

       Now that we  have  disposed  of  these  sideline  issues,  we can
       finally get back into the mainstream.  In  the  next installment,
       we'll talk  about procedures and parameter passing, and we'll add
       these important features to TINY.  See you then.


       *****************************************************************
       *                                                               *
       *                        COPYRIGHT NOTICE                       *
       *                                                               *
       *   Copyright (C) 1989 Jack W. Crenshaw. All rights reserved.   *A*2A*
                                    - 15 -

PA2A





       *                                                               *
       *****************************************************************AU2AU
AS2AS






                                    - 16 -A*2A*
@

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品欧美一区二区三区| 一二三区精品视频| 亚洲欧美区自拍先锋| 丝袜亚洲另类丝袜在线| 成人黄色网址在线观看| 欧美一区中文字幕| 亚洲精品国产a| 国产成人av电影| 欧美成人a∨高清免费观看| 一区二区久久久| 成人99免费视频| 国产亚洲欧洲一区高清在线观看| 亚洲精选一二三| 国产99久久久久久免费看农村| 日韩一区二区三区精品视频| 中文字幕亚洲综合久久菠萝蜜| 蜜臀精品一区二区三区在线观看| 色综合视频在线观看| 国产欧美精品日韩区二区麻豆天美 | 欧美精品精品一区| 亚洲日本在线a| 成人福利视频在线| 国产欧美日韩久久| 国产精品综合av一区二区国产馆| 日韩欧美久久久| 日本美女一区二区三区| 欧美日韩大陆一区二区| 亚洲aaa精品| 欧美日韩精品免费| 偷拍日韩校园综合在线| 欧美日韩精品一区二区三区 | 久久综合中文字幕| 蜜桃一区二区三区在线| 日韩一区二区高清| 久久激情综合网| 日韩一区二区电影在线| 老司机午夜精品| 精品va天堂亚洲国产| 国产乱码一区二区三区| 国产精品日韩成人| 成人教育av在线| 一区二区三区在线视频观看58| 色哟哟国产精品| 亚洲二区在线视频| 91精品国产手机| 韩国欧美一区二区| 国产精品久久久久久久久动漫 | 欧美一区二区三区四区久久 | 波多野结衣中文一区| 亚洲视频狠狠干| 在线免费亚洲电影| 日韩在线一区二区三区| 日韩免费观看高清完整版| 国产成人av电影在线播放| 中文字幕在线观看一区| 欧美日韩黄色一区二区| 精品在线免费视频| 国产精品久久久久aaaa樱花| 91麻豆视频网站| 美女网站色91| 国产精品久久久99| 欧美色老头old∨ideo| 狠狠色丁香久久婷婷综| 成人免费在线观看入口| 欧美一级艳片视频免费观看| 国产精品羞羞答答xxdd| 亚洲国产综合人成综合网站| 欧美tickling网站挠脚心| av成人免费在线| 日韩av中文字幕一区二区三区| 久久久久久久久岛国免费| 在线观看网站黄不卡| 老司机精品视频在线| 国产欧美日韩另类一区| 91麻豆精品国产91久久久资源速度 | 一本一道波多野结衣一区二区| 日本网站在线观看一区二区三区 | 亚洲国产精品一区二区www | 亚洲免费观看视频| 欧美大白屁股肥臀xxxxxx| 日本精品免费观看高清观看| 韩国午夜理伦三级不卡影院| 亚洲一区二区精品3399| 国产欧美日韩亚州综合| 91精品国产欧美一区二区18 | 亚洲男同性视频| 欧美精品一区二区三区一线天视频| 日本道在线观看一区二区| 国产91精品久久久久久久网曝门| 日本最新不卡在线| 亚洲一区二区精品久久av| 欧美国产精品中文字幕| 日韩欧美激情一区| 欧美丰满高潮xxxx喷水动漫| 色综合久久88色综合天天免费| 国产精品亚洲一区二区三区在线| 丝袜诱惑制服诱惑色一区在线观看| 亚洲色图欧美偷拍| 亚洲国产精品成人综合色在线婷婷 | 精品一区二区免费视频| 性欧美疯狂xxxxbbbb| 亚洲精品国产视频| 亚洲情趣在线观看| 国产精品久久久久三级| 欧美激情综合在线| 国产欧美一区二区精品秋霞影院 | 亚洲国产精品精华液ab| 日韩午夜在线观看视频| 欧美日韩精品一区二区天天拍小说 | 日本一二三四高清不卡| 久久久亚洲精品石原莉奈| 精品国内二区三区| 精品国产一二三区| 欧美xingq一区二区| 日韩丝袜美女视频| 精品理论电影在线| 欧美一区午夜视频在线观看 | 亚洲男人都懂的| 亚洲欧美激情一区二区| 日韩理论片在线| 亚洲精选一二三| 午夜精品在线看| 麻豆国产欧美日韩综合精品二区 | 日韩精品国产欧美| 免费观看91视频大全| 精品午夜久久福利影院| 国产一区二区不卡在线| 成人网在线免费视频| 99久久久免费精品国产一区二区| 91在线观看高清| 欧美日韩的一区二区| 日韩精品一区二区三区视频在线观看 | 国产精品亚洲成人| 东方欧美亚洲色图在线| 91麻豆精品一区二区三区| 欧美亚洲动漫精品| 日韩一区二区精品在线观看| 欧美精品一区二区三| 国产精品国模大尺度视频| 夜色激情一区二区| 麻豆精品国产传媒mv男同| 成人午夜av电影| 欧美日产在线观看| 久久久久久亚洲综合影院红桃| 蜜桃91丨九色丨蝌蚪91桃色| 久久99精品一区二区三区| 成人短视频下载| 3751色影院一区二区三区| 国产午夜精品一区二区| 亚洲风情在线资源站| 国产精品 日产精品 欧美精品| 91猫先生在线| 精品国产sm最大网站| 亚洲欧美另类在线| 国产又黄又大久久| 欧美在线观看一区| 国产欧美一区二区三区在线看蜜臀| 国产成+人+日韩+欧美+亚洲| 色久综合一二码| 国产网站一区二区| 日韩高清在线电影| 色综合色狠狠天天综合色| 精品电影一区二区三区| 亚洲五码中文字幕| 成人91在线观看| 久久婷婷国产综合精品青草| 亚洲aⅴ怡春院| 99精品偷自拍| 久久欧美一区二区| 日韩电影免费在线| 欧洲精品在线观看| 国产女人18毛片水真多成人如厕| 日韩黄色小视频| 一本一道久久a久久精品| 国产日韩影视精品| 韩日欧美一区二区三区| 91精品国产手机| 午夜视频一区在线观看| 一本到高清视频免费精品| 欧美激情一二三区| 国产精品一级黄| 精品日本一线二线三线不卡| 婷婷成人激情在线网| 欧美综合久久久| 一区二区在线免费观看| 91亚洲资源网| 国产精品亲子伦对白| 国内成人免费视频| 精品蜜桃在线看| 精品亚洲国产成人av制服丝袜| 67194成人在线观看| 亚洲成人动漫在线免费观看| 在线观看欧美精品| 一区二区三区四区在线免费观看| 不卡的av电影在线观看| 国产精品久久久久影院色老大 | 中文在线一区二区| 国产盗摄一区二区三区| 久久亚洲一级片| 国产91在线看|