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

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

?? yacc-docs.txt

?? 句法分析器。一般用文法(grammar)來刻畫.常見的是短語結構文法(chomsky hierarchy),其中最常用的是上下文無關文法(CFG)。
?? TXT
?? 第 1 頁 / 共 5 頁
字號:

     In effect, the reduce action ``turns back the clock'' in the
parse,  popping  the states off the stack to go back to the state
where the right hand side of the rule was first seen.  The parser
then  behaves  as  if it had seen the left side at that time.  If
the right hand side of the rule is empty, no  states  are  popped
off  of  the  stack:  the  uncovered state is in fact the current
state.

     The reduce action is also  important  in  the  treatment  of
user-supplied  actions  and  values.  When a rule is reduced, the
code supplied with the rule  is  executed  before  the  stack  is
adjusted.   In  addition to the stack holding the states, another
stack, running in parallel with it,  holds  the  values  returned
from  the  lexical  analyzer and the actions.  When a shift takes
place, the external variable yylval  is  copied  onto  the  value
stack.   After  the  return  from the user code, the reduction is
carried out.  When the goto action is done, the external variable
yyval  is  copied onto the value stack.  The pseudo-variables $1,
$2, etc., refer to the value stack.

     The other two parser actions are conceptually much  simpler.
The  accept  action indicates that the entire input has been seen
and that it matches the specification.  This action appears  only
when the lookahead token is the endmarker, and indicates that the
parser has successfully done its job.  The error action,  on  the
other  hand,  represents  a  place where the parser can no longer
continue parsing  according  to  the  specification.   The  input









Yacc: Yet Another Compiler-Compiler                     PS1:15-13


tokens  it has seen, together with the lookahead token, cannot be
followed by anything that would result in  a  legal  input.   The
parser  reports  an  error, and attempts to recover the situation
and resume parsing: the error recovery (as opposed to the  detec-
tion of error) will be covered in Section 7.

     It is time for an example!  Consider the specification

        %token  DING  DONG  DELL
        %%
        rhyme   :       sound  place
                ;
        sound   :       DING  DONG
                ;
        place   :       DELL
                ;


     When Yacc is invoked with  the  -v  option,  a  file  called
y.output  is  produced,  with a human-readable description of the
parser.  The y.output file corresponding  to  the  above  grammar
(with some statistics stripped off the end) is:









































PS1:15-14                     Yacc: Yet Another Compiler-Compiler



        state 0
                $accept  :  _rhyme  $end

                DING  shift 3
                .  error

                rhyme  goto 1
                sound  goto 2

        state 1
                $accept  :   rhyme_$end

                $end  accept
                .  error

        state 2
                rhyme  :   sound_place

                DELL  shift 5
                .  error

                place   goto 4

        state 3
                sound   :   DING_DONG

                DONG  shift 6
                .  error

        state 4
                rhyme  :   sound  place_    (1)

                .   reduce  1

        state 5
                place  :   DELL_    (3)

                .   reduce  3

        state 6
                sound   :   DING  DONG_    (2)

                .   reduce  2

Notice that, in addition to the actions for each state, there  is
a description of the parsing rules being processed in each state.
The _ character is used to indicate what has been seen, and  what
is yet to come, in each rule.  Suppose the input is

        DING  DONG  DELL

It is instructive to follow the steps of the  parser  while  pro-
cessing this input.









Yacc: Yet Another Compiler-Compiler                     PS1:15-15


     Initially, the current state is state 0.  The  parser  needs
to  refer  to  the  input  in order to decide between the actions
available in state 0, so the first token, DING, is read, becoming
the lookahead token.  The action in state 0 on DING is is ``shift
3'', so state 3 is pushed onto the stack, and the lookahead token
is  cleared.  State 3 becomes the current state.  The next token,
DONG, is read, becoming the lookahead token.  The action in state
3 on the token DONG is ``shift 6'', so state 6 is pushed onto the
stack, and the lookahead is cleared.  The stack now  contains  0,
3, and 6.  In state 6, without even consulting the lookahead, the
parser reduces by rule 2.

                sound  :   DING  DONG

