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

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

?? tply.tex

?? YACC和LEX的資料書籍 以及一些源碼 很有幫助
?? TEX
?? 第 1 頁 / 共 5 頁
字號:
expr : expr '+' expr
     | expr '*' expr
     | '(' expr ')'
     | NUM
     ;
\end{verbatim}\end{quote}

Without the precedence definitions, this is an ambigious grammar causing
a number of shift/reduce conflicts. The precedence definitions are used
to correctly resolve these conflicts (conflicts resolved using precedence
will not be reported by TP Yacc).

Each precedence definition introduces a new precedence level (lowest
precedence first) and specifies whether the corresponding operators
should be left-, right- or nonassociative (nonassociative operators
cannot be combined at all; example: relational operators in Pascal).

TP Yacc uses precedence information to resolve shift/reduce conflicts as
follows. Precedences are associated with each terminal occuring in a
precedence definition. Furthermore, each grammar rule is given the
precedence of its rightmost terminal (this default choice can be
overwritten using a \verb"%prec" tag; see below). To resolve a shift/reduce
conflict using precedence, both the symbol and the rule involved must
have been assigned precedences. TP Yacc then chooses the parse action
as follows:

\begin{itemize}
   \item
      If the symbol has higher precedence than the rule: shift.
   \item
      If the rule has higher precedence than the symbol: reduce.
   \item
      If symbol and rule have the same precedence, the associativity of the
      symbol determines the parse action: if the symbol is left-associative:
      reduce; if the symbol is right-associative: shift; if the symbol is
      non-associative: error.
\end{itemize}

To give you an idea of how this works, let us consider our ambigious
arithmetic expression grammar (without precedences):

\begin{quote}\begin{verbatim}
%token NUM
%%
expr : expr '+' expr
     | expr '*' expr
     | '(' expr ')'
     | NUM
     ;
\end{verbatim}\end{quote}

This grammar generates four shift/reduce conflicts. The description
of state 8 reads as follows:

\begin{quote}\begin{verbatim}
state 8:

        *** conflicts:

        shift 4, reduce 1 on '*'
        shift 5, reduce 1 on '+'

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

        '*'     shift 4
        '+'     shift 5
        $end    reduce 1
        ')'     reduce 1
        .       error
\end{verbatim}\end{quote}

In this state, we have successfully parsed a \verb"+" expression (rule 1).
When the next symbol is \verb"+" or \verb"*", we have the choice between the
reduction and shifting the symbol. Using the default shift/reduce
disambiguating rule, TP Yacc has resolved these conflicts in favour of shift.

Now let us assume the above precedence definition:
\begin{quote}\begin{verbatim}
   %left '+'
   %left '*'
\end{verbatim}\end{quote}
which gives \verb"*" higher precedence than \verb"+" and makes both operators
left-associative. The rightmost terminal in rule 1 is \verb"+". Hence, given
these precedence definitions, the first conflict will be resolved in favour
of shift (\verb"*" has higher precedence than \verb"+"), while the second one
is resolved in favour of reduce (\verb"+" is left-associative).

Similar conflicts arise in state 7:

\begin{quote}\begin{verbatim}
state 7:

        *** conflicts:

        shift 4, reduce 2 on '*'
        shift 5, reduce 2 on '+'

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

        '*'     shift 4
        '+'     shift 5
        $end    reduce 2
        ')'     reduce 2
        .       error
\end{verbatim}\end{quote}

Here, we have successfully parsed a \verb"*" expression which may be followed
by another \verb"+" or \verb"*" operator. Since \verb"*" is left-associative
and has higher precedence than \verb"+", both conflicts will be resolved in
favour of reduce.

Of course, you can also have different operators on the same precedence
level. For instance, consider the following extended version of the
arithmetic expression grammar:

\begin{quote}\begin{verbatim}
%token NUM
%left '+' '-'
%left '*' '/'
%%
expr    : expr '+' expr
        | expr '-' expr
        | expr '*' expr
        | expr '/' expr
        | '(' expr ')'
        | NUM
        ;
\end{verbatim}\end{quote}

This puts all ``addition'' operators on the first and all ``multiplication''
operators on the second precedence level. All operators are left-associative;
for instance, \verb"5+3-2" will be parsed as \verb"(5+3)-2".

By default, TP Yacc assigns each rule the precedence of its rightmost
terminal. This is a sensible decision in most cases. Occasionally, it
may be necessary to overwrite this default choice and explicitly assign
a precedence to a rule. This can be done by putting a precedence tag
of the form
\begin{quote}\begin{verbatim}
   %prec symbol
