厌胜之术 影响长相:谁能帮我翻译一下下边这篇文章。是关于编译原理的,翻译软件效果太差了。

来源:百度文库 编辑:高校问答 时间:2024/05/13 05:40:00
When you are using multiple data types, yylval’s type is a union made from
the %union declaration. So when you store a token’s value, you must use the
proper member of the union. If the %union declaration looks like this:
...

then the code in yylex might look like this:
...

Textual Positions of Tokens
If you are using the @n-feature in actions to keep track of the textual locations
of tokens and groupings, then you must provide this information in yylex. The
function yyparse expects to find the textual location of a token just parsed
in the global variable yylloc. So yylex must store the proper data in that
variable. The value of yylloc is a structure and you need only initialize the
members that are going to be used by the actions. The four members are called
first line, first column, last line and last column. Note that the use of
this feature makes the parser noticeably slower.
The data type of yylloc has the name YYLTYPE.

The Error Reporting Function yyerror
The Yacc/Bison parser detects a parse error or syntax error whenever it reads
a token which cannot satisfy any syntax rule. A action in the grammar can also
explicitly proclaim an error, using the macro YYERROR.
The Yacc/Bison parser expects to report the error by calling an error report-
ing function named yyerror, which you must supply. It is called by yyparse
whenever a syntax error is found, and it receives one argument. For a parse
error, the string is always "parse error".
The following definition suffices in simple programs: ...

装个金山快译2006