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

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

?? tply.tex

?? 編譯原理基礎(chǔ)
?? TEX
?? 第 1 頁 / 共 5 頁
字號:
state 2:

        expr : '(' _ expr ')'

        '('     shift 2
        NUM     shift 3
        .       error

        expr    goto 6

state 3:

        expr : NUM _    (4)

        .       reduce 4

state 4:

        expr : expr '*' _ expr

        '('     shift 2
        NUM     shift 3
        .       error

        expr    goto 7

state 5:

        expr : expr '+' _ expr

        '('     shift 2
        NUM     shift 3
        .       error

        expr    goto 8

state 6:

        expr : '(' expr _ ')'
        expr : expr _ '+' expr
        expr : expr _ '*' expr

        ')'     shift 9
        '*'     shift 4
        '+'     shift 5
        .       error

state 7:

        expr : expr '*' expr _  (2)
        expr : expr _ '+' expr
        expr : expr _ '*' expr

        .       reduce 2

state 8:

        expr : expr '+' expr _  (1)
        expr : expr _ '+' expr
        expr : expr _ '*' expr

        '*'     shift 4
        $end    reduce 1
        ')'     reduce 1
        '+'     reduce 1
        .       error

state 9:

        expr : '(' expr ')' _   (3)

        .       reduce 3
\end{verbatim}\end{quote}

Each state of the parser corresponds to a certain prefix of the input
which has already been seen. The parser description lists the grammar
rules wich are parsed in each state, and indicates the portion of each
rule which has already been parsed by an underscore. In state 0, the
start state of the parser, the parsed rule is
\begin{quote}\begin{verbatim}
        $accept : expr $end
\end{verbatim}\end{quote}

This is not an actual grammar rule, but a starting rule automatically
added by TP Yacc. In general, it has the format
\begin{quote}\begin{verbatim}
        $accept : X $end
\end{verbatim}\end{quote}
where \verb"X" is the start nonterminal of the grammar, and \verb"$end" is
a pseudo token denoting end-of-input (the \verb"$end" symbol is used by the
parser to determine when it has successfully parsed the input).

The description of the start rule in state 0,
\begin{quote}\begin{verbatim}
        $accept : _ expr $end
\end{verbatim}\end{quote}
with the underscore positioned before the \verb"expr" symbol, indicates that
we are at the beginning of the parse and are ready to parse an expression
(nonterminal \verb"expr").

The parser maintains a stack to keep track of states visited during the
parse. There are two basic kinds of actions in each state: {\em shift\/},
which reads an input symbol and pushes the corresponding next state on top of
the stack, and {\em reduce\/} which pops a number of states from the stack
(corresponding to the number of right-hand side symbols of the rule used
in the reduction) and consults the {\em goto\/} entries of the uncovered
state to find the transition corresponding to the left-hand side symbol of the
reduced rule.

In each step of the parse, the parser is in a given state (the state on
top of its stack) and may consult the current {\em lookahead symbol\/}, the
next symbol in the input, to determine the parse action -- shift or reduce --
to perform. The parser terminates as soon as it reaches state 1 and reads
in the endmarker, indicated by the {\em accept\/} action on \verb"$end" in
state 1.

Sometimes the parser may also carry out an action without inspecting the
current lookahead token. This is the case, e.g., in state 3 where the
only action is reduction by rule 4:
\begin{quote}\begin{verbatim}
        .       reduce 4
\end{verbatim}\end{quote}

The default action in a state can also be {\em error\/} indicating that any
other input represents a syntax error. (In case of such an error the
parser will start syntactic error recovery, as described in Section
{\em Error Handling\/}.)

Now let us see how the parser responds to a given input. We consider the
input string \verb"2+5*3" which is presented to the parser as the token
sequence:
\begin{quote}\begin{verbatim}
   NUM + NUM * NUM
\end{verbatim}\end{quote}

Table \ref{tab2} traces the corresponding actions of the parser. We also
show the current state in each move, and the remaining states on the stack.

\begin{table*}\centering
   \begin{tabular}{l|l|l|p{8cm}}
      \hline\hline
      {\sc State}& {\sc Stack}& {\sc Lookahead}& {\sc Action}\\
      \hline
0 &               &    \verb"NUM"    &    shift state 3\\
3 &     0         &                  &    reduce rule 4 (pop 1 state, uncovering state
                                          0, then goto state 1 on symbol \verb"expr")\\
