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

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

?? tply.tex

?? YACC和LEX的資料書籍 以及一些源碼 很有幫助
?? TEX
?? 第 1 頁 / 共 5 頁
字號:
      A terminal identifier introduced in a precedence definition may, but
      need not, appear in a \verb"%token" definition as well.
   \item
      type definitions: Any (terminal or nonterminal) grammar symbol may be
      associated with a type identifier which is used in the processing of
      semantic values. Type tags of the form \verb"<name>" may be used in
      token and precedence definitions to declare the type of a terminal
      symbol, e.g.:
      \begin{quote}\begin{verbatim}
   %token <Real>  NUM
   %left  <AddOp> '+' '-'
      \end{verbatim}\end{quote}

      To declare the type of a nonterminal symbol, use a type definition of
      the form:
      \begin{quote}\begin{verbatim}
   %type <name> symbol ...
      \end{verbatim}\end{quote}
      e.g.:
      \begin{quote}\begin{verbatim}
   %type <Real> expr
      \end{verbatim}\end{quote}

      In a \verb"%type" definition, you may also omit the nonterminals, i.e.
      you may write:
      \begin{quote}\begin{verbatim}
   %type <name>
      \end{verbatim}\end{quote}

      This is useful when a given type is only used with type casts (see
      Section {\em Grammar Rules and Actions\/}), and is not associated with
      a specific nonterminal.
   \item
      Turbo Pascal declarations: You may also include arbitrary Turbo Pascal
      code in the definitions section, enclosed in \verb"%{ %}". This code
      will be inserted as global declarations into the output file, unchanged.
\end{itemize}

\subsection*{Grammar Rules and Actions}

The second part of a TP Yacc grammar contains the grammar rules for the
target language. Grammar rules have the format

\begin{quote}\begin{verbatim}
   name : symbol ... ;
\end{verbatim}\end{quote}

The left-hand side of a rule must be an identifier (which denotes a
nonterminal symbol). The right-hand side may be an arbitrary (possibly
empty) sequence of nonterminal and terminal symbols (including literals
enclosed in single quotes). The terminating semicolon may also be omitted.
Different rules for the same left-hand side symbols may be written using
the \verb"|" character to separate the different alternatives:

\begin{quote}\begin{verbatim}
   name : symbol ...
        | symbol ...
        ...
        ;
\end{verbatim}\end{quote}

For instance, to specify a simple grammar for arithmetic expressions, you
may write:

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

(The \verb"%left" definitions at the beginning of the grammar are needed to
specify the precedence and associativity of the operator symbols. This will be
discussed in more detail in Section {\em Ambigious Grammars\/}.)

Grammar rules may contain actions -- Turbo Pascal statements enclosed in
\verb"{ }" -- to be executed as the corresponding rules are recognized.
Furthermore, rules may return values, and access values returned by other
rules. These ``semantic'' values are written as \verb"$$" (value of the
left-hand side nonterminal) and \verb"$i" (value of the $i$th right-hand
side symbol). They are kept on a special value stack which is maintained
automatically by the parser.

Values associated with terminal symbols must be set by the lexical analyzer
(more about this in Section {\em Lexical Analysis\/}). Actions of the form
\verb"$$ := $1" can frequently be omitted, since it is the default action
assumed by TP Yacc for any rule that does not have an explicit action.

By default, the semantic value type provided by Yacc is \verb"Integer". You
can also put a declaration like
\begin{quote}\begin{verbatim}
   %{
   type YYSType = Real;
   %}
\end{verbatim}\end{quote}
into the definitions section of your Yacc grammar to change the default value
type. However, if you have different value types, the preferred method is to
use type definitions as discussed in Section {\em Definitions\/}. When such
type definitions are given, TP Yacc handles all the necessary details of the
\verb"YYSType" definition and also provides a fair amount of type checking
which makes it easier to find type errors in the grammar.

For instance, we may declare the symbols \verb"NUM" and \verb"expr" in the
example above to be of type \verb"Real", and then use these values to
evaluate an expression as it is parsed.

\begin{quote}\begin{verbatim}
%left '+' '-'
%left '*' '/'
%token <Real> NUM
%type  <Real> expr
%%
expr : expr '+' expr   { $$ := $1+$3; }
     | expr '-' expr   { $$ := $1-$3; }
     | expr '*' expr   { $$ := $1*$3; }
     | expr '/' expr   { $$ := $1/$3; }
     | '(' expr ')'    { $$ := $2;    }
     | NUM
     ;
\end{verbatim}\end{quote}