\end{verbatim}\end{quote}
at the end of the corresponding rule which gives the rule the precedence
of the specified symbol. For instance, to extend the expression grammar
with a unary minus operator, giving it highest precedence, you may write:

\begin{quote}\begin{verbatim}
%token NUM
%left '+' '-'
%left '*' '/'
%right UMINUS
%%
expr    : expr '+' expr
        | expr '-' expr
        | expr '*' expr
        | expr '/' expr
        | '-' expr      %prec UMINUS
        | '(' expr ')'
        | NUM
        ;
\end{verbatim}\end{quote}

Note the use of the \verb"UMINUS" token which is not an actual input symbol
but whose sole purpose it is to give unary minus its proper precedence. If
we omitted the precedence tag, both unary and binary minus would have the
same precedence because they are represented by the same input symbol.

\subsection*{Error Handling}

Syntactic error handling is a difficult area in the design of user-friendly
parsers. Usually, you will not like to have the parser give up upon the
first occurrence of an errorneous input symbol. Instead, the parser should
recover from a syntax error, that is, it should try to find a place in the
input where it can resume the parse.

TP Yacc provides a general mechanism to implement parsers with error
recovery. A special predefined \verb"error" token may be used in grammar rules
to indicate positions where syntax errors might occur. When the parser runs
into an error action (i.e., reads an errorneous input symbol) it prints out
an error message and starts error recovery by popping its stack until it
uncovers a state in which there is a shift action on the \verb"error" token.
If there is no such state, the parser terminates with return value 1,
indicating an unrecoverable syntax error. If there is such a state, the
parser takes the shift on the \verb"error" token (pretending it has seen
an imaginary \verb"error" token in the input), and resumes parsing in a
special ``error mode.''

While in error mode, the parser quietly skips symbols until it can again
perform a legal shift action. To prevent a cascade of error messages, the
parser returns to its normal mode of operation only after it has seen
and shifted three legal input symbols. Any additional error found after
the first shifted symbol restarts error recovery, but no error message
is printed. The TP Yacc library routine \verb"yyerrok" may be used to reset
the parser to its normal mode of operation explicitly.

For a simple example, consider the rule
\begin{quote}\begin{verbatim}
   stmt : error ';' { yyerrok; }
\end{verbatim}\end{quote}
and assume a syntax error occurs while a statement (nonterminal \verb"stmt")
is parsed. The parser prints an error message, then pops its stack until it
can shift the token \verb"error" of the error rule. Proceeding in error mode,
it will skip symbols until it finds a semicolon, then reduces by the error
rule. The call to \verb"yyerrok" tells the parser that we have recovered from
the error and that it should proceed with the normal parse. This kind of
``panic mode'' error recovery scheme works well when statements are always
terminated with a semicolon. The parser simply skips the ``bad'' statement
and then resumes the parse.

Implementing a good error recovery scheme can be a difficult task; see
Aho/Sethi/Ullman (1986) for a more comprehensive treatment of this topic.
Schreiner and Friedman have developed a systematic technique to implement
error recovery with Yacc which I found quite useful (I used it myself
to implement error recovery in the TP Yacc parser); see Schreiner/Friedman
(1985).

\subsection*{Yacc Library}

The TP Yacc library (\verb"YaccLib") unit provides some global declarations
used by the parser routine \verb"yyparse", and some variables and utility
routines which may be used to control the actions of the parser and to
implement error recovery. See the file \verb"YACCLIB.PAS" for a description
of these variables and routines.

You can also modify the Yacc library unit (and/or the code template in the
\verb"YYPARSE.COD" file) to customize TP Yacc to your target applications.

\subsection*{Other Features}

TP Yacc supports all additional language elements entitled as ``Old Features
Supported But not Encouraged'' in the UNIX manual, which are provided for
backward compatibility with older versions of (UNIX) Yacc:

\begin{itemize}
   \item
      literals delimited by double quotes.
   \item
      multiple-character literals. Note that these are not treated as
      character sequences but represent single tokens which are given a
      symbolic integer code just like any other token identifier. However,
      they will not be declared in the output file, so you have to make sure
      yourself that the lexical analyzer returns the correct codes for these
      symbols. E.g., you might explicitly assign token numbers by using a
      definition like
      \begin{quote}\begin{verbatim}
   %token ':=' 257
      \end{verbatim}\end{quote}
      at the beginning of the Yacc grammar.
   \item
      \verb"\" may be used instead of \verb"%", i.e. \verb"\\" means
      \verb"%%", \verb"\left" is the same as \verb"%left", etc.
   \item
      other synonyms:
      \begin{itemize}
         \item \verb"%<"                    for \verb"%left"
         \item \verb"%>"                    for \verb"%right"
         \item \verb"%binary" or \verb"%2"  for \verb"%nonassoc"
         \item \verb"%term" or \verb"%0"    for \verb"%token"
         \item \verb"%="                    for \verb"%prec"
      \end{itemize}
   \item
      actions may also be written as \verb"= { ... }" or
      \verb"= single-statement;"
   \item
      Turbo Pascal declarations (\verb"%{ ... %}") may be put at the
      beginning of the rules section. They will be treated as local
      declarations of the actions routine.
