changes_from_133_before_mr13.txt
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· 文本 代码 · 共 1,543 行 · 第 1/5 页
TXT
1,543 行
A temporary workaround might be to use different #pred statements
for predicates you know have different context. This would avoid
extraneous warnings.
The above example might be termed a "false positive". Comparison
without context will also lead to "false negatives". Consider the
following example:
#pred Alpha
#pred Beta
rule1: <<Alpha>>? A
| rule2
;
rule2: <<Alpha>>? A
| <<Beta>>? B
;
The predicate used for alt 2 of rule1 is (Alpha || Beta). This
appears to be different than the predicate Alpha used for alt1.
However, the context of Beta is B. Thus when the lookahead is A
Beta will have no resolving power and Alpha will be used for both
alternatives. Using the same predicate for both alternatives isn't
very helpful, but this will not be detected with 1.33MR11.
To properly handle this the predicate expression would have to be
evaluated for each distinct lookahead context.
To determine whether two predicate expressions are identical is
difficult. The routine may fail to identify identical predicates.
The #pred feature also compares predicates to see if a choice between
alternatives which is resolved by a predicate which makes the second
choice unreachable. Consider the following example:
#pred A <<A(LATEXT(1)>>?
#pred B <<B(LATEXT(1)>>?
#pred A_or_B A || B
r : s
| t
;
s : <<A_or_B>>? ID
;
t : <<A>>? ID
;
----------------------------------------------------------------------------
t11.g, line 5: warning: the predicate used to disambiguate the
first choice of rule r
(file t11.g alt 1 line 5 and alt 2 line 6)
appears to "cover" the second predicate when compared without context.
The second predicate may have no resolving power for some lookahead
sequences.
----------------------------------------------------------------------------
#139. (Changed in MR11) Problem with -gp in C++ mode
The -gp option to add a prefix to rule names did not work in
C++ mode. This has been fixed.
Reported by Alexey Demakov (demakov@kazbek.ispras.ru).
#138. (Changed in MR11) Additional makefiles for non-MSVC++ MS systems
Sramji Ramanathan (ps@kumaran.com) has supplied makefiles for
building antlr and dlg with Win95/NT development tools that
are not based on MSVC5. They are pccts/antlr/AntlrMS.mak and
pccts/dlg/DlgMS.mak.
The first line of the makefiles require a definition of PCCTS_HOME.
These are in additiion to the AntlrMSVC50.* and DlgMSVC50.*
supplied by Jeff Vincent (JVincent@novell.com).
#137. (Changed in MR11) Token getType(), getText(), getLine() const members
--------------------------------------------------------------------
If you use ANTLRCommonToken this change probably does not affect you.
--------------------------------------------------------------------
For a long time it has bothered me that these accessor functions
in ANTLRAbstractToken were not const member functions. I have
refrained from changing them because it require users to modify
existing token class definitions which are derived directly
from ANTLRAbstractToken. I think it is now time.
For those who are not used to C++, a "const member function" is a
member function which does not modify its own object - the thing
to which "this" points. This is quite different from a function
which does not modify its arguments
Most token definitions based on ANTLRAbstractToken have something like
the following in order to create concrete definitions of the pure
virtual methods in ANTLRAbstractToken:
class MyToken : public ANTLRAbstractToken {
...
ANTLRTokenType getType() {return _type; }
int getLine() {return _line; }
ANTLRChar * getText() {return _text; }
...
}
The required change is simply to put "const" following the function
prototype in the header (.h file) and the definition file (.cpp if
it is not inline):
class MyToken : public ANTLRAbstractToken {
...
ANTLRTokenType getType() const {return _type; }
int getLine() const {return _line; }
ANTLRChar * getText() const {return _text; }
...
}
This was originally proposed a long time ago by Bruce
Guenter (bruceg@qcc.sk.ca).
#136. (Changed in MR11) Added getLength() to ANTLRCommonToken
Classes ANTLRCommonToken and ANTLRCommonTokenNoRefCountToken
now have a member function:
int getLength() const { return strlen(getText()) }
Suggested by Sramji Ramanathan (ps@kumaran.com).
#135. (Changed in MR11) Raised antlr's own default ZZLEXBUFSIZE to 8k
#134a. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
There is a typographical error in the definition of BITWISEOREQ:
#token BITWISEOREQ "!=" should be "\|="
When this change is combined with the bugfix to the follow set cache
problem (Item #147) and a minor rearrangement of the grammar
(Item #134b) it becomes a k=1 ck=2 grammar.
#134b. (ansi_mr10.zip) T.J. Parr's ANSI C grammar made 1.33MR11 compatible
The following changes were made in the ansi.g grammar (along with
using -mrhoist on):
ansi.g
======
void tracein(char *) ====> void tracein(const char *)
void traceout(char *) ====> void traceout(const char *)
<LT(1)->getType()==IDENTIFIER ? isTypeName(LT(1)->getText()) : 1>>?
====> <<isTypeName(LT(1)->getText())>>?
<<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
isTypeName(LT(2)->getText()) : 1>>?
====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
<<(LT(1)->getType()==LPARENTHESIS && LT(2)->getType()==IDENTIFIER) ? \
isTypeName(LT(2)->getText()) : 1>>?
====> (LPARENTHESIS IDENTIFIER)? => <<isTypeName(LT(2)->getText())>>?
added to init(): traceOptionValueDefault=0;
added to init(): traceOption(-1);
change rule "statement":
statement
: plain_label_statement
| case_label_statement
| <<;>> expression SEMICOLON
| compound_statement
| selection_statement
| iteration_statement
| jump_statement
| SEMICOLON
;
plain_label_statement
: IDENTIFIER COLON statement
;
case_label_statement
: CASE constant_expression COLON statement
| DEFAULT COLON statement
;
support.cpp
===========
void tracein(char *) ====> void tracein(const char *)
void traceout(char *) ====> void traceout(const char *)
added to tracein(): ANTLRParser::tracein(r); // call superclass method
added to traceout(): ANTLRParser::traceout(r); // call superclass method
Makefile
========
added to AFLAGS: -mrhoist on -prc on
#133. (Changed in 1.33MR11) Make trace options public in ANTLRParser
In checking T.J. Parr's ANSI C grammar for compatibility with
1.33MR11 discovered that it was inconvenient to have the
trace facilities with protected access.
#132. (Changed in 1.33MR11) Recognition of identical predicates in alts
Prior to 1.33MR11, there would be no ambiguity warning when the
very same predicate was used to disambiguate both alternatives:
test: ref B
| ref C
;
ref : <<pred(LATEXT(1)>>? A
In 1.33MR11 this will cause the warning:
warning: the predicates used to disambiguate rule test
(file v98.g alt 1 line 1 and alt 2 line 2)
are identical and have no resolving power
----------------- Note -----------------
This is different than the following case
test: <<pred(LATEXT(1))>>? A B
| <<pred(LATEXT(1)>>? A C
;
In this case there are two distinct predicates
which have exactly the same text. In the first
example there are two references to the same
predicate. The problem represented by this
grammar will be addressed later.
#131. (Changed in 1.33MR11) Case insensitive command line options
Command line switches like "-CC" and keywords like "on", "off",
and "stdin" are no longer case sensitive in antlr, dlg, and sorcerer.
#130. (Changed in 1.33MR11) Changed ANTLR_VERSION to int from string
The ANTLR_VERSION was not an integer, making it difficult to
perform conditional compilation based on the antlr version.
Henceforth, ANTLR_VERSION will be:
(base_version * 10000) + release number
thus 1.33MR11 will be: 133*100+11 = 13311
Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE).
#129. (Changed in 1.33MR11) Addition of ANTLR_VERSION to <parserName>.h
The following code is now inserted into <parserName>.h amd
stdpccts.h:
#ifndef ANTLR_VERSION
#define ANTLR_VERSION 13311
#endif
Suggested by Rainer Janssen (Rainer.Janssen@Informatik.Uni-Oldenburg.DE)
#128. (Changed in 1.33MR11) Redundant predicate code in (<<pred>>? ...)+
Prior to 1.33MR11, the following grammar would generate
redundant tests for the "while" condition.
rule2 : (<<pred>>? X)+ X
| B
;
The code would resemble:
if (LA(1)==X) {
if (pred) {
do {
if (!pred) {zzfailed_pred(" pred");}
zzmatch(X); zzCONSUME;
} while (LA(1)==X && pred && pred);
} else {...
With 1.33MR11 the redundant predicate test is omitted.
#127. (Changed in 1.33MR11)
Count Syntax Errors Count DLG Errors
------------------- ----------------
C++ mode ANTLRParser:: DLGLexerBase::
syntaxErrCount lexErrCount
C mode zzSyntaxErrCount zzLexErrCount
The C mode variables are global and initialized to 0.
They are *not* reset to 0 automatically when antlr is
restarted.
The C++ mode variables are public. They are initialized
to 0 by the constructors. They are *not* reset to 0 by the
ANTLRParser::init() method.
Suggested by Reinier van den Born (reinier@vnet.ibm.com).
#126. (Changed in 1.33MR11) Addition of #first <<...>>
The #first <<...>> inserts the specified text in the output
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?