1 &     0         &    \verb"+"      &    shift state 5\\
5 &     1 0       &    \verb"NUM"    &    shift state 3\\
3 &     5 1 0     &                  &    reduce rule 4 (pop 1 state, uncovering state
                                          5, then goto state 8 on symbol \verb"expr")\\
8 &     5 1 0     &    \verb"*"      &    shift 4\\
4 &     8 5 1 0   &    \verb"NUM"    &    shift 3\\
3 &     4 8 5 1 0 &                  &    reduce rule 4 (pop 1 state, uncovering state
                                          4, then goto state 7 on symbol \verb"expr")\\
7 &     4 8 5 1 0 &                  &    reduce rule 2 (pop 3 states, uncovering state
                                          5, then goto state 8 on symbol \verb"expr")\\
8 &     5 1 0     &    \verb"$end"   &    reduce rule 1 (pop 3 states, uncovering state
                                          0, then goto state 1 on symbol \verb"expr")\\
1 &     0         &    \verb"$end"   &    accept\\
      \hline
   \end{tabular}
   \caption{Parse of \protect\verb"NUM + NUM * NUM".}
   \label{tab2}
\end{table*}

It is also instructive to see how the parser responds to illegal inputs.
E.g., you may try to figure out what the parser does when confronted with:
\begin{quote}\begin{verbatim}
   NUM + )
