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

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

?? tply.doc

?? YACC和LEX的資料書籍 以及一些源碼 很有幫助
?? DOC
?? 第 1 頁 / 共 4 頁
字號(hào):

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

%right SUB SUP
%%
expr : expr SUB expr SUP expr
     | expr SUB expr
     | expr SUP expr
     ;

Here, the SUB and 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. 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 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 /v option to generate the parser description (.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:

%token NUM

%%

expr	: term
	| expr '+' term
        ;

term	: factor
	| term '*' factor
        ;

factor	: '(' expr ')'
	| NUM
        ;

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

%token NUM
%left '+'
%left '*'
%%
expr : expr '+' expr
     | expr '*' expr
     | '(' expr ')'
     | NUM
     ;

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 %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:

- If the symbol has higher precedence than the rule: shift.

- If the rule has higher precedence than the symbol: reduce.

- 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.

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

%token NUM
%%
expr : expr '+' expr
     | expr '*' expr
     | '(' expr ')'
     | NUM
     ;

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

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

In this state, we have successfully parsed a + expression (rule 1). When
the next symbol is + or *, 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:

   %left '+'
   %left '*'

which gives * higher precedence than + and makes both operators left-
associative. The rightmost terminal in rule 1 is +. Hence, given these
precedence definitions, the first conflict will be resolved in favour
of shift (* has higher precedence than +), while the second one is resolved
in favour of reduce (+ is left-associative).

Similar conflicts arise in state 7:

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

Here, we have successfully parsed a * expression which may be followed
by another + or * operator. Since * is left-associative and has higher
precedence than +, 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:

%token NUM
%left '+' '-'
%left '*' '/'
%%
expr	: expr '+' expr
	| expr '-' expr
        | expr '*' expr
        | expr '/' expr
        | '(' expr ')'
        | NUM
        ;

This puts all "addition" operators on the first and all "multiplication"
operators on the second precedence level. All operators are left-associative;
for instance, 5+3-2 will be parsed as (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

   %prec symbol

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:

%token NUM
%left '+' '-'
%left '*' '/'
%right UMINUS
%%
expr	: expr '+' expr
	| expr '-' expr
        | expr '*' expr
        | expr '/' expr
        | '-' expr      %prec UMINUS
        | '(' expr ')'
        | NUM
        ;

Note the use of the 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.


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 "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 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 error token (pretending it has seen an imaginary 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 yyerrok may be used to reset the
parser to its normal mode of operation explicitly.

For a simple example, consider the rule

stmt	: error ';' { yyerrok; }

and assume a syntax error occurs while a statement (nonterminal stmt) is
parsed. The parser prints an error message, then pops its stack until it
can shift the token 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 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).


Yacc Library
------------

The TP Yacc library (YaccLib) unit provides some global declarations used
by the parser routine 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 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
YYPARSE.COD file) to customize TP Yacc to your target applications.


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:

- literals delimited by double quotes.

- 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

     %token ':=' 257

  at the beginning of the Yacc grammar.

- \ may be used instead of %, i.e. \\ means %%, \left is the same as %left,
  etc.

- other synonyms:
  %<             for %left
  %>             for %right
  %binary or %2  for %nonassoc
  %term or %0    for %token
  %=             for %prec

- actions may also be written as = { ... } or = single-statement;

- Turbo Pascal declarations (%{ ... %}) may be put at the beginning of the
  rules section. They will be treated as local declarations of the actions
  routine.


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 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 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.


Differences from UNIX Yacc
--------------------------

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

- TP Yacc produces output code for Turbo Pascal, rather than for C.

- TP Yacc does not support %union definitions. Instead, a value type is
  declared by specifying the type identifier itself as the tag of a %token
  or %type definition. TP Yacc will automatically generate an appropriate
  variant record type (YYSType) which is capable of holding values of any
  of the types used in %token and %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 $<type-identifier> notation
  must be used. The syntax of the %type definition has been changed
  slightly to allow definitions of the form
     %type <type-identifier>
  (omitting the nonterminals) which may be used to declare types which
  are not assigned to any grammar symbol, but are used with the
  $<...> construct.