(Note that we omitted the action of the last rule. The ``copy action''
\verb"$$ := $1" required by this rule is automatically added by TP Yacc.)

Actions may not only appear at the end, but also in the middle of a rule
which is useful to perform some processing before a rule is fully parsed.
Such actions inside a rule are treated as special nonterminals which are
associated with an empty right-hand side. Thus, a rule like
\begin{quote}\begin{verbatim}
   x : y { action; } z
\end{verbatim}\end{quote}
will be treated as:
\begin{quote}\begin{verbatim}
  x : y $act z
  $act : { action; }
\end{verbatim}\end{quote}

Actions inside a rule may also access values to the left of the action,
and may return values by assigning to the \verb"$$" value. The value returned
by such an action can then be accessed by other actions using the usual
\verb"$i" notation. E.g., we may write:
\begin{quote}\begin{verbatim}
   x : y { $$ := 2*$1; } z { $$ := $2+$3; }
\end{verbatim}\end{quote}
which has the effect of setting the value of \verb"x" to
\begin{quote}\begin{verbatim}
   2*(the value of y)+(the value of z).
\end{verbatim}\end{quote}

Sometimes it is desirable to access values in enclosing rules. This can be
done using the notation \verb"$i" with $i\leq 0$. \verb"$0" refers to the
first value ``to the left'' of the current rule, \verb"$-1" to the second,
and so on. Note that in this case the referenced value depends on the actual
contents of the parse stack, so you have to make sure that the requested
values are always where you expect them.

There are some situations in which TP Yacc cannot easily determine the
type of values (when a typed parser is used). This is true, in particular,
for values in enclosing rules and for the \verb"$$" value in an action inside
a rule. In such cases you may use a type cast to explicitly specify the type
of a value. The format for such type casts is \verb"$<name>$" (for left-hand
side values) and \verb"$<name>i" (for right-hand side values) where
\verb"name" is a type identifier (which must occur in a \verb"%token",
precedence or \verb"%type" definition).

\subsection*{Auxiliary Procedures}

The third section of a TP Yacc program is optional. If it is present, it
may contain any Turbo Pascal code (such as supporting routines or a main
program) which is tacked on to the end of the output file.

\subsection*{Lexical Analysis}

For any TP Yacc-generated parser, the programmer must supply a lexical
analyzer routine named \verb"yylex" which performs the lexical analysis for
the parser. This routine must be declared as

\begin{quote}\begin{verbatim}
   function yylex : Integer;
\end{verbatim}\end{quote}

The \verb"yylex" routine may either be prepared by hand, or by using the
lexical analyzer generator TP Lex (see Section {\em TP Lex\/}).

The lexical analyzer must be included in your main program behind the
parser subroutine (the \verb"yyparse" code template includes a forward
definition of the \verb"yylex" routine such that the parser can access the
lexical analyzer). For instance, you may put the lexical analyzer
routine into the auxiliary procedures section of your TP Yacc grammar,
either directly, or by using the the Turbo Pascal include directive
(\verb"$I").

The parser repeatedly calls the \verb"yylex" routine to tokenize the input
stream and obtain the individual lexical items in the input. For any
literal character, the \verb"yylex" routine has to return the corresponding
character code. For the other, symbolic, terminals of the input language,
the lexical analyzer must return corresponding integer codes. These are
assigned automatically by TP Yacc in the order in which token definitions
appear in the definitions section of the source grammar. The lexical
analyzer can access these values through corresponding integer constants
which are declared by TP Yacc in the output file.

For instance, if
\begin{quote}\begin{verbatim}
   %token NUM
\end{verbatim}\end{quote}
is the first definition in the Yacc grammar, then TP Yacc will create
a corresponding constant declaration
\begin{quote}\begin{verbatim}
   const NUM = 257;
\end{verbatim}\end{quote}
in the output file (TP Yacc automatically assigns symbolic token numbers
starting at 257; 1 thru 255 are reserved for character literals, 0 denotes
end-of-file, and 256 is reserved for the special error token which will be
discussed in Section {\em Error Handling\/}). This definition may then be
used, e.g., in a corresponding TP Lex program as follows:
\begin{quote}\begin{verbatim}
   [0-9]+   return(NUM);
\end{verbatim}\end{quote}

You can also explicitly assign token numbers in the grammar. For this
purpose, the first occurrence of a token identifier in the definitions
section may be followed by an unsigned integer. E.g. you may write:
\begin{quote}\begin{verbatim}
   %token NUM 299
\end{verbatim}\end{quote}