\end{verbatim}\end{quote}
or:
\begin{quote}\begin{verbatim}
   ( NUM * NUM
\end{verbatim}\end{quote}

You will find that the parser, sooner or later, will always run into an
error action when confronted with errorneous inputs. An LALR parser will
never shift an invalid symbol and thus will always find syntax errors as
soon as it is possible during a left-to-right scan of the input.

TP Yacc provides a debugging option (\verb"/d") that may be used to trace
the actions performed by the parser. When a grammar is compiled with the
\verb"/d" option, the generated parser will print out the actions as it
parses its input.

\subsection*{Ambigious Grammars}

There are situations in which TP Yacc will not produce a valid parser for
a given input language. LALR(1) parsers are restricted to one-symbol
lookahead on which they have to base their parsing decisions. If a
grammar is ambigious, or cannot be parsed unambigiously using one-symbol
lookahead, TP Yacc will generate parsing conflicts when constructing the
parse table. There are two types of such conflicts: {\em shift/reduce
conflicts\/} (when there is both a shift and a reduce action for a given
input symbol in a given state), and {\em reduce/reduce\/} conflicts (if
there is more than one reduce action for a given input symbol in a given
state). Note that there never will be a shift/shift conflict.

When a grammar generates parsing conflicts, TP Yacc prints out the number
of shift/reduce and reduce/reduce conflicts it encountered when constructing
the parse table. However, TP Yacc will still generate the output code for the
parser. To resolve parsing conflicts, TP Yacc uses the following built-in
disambiguating rules:

\begin{itemize}
   \item
      in a shift/reduce conflict, TP Yacc chooses the shift action.
   \item
      in a reduce/reduce conflict, TP Yacc chooses reduction of the first
      grammar rule.
\end{itemize}

The shift/reduce disambiguating rule correctly resolves a type of
ambiguity known as the ``dangling-else ambiguity'' which arises in the
syntax of conditional statements of many programming languages (as in
Pascal):

\begin{quote}\begin{verbatim}
%token IF THEN ELSE
%%
stmt : IF expr THEN stmt
     | IF expr THEN stmt ELSE stmt
     ;
\end{verbatim}\end{quote}

This grammar is ambigious, because a nested construct like
\begin{quote}\begin{verbatim}
   IF expr-1 THEN IF expr-2 THEN stmt-1
     ELSE stmt-2
\end{verbatim}\end{quote}
can be parsed two ways, either as:
\begin{quote}\begin{verbatim}
   IF expr-1 THEN ( IF expr-2 THEN stmt-1
     ELSE stmt-2 )
\end{verbatim}\end{quote}
or as:
\begin{quote}\begin{verbatim}
   IF expr-1 THEN ( IF expr-2 THEN stmt-1 )
     ELSE stmt-2
\end{verbatim}\end{quote}

The first interpretation makes an \verb"ELSE" belong to the last unmatched
\verb"IF" which also is the interpretation chosen in most programming
languages. This is also the way that a TP Yacc-generated parser will parse
the construct since the shift/reduce disambiguating rule has the effect of
neglecting the reduction of \verb"IF expr-2 THEN stmt-1"; instead, the parser
will shift the \verb"ELSE" symbol which eventually leads to the reduction of
\verb"IF expr-2 THEN stmt-1 ELSE stmt-2".

The reduce/reduce disambiguating rule is used to resolve conflicts that
arise when there is more than one grammar rule matching a given construct.
Such ambiguities are often caused by ``special case constructs'' which may be
given priority by simply listing the more specific rules ahead of the more
general ones.

For instance, the following is an excerpt from the grammar describing the
input language of the UNIX equation formatter EQN:

\begin{quote}\begin{verbatim}
%right SUB SUP
%%
expr : expr SUB expr SUP expr
     | expr SUB expr
     | expr SUP expr
     ;
\end{verbatim}\end{quote}

Here, the \verb"SUB" and \verb"SUP" operator symbols denote sub- and
superscript, respectively. The rationale behind this example is that
an expression involving both sub- and superscript is often set differently
from a superscripted subscripted expression (compare $x_i^n$ to ${x_i}^n$).
This special case is therefore caught by the first rule in the above example
which causes a reduce/reduce conflict with rule 3 in expressions like
\verb"expr-1 SUB expr-2 SUP expr-3". The conflict is resolved in favour of
the first rule.

In both cases discussed above, the ambiguities could also be eliminated
by rewriting the grammar accordingly (although this yields more complicated
and less readable grammars). This may not always be the case. Often
ambiguities are also caused by design errors in the grammar. Hence, if
TP Yacc reports any parsing conflicts when constructing the parser, you
should use the \verb"/v" option to generate the parser description
(\verb".LST" file) and check whether TP Yacc resolved the conflicts correctly.

There is one type of syntactic constructs for which one often deliberately
uses an ambigious grammar as a more concise representation for a language
that could also be specified unambigiously: the syntax of expressions.
For instance, the following is an unambigious grammar for simple arithmetic
expressions:

\begin{quote}\begin{verbatim}
%token NUM

%%

expr    : term
        | expr '+' term
        ;

term    : factor
        | term '*' factor
        ;

factor  : '(' expr ')'
        | NUM
        ;
\end{verbatim}\end{quote}

You may check yourself that this grammar gives \verb"*" a higher precedence
than \verb"+" and makes both operators left-associative. The same effect can
be achieved with the following ambigious grammar using precedence definitions:

\begin{quote}\begin{verbatim}
%token NUM
%left '+'
%left '*'
%%

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美一区| 性做久久久久久久久| 欧美中文一区二区三区| 国内外成人在线| 亚洲图片欧美一区| 中文字幕精品三区| 欧美电视剧在线观看完整版| av在线不卡免费看| 狠狠色综合播放一区二区| 亚洲国产日韩精品| 中文字幕在线观看不卡视频| 精品国产一区二区精华| 欧美日韩成人激情| 色综合一区二区| 成人午夜精品在线| 国产精品一区二区在线看| 香港成人在线视频| 亚洲精选在线视频| 亚洲欧美怡红院| 国产精品三级av| 久久九九久久九九| 精品久久久久99| 日韩欧美精品在线| 7777精品伊人久久久大香线蕉经典版下载 | 欧美色区777第一页| 成人免费视频caoporn| 国产真实乱对白精彩久久| 日韩高清电影一区| 天堂影院一区二区| 丝袜诱惑亚洲看片| 午夜免费久久看| 亚洲va国产va欧美va观看| 怡红院av一区二区三区| 亚洲天堂精品在线观看| 日韩理论片在线| 亚洲人成网站色在线观看| 国产精品二三区| 综合色天天鬼久久鬼色| 国产精品久久久久久久久免费丝袜| 国产三区在线成人av| 久久精品综合网| 欧美激情综合五月色丁香小说| 国产农村妇女精品| 国产精品久线在线观看| 国产精品久久久久久一区二区三区 | 成人一区二区三区视频 | 91年精品国产| 日本伦理一区二区| 色综合久久久久综合99| 在线看一区二区| 欧美三级午夜理伦三级中视频| 欧美日韩久久一区二区| 7878成人国产在线观看| 日韩精品专区在线影院观看| 欧美精品一区二区不卡| 国产亚洲欧美在线| 亚洲日本欧美天堂| 五月婷婷另类国产| 国内精品免费**视频| 盗摄精品av一区二区三区| 99国产精品国产精品毛片| 欧美综合一区二区三区| 欧美一级日韩一级| 国产欧美综合在线观看第十页| 欧美国产精品一区| 亚洲人成精品久久久久久| 天天影视色香欲综合网老头| 久久se精品一区精品二区| 国产精品综合视频| 91香蕉视频污在线| 日韩一级精品视频在线观看| 国产女主播在线一区二区| 一区二区三区丝袜| 青青国产91久久久久久 | av毛片久久久久**hd| 欧美亚洲综合一区| 久久综合九色综合97_久久久| 中文字幕欧美三区| 婷婷综合五月天| 国产a精品视频| 欧美三级中文字| 日本一区免费视频| 亚洲国产裸拍裸体视频在线观看乱了 | 蜜桃视频在线观看一区| 国产乱人伦偷精品视频免下载 | 不卡一区中文字幕| 欧美日韩一级二级| 国产亚洲成aⅴ人片在线观看| 一区二区三区中文字幕| 欧美在线免费播放| 久久男人中文字幕资源站| 亚洲精品视频观看| 激情综合色播激情啊| 欧美亚洲禁片免费| 国产女人aaa级久久久级| 日韩不卡一区二区三区| 色综合视频一区二区三区高清| 欧美成人女星排名| 亚洲成av人综合在线观看| 成人va在线观看| 日韩精品一区二| 亚洲国产wwwccc36天堂| 本田岬高潮一区二区三区| 日韩精品一区二区三区在线| 亚洲综合自拍偷拍| 91原创在线视频| 久久久国产精华| 久久99国产精品麻豆| 51精品秘密在线观看| 亚洲一区二区中文在线| 成人激情综合网站| 久久婷婷国产综合国色天香| 亚洲成人1区2区| 91传媒视频在线播放| 日韩一区日韩二区| 国产a久久麻豆| 久久精品在线免费观看| 极品尤物av久久免费看| 欧美日韩aaa| 亚洲成av人在线观看| 日本高清不卡aⅴ免费网站| 综合在线观看色| 99久久精品免费看国产免费软件| 久久久久久久久99精品| 精久久久久久久久久久| 26uuu成人网一区二区三区| 蜜桃视频在线一区| 日韩免费电影网站| 老司机免费视频一区二区| 日韩丝袜美女视频| 蜜臀av性久久久久av蜜臀妖精| 91精品国产乱| 老色鬼精品视频在线观看播放| 欧美一级高清片在线观看| 日韩av中文在线观看| 欧美精品久久99| 日本不卡123| 欧美xxxxx裸体时装秀| 国产在线视频一区二区| 久久网站最新地址| 福利视频网站一区二区三区| 国产精品你懂的| 色噜噜狠狠一区二区三区果冻| 亚洲乱码一区二区三区在线观看| 色综合天天综合网天天狠天天| 亚洲精品中文在线观看| 欧美日韩一区中文字幕| 日本午夜一区二区| 久久人人97超碰com| www.综合网.com| 亚洲一区二区在线免费看| 91精品国产一区二区人妖| 久久精品久久99精品久久| 国产亚洲va综合人人澡精品 | 91精品国产综合久久久久久漫画 | 久久网这里都是精品| 成人av资源站| 亚洲电影你懂得| 日韩午夜在线影院| 国产一区二区h| 亚洲色图视频网站| 欧美丰满少妇xxxxx高潮对白| 久久激情综合网| 中国av一区二区三区| 欧美视频精品在线| 国内精品伊人久久久久av影院 | 久久国产精品99久久久久久老狼 | 日本最新不卡在线| 国产网站一区二区| 欧洲视频一区二区| 久久精品理论片| 亚洲欧美日韩中文播放| 日韩欧美在线不卡| 色伊人久久综合中文字幕| 毛片av中文字幕一区二区| 国产精品人人做人人爽人人添| 欧美艳星brazzers| 国产成人av电影在线| 亚洲激情在线激情| 久久男人中文字幕资源站| 在线观看国产91| 国产剧情av麻豆香蕉精品| 亚洲理论在线观看| 久久久五月婷婷| 欧美特级限制片免费在线观看| 国产乱一区二区| 五月天一区二区| 成人欧美一区二区三区| 欧美一区二区三区男人的天堂| gogo大胆日本视频一区| 奇米影视一区二区三区小说| 日韩美女视频一区| 亚洲精品一区二区三区在线观看| 99久久久国产精品| 国产伦精品一区二区三区视频青涩 | 日韩中文字幕1| 亚洲欧洲日产国产综合网| 精品久久人人做人人爰| 色噜噜狠狠成人中文综合| 国产91高潮流白浆在线麻豆|