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

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

?? guide.tex

?? PL/0源碼
?? TEX
?? 第 1 頁 / 共 2 頁
字號:
\documentstyle[guide,sortbib,11pt]{article}\thispagestyle{empty}\begin{document}\title{A Guide to the Rochester PL/0 Compiler    \thanks{Copyright \copyright\ 1994--1999 Michael L. Scott}}\author{Michael L. Scott\\[2ex]Computer Science Department\\University of Rochester}\date{Revised July 1999}\maketitleRochester's PL/0 compiler attempts to illustrate thecharacteristics of a ``real'' compiler on a modest scale.It runs on Unix systems and generates MIPS~I assembler.Unlike many pedagogicalcompilers, it has multiple passes, employs a table-driven scanner andparser, performs high-quality syntax error repair, and issueswell-formatted diagnostic messages.  It does notinclude any significant code improvement (optimization), though thisis planned for the future.  For now, it generates very poor code.\section{The PL/0 Language}The PL/0 compiler is small mainly because it compiles a very smalllanguage.  PL/0 was defined by Niklaus Wirth (the inventor of Pascaland Modula) as part of an extended example in his 1976 book, {\it  Algorithms + Data Structures = Languages\/} (pp.\ 307--347).  It isessentially a subset of Pascal, with nested procedures, but withoutparameters; functions; case, for, or repeat statements; else clauses;or any types other than integer.  The PL/0 compiler implements thelanguage exactly as defined by Wirth, with the addition of primitiveI/O.\subsection{Tokens}Case is insignificant in PL/0.  The PL/0 tokens are:\begin{itemize}\item keywords \\  {\tt begin}, {\tt call}, {\tt const}, {\tt do}, {\tt    end}, {\tt if}, {\tt odd}, {\tt procedure}, {\tt then}, {\tt var},  {\tt while}.\item identifiers \\Any other string of letters and digits beginning  with a letter.\item numbers \\  A string of (decimal) digits.\item operators, relations, and punctuation marks \\   {\tt +}, {\tt -}, {\tt *}, {\tt /}, {\tt =}, {\tt \#}, {\tt <}, {\tt    >}, {\tt <=}, {\tt >=}, {\tt (}, {\tt )}, {\tt ,}, {\tt ;}, {\tt    .}, {\tt :=}.\end{itemize}\subsection{Syntax}In the EBNF below,{\tt typewriter font} is used for tokens and {\em italicized font\/}is used for non-terminals.  Bold parentheses areused for grouping.  The vertical bar is used for alternation (``or'').Bold curly brackets indicate an optional item.  A Kleene star (\kstar)indicates that the preceding item can be repeated zero or more times.Epsilon (\nothing) denotes the empty string.White space (spaces, tabs, and newlines) is required in PL/0 programs toseparate characters that could otherwise be considered part of the sametoken.  Otherwise, input is ``free format'': indentation and additionalwhite space are irrelevant.\begin{grammar}\item[program] block \lit{.}\item[block]    \lcurly \lit{CONST} \lit{identifier} \lit{=} \lit{number}        \lparen \lit{,} \lit{identifier} \lit{=} \lit{number}        \rparen\kstar\ \lit{;} \rcurly\\    \lcurly \lit{VAR} \lit{identifier}        \lparen \lit{,} \lit{identifier} \rparen\kstar\ \lit{;} \rcurly\\    \lparen \lit{PROCEDURE} \lit{identifier} \lit{;}        block \lit{;} \rparen\kstar\\    statement\item[statement]    \lit{identifier} \lit{:=} expression\\    \alt \lit{CALL} \lit{identifier}\\    \alt \lit{BEGIN} statement \lparen \lit{;}        statement \rparen\kstar\ \lit{END}\\    \alt \lit{IF} condition \lit{THEN} statement\\    \alt \lit{WHILE} condition \lit{DO} statement\\    \alt \nothing\item[expression]    fragment \lparen        \lparen \lit{+} \alt \lit{-} \alt \lit{*} \alt \lit{/} \rparen        fragment \rparen\kstar\item[fragment]    \lit{identifier}    \alt \lit{number}    \alt \lparen {\tt +} \alt {\tt -} \rparen fragment    \alt \lit{(} expression \lit{)}\item[condition]    \lit{ODD} expression    \alt expression        \lparen \lit{=} \alt \lit{\#} \alt \lit{<} \alt \lit{>}        \alt \lit{<=} \alt \lit{>=} \rparen expression\end{grammar}\subsection{Semantics}PL/0 is simple enough that semantic issues generally amount to commonsense.  The checks performed by the PL/0 compiler are listed insection~\ref{sec-semantic-checks} below.  Constants, variables, andprocedures declared within a block are local to that block, and cannotbe referenced outside it.  The arithmetic operators associateleft-to-right.  Precedence is as follows: unary \code{+} and \code{-}group mosttightly, followed by binary \code{*} and \code{/},and then binary \code{+} and \code{-}.Conditions (comparisons) are above the level of expressions in thegrammar, effectively giving them the lowest precedence of all.  Thesymbol \code{\#} means ``not equal''.Two special ``variables'' are pre-defined:  The variable \code{input},when read, yields the next integer from the standard input stream.The variable \code{output}, when written, produces an integer (withtrailing linefeed) on the standard output stream.\section{Tools}Construction and operation of the PL/0 compiler are assisted by anumber of tools, as illustrated in figure~\ref{fig-structure}.\begin{figure}\centerline{%\epsfysize 6in\epsfbox{structure.eps}}\caption{Construction and operation of the PL/O compiler.}\label{fig-structure}\end{figure}\subsection{Scanner and Parser Generators}{\tt Scangen} and {\tt fmq} are scanner and parser generators,respectively.  They were written by students of Charles Fischer at theUniversity of Wisconsin around about 1980, and are described in detail inappendices B, C, and E of Fischer and LeBlanc's book, {\it Crafting aCompiler}.\footnote{Note that {\tt fmq} isreferred to as {\tt LLgen} in the book.  In the standard tool distribution,{\tt llgen} is a version of {\tt fmq} without error repair.}{\tt Scangen} takes as input a set of regular expressions, and produces DFAtables (file {\tt tables}) to drive a scanner for the tokens described bythe regular expressions.  {\tt Fmq} takes as input a context free grammar,and produces tables (file {\tt ptablebin}) to drive an LL(1) parser forthat grammar.  {\tt Fmq} takes its name from the Fischer/Milton/Quiringsyntax error repair algorithm, for which it also generates tables (file{\tt etablebin}).Both {\tt scangen} and {\tt fmq} produce numeric tables, in contrast to theC code produced by Unix's standard {\tt lex} and {\tt yacc}.  ({\ttScangen} produces tables in {\sc ascii}.{\tt Fmq} can produce tables in either {\sc ascii} or binary; the PL/0compiler uses the binary option.)  These tablesare turned into initialized data structures by the tools {\tt makescan} and{\tt makeparse}.  The C++ output files, {\tt scantab.cc} and {\ttparsetab.cc} are then compiled by the GNU C++ compiler, {\tt g++}, with theother C++ source files.  The files {\tt scantab.h} and {\tt parsetab.h}contain definitions for variables exported by {\tt scantab.cc} and {\ttparsetab.cc} respectively.\subsection{Mungegrammar}Several source files for the PL/0 compiler contain redundant informationabout the PL/0 syntax.  These include the input to {\tt scangen} and {\ttfmq} ({\tt scangen.in} and {\tt fmq.in}, respectively), semantic actionroutine numbers (switch statement labels in {\tt actions.cc}), anddeclarations of token numbers used in semantic analysis ({\tt tokens.h}).To free the programmer from the need to keep these files mutuallyconsistent, they are all generated automatically by a preprocessor named{\tt mungegrammar}.  The input to {\tt mungegrammar} is roughly a merger ofthe input expected by {\tt scangen} and {\tt fmq}, with some syntacticchanges necessary to make the merger work and to simplify the specificationof long productions and action routines.  The {\tt grammar} filedistributed with the PL/0 compiler contains extensive self-descriptivecomments.  Read them carefully before making any changes.  Principalfeatures include the following:\begin{itemize}\item Ada-style (double dash through end-of-line) comments are allowed  anywhere in the {\tt grammar} file.\item Tokens are declared in a single list that includes alphabetic token  names, optional character string images (for error messages), insertion  and deletion costs (for syntax error repair), and lexical definitions  (regular expressions).  A token may have {\em variants}, which will all  appear the same to the parser, but may be distinguished by semantic  action routines.  Variants are output as tokens with matching major token  numbers in {\tt scangen.in}.  Note the following limitations: the semicolon that terminates a token  definition must be the last thing on its input line (other than white  space or a comment).  Similarly, the comma that separates token variants  must be the last thing (ther than white space or a comment) on its line,  and a comma within a regular expression must {\em not\/} be the last thing  (other than white space or a comment) on its line.\item Two special token names {\em must\/} appear: \lit{IDENT} and  \lit{SPACE}.  Reserve words must match the lexical definition of  \lit{IDENT}, but appear in the token list with a double-quoted character  string definition, rather than a regular expression.  \lit{SPACE} is the  only token recognized by the scanner but not passed to the parser.\item Semantic action routines can be embedded directly in productions,  delimited by double square brackets (\verb|[[|\ldots\verb|]]|).  The  code in {\tt actions.cc} will  look better if you leave the square brackets on lines by themselves, but  this is not required.\item Second and subsequent lines of multi-line productions do not  begin with ellipsis (\lit{\dots}), as they do in {\tt fmq.in}.  First  lines of productions, however, must begin in column 1, and second and  subsequent lines must not do so.\end{itemize}In addition to generating {\tt scangen.in} and {\tt fmq.in}, {\ttmungegrammar} collects action routines into the arms of a large switchstatement, which it then embeds in a procedure named {\tt do\_action} infile {\tt actions.cc}.  The parser calls {\tt do\_action} when it reachesthe appropriate point in the right-hand side of a production.  Finally,{\tt mungegrammar} generates file {\tt tokens.h}, containing a definition({\tt \#define}) for every major and minor token number.  Major tokennumbers distinguish non-terminals in the context-free grammar understood bythe parser.  Minor token numbers distinguish token variants.  For example,in PL/0 the multiplication and division operators play identical roles inthe grammar, and are therefore defined as variants of a single token namedMULOP.  {\tt Tokens.h} defines the symbol {\tt MAJ\_MULOP} to contain themajor token number for MULOP.  The two variants of MULOP are named TIMESand SLASH, with minor token numbers {\tt MIN\_TIMES} and {\tt MIN\_SLASH},respectively in {\tt tokens.h}.  The character string image for MULOP is``*'', which the syntax error repair routines will use in error messageswhen they insert a MULOP.  If an image is not provided, the repair routineswill use the token name.With the exceptions noted above, the token definitions (regular expressions)and productions in the {\tt grammar} file conform to the syntax expected by{\tt scangen} and {\tt fmq}.  One potentially confusing feature is the``\{TOSS\}'' annotation in regular expressions: it indicates that thepreceding character will not be important to the rest of the compiler, andmay be discarded by the scanner.  In general, characters of tokens thatrepresent only a single possible string (e.g.\ \lit{:=} or \lit{IF}) cansafely be tossed; characters of tokens for which there are many possiblestrings (e.g.\ \lit{IDENT} or \lit{NUMBER}) should not be tossed.Sometimes (e.g.\ in character strings, which are not present in PL/0 asoriginally defined) it makes sense to toss some characters (the quotemarks) and save the rest.\subsection{RCS}I strongly recommend that you use RCS (the Revision Control System, developedby Walter Tichy of Purdue University) to manage your compiler source.As you make changes over time, RCS can be used to keep track of all the oldversions of all your files, in an organized and highly space-efficient way.Read the man pages for {\tt ci}, {\tt co}, {\tt rcs}, {\tt rlog}, and {\tt rcsdiff}, in that order.\subsection{The {\tt Makefile}}Creation of the PL/0 compiler is automated by a {\tt Makefile}.You should read the {\tt Makefile} and figure out how it works.You should also learn to use the extra rules it provides, in addition to{\tt make pl0}.In particular, you will want to use the following:\begin{description}\item[{\tt make depend}]This rule modifies the {\tt Makefile} itself to incorporate knowledge ofwhich files {\tt \#include} which others.If you add or alter inclusions anywhere in the compiler, you will want tore-run {\tt make depend}.\item [{\tt make tags}]This rule creates cross-reference indices (files {\tt tags} and {\ttTAGS}), which are used by editors such as {\tt vi} and {\tt emacs} to assistin source perusal.Typing the appropriate command to the editorwill cause the cursor to move to the file andline at which the identifier is declared.In {\tt vi}, the command is {\tt :ta tag\_name},or control-\verb|]| when the cursor is positioned on the identifier.In {\tt emacs}, the command is meta-{\tt x find-tag} {\em tag-name},or meta-{\tt .} {\em tag-name}.If the cursor is on or near an identifier, {\tt emacs} will supply itas a default when prompting for {\em tag-name}.To pop back to the previous tag in {\tt vi}, type control-{\tt t}.To pop back in {\tt emacs}, type meta-{\tt-} meta-{\tt x find-tag},or meta-{\tt -} meta-{\tt .}.Note that the algorithm used to build the tag cross-reference database isheuristic; tags work most of the time but not always.{\tt Vi} keeps track of a single location for each tag.{\tt Emacs} keeps track of several possibilities, and jumps to the most``likely'' one first. If you don't like that one and want to try thenext, type control-{\tt u} meta-{\tt .}.In addition to creating cross-references for identifiers,{\tt make tags} creates cross-ref\-er\-ences for action routines, grammarsymbols, and production numbers.Tag search for a grammar symbol moves the cursor to a production inthe grammar in which that symbol appears on the left hand side.Tag search for {\tt R37} (and similarly {\tt R$n$} for any appropriate $n$) moves to the 37th ($n$th) action routine.This is useful for finding syntax errors in action routines, since the C++compiler produces error messages for the file {\tt actions.cc}, not for{\tt grammar}.Tag search for {\tt P37} (in general P$n$) moves to the 37th ($n$th)production inthe grammar. This is useful for debugging the parser, and shouldn't benecessary unless you break something.\item[{\tt make sources}]This rule simply prints the names of all the source files required to buildthe compiler.It is useful when embedded in backward quotes in the argument lists of otherprograms.For example, \begin{verbatim}    grep foobar `make sources`\end{verbatim}will find all occurrences of {\tt foobar} in the source ofthe compiler.  Similarly, \begin{verbatim}    ls -l `make sources` | grep "^\\-rw"\end{verbatim}will list all source files that are currently writable.If you use RCS with strict locking, these will be the files that you havechecked out to make modifications.If you don't want the long version of the listing,\begin{verbatim}    ls -l `make sources` | grep "^\\-rw" | awk '{print $8}'\end{verbatim}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩在线a电影| 国产在线播放一区三区四| 精品国产一区二区三区久久久蜜月 | 国产成人av影院| 亚洲一区二区三区小说| 欧美成人一区二区三区片免费| 91麻豆免费视频| 激情国产一区二区| 亚洲第一综合色| 一区视频在线播放| wwwwxxxxx欧美| 337p亚洲精品色噜噜噜| 色噜噜久久综合| 成人h精品动漫一区二区三区| 蜜臀久久99精品久久久画质超高清| 最近中文字幕一区二区三区| 精品国产一区二区三区四区四 | 国产精品乱码久久久久久| 宅男噜噜噜66一区二区66| 97国产一区二区| 国产黄色成人av| 狠狠色丁香九九婷婷综合五月| 日韩高清不卡一区二区三区| 一级特黄大欧美久久久| 国产色婷婷亚洲99精品小说| 欧美www视频| 日韩欧美国产wwwww| 欧美精品久久久久久久多人混战| 色又黄又爽网站www久久| 波多野结衣中文字幕一区| 国产99久久久国产精品| 国产一区二区三区免费播放 | 麻豆精品视频在线观看| 日韩国产精品久久久| 亚洲午夜一区二区| 一区二区三区四区在线免费观看 | 成人avav在线| av不卡在线播放| 成人av高清在线| 99久久精品国产毛片| 成人涩涩免费视频| av成人老司机| 91色乱码一区二区三区| 91麻豆自制传媒国产之光| 色综合久久久久网| 在线亚洲高清视频| 在线一区二区三区四区五区 | 欧美一卡二卡在线| 日韩一区二区三区在线| 欧美一级艳片视频免费观看| 欧美一区二区三区四区久久| 欧美xingq一区二区| 久久久精品天堂| 欧美国产日本视频| 国产精品福利av| 亚洲综合色在线| 日日噜噜夜夜狠狠视频欧美人| 五月激情丁香一区二区三区| 久久福利视频一区二区| 国产v日产∨综合v精品视频| 成人av网址在线观看| 欧美色视频在线观看| 91精品国产福利在线观看| 日韩精品一区二区三区四区| 国产亚洲精品7777| 亚洲欧美成人一区二区三区| 日精品一区二区三区| 国产在线精品一区二区三区不卡| 波多野洁衣一区| 精品视频一区三区九区| 精品免费日韩av| 中文字幕一区在线观看| 午夜久久久久久久久久一区二区| 久久99精品国产麻豆不卡| 成人黄色免费短视频| 欧美久久久久免费| 久久精品欧美日韩精品| 中文字幕在线不卡| 青青国产91久久久久久| 粉嫩一区二区三区性色av| 国产亚洲女人久久久久毛片| 最新日韩在线视频| 强制捆绑调教一区二区| 国产成人在线免费观看| 欧美午夜理伦三级在线观看| 日韩美女一区二区三区| 亚洲欧洲av在线| 日韩国产欧美视频| 91丨九色丨黑人外教| 日韩视频国产视频| 亚洲日本乱码在线观看| 美美哒免费高清在线观看视频一区二区| 国产成人精品aa毛片| 欧美在线你懂的| 国产日韩欧美综合一区| 日本不卡一区二区三区高清视频| 成人99免费视频| 精品成人一区二区| 午夜一区二区三区视频| 波多野结衣中文一区| 欧美xxxx在线观看| 亚洲午夜在线电影| 成人app网站| 久久久综合网站| 日韩成人一区二区三区在线观看| av一区二区三区在线| 26uuu久久天堂性欧美| 亚洲成人资源在线| 91网址在线看| 欧美国产精品专区| 精品制服美女久久| 在线播放日韩导航| 亚洲一区二区三区四区在线| 成人av午夜电影| 久久亚洲精精品中文字幕早川悠里 | 91精品国产欧美一区二区| 亚洲最新视频在线观看| 成人影视亚洲图片在线| 欧美不卡在线视频| 日本欧美加勒比视频| 欧美无乱码久久久免费午夜一区| 国产精品毛片大码女人| 国产揄拍国内精品对白| 精品美女在线观看| 美女被吸乳得到大胸91| 欧美精品免费视频| 日韩激情在线观看| 91麻豆精品久久久久蜜臀| 亚洲chinese男男1069| 在线视频一区二区三区| 丁香激情综合五月| 欧美韩国日本不卡| 成人开心网精品视频| 国产欧美精品在线观看| 成人午夜激情在线| 中文字幕一区二| 91首页免费视频| 亚洲视频一区二区在线| 99精品欧美一区二区三区小说| 国产精品女主播av| 不卡电影免费在线播放一区| 中文字幕一区二区视频| www.欧美日韩| 亚洲日本在线a| 色噜噜久久综合| 午夜电影一区二区三区| 日韩一级完整毛片| 久久av老司机精品网站导航| 欧美xxxx在线观看| 丁香五精品蜜臀久久久久99网站 | 午夜国产精品一区| 欧美一区在线视频| 久久国产精品第一页| 国产婷婷一区二区| 97se亚洲国产综合在线| 亚洲最大成人综合| 91精品久久久久久久91蜜桃| 麻豆高清免费国产一区| 久久精品日韩一区二区三区| 99久久久久久99| 一区二区三区蜜桃网| 91麻豆精品国产91| 国产美女精品人人做人人爽| 亚洲欧洲日本在线| 欧美日韩在线播放一区| 麻豆精品精品国产自在97香蕉| 国产亚洲成av人在线观看导航 | 黄页视频在线91| 国产精品青草久久| 欧美视频精品在线| 国精品**一区二区三区在线蜜桃| 国产精品久久久久久久第一福利 | 欧美日韩午夜精品| 经典三级视频一区| 国产精品福利影院| 欧美一区二区三区在线看| 国产91在线|亚洲| 亚洲午夜国产一区99re久久| 精品国产免费一区二区三区四区| 成人一二三区视频| 三级精品在线观看| 中文av一区二区| 欧美片在线播放| 成人夜色视频网站在线观看| 亚洲va国产天堂va久久en| 国产亚洲精品资源在线26u| 欧美日韩你懂得| 成人高清视频在线| 日韩精品成人一区二区在线| 国产精品久久久久影院亚瑟| 91精品国产综合久久久久| 成人av电影观看| 激情综合网天天干| 日日摸夜夜添夜夜添亚洲女人| 亚洲国产精品成人综合| 91精品国产入口| 色哟哟国产精品| 国产91精品入口| 免费看日韩a级影片| 亚洲综合激情网|