- The parse tables constructed by this Yacc version are slightly greater
  than those constructed by UNIX Yacc, since a reduce action will only be
  chosen as the default action if it is the only action in the state.
  In difference, UNIX Yacc chooses a reduce action as the default action
  whenever it is the only reduce action of the state (even if there are
  other shift actions).

  This solves a bug in UNIX Yacc that makes the generated parser start
  error recovery too late with certain types of error productions (see
  also Schreiner/Friedman, "Introduction to compiler construction with
  UNIX," 1985). Also, errors will be caught sooner in most cases where
  UNIX Yacc would carry out an additional (default) reduction before
  detecting the error.

- Library routines are named differently from the UNIX version (e.g.,
  the `yyerrlab' routine takes the place of the `YYERROR' macro of UNIX
  Yacc), and, of course, all macros of UNIX Yacc (YYERROR, YYACCEPT, etc.)
  had to be implemented as procedures.



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨porny丨中文| 国产成人精品三级| 亚洲少妇30p| 国产精品色哟哟网站| 欧美国产1区2区| 中文字幕精品—区二区四季| 久久先锋影音av| 国产女主播视频一区二区| 久久夜色精品一区| 国产精品色呦呦| 一区二区三区资源| 天堂va蜜桃一区二区三区漫画版| 亚洲动漫第一页| 麻豆91精品视频| 国产一区二区免费在线| 国产91在线观看丝袜| 成人天堂资源www在线| 不卡一区二区在线| 日本久久一区二区| 欧美浪妇xxxx高跟鞋交| 日韩欧美精品在线| 国产日本欧洲亚洲| 亚洲视频综合在线| 免费视频一区二区| 成人深夜在线观看| 欧美性感一类影片在线播放| 欧美久久婷婷综合色| 久久久久久久综合日本| 国产精品初高中害羞小美女文 | 丁香激情综合国产| 日本高清成人免费播放| 日韩午夜激情电影| 国产精品久久久久久久久动漫 | 视频一区中文字幕| 国产精品资源站在线| 在线区一区二视频| 26uuu亚洲综合色| 一个色综合网站| 国产米奇在线777精品观看| 91影院在线观看| 欧美成人一级视频| 亚洲一二三四区不卡| 国产成人精品亚洲午夜麻豆| 欧美精选午夜久久久乱码6080| 精品91自产拍在线观看一区| 樱桃国产成人精品视频| 国产一区二区三区高清播放| 欧美三级三级三级爽爽爽| 国产欧美中文在线| 日本不卡视频在线观看| 在线视频你懂得一区| 国产亚洲精品福利| 秋霞电影一区二区| 91高清在线观看| 亚洲欧美综合在线精品| 午夜久久久久久电影| 色综合久久综合网97色综合| 亚洲国产精品成人久久综合一区| 婷婷亚洲久悠悠色悠在线播放| av午夜一区麻豆| 中文在线一区二区| 国产成人av一区二区三区在线观看| 精品视频一区二区不卡| 亚洲一区在线电影| 91丨九色丨蝌蚪富婆spa| 中文字幕精品一区二区精品绿巨人| 久久不见久久见免费视频7| 欧美日韩国产一区二区三区地区| 国产日韩欧美精品在线| 精品夜夜嗨av一区二区三区| 在线播放91灌醉迷j高跟美女 | 1区2区3区精品视频| 国产精品一区二区无线| 欧美大白屁股肥臀xxxxxx| 亚洲已满18点击进入久久| 色吊一区二区三区| 亚洲国产日韩一级| 6080yy午夜一二三区久久| 亚洲成人av一区二区| 欧美少妇bbb| 丝袜美腿亚洲色图| 91精品国产综合久久久蜜臀图片| 亚洲国产你懂的| 欧美疯狂做受xxxx富婆| 日韩极品在线观看| 日韩精品一区二区三区swag| 激情六月婷婷综合| 中文一区二区在线观看| 97久久精品人人澡人人爽| 亚洲人成7777| 欧美精品黑人性xxxx| 老司机精品视频线观看86| 久久你懂得1024| 99久久精品99国产精品| 一区二区三区不卡视频在线观看| 欧美日韩精品三区| 激情小说欧美图片| 国产精品素人视频| 精品视频一区三区九区| 狠狠色狠狠色综合日日91app| 国产精品沙发午睡系列990531| 日本韩国欧美国产| 美女网站在线免费欧美精品| 欧美国产国产综合| 欧美日韩精品三区| 国产福利一区二区三区视频在线 | 成人午夜激情在线| 亚洲国产一区二区三区| 精品国产1区二区| 91年精品国产| 久久不见久久见免费视频7| 成人免费在线播放视频| 日韩三区在线观看| 92精品国产成人观看免费| 亚洲国产美女搞黄色| 国产欧美日韩不卡免费| 欧美日韩一区三区四区| 国产 欧美在线| 蜜桃精品视频在线观看| **性色生活片久久毛片| 91精品欧美综合在线观看最新| 国产乱码一区二区三区| 亚洲成人免费看| 国产精品第五页| 久久综合99re88久久爱| 欧美三电影在线| 成人av一区二区三区| 男女男精品视频网| 一区二区三区中文字幕在线观看| 国产亚洲综合性久久久影院| 欧美精品久久一区| 色婷婷精品大在线视频| 丰满放荡岳乱妇91ww| 美女免费视频一区| 亚洲一区二区三区四区在线免费观看 | 精品一区二区三区视频| 亚洲综合色成人| 亚洲欧美综合网| 久久久久88色偷偷免费| 日韩欧美国产不卡| 欧美日本在线视频| 91国模大尺度私拍在线视频| 91丨porny丨国产| 成人激情开心网| 顶级嫩模精品视频在线看| 狠狠v欧美v日韩v亚洲ⅴ| 乱一区二区av| 精品一区二区免费在线观看| 久久se这里有精品| 日本少妇一区二区| 免播放器亚洲一区| 国产在线不卡一区| 精东粉嫩av免费一区二区三区| 午夜国产不卡在线观看视频| 亚洲综合免费观看高清完整版| 亚洲综合区在线| 亚洲成人免费电影| 日韩电影一区二区三区| 六月丁香综合在线视频| 韩国一区二区视频| 韩国成人福利片在线播放| 国产精品中文字幕日韩精品| 国产成人aaa| 99久久精品久久久久久清纯| 日本道免费精品一区二区三区| 色琪琪一区二区三区亚洲区| 欧美日韩和欧美的一区二区| 6080国产精品一区二区| 日韩美女在线视频| 国产午夜精品一区二区三区四区| 久久久精品综合| 亚洲欧美aⅴ...| 午夜视频久久久久久| 蜜桃视频一区二区三区在线观看 | 亚洲免费色视频| 亚洲超碰97人人做人人爱| 日本特黄久久久高潮| 国产精品亚洲第一区在线暖暖韩国| 国产精品99久久久| 色偷偷88欧美精品久久久 | 精品一区二区国语对白| 国产a精品视频| 欧美日韩一区视频| 久久久精品国产免大香伊| 综合欧美亚洲日本| 青青草国产成人av片免费| 成人国产精品免费| 欧美老肥妇做.爰bbww| 欧美激情在线免费观看| 首页欧美精品中文字幕| 福利电影一区二区三区| 欧美日韩色一区| 国产精品久久久久毛片软件| 亚洲va国产va欧美va观看| 国产精品一区二区久久不卡| 欧美日韩综合色| 国产午夜精品一区二区三区视频 | 92国产精品观看| 精品免费日韩av| 亚洲国产一区二区三区|