This rule has two symbols on the right hand side, so two  states,
6  and  3, are popped off of the stack, uncovering state 0.  Con-
sulting the description of state 0, looking for a goto on sound,

                sound   goto 2

is obtained; thus state 2 is pushed onto the stack, becoming  the
current state.

     In state 2, the next token, DELL, must be read.  The  action
is  ``shift  5'',  so state 5 is pushed onto the stack, which now
has 0, 2, and 5 on it, and the lookahead token  is  cleared.   In
state  5,  the  only action is to reduce by rule 3.  This has one
symbol on the right hand side, so one state, 5,  is  popped  off,
and state 2 is uncovered.  The goto in state 2 on place, the left
side of rule 3, is state 4.  Now, the stack contains 0, 2, and 4.
In  state  4,  the only action is to reduce by rule 1.  There are
two symbols on the right, so the top two states are  popped  off,
uncovering  state  0 again.  In state 0, there is a goto on rhyme
causing the parser to enter state 1.  In state 1,  the  input  is
read;  the  endmarker  is  obtained, indicated by ``$end'' in the
y.output file.  The action in state 1 when the endmarker is  seen
is to accept, successfully ending the parse.

     The reader is urged to consider how the  parser  works  when
confronted  with  such  incorrect strings as DING DONG DONG, DING
DONG, DING DONG DELL DELL, etc.  A few minutes  spend  with  this
and  other  simple examples will probably be repaid when problems
arise in more complicated contexts.

5: Ambiguity and Conflicts

     A set of grammar rules is ambiguous if there is  some  input
string that can be structured in two or more different ways.  For
example, the grammar rule

        expr    :       expr  '-'  expr

is a natural way of expressing the fact that one way  of  forming
an arithmetic expression is to put two other expressions together









PS1:15-16                     Yacc: Yet Another Compiler-Compiler


with a minus sign between them.  Unfortunately, this grammar rule
does  not  completely  specify  the  way  that all complex inputs
should be structured.  For example, if the input is

        expr  -  expr  -  expr

the rule allows this input to be structured as either

        (  expr  -  expr  )  -  expr

or as

        expr  -  (  expr  -  expr  )

(The first is called left association, the second right  associa-
tion).

     Yacc detects such ambiguities when it is attempting to build
the  parser.  It is instructive to consider the problem that con-
fronts the parser when it is given an input such as

        expr  -  expr  -  expr

When the parser has read the second expr, the input that  it  has
seen:

        expr  -  expr

matches the right side of the grammar  rule  above.   The  parser
could  reduce the input by applying this rule; after applying the
rule; the input is reduced to expr(the left side  of  the  rule).
The parser would then read the final part of the input:

        -  expr

and again reduce.  The effect of this is to take the left associ-
ative interpretation.

     Alternatively, when the parser has seen

        expr  -  expr

it could defer the immediate application of the  rule,  and  con-
tinue reading the input until it had seen

        expr  -  expr  -  expr

It could then apply the rule  to  the  rightmost  three  symbols,
reducing them to expr and leaving

        expr  -  expr

Now the rule can be reduced once more; the effect is to take  the
right associative interpretation.  Thus, having read









Yacc: Yet Another Compiler-Compiler                     PS1:15-17



        expr  -  expr

the parser can do two legal things, a shift or a  reduction,  and
has  no  way  of deciding between them.  This is called a shift /
reduce conflict.  It may also happen that the parser has a choice
of  two  legal  reductions; this is called a reduce / reduce con-
flict.  Note that there are never any ``Shift/shift'' conflicts.

     When there are shift/reduce or reduce/reduce conflicts, Yacc
still  produces  a  parser.  It does this by selecting one of the
valid steps wherever it has a choice.  A  rule  describing  which
choice  to  make  in a given situation is called a disambiguating
rule.

     Yacc invokes two disambiguating rules by default:

1.   In a shift/reduce conflict, the default is to do the shift.

2.   In a reduce/reduce conflict, the default is to reduce by the
     earlier grammar rule (in the input sequence).

     Rule 1 implies that reductions are deferred  whenever  there
is  a  choice,  in favor of shifts.  Rule 2 gives the user rather
crude control over the behavior of the parser in this  situation,
but reduce/reduce conflicts should be avoided whenever possible.

     Conflicts may arise because of mistakes in input  or  logic,