\end{itemize}

\subsection*{Implementation Restrictions}

As with TP Lex, internal table sizes and the main memory available limit the
complexity of source grammars that TP Yacc can handle. There is currently no
possibility to change internal table sizes (apart from modifying the sources
of TP Yacc itself) or to make use of extended memory. However, the maximum
table sizes provided by TP Yacc are large enough to handle quite complex
grammars (such as the Pascal grammar in the TP Yacc distribution). The
current limits are 600 s (states), 2400 i (LR0 kernel items), 2400 t (shift
and goto transitions) and 1200 r (reductions).

The default stack size of the generated parsers is \verb"yymaxdepth = 1024",
as declared in the TP Yacc library unit. This should be sufficient for any
average application, but you can change the stack size by including a
corresponding declaration in the definitions part of the Yacc grammar
(or change the value in the \verb"YaccLib" unit). Note that right-recursive
grammar rules may increase stack space requirements, so it is a good
idea to use left-recursive rules wherever possible.

\subsection*{Differences from UNIX Yacc}

Major differences between TP Yacc and UNIX Yacc are listed below.

\begin{itemize}
   \item
      TP Yacc produces output code for Turbo Pascal, rather than for C.
   \item
      TP Yacc does not support \verb"%union" definitions. Instead, a value
      type is declared by specifying the type identifier itself as the tag of
      a \verb"%token" or \verb"%type" definition. TP Yacc will automatically
      generate an appropriate variant record type (\verb"YYSType") which is
      capable of holding values of any of the types used in \verb"%token" and
      \verb"%type".
    
      Type checking is very strict. If you use type definitions, then
      any symbol referred to in an action must have a type introduced
      in a type definition. Either the symbol must have been assigned a
      type in the definitions section, or the \verb"$<type-identifier>"
      notation must be used. The syntax of the \verb"%type" definition has
      been changed slightly to allow definitions of the form
      \begin{quote}\begin{verbatim}
   %type <type-identifier>
      \end{verbatim}\end{quote}
      (omitting the nonterminals) which may be used to declare types which
      are not assigned to any gra

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩aaaaa| 毛片不卡一区二区| av在线播放不卡| 国产欧美日韩不卡免费| 蜜臀av一区二区在线免费观看| 一本一本大道香蕉久在线精品| 国产精品看片你懂得| 国产91丝袜在线播放| 欧美国产日韩a欧美在线观看| 久久国产尿小便嘘嘘| 精品免费日韩av| 久久99精品久久久久| 日韩一区二区三区四区 | 成人av小说网| 国产精品视频第一区| 高清国产午夜精品久久久久久| 久久久久久久久蜜桃| 成人在线视频一区| 自拍av一区二区三区| 色婷婷综合久久久中文字幕| 一区二区三区影院| 欧美日韩精品一区二区| 久久国产精品露脸对白| 精品国产99国产精品| 国产成人精品一区二| 国产精品看片你懂得| 91网站在线播放| 毛片av一区二区| 国产精品久久久爽爽爽麻豆色哟哟 | 欧美午夜片在线观看| 日本视频在线一区| 国产拍欧美日韩视频二区| 91精品1区2区| 麻豆免费看一区二区三区| 国产日韩av一区| 色婷婷亚洲综合| 久久精品国产秦先生| 亚洲欧洲日本在线| 制服丝袜亚洲精品中文字幕| 粉嫩一区二区三区性色av| 亚洲久草在线视频| 久久精品视频一区二区| 欧美日韩aaa| 99在线精品观看| 久久99精品久久久久| 亚洲高清视频中文字幕| 国产女同互慰高潮91漫画| 欧美一区二区在线播放| 91老司机福利 在线| 国产精品99久久久久久久vr| 五月婷婷综合激情| 一区二区三区中文字幕精品精品 | 欧美日韩在线播放一区| 成人免费av网站| 精品一区二区国语对白| 亚洲bt欧美bt精品| 亚洲愉拍自拍另类高清精品| 欧美激情综合在线| 精品乱人伦一区二区三区| 欧美吞精做爰啪啪高潮| 91福利精品视频| 99久久久精品免费观看国产蜜| 国产一区二区女| 国产精品一色哟哟哟| 日韩欧美一二区| 日韩欧美在线影院| 日韩欧美的一区| 欧美va在线播放| 26uuuu精品一区二区| 精品国产乱码久久久久久久久 | 亚洲色大成网站www久久九九| 国产日韩精品一区| 国产日产亚洲精品系列| 国产女人aaa级久久久级| 国产精品女上位| 亚洲婷婷国产精品电影人久久| 亚洲欧洲综合另类在线| 亚洲va在线va天堂| 五月激情综合网| 精品在线观看视频| 国产不卡视频在线播放| 一本一本大道香蕉久在线精品 | 1000部国产精品成人观看| 亚洲激情男女视频| 三级欧美韩日大片在线看| 久热成人在线视频| 懂色av一区二区三区免费观看| 97aⅴ精品视频一二三区| 欧美精品视频www在线观看| 日韩精品一区国产麻豆| 亚洲欧洲精品一区二区精品久久久 | 91视频观看视频| 91精品免费在线观看| 亚洲国产精品高清| 亚洲丶国产丶欧美一区二区三区| 国产一区高清在线| 欧美中文字幕一二三区视频| 日韩欧美在线网站| 亚洲一卡二卡三卡四卡五卡| 蓝色福利精品导航| 欧美熟乱第一页| 精品动漫一区二区三区在线观看| 亚洲欧美综合另类在线卡通| 日本系列欧美系列| 91麻豆国产福利精品| 久久综合久色欧美综合狠狠| 亚洲免费在线视频一区 二区| 久久99这里只有精品| 欧美日本在线播放| 一区二区三区在线免费视频| 国产69精品一区二区亚洲孕妇| 51久久夜色精品国产麻豆| 一区二区三区四区高清精品免费观看| 精品一区二区三区不卡| 91麻豆精品国产91久久久更新时间| 亚洲精品美腿丝袜| av电影在线观看一区| 国产婷婷精品av在线| 激情图片小说一区| 在线中文字幕不卡| 国产精品久久久久一区二区三区| 精品午夜一区二区三区在线观看| 97久久精品人人做人人爽| 久久这里只有精品视频网| 天堂影院一区二区| 91麻豆自制传媒国产之光| 欧美—级在线免费片| 国产乱国产乱300精品| 日韩丝袜情趣美女图片| 午夜不卡av免费| 欧美午夜精品一区二区蜜桃| 综合电影一区二区三区| 99久久99久久综合| 精品国产乱码久久| 国模大尺度一区二区三区| 日韩一区二区三区在线视频| 三级欧美在线一区| 欧美日韩国产综合久久 | 国产乱码精品一区二区三区av| 欧美一级理论片| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美丰满一区二区免费视频| 亚洲v中文字幕| 91精品国产高清一区二区三区| 九色综合国产一区二区三区| 久久综合成人精品亚洲另类欧美| 国产一区二三区好的| 国产精品三级电影| 欧美性一二三区| 久久99久久精品欧美| 久久久蜜臀国产一区二区| caoporm超碰国产精品| 日韩成人一区二区| 26uuu精品一区二区| 不卡一区二区在线| 亚洲丝袜美腿综合| 久久综合网色—综合色88| 成人精品鲁一区一区二区| 亚洲精品ww久久久久久p站| 精品人伦一区二区色婷婷| 波多野结衣中文字幕一区| 丝袜美腿亚洲一区二区图片| 精品毛片乱码1区2区3区| 一本大道久久a久久精二百 | 日韩va亚洲va欧美va久久| 一区视频在线播放| 日韩一级视频免费观看在线| 99久久亚洲一区二区三区青草 | wwww国产精品欧美| 日韩一区二区三区av| 99r精品视频| 国产风韵犹存在线视精品| 国产精品视频在线看| 精品国产成人在线影院 | 日韩亚洲欧美一区| 色噜噜狠狠成人网p站| 97超碰欧美中文字幕| 国产精品538一区二区在线| 日日骚欧美日韩| 亚洲电影中文字幕在线观看| 国产精品久久久久婷婷| 久久女同互慰一区二区三区| 欧美精品v国产精品v日韩精品 | 欧美日韩亚州综合| 99视频热这里只有精品免费| youjizz久久| 国产精品一卡二卡在线观看| 另类小说综合欧美亚洲| 亚洲午夜精品17c| 爽爽淫人综合网网站| 亚洲综合久久久| 亚洲国产精品人人做人人爽| 亚洲国产中文字幕| 日韩综合一区二区| 亚洲午夜精品在线| 国产精品激情偷乱一区二区∴| 亚洲人成网站在线| 一区二区三区日韩精品| 一区二区在线观看视频| 午夜精品久久久久久|