Besides the return value of \verb"yylex", the lexical analyzer routine may
also return an additional semantic value for the recognized token. This value
is assigned to a variable named \verb"yylval" and may then be accessed in
actions through the \verb"$i" notation (see above, Section {\em Grammar
Rules and Actions\/}). The \verb"yylval" variable is of type \verb"YYSType"
(the semantic value type, \verb"Integer" by default); its declaration may be
found in the \verb"YYPARSE.COD" file.

For instance, to assign an \verb"Integer" value to a \verb"NUM" token in the
above example, we may write:

\begin{quote}\begin{verbatim}
   [0-9]+   begin
              val(yytext, yylval, code);
              return(NUM);
            end;
\end{verbatim}\end{quote}

This assigns \verb"yylval" the value of the \verb"NUM" token (using the Turbo
Pascal standard procedure \verb"val").

If a parser uses tokens of different types (via a \verb"%token <name>"
definition), then the \verb"yylval" variable will not be of type
\verb"Integer", but instead of a corresponding variant record type which is
capable of holding all the different value types declared in the TP Yacc
grammar. In this case, the lexical analyzer must assign a semantic value to
the corresponding record component which is named \verb"yy"{\em name\/}
(where {\em name\/} stands for the corresponding type identifier).

E.g., if token \verb"NUM" is declared \verb"Real":
\begin{quote}\begin{verbatim}
   %token <Real> NUM
\end{verbatim}\end{quote}
then the value for token \verb"NUM" must be assigned to \verb"yylval.yyReal".

\subsection*{How The Parser Works}

TP Yacc uses the LALR(1) technique developed by Donald E.\ Knuth and F.\
DeRemer to construct a simple, efficient, non-backtracking bottom-up
parser for the source grammar. The LALR parsing technique is described
in detail in Aho/Sethi/Ullman (1986). It is quite instructive to take a
look at the parser description TP Yacc generates from a small sample
grammar, to get an idea of how the LALR parsing algorithm works. We
consider the following simplified version of the arithmetic expression
grammar:

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

When run with the \verb"/v" option on the above grammar, TP Yacc generates
the parser description listed below.

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

        $accept : _ expr $end

        '('     shift 2
        NUM     shift 3
        .       error

        expr    goto 1