or  because  the  grammar rules, while consistent, require a more
complex parser than Yacc  can  construct.   The  use  of  actions
within rules can also cause conflicts, if the action must be done
before the parser can be sure which rule is being recognized.  In
these  cases,  the  application  of disambiguating rules is inap-
propriate, and leads to an incorrect parser.   For  this  reason,
Yacc  always reports the number of shift/reduce and reduce/reduce
conflicts resolved by Rule 1 and Rule 2.

     In general, whenever it is possible to apply  disambiguating
rules to produce a correct parser, it is also possible to rewrite
the grammar rules so that the same inputs are read but there  are
no  conflicts.   For this reason, most previous parser generators
have considered conflicts to be fatal errors.  Our experience has
suggested that this rewriting is somewhat unnatural, and produces
slower parsers; thus, Yacc will produce parsers even in the pres-
ence of conflicts.

     As an example of the power of disambiguating rules, consider
a  fragment  from  a programming language involving an ``if-then-
else'' construction:

        stat    :       IF  '('  cond  ')'  stat
                |       IF  '('  cond  ')'  stat  ELSE  stat
                ;










PS1:15-18                     Yacc: Yet Another Compiler-Compiler


In these rules, IF and ELSE are tokens,  cond  is  a  nonterminal
symbol  describing conditional (logical) expressions, and stat is
a nonterminal symbol describing statements.  The first rule  will
be called the simple-if rule, and the second the if-else rule.

     These two rules form an ambiguous construction, since  input