state 1:

        $accept : expr _ $end
        expr : expr _ '+' expr
        expr : expr _ '*' expr

        $end    accept
        '*'     shift 4
        '+'     shift 5
        .       error

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美在线视频观看| 成人av第一页| 久久综合色综合88| 国产成人精品免费视频网站| 久久久久青草大香线综合精品| 韩国女主播一区二区三区| 久久久久久久av麻豆果冻| 国产成人三级在线观看| 亚洲人成网站色在线观看| 欧美在线你懂得| 蜜臀av性久久久久蜜臀av麻豆| 精品日韩一区二区三区| 成人小视频在线| 亚洲自拍与偷拍| 欧美xxxxxxxxx| 不卡一区中文字幕| 日韩精品电影在线观看| 国产欧美日韩精品在线| 在线精品观看国产| 国产一区二区免费在线| 一区二区三区中文字幕精品精品| 欧美一区二区精品在线| 福利一区二区在线| 香蕉加勒比综合久久| 国产清纯白嫩初高生在线观看91 | 国产成人99久久亚洲综合精品| 国产三级精品视频| 91首页免费视频| 午夜精彩视频在线观看不卡| 精品久久免费看| 不卡一区在线观看| 亚洲第一搞黄网站| 精品乱人伦小说| 国产一区二区三区在线观看免费视频 | 亚洲色图清纯唯美| 欧美性大战久久久久久久蜜臀 | 日本少妇一区二区| 久久午夜电影网| 91精品福利在线| 精品一区二区av| 亚洲伦理在线精品| 日韩美女一区二区三区| 99视频精品在线| 日韩1区2区3区| 国产精品久久久久久久久免费樱桃 | 一片黄亚洲嫩模| 欧美刺激脚交jootjob| 国产成人综合在线播放| 亚洲高清免费观看高清完整版在线观看 | 久久99久久99| 亚洲人成精品久久久久久| 日韩三级电影网址| 99r国产精品| 激情综合五月天| 一区二区三区.www| 久久免费午夜影院| 欧美福利视频一区| 成人高清在线视频| 久久电影网站中文字幕| 一区二区三区日韩精品视频| 欧美福利电影网| 91色porny| 国产乱码精品一区二区三| 免费成人结看片| 国产农村妇女毛片精品久久麻豆| 日韩一区二区电影| 97久久精品人人爽人人爽蜜臀| 激情深爱一区二区| 日韩国产成人精品| 亚洲综合在线第一页| 国产视频一区在线观看| 日韩欧美国产三级| 欧美日韩美女一区二区| 成人av综合在线| 久久99精品视频| 日韩高清国产一区在线| 一区二区三区丝袜| 中文字幕字幕中文在线中不卡视频| 精品国产乱码久久久久久闺蜜| 欧美日韩久久一区二区| 色狠狠桃花综合| 99久久国产综合精品女不卡| 高清不卡在线观看av| 国产一区999| 国产一区二区精品久久91| 九一九一国产精品| 美女www一区二区| 日韩av一区二区三区| 亚洲18女电影在线观看| 午夜视黄欧洲亚洲| 亚洲福利电影网| 依依成人综合视频| 一区二区三区中文字幕| 亚洲国产综合人成综合网站| 亚洲人成7777| 亚洲第一搞黄网站| 一区二区三区四区不卡在线| 伊人婷婷欧美激情| 一区二区三区不卡在线观看| 亚洲欧洲在线观看av| 亚洲欧美视频在线观看| 亚洲在线一区二区三区| 亚洲一二三四区不卡| 日韩中文字幕不卡| 久久精品国产澳门| 国产精品亚洲成人| 成人丝袜视频网| 91免费看`日韩一区二区| 色婷婷综合激情| 欧美日韩一区二区三区免费看| 欧美日韩中文一区| 欧美成人性福生活免费看| 精品福利二区三区| 中国av一区二区三区| 国产精品美女一区二区在线观看| 亚洲国产一区视频| 奇米影视一区二区三区| 韩国精品一区二区| 成人动漫视频在线| 在线观看亚洲专区| 精品国产露脸精彩对白| 国产精品国产三级国产a| 亚洲激情男女视频| 久久精品噜噜噜成人av农村| 国产99精品视频| 99精品视频在线观看免费| 7777精品伊人久久久大香线蕉超级流畅 | 91精品国产综合久久精品app| 日韩欧美色电影| 国产精品美女视频| 亚洲成国产人片在线观看| 激情成人综合网| 91视频你懂的| 欧美va亚洲va香蕉在线| 中文字幕亚洲电影| 日韩电影一区二区三区四区| 国产一区激情在线| 欧美性感一区二区三区| 久久嫩草精品久久久精品一| 亚洲嫩草精品久久| 婷婷夜色潮精品综合在线| 92精品国产成人观看免费| 91精品国产综合久久精品app| 中文无字幕一区二区三区| 亚洲福利视频一区| 成人一区二区三区中文字幕| 欧美日韩mp4| 国产婷婷色一区二区三区在线| 亚洲不卡av一区二区三区| 国产精品一区二区久激情瑜伽| 欧美日韩在线播放三区| 国产欧美一区二区三区在线看蜜臀| 亚洲h精品动漫在线观看| 97精品视频在线观看自产线路二| 欧美一区二区三区喷汁尤物| 亚洲人成亚洲人成在线观看图片| 国产一区福利在线| 制服丝袜中文字幕一区| 中文字幕日韩精品一区| 国产在线观看一区二区| 在线综合视频播放| 一区二区三区四区视频精品免费 | 久久超碰97人人做人人爱| 国产精品自产自拍| 欧美无砖专区一中文字| 亚洲啪啪综合av一区二区三区| 国产精品一线二线三线精华| 91精品一区二区三区久久久久久| 国产精品毛片久久久久久久| 奇米一区二区三区| 欧美少妇一区二区| 亚洲欧美日韩国产成人精品影院| 成人一区二区三区视频在线观看| 欧美精品一区二区不卡 | 91精品91久久久中77777| 中文字幕av一区 二区| 国产原创一区二区三区| 538在线一区二区精品国产| 亚洲国产成人porn| 欧美视频一区在线观看| 亚洲一区二区三区在线| 欧美性三三影院| 午夜精品福利一区二区三区av | 美女被吸乳得到大胸91| 欧美色电影在线| 日韩高清一级片| 日韩精品影音先锋| 国产自产视频一区二区三区| 久久色在线观看| 大尺度一区二区| 欧美激情中文字幕| 99久久综合色| 一区二区三区欧美| 欧美日韩aaa| 日韩国产精品久久久久久亚洲| 日韩精品专区在线影院重磅| 国产乱人伦偷精品视频免下载| 国产欧美在线观看一区| 97精品久久久久中文字幕| 亚洲免费电影在线|