of the form

        IF  (  C1  )  IF  (  C2  )  S1  ELSE  S2

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂久久久久久久| 日日夜夜精品视频免费| 国产精品久线观看视频| 国产综合久久久久久鬼色| 91精品国产综合久久香蕉麻豆| 91污片在线观看| 亚洲与欧洲av电影| 国产午夜精品一区二区三区嫩草 | 久久午夜免费电影| 高清不卡一区二区在线| 国产91精品免费| 久久精品夜色噜噜亚洲aⅴ| 精品一区二区三区在线播放视频| 精品免费日韩av| 精品亚洲免费视频| 欧美一区二区三区日韩| 成人午夜又粗又硬又大| 亚洲视频一区二区在线| 欧美日韩国产精选| 精品一区二区三区久久久| 国产精品色噜噜| 成人黄色免费短视频| 国产日韩欧美精品在线| 日韩vs国产vs欧美| 久久久99精品免费观看| 国产欧美日韩不卡免费| 成人av资源网站| 日本一区二区三区四区在线视频| 久久精品久久精品| 日本精品一级二级| 中文字幕日韩av资源站| 精品一区二区三区免费毛片爱| 久久婷婷综合激情| 99免费精品视频| 久热成人在线视频| 一区二区三区免费| 日本一区二区三区四区在线视频| 日韩美女视频一区二区| 日韩一级黄色片| 综合久久久久久久| 久久综合综合久久综合| 色婷婷久久综合| 精品国产第一区二区三区观看体验| 亚洲人精品一区| 久久99精品久久久| 在线电影院国产精品| 亚洲黄色av一区| 波波电影院一区二区三区| 国产精品一级在线| 久久福利视频一区二区| 国产一区二区三区黄视频 | 99久免费精品视频在线观看| 亚洲一区二区三区免费视频| 国产精品动漫网站| 国产午夜亚洲精品午夜鲁丝片| 欧美性色aⅴ视频一区日韩精品| 色一情一乱一乱一91av| 成人一区二区三区在线观看| 国产成人aaaa| 精品久久国产老人久久综合| 在线观看91精品国产麻豆| 国产精品一二三四区| 亚洲综合激情网| 久久久久久麻豆| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 午夜精品久久久久影视| 国产一区二区三区黄视频 | 国产精品综合一区二区三区| 视频一区二区欧美| 丁香婷婷深情五月亚洲| 日本韩国精品在线| 日韩欧美精品在线视频| 久久精品国产亚洲一区二区三区 | 美女mm1313爽爽久久久蜜臀| 欧美精品丝袜久久久中文字幕| 亚洲人成精品久久久久久 | 国产一区激情在线| 国产午夜精品一区二区三区四区| 91国模大尺度私拍在线视频 | 亚洲男人的天堂网| 色婷婷综合久色| 欧美一区二视频| 中文字幕亚洲成人| 成人免费毛片app| 日韩一级片在线观看| 日本一区二区成人在线| 免费精品视频最新在线| 欧美男男青年gay1069videost| 国产人伦精品一区二区| 五月激情综合网| 99精品视频在线播放观看| 欧美伊人久久久久久午夜久久久久| 亚洲精品在线三区| 亚洲一区二区四区蜜桃| 日韩亚洲国产中文字幕欧美| 国产日本欧洲亚洲| 日韩中文字幕av电影| 成年人国产精品| 欧美zozo另类异族| 亚洲国产精品久久艾草纯爱| 国产91精品一区二区麻豆亚洲| 日韩一区和二区| 亚洲国产成人高清精品| kk眼镜猥琐国模调教系列一区二区| 日韩一区二区三区免费看| 亚洲激情成人在线| 成人永久aaa| 日韩精品一区二区三区swag| 亚洲一区在线视频观看| www.综合网.com| 久久精品夜色噜噜亚洲a∨| 蜜桃精品在线观看| 欧美写真视频网站| 亚洲美女少妇撒尿| 99视频国产精品| 国产欧美一区视频| 激情图区综合网| 日韩精品最新网址| 爽好久久久欧美精品| 欧美在线视频你懂得| 亚洲三级电影网站| 99r国产精品| 国产精品国产三级国产普通话99| 国产一区二区三区久久悠悠色av| 日韩欧美国产综合一区| 日韩精品国产精品| 3d成人动漫网站| 日韩高清不卡一区二区三区| 欧美日韩国产另类不卡| 午夜精品一区二区三区免费视频 | 亚洲成在人线免费| 色综合中文综合网| 激情综合色播五月| 日韩欧美亚洲国产另类| 日日夜夜精品视频天天综合网| 欧美色中文字幕| 亚洲国产精品一区二区www| 在线观看欧美日本| 亚洲一区二区五区| 在线成人免费视频| 免费久久99精品国产| 精品少妇一区二区三区视频免付费| 轻轻草成人在线| 日韩区在线观看| 国产在线视频不卡二| 久久亚洲欧美国产精品乐播 | 欧美三级在线视频| 亚洲aaa精品| 91精品国产免费久久综合| 蜜臀久久久久久久| 久久久久久久久久美女| 国产成人综合在线| 亚洲色图欧美在线| 欧美无人高清视频在线观看| 天天影视色香欲综合网老头| 91精品一区二区三区久久久久久 | 99久久婷婷国产综合精品| 亚洲欧美日韩综合aⅴ视频| 欧美系列亚洲系列| 免费成人在线观看视频| 久久先锋影音av鲁色资源网| 成熟亚洲日本毛茸茸凸凹| 日韩美女视频一区二区| 欧美精品九九99久久| 久久99精品国产| 中文字幕在线播放不卡一区| 一本色道久久综合亚洲91 | 污片在线观看一区二区| 欧美一区二区日韩| 成人一区二区三区中文字幕| 亚洲最色的网站| 日韩欧美www| 成人影视亚洲图片在线| 欧美电视剧在线看免费| 欧美一级免费大片| 欧美一区二区三区四区视频 | 国产日韩三级在线| 久久久久久久免费视频了| 精品国免费一区二区三区| 欧美男男青年gay1069videost| 69堂精品视频| 精品久久一区二区三区| 国产亚洲欧美在线| 综合久久给合久久狠狠狠97色 | 色婷婷亚洲一区二区三区| 亚洲影院理伦片| 精品99一区二区三区| 色综合久久久久综合| 久久草av在线| 亚洲精品视频在线看| 26uuu久久天堂性欧美| 一本到不卡精品视频在线观看| 麻豆国产精品视频| 亚洲视频电影在线| 久久免费电影网| 欧美剧情电影在线观看完整版免费励志电影 | 日韩欧美精品在线| 色综合咪咪久久| 国产成人精品影视| 日韩精品视频网站|