>? ) should not
have side-effects. If there is no match then the rest of the rule using the
semantic predicate won't be executed.
Page 39
(Item 117)
##. What is the "context" of a semantic predicate ? Answer due to TJP:
The context of a predicate is the set of k-strings (comprised of lookahead
symbols) that can be matched following the execution of a predicate. For
example,
a : <>? alpha ;
The context of "p" is LOOK(alpha) where LOOK(alpha) is the set of
lookahead k-strings for alpha.
Normally, one should compute the context for ANTLR (manually) because
ANTLR is not smart enough to know the nature of your predicate and does not
know how much context information is needed; it's conservative and tries
to compute full LL(k) lookahead. Normally, you only need one token:
class_name: <>? ID ;
This example is incomplete, the predicate should really be:
class_name: <>? ID ;
This says, "I can tell you something if you have an ID, otherwise
just assume that the rule is semantically valid." This only makes a
difference if the predicate is *hoisted* out of the rule. Here is an
example that won't work because it doesn't have context check in the
predicates:
a : ( class_name | NUM )
| type_name
;
class_name : <>? ID ;
type_name : <>? ID ;
The prediction for production one of rule "a" will be:
if ( LA(1) in { ID, NUM } && isClass(LATEXT(1)) ) { ...
Clearly, NUM will never satisfy isClass(), so the production will never
match.
When you ask ANTLR to compute context, it can check for missing predicates.
With -prc on, for this grammar:
a : b
| <>? ID
| <>? NUM
;
b : <>? ID
| NUM
;
ANTLR reports:
warning alt 1 of rule itself has no predicate to resolve
ambiguity upon \{ NUM \}
Page 40
(Item 118)
##. A documented restriction of ANTLR is the inability to hoist multiple
semantic predicates. However, no error message is given when one attempts
this. When compiled with k=1 and ck=2 this generates inappropriate code
in "statement" when attempting to predict "expr":
#header <<
#include "charbuf.h"
int istypedefName (char *);
int isCommand (char *);
>>
#token BARK
#token GROWL
#token ID
statement
: expr
| declaration
;expr
: commandName BARK
| typedefName GROWL
;declaration
: typedefName BARK
;typedefName
: <>? ID
;commandName
: <>? ID
;
The generated code resembles the following:
void statement()
{
if ( (LA(1)==ID) &&
(LA(2)==BARK || LA(2)==GROWL) &&
( (LA(1)==ID ? isCommand(LATEXT(1)) : 1) ||
(LA(1)==ID ? istypedefName(LATEXT(1)) : 1)) ) {
expr();
} else {
if ( (LA(1)==ID) &&
(LA(2)==BARK) &&
(LA(1)==ID ? istypedefName(LATEXT(1)) : 1)) ) {
declaration();
} ...
The problem is that " BARK" will be passed to expr() rather
than declaration().
Some help is obtained by using leading actions to inhibit hoisting as
described in the next notes. (Don't confuse leading actions with
init-actions.) However, omitting all semantic predicates in the prediction
expression doesn't help if one requires them to predict the rule.
Page 41
(Item 119)
##. Leading actions will inhibit the hoisting of semantic predicates into
the prediction of rules.
expr_rhs
: <<;>> <<>> expr0
| command
See the section about known bugs for a more complete example.
(Item 120)
##. When using semantic predicates in ANTLR is is *IMPORTANT* to
understand what the "-prc on" ("predicate context computation")
option does and what "-prc off" doesn't do. Consider the following
example:
+------------------------------------------------------+
| Note: All examples in this sub-section are based on |
| code generated with -k=1 and -ck=1. |
+------------------------------------------------------+
expr : upper
| lower
| number
;
upper : <>? ID ;
lower : <>? ID ;
number : NUMBER ;
With "-prc on" ("-prc off" is the default) the code for expr() to predict
upper() would resemble:
if (LA(1)==ID && isU(LATEXT(1)) && LA(1)==ID) { /* a1 */
upper(zzSTR); /* a2 */
} /* a3 */
else { /* a4 */
if (LA(1)==ID && isL(LATEXT(1)) && LA(1)==ID) { /* a5 */
lower(zzSTR); /* a6 */
} /* a7 */
else { /* a8 */
if (LA(1)==NUMBER) { /* a9 */
zzmatch(NUMBER); /* a10 */
} /* a11 */
else /* a12 */
{zzFAIL();goto fail;} /* a13 */
} /* a14 */
} ...
...
*******************************************************
*** ***
*** Starting with version 1.20: ***
*** Predicate tests appear AFTER lookahead tests ***
*** ***
*******************************************************
Note that each test of LATEXT(i) is guarded by a test of the token type
(e.g. "LA(1)==ID && isU(LATEXT(1)").
Page 42
With "-prc off" the code would resemble:
if (isU(LATEXT(1)) && LA(1)==ID) { /* b1 */
upper(zzSTR); /* b2 */
} /* b3 */
else { /* b4 */
if (isL(LATEXT(1)) && LA(1)==ID) { /* b5 */
lower(zzSTR); /* b6 */
} /* b7 */
else { /* b8 */
if ( (LA(1)==NUMBER) ) { /* b9 */
zzmatch(NUMBER); /* b10 */
} /* b11 */
else /* b12 */
{zzFAIL();goto fail;} /* b13 */
} /* b14 */
} ...
...
Thus when coding the grammar for use with "-prc off" it is necessary
to do something like:
upper : <>? ID ;
lower : <>? ID ;
This will make sure that if the token is of type NUMBER that it is not
passed to isU() or isL() when using "-prc off".
So, you say to yourself, "-prc on" is good and "-prc off" is bad. Wrong.
Consider the following slightly more complicated example in which the
first alternative of rule "expr" contains tokens of two different types:
expr : ( upper | NUMBER ) NUMBER
| lower
| ID
;
upper : <>? ID ;
lower : <>? ID ;
number : NUMBER ;
With "-prc off" the code would resemble:
...
{ /* c1 */
if (LA(1)==ID && isU(LATEXT(1)) && /* c2 */
( LA(1)==ID || LA(1)==NUMBER) ) { /* c3 */
{ /* c4 */
if (LA(1)==ID) { /* c5 */
upper(zzSTR); /* c6 */
} /* c7 */
else { /* c8 */
if (LA(1)==NUMBER) { /* c9 */
zzmatch(NUMBER); /* c10 */
} /* c11 */
else {zzFAIL();goto fail;}/* c12 */
} /* c13 */
} ...
...
Page 43
Note that if the token is a NUMBER (i.e. LA(1)==NUMBER) then the clause at
line c2 ("LA(1)==ID && ...") will always be false, which implies that the
test in the "if" statement (lines c2/c3) will always be false. (In other
words LA(1)==NUMBER implies LA(1)!=ID). Thus the sub-rule for NUMBER at
line c9 can never be reached.
With "-prc on" essentially the same code is generated, although it
is not necessary to manually code a test for token type ID preceding
the call to "isU()".
The workaround is to to bypass the heart of the predicate when
testing the wrong type of token.
upper : <>? ID ;
lower : <>? ID ;
Then with "-prc off" the code would resemble:
...
{ /* d1 */
if ( (LA(1)==ID ? isU(LATEXT(1)) : 1) && /* d2 */
(LA(1)==ID || LA(1)==NUMBER) ) { /* d3 */
...
...
With this correction the body of the "if" statement is now reachable
even if the token type is NUMBER - the "if" statement does what one
wants.
With "-prc on" the code would resemble:
... /* e1 */
if (LA(1)==ID && /* e2 */
(LA(1)==ID ? isU(LATEXT(1)) : 1) && /* e3 */
(LA(1)==ID || LA(1)==NUMBER) ) { /* e4 */
...
...
Note that the problem of the unreachable "if" statement body has
reappeared because of the redundant test ("e2") added by the predicate
computation.
The lesson seems to be: when using rules which have alternatives which
are "visible" to ANTLR (within the lookahead distance) that have different
token types it is probably dangerous to use "-prc on".
Page 44
(Item 121)
##. You cannot use downward inheritance to pass parameters
to semantic predicates which are NOT validation predicates. The
problem appears when the semantic predicate is hoisted into a
parent rule to predict which rule to call:
For instance:
a : b1 [flag]
| b2
| b3
b1 [int flag]
: <>? ID ;
b2 :
: <>? ID ;
b3 : ID ;
When the semantic predicate is evaluated within rule "a" to determine
whether to call b1, b2, or b3 the compiler will discover that there
is no variable named "flag" for procedure "a()". If you are unlucky
enough to have a variable named "flag" in a() then you will have a
VERY difficult-to-find bug.
The -prc option has no effect on this behavior.
It is possible that a leading action (init-actions are ignored for purposes
of hoisting) will inhibit the hoisting of the predicate and make this code
work. I have not verified this with versions 1.2x.
(Item 122)
##. Another reason why semantic predicates must not have side effects is
that when they are hoisted into a parent rule in order to decide which
rule to call they will be invoked twice: once as part of the prediction
and a second time as part of the validation of the rule.
Consider the example above of upper and lower. When the input does
in fact match "upper" the routine isU() will be called twice: once inside
expr() to help predict which rule to call, and a second time in upper() to
validate the prediction. If the second test fails the macro zzpred_fail()
is called.
As far as I can tell, there is no simple way to disable the use of a
semantic predicate for validation after it has been used for prediction.
Page 45
(Item 123)
##. I had a problem in which I needed to do a limited amount of
lookahead, but didn't want to use all the machinery of syntactic
predicates. I found that I could enlarge the set of expressions accepted
by "expr" and then look at the AST created in order to determined what
rules could follow:
cast_expr /* a1 */
: <> /* a2 */
/* a3 */
LP! predefined_type RP! cast_expr /* a4 */
<<#0=#(toAST(T_cast),#0);>> /* a5 */
| LP! expr0 RP! /* a6 */
<token)==T_class_name) { /* a7 */
isCast=1; /* a8 */
} else { /* a9 */
isCast=0; /* a10 */
}; /* a11 */
>> /* a12 */
( <<;>> <>? /* a13 */
<> /* a14 */
cast_expr /* a15 */
<<#0=#(toAST(T_cast),#0);>> /* a16 */
/* a17 */
| <> /* a18 */
() /* empty */ /* a19 */
) /* a20 */
| unary_expr /* a21 */
Later on I gave up on this approach and decided to use syntactic
predicates anyway. It not only solved this problem, but others
where it was more difficult to patch up the grammar. I can't bring
myself to remove the example, though.
Page 46
===============================================================================
Section on Syntactic Predicates (also known as "Guess Mode")
-------------------------------------------------------------------------------
(Item 124)
##. The terms "infinite lookahead", "guess mode","syntactic predicates"
are all equivalent. Sometimes the term "backtracking" is used as well,
although " backtracking" can sometimes be used to discuss lexing and DLG
as well. The term "syntactic predicate" emphasizes that is handled by the
parser. The term "guess mode" emphasizes that the parser may have to
backtrack. The term "infinite lookahead" emphasizes the implementation in
ANTLR: the entire input is read, processed, and tokenized by DLG before
ANTLR begins parsing.
(Item 125)
##. An expression in a syntactic predicate should not have side-effects.
If there is no match then the rule which uses the syntactic predicate won't be
executed.
(Item 126)
##. In some extremely unusual cases a user wants side-effects during guess
mode. In this case one can use exploit the fact that Antlr always
executes init-actions, even when in guess mode:
rule : (guess)? A
| B
;
guess : <>
A ( <> ) B
;
The init-action in the sub-rule will always be executed, even in guess-mode.
Contributed by TJP.
(Item 127)
##. When using syntactic predicates the entire input buffer is read and
tokenized by DLG before parsing by ANTLR begins. If a "wrong" guess
requires that parsing be rewound to an earlier point all attributes
that were creating during the "guess" are destroyed and the parsing
begins again and it creates new attributes at it reparses the (previously)
tokenized input.
(Item 128)
##. In infinite lookahead mode the line and column information is
hopelessly out-of-sync because zzline will contain the line number of
the last line of input - the entire input was parsed before
scanning was begun. The line and column information is not restored
during backtracking. To keep track of the line information in a meaningful
way one has to use the ZZINF_LINE macro which was added to pccts in version
1.20.
Putting line and column information in a field of the attribute will not
help. The attributes are created by ANTLR, not DLG, and when ANTLR
backtracks it destroys any attributes that were created in making the
incorrect guess.
(Item 129)
##. As infinite lookahead mode causes the entire input to be scanned
by DLG before ANTLR begins parsing, one cannot depend on feedback from
the parser to the lexer to handle things like providing special token codes
for items which are in a symbol table (the "lex hack" for typedefs
in the C language). Instead one MUST use semantic predicates which allow
for such decisions to be made by the parser.
(Item 130)
##. One cannot use an interactive scanner (ANTLR -gk option) with the
ANTLR infinite lookahead and backtracking options (syntactic predicates).
Page 47
(Item 131)
##. An example of the need for syntactic predicates is the case where
relational expressions involving "<" and ">" are enclosed in angle bracket
pairs.
Relation: a < b
Array Index: b
Problem: a < b
vs. b < a>
I was going to make this into an extended example, but I haven't had
time yet.
(Item 132)
##. Version 1.20 fixes a problem in 1.10 in which ASTs were constructed
during guess mode. In version 1.10 care had to be taken to deallocate the
ASTs that were created in the rules which were invoked in guess mode.
(Item 133)
##. The following is an example of the use of syntactic predicates.
program : ( s SEMI )* ;
s : ( ID EQUALS )? ID EQUALS e
| e
;
e : t ( PLUS t | MINUS t )* ;
t : f ( TIMES f | DIV f )* ;
f : Num
| ID
| "\(" e "\)"
;
When compiled with k=1:
antlr -fe err.c -fh stdpccts.h -fl parser.dlg -ft tokens.h \
-fm mode.h -k 1 test.g
One gets the following warning:
warning: alts 1 and 2 of the rule itself ambiguous upon { ID }
even though the manual suggests that this is okay. The only problem is
that ANTLR 1.10 should NOT issue this error message unless the -w2 option
is selected.
Included with permission of S. Salters
Page 48
===============================================================================
Section on Inheritance
-------------------------------------------------------------------------------
(Item 134)
##. A rule which uses upward inheritance:
rule > [int result] : x | y | z;
Is simply declaring a function which returns an "int" as a function
value. If the function has more than one item passed via upward
inheritance then ANTLR creates a structure to hold the result and
then copies each component of the structure to the upward inheritance
variables.
(Item 135)
##. When writing a rule that uses downward inheritance:
rule [int *x] : r1 r2 r3
one should remember that the arguments passed via downward inheritance are
simply arguments to a function. If one is using downward inheritance
syntax to pass results back to the caller (really upward inheritance !)
then it is necessary to pass the address of the variable which will receive
the result.
(Item 136)
##. ANTLR is smart enough to combine the declaration for an AST with
the items declared via downward inheritance when constructing the
prototype for a function which uses both ASTs and downward inheritance.
Page 49
===============================================================================
Section on LA, LATEXT, NLA, and NLATEXT
-------------------------------------------------------------------------------
(Item 137)
##. Do not use LA(i) or LATEXT(i) in the action routines of #token
statements. To refer to the token code (in a #token action) of the token
just recognized use "NLA". NLA is an lvalue (can appear on the left hand
side of an assignment statement). To refer to the text just recognized
use zzlextext (the entire text), NLATEXT. One can also use
zzbegexpr/zzendexpr which refer to the regular expression just matched.
The char array pointed to by zzlextext may be larger than the string
pointed to by zzbegexpr and zzendexpr because it includes substrings
accumulated through the use of zzmore().
(Item 138)
##. Extra care must be taken in using LA(i) and LATEXT(i) when in
interactive mode (Antlr switch -gk) because Antlr doesn't guarantee that
it will fetch lookahead tokens until absolutely necessary. It is somewhat
safer to refer to lookahead information in semantic predicates, but care
is still required. I have summarized the output from Example 7:
-----------------------------------------------------------------------
k=1 k=1 k=3 k=3 k=3
standard infinite standard interactive infinite
-----------------------------------------------------------------------
for a semantic predicate
------------------------
LA(0) Next Next -- -- --
LA(1) Next Next Next Next Next
zzlextext Next Next Next -- Next
ZZINF_LA(0) Next Next
ZZINF_LA(1) NextNext NextNext
-----------------
for a rule action
-----------------
LA(0) Prev Prev -- Prev --
LA(1) Prev Prev Prev Next Prev
zzlextext Prev Prev Prev -- Prev
ZZINF_LA(0) Prev Prev
ZZINF_LA(1) Next Next
-----------------------------------------------------------------------
The entries "prev" and "next" means that the left hand item refers to the
token which precedes (or follows) the action which generated the output.
For semantic predicate entries think of the following rule:
rule : <>? Next NextNext;
For rule-action entries think of the following rule:
rule : Prev <> Next NextNext;
(Item 139)
##. Example 7 below gives some diagnostic output for a k=3 grammar compiled
with "standard" options, interactive options (AFLAGS=-gk), and infinite
lookahead option (CFLAGS=-DZZINF_LOOK).
(Item 140)
##. Example 8 shows how to modify the lookahead token NLA.
Page 50
(Item 141)
##. I find it helpful to think of lexical processing by DLG as a process
which fills a pipeline and of Antlr as a process which empties a pipeline.
(This relationship is exposed in C++ mode because DLG passes an object of
a certain class to Antlr).
With LL_K=1 the pipeline is only one item deep and is trivial and pretty much
invisible. It is invisible because one can make a decision in Antlr which
affects how the very next token is processed. For instance with LL_K=1 it is
possible to change the DLG mode in an Antlr action with zzmode() and have
the next token (the one following the one just parsed by Antlr) parsed
according to the new #lexclass.
With LL_K>1 the pipeline is not invisible. DLG will put a number of tokens
into the pipeline and Antlr will analyze them in the same order. How many
tokens are in the pipeline depends on options one has chosen.
Case 1: If one has infinite lookahead mode ("(...)?") (also known as
syntactic predicates) then the pipeline is as huge as the input stream
since the entire input is tokenized by DLG before Antlr even begins
analysis.
Case 2: If you have demand lookahead (interactive mode) then you'll have a
varying amount of lookahead depending on how much Antlr thinks it needs to
parse the thing it is working on. This may be zero (or maybe its 1 token)
up to k tokens. Naturally it takes extra work by Antlr to keep track of
how many tokens are in the pipe and how many are needed to parse the next
rule.
Case 3: In "normal" mode DLG tries to stay exactly k tokens ahead of
Antlr. This is a half-truth. It rounds k up to the next power of
2 so that with k=3 it actually has a pipeline of 4 tokens. If one says
"k=3" the analysis is still k=3, but the pipeline size is rounded up
because TJP decided it was better to use a bit-wise "and" then some other
mechanism to compute (n+1) mod k - where n is the position in a circular
buffer.
Page 51
===============================================================================
Section on Prototypes
-------------------------------------------------------------------------------
(Item 142)
##. Prototype for typical create_attr routine:
#define zzcr_attr(attr,token,text) \
create_attr(attr,token,text)
void create_attr (Attrib *attr,int token,char *text);
(Item 143)
##. Prototype for a typical create_ast routine invoked to automatically
construct an AST from an attribute:
#define zzcr_ast(ast,attr,tok,astText) \
create_ast(ast,attr,tok,text)
void create_ast (AST *ast,Attr *attr,int tok,char *text);
(Item 144)
##. Prototype for a typical make_ast routine invoked by the #[...]
notation.
AST *zzmk_ast (AST *ast,int token,char *text)
(Item 145)
##. Prototype for a typical zzd_ast macro which is invoked when destroying
an AST node:
#define zzd_ast(node) delete_ast(node)
void delete_ast (AST * node);
(Item 146)
##. Prototype for zzdef0 macro to initialize $0 of a rule:
#define zzdef0(attr) define_attr_0 (attr)
void define_attr_0 (Attrib *attr);
(Item 147)
##. Prototype for ANTLR (these are actually macros):
read from file: void ANTLR (void startRule(...),FILE *)
read from string: void ANTLRs (void startRule(...),zzchar_t *)
read from function: void ANTLRf (void startRule(...),int (*)())
read from file: void ANTLRm
(void startRule(...),FILE *,int lexclass)
In the call to ANTLRf the function behaves like getchar()
in that it returns EOF (-1) to indicate end-of-file.
If ASTs are used or there is downward or upward inheritance then the
call to the startRule must pass these arguments:
AST *root;
ANTLRf (startRule(&root),stdin);
Page 52
===============================================================================
Section on ANTLR/DLG Internals and Routines That Might Be Useful
-------------------------------------------------------------------------------
****************************
****************************
** **
** Use at your own risk **
** **
****************************
****************************
(Item 148)
##. Sometimes I have wanted to add code which appears before every
#token action or after every #token action. Rather than modify every
#token statement one could add code to pccts/h/dlgauto.h near line 430:
(*actions)[accepts[state]]();
This statement is executed for every #token statement. Even #token
statements without a user-written action contain the required action:
NLA=TokenIdentifier
Following the statement near line 430 of dlgauto.h would be an appropriate
place to insert debug code to print out token definitions. The name
for token "i" is in the char * array zztokens[i] (defined in antlr.h).
(Item 149)
##. static int zzauto - defined in dlgauto.h
Current DLG mode. This is used by zzmode() only.
(Item 150)
##. void zzerr (char * s) defined in dlgauto.h
Defaults to zzerrstd(char *s) in dlgauto.h
Unless replaced by a user-written error reporting routine:
fprintf(stderr,
"%s near line %d (text was '%s')\n",
((s == NULL) ? "Lexical error" : s),
zzline,zzlextext);
This should probably be "void zzerr (const char * s)".
(Item 151)
##. static char zzebuf[70] defined in dlgauto.h
Page 53
===============================================================================
Section on Known Minor Bugs in pccts (in reverse chronological order)
-------------------------------------------------------------------------------
(Item 152)
##. Fixed in 1.30b2: The generation of sets for #errclass may reference
bits beyond the end of the set. Modify line 462 in pccts/antlr/bits.c:
old: endp = &(f->setword[NumWords(TokenNum-1)]);
workaround: endp = &(f->setword[f->n]);
(Item 153)
##. The fail action following a semantic predicate is not enclosed
in "{...}". This can lead to problems when the fail action contains
more than one statement. Reported by Douglas Cuthbertson
([email protected]_qmail.hanscom.af.mil).
(Item 154)
##. Fixed in 1.23: In version 1.22 (and earlier versions) when there are
more than 255 #token statements then a truncation problem occurs in
zzedecode() during the creation of the zzerr(i) for err.c. The problem was
reported in netnews #517.
(Item 155)
##. Fixed in 1.23: In version 1.22 (and earlier versions) there is a bug in
set_sub().
(Item 156)
##. Reported as fixed in 1.23: In C++ mode in versions 1.20, 1.21, and
1.22 there is a bug which can cause ANTLR to generate an ast temporary
with the same label more than once in a module. A patch to to genast.c is
described in netnews note #449. The problem was reported by Sanjay
Ghemawat ([email protected])
(Item 157)
##. Reported as fixed in 1.22: The following problem was first reported
by Carle Patrice in netnews note #347. TJP describes the problem in
netnews note #428:
It is related to lookahead computation for k=3 with a hoisted
predicate. I have reduced the error to this case:
a : (A B | B C) | b ;
b : <>? B B ;
It did not compute the correct lookahead decision for
alternative one in rule "a". It should generate:
if ( (LA(1)==A || LA(1)==B) && (LA(2)==B || LA(2)==C) &&
!((LA(1)==B&&(LA(2)==B))) ) {
...
}
else blah
*NOT* simply:
if ( (LA(1)==A || LA(1)==B) && (LA(2)==B || LA(2)==C) ) {
...
}
else blah
(Item 158)
##. Reported as fixed in 1.21: With version 1.20 (1-Apr-94) of ANTLR the
-w2 switch will sometimes cause items to be reported as lacking an
associated regular expression when they actually do have an associated
regular expression. Sometimes #lexclass names and #tokclass names will
also be reported.
Page 54
(Item 159)
##. The UPDATE.120 of (1-Apr-94) reports that there are problems in
combining guess mode and semantic predicates under some circumstances.
(Item 160)
##. Reported as fixed in 1.21: In version 1.20 there is a bug in the
1-Apr-94 distribution of routine _zzsetmatch() which appears when used
with ANTLR -gk (demand lookahead.
(Item 161)
##. Reported as fixed in 1.21: In version 1.20 a rule which returns more
than two arguments (via upward inheritance) generates code which cannot be
compiled by a strict K&R compiler. It is accepted by ANSI compilers,
however. Reported by Joachim Schrod ([email protected]).
(Item 162)
##. Reported fixed in 1.20: In version 1.10 there was a bug in the
hoisting of semantic predicates when all alternatives of a rule had the
same lookahead token. Consider the following (compiled with -prc off -k 1
-ck 3):
;obj_name
: global_func_id
| simple_class SUFFIX_DOT
| ID
;simple_class
: <<(LA(1)==ID ? isClass(LATEXT(1)) : 1)>>? ID
;global_func_id
: <<(LA(1)==ID ? isFunction(LATEXT(1)) : 1)>>? ID
In version 1.2x the generated code resembles:
void obj_name(void) {
if ( (LA(1)==ID) &&
(LA(1)==ID ? isFunction(LATEXT(1)) : 1)) ) {
global_func_id();
} else {
if ( (LA(1)==ID) &&
(LA(2)==SUFFIX_DOT) ) {
simple_class();
} else {
if ( (LA(1)==ID) ) {
zzmatch(ID);
...
The workaround, previously, was to precede semantic predicates with an
action (such as "<<;>>") which inhibits hoisting into the prediction
expression.
Page 55
#header
<<
#include "charptr.h"
>>
#token QUESTION
#token COMMA
#token ID
#token Eof "@"
#token SUFFIX_DOT
statement
: (information_request)?
| obj_name
;information_request
: QUESTION id_list ( QUESTION )*
| id_list ( QUESTION )+
;id_list
: obj_name ( COMMA | obj_name )*
;simple_class
: <<(LA(1)==ID ? isClass(LATEXT(1)) : 1)>>? ID
;global_func_id
: <<(LA(1)==ID ? isFunction(LATEXT(1)) : 1)>>? ID
;obj_name
: <<;>> global_func_id
| <<;>> simple_class SUFFIX_DOT
| ID
;
Page 56
===============================================================================
Ideas on the Construction of ASTs and their use with Sorcerer
-------------------------------------------------------------------------------
Consider the problem of a grammar which would normally require two
passes through the source code to properly analyze. In some cases
it is convenient to perform a first pass which creates AST trees
and perform the second pass by analyzing the AST trees with Sorcerer.
1) Define an AST node that contains the information you'll need in the
second pass. For example,
/*
* Parse trees are represented by an abstract-syntax-tree (AST)
* (forward declare the pointer here). Refer to parse.h for description
* of parse_info.
*/
typedef struct parse_struct *ast_ref;
/* parser attributes ($-symbols) & AST nodes */
typedef struct parse_struct *pinfo_ref;
/*
* the parse structure is used to describe both attributes and
* AST nodes
*/
struct parse_struct {
pinfo_ref right; /* points to siblings */
pinfo_ref down; /* points to children */
int token; /* token number (see tokens.h) */
char *text; /* input text */
src_pos pos; /* position in source file */
object_ref obj; /* object description (id's) */
type_ref typ; /* type description (expr's) */
const_value value; /* value of a constant expression */
} ;
/*
* define Abstract Syntax Tree (AST) nodes
*/
/* ast_ref was forward-defined */
typedef struct parse_struct AST;
/*
* the Pass-1 (parse phase) parse-attributes ($-variables)
* have the same structure as an AST node.
*/
typedef struct parse_struct Attrib, *Attrib_ref;
In the code above, the parse-attribute was defined to have the same
structure as an AST node. This isn't a requirement, but just makes it
easier to pass information produced in the first pass on to subsequent
passes.
Page 57
2) Have the first pass build a symbol table as it parses the input, perform
semantic checks, and build an AST. Use the -gt (generate tree) option on
ANTLR, and override the automatically generated tree construction operations
as needed. For example,
var_declare:
<< pvec_ref v_list;
int i;
boolean has_var_section = FALSE;
>>
VAR^
(
var_id_list > [v_list] COLON
{ extern_kw
| static_kw
}
type
<<
for (i = 0; i < v_list->len; ++i) {
object_ref v = (object_ref) v_list->val[i];
define_var(v, $4.typ);
}
>>
{ ASSIGNMENT expr
<< mark_var_use(#2, VAR_RHS); >>
}
SEMI
<< free_pvec(v_list); >>
)+
;
var_id_list > [pvec_ref v_list]:
<< object_ref this_var;
$v_list = new_pvec();
>>
ID
<< this_var = new_var_id(&$1);
if (this_var != NULL) append_pvec($v_list, (void *)this_var);
>>
(
COMMA ID
<< this_var = new_var_id(&$2);
if (this_var != NULL) append_pvec($v_list, (void *)this_var);
>>
)*
;
The "pvec" stuff above is just a vector of pointers that can be
extended automatically. A linked list would work just as well. The
idea is that we must first collect the declared variables, then
parse the type declaration, then apply bind the type to the declared
variables. We used ANTLR's auto-tree-generation mode, and didn't
override its actions with our own. Therefore, the following Sorcerer
fragment will recognize the AST built for a variable declaration:
Page 58
var_declare:
#( VAR
( v_list: var_id_list COLON
{ EXTERN | STATIC }
type
{ ASSIGNMENT expr }
SEMI
)+
)
;
var_id_list:
ID ( COMMA ID)*
;
Here's an example, where we use explicit rules to build an AST:
expr!:
simple_expr
<< $expr = $1; #0 = #1; >>
( rel_op simple_expr
<< parse_binary_op(&$expr, &$1, &$2); #0 = #(NULL, #0, #1, #2); >>
)*
<< $expr.token = EXPR;
$expr.text = "expr";
#0 = #(#[&$expr], #0);
>>
;
The construct, #[&$expr] first takes the address of the $expr
attribute (attributes are structures, not pointers, in this example),
and then applies the #[] operation which makes a call to the routine
that creates an AST node, given an attribute (or attribute address
in our case). It takes a while to get the hang of where the &'s
#'s, and $'s go, but can be a real time-saver once you master it.
What we're doing above is building a special EXPR (expression) node.
This node would be parsed as follows in subsequent passes, using
Sorcerer:
expr: #( e: EXPR
l_oprnd: simple_expr << e->typ = l_oprnd->typ; >>
(op: rel_op r_oprnd: simple_expr
<<
e->typ = std_bool_type->obj_type;
if (op->token == IN) {
/* no type conversion checking for IN.
* try to rewrite simple IN ops.
*/
if (is_simple_in_op(l_oprnd, op, r_oprnd)) {
rewrite_simple_in_op(l_oprnd, op, r_oprnd);
}
} else {
cvt_term(&l_oprnd, op, r_oprnd, _t);
}
>>
)*
);
Page 59
We left in the actual actions of the second (Sorcerer driven) pass.
Notice how the Sorcerer grammar labels various parts of the expr
node ("e", "l_oprnd", "op", and "r_oprnd"). This gives the second
pass access to each node, as it is recognized.
The second pass uses the "typ" field, which contains the type of
the ID, expression, or literal parsed by the first pass. In the
actions above, we are propagating additional type information (for
example, the result of a relational op is always a boolean, checking
for implicit type conversions, and handling simple cases of Pascal's
IN operation). The fragment above is from a Pascal to Ada translator,
so the translator has to make Pascal's implicit type conversions
between integer and real into explicit Ada type conversions, and
has to convert operations on sets (i.e. IN) into operations on
packed boolean arrays, in Ada, or calls to runtime routines.
Sometimes when you are building the AST for a given construct,
you need to use information gained from semantic analysis. An
example is the "assignment" or "call" statement:
/*
* If a variable access appears alone, then it must be either a call to
* procedure with no parameters, or an indirection through a pointer
* to a procedure with no parameters.
*/
assign_or_call_stmt!:
<< type_ref r_type = NULL;
ast_ref v;
>>
variable
<< v = #1;
$assign_or_call_stmt = $1;
$assign_or_call_stmt.token = PROC_CALL;
$assign_or_call_stmt.text = "proc_call";
r_type = $assign_or_call_stmt.typ;
if (v != NULL && v->obj != NULL
&& v->obj->obj_result != NULL
&& v->obj->obj_kind == func_obj
&& v->down->token == ID
&& v->down->right == NULL) {
object_ref func = v->obj;
/* function name used on left hand side;
* convert to reference to the function's return value
*/
v->obj = func->obj_result;
v->typ = func->obj_result->obj_type;
v->down->text = func->obj_result->obj_name;
v->down->obj = func->obj_result;
v->down->typ = func->obj_result->obj_type;
}
#0 = v;
>>
Page 60
{ ASSIGNMENT expr
<< $assign_or_call_stmt.token = ASSIGNMENT;
$assign_or_call_stmt.text = ":=";
mark_var_use(#2, VAR_RHS);
mark_var_use(v, VAR_LHS);
#0 = #(NULL, #0, #[&$1], #2);
>>
| ( LPAREN actual_param_list RPAREN
<< mark_actual_param_use(#2, r_type);
mark_var_use(v, VAR_RHS);
#0 = #(NULL, #0, #[&$1], #2, #[&$3]);
>>
)
}
<< #0 = #( #[&$assign_or_call_stmt], #0); >>
;
The problem we're solving is that both an assignment statement and a
procedure call statement begin with a "variable". Since ANTLR is
LL-based, this statement construct is "ambiguous" in that both statement
types (assignment and call) begin with the same non-terminal. A
"variable" includes such operations as array subscripting, pointer
deferencing, and record field selection. Thus, a "variable" may comprise
an arbitrary number of tokens.
We might use syntactic predicates as a form a look-ahead to resolve the
two cases above, but instead I decided to make the assumption that we have
"PROC_CALL", and to correct that "guess" once we see the assignment
operation. Thus, the above rule will build one of the following two AST
structures:
assign_stmt:
#( ASSIGNMENT
variable ASSIGNMENT expr
)
;
call_stmt:
#( PROC_CALL
variable {LPAREN actual_param_list RPAREN}
)
;
In your AST, you might want to drop unnecessary syntactic tokens such as
ASSIGNMENT, LPAREN, RPAREN, COMMA, COLON, etc. We kept them, because we
thought it would be necessary for certain parts of source-to-source
translation. We don't think that's true, any more, but have not gone back
and changed the AST structure either.
Page 61
3) Build a separate Sorcerer grammar file to recognize the AST that you
have built, and then add your second pass actions. These actions will
access fields in the AST node, that were filled in by the first pass. For
example, identifiers will probably have an "object_ref" that points to the
object named by the identifier, and expression (EXPR) nodes will have a
"typ" field that gives the expression's type. You might also add a "value"
field that gives the value of a literal, named literal, or statically
evaluated constant expression. See the code fragments above for some ideas
on how this is done.
Conclusions:
1) You'll need an ANTLR (.g) description for pass1, and a separate
Sorcerer (.sor) description for pass2. Often the pass2 AST
representation is much more regular and well-formed than the
original text token stream used by pass1.
2) It can be a bit intimidating putting the pieces together.
Try it incrementally, trying a small subset of your larger
problem.
3) There are a lot of ways to go with how you represent
attributes ($-variables), AST nodes, and the things that
go on in various passes. For example, you might have
pass1 simply build the AST and perform *no* symbol definitions
or semantic checks. Then pass2 might walk the tree and build
the symbol, and make various checks. Pass2 might also disambiguate
cases that look syntactically similar, and can only be disambiguated
using symbol definitions. Then, you could have a pass3 (another
Sorcerer driven tree-walk) that does the 'real work' of your
compiler/translator.
Contributed by Gary Funck ([email protected])
Page 62
===============================================================================
Example 1 of #lexclass
===============================================================================
Borrowed code
-------------------------------------------------------------------------------
/*
* Various tokens
*/
#token "[\t\ ]+" << zzskip(); >> /* Ignore whitespace */
#token "\n" << zzline++; zzskip(); >> /* Count lines */
#token "\"" << zzmode(STRINGS); zzmore(); >>
#token "'" << zzmode(CHARACTERS); zzmore(); >>
#token "/\*" << zzmode(COMMENT); zzskip(); >>
#token "//" << zzmode(CPPCOMMENT); zzskip(); >>
/*
* C++ String literal handling
*/
#lexclass STRINGS
#token STRING "\"" << zzmode(START); >>
#token "\\\"" << zzmore(); >>
#token "\\n" << zzreplchar('\n'); zzmore(); >>
#token "\\r" << zzreplchar('\r'); zzmore(); >>
#token "\\t" << zzreplchar('\t'); zzmore(); >>
#token "\\[1-9][0-9]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 10));
zzmore(); >>
#token "\\0[0-7]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 8));
zzmore(); >>
#token "\\0x[0-9a-fA-F]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 16));
zzmore(); >>
#token "\\~[\n\r]" << zzmore(); >>
#token "[\n\r]" << zzline++; zzmore(); /* Print warning */ >>
#token "~[\"\n\r\\]+" << zzmore(); >>
/*
* C++ Character literal handling
*/
#lexclass CHARACTERS
#token CHARACTER "'" << zzmode(START); >>
#token "\\'" << zzmore(); >>
#token "\\n" << zzreplchar('\n'); zzmore(); >>
#token "\\r" << zzreplchar('\r'); zzmore(); >>
#token "\\t" << zzreplchar('\t'); zzmore(); >>
#token "\\[1-9][0-9]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 10));
zzmore(); >>
#token "\\0[0-7]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 8));
zzmore(); >>
#token "\\0x[0-9a-fA-F]*" << zzreplchar((char)strtol(zzbegexpr, NULL, 16));
zzmore(); >>
#token "\\~[\n\r]" << zzmore(); >>
#token "[\n\r]" << zzline++; zzmore(); /* Print warning */ >>
#token "~[\'\n\r\\]" << zzmore(); >>
Page 63
/*
* C-style comment handling
*/
#lexclass COMMENT
#token "\*/" << zzmode(START); zzskip(); >>
#token "~[\*]*" << zzskip(); >>
#token "\*~[/]" << zzskip(); >>
/*
* C++-style comment handling
*/
#lexclass CPPCOMMENT
#token "[\n\r]" << zzmode(START); zzskip(); >>
#token "~[\n\r]" << zzskip(); >>
#lexclass START
/*
* Assorted literals
*/
#token OCT_NUM "0[0-7]*"
#token L_OCT_NUM "0[0-7]*[Ll]"
#token INT_NUM "[1-9][0-9]*"
#token L_INT_NUM "[1-9][0-9]*[Ll]"
#token HEX_NUM "0[Xx][0-9A-Fa-f]+"
#token L_HEX_NUM "0[Xx][0-9A-Fa-f]+[Ll]"
#token FLOAT_NUM "([1-9][0-9]*{.[0-9]*} | {0}.[0-9]+) {[Ee]{[\+\-]}[0-9]+}"
/*
* Identifiers
*/
#token Identifier "[_a-zA-Z][_a-zA-Z0-9]*"
Page 64
===============================================================================
Example 2: ASTs
===============================================================================
#header <<
#include "charbuf.h"
#include
int nextSerial;
#define AST_FIELDS int token; int serial; char *text;
#include "ast.h"
#define zzcr_ast(ast,attr,tok,astText) \
(ast)->token=tok; \
(ast)->text=strdup( (char *) &( ( (attr)->text ) ) ); \
nextSerial++; \
(ast)->serial=nextSerial; \
#define zzd_ast(node) delete_ast(node)
void delete_ast (AST *node);
>>
<<
AST *root=NULL;
void show(AST *tree) {
if (tree->token==ID) {
printf (" %s <#%d> ",
tree->text,tree->serial);}
else {
printf (" %s <#%d> ",
zztokens[tree->token],
tree->serial);
};
}
void before (AST *tree) {
printf ("(");
}
void after (AST *tree) {
printf (")");
}
void delete_ast(AST *node) {
printf ("\nzzd_ast called for \n",node->serial);
free (node->text);
return;
}
Page 65
int main() {
nextSerial=0;
ANTLR (expr(&root),stdin);
printf ("\n");
zzpre_ast(root,show,before,after);
printf ("\n");
zzfree_ast(root);
return 0;
}
>>
#token WhiteSpace "[\ \t]" <>
#token ID "[a-z A-Z]*"
#token NEWLINE "\n"
#token OpenAngle "<"
#token CloseAngle ">"
expr : (expr0 NEWLINE)
;expr0 : expr1 {"="^ expr0}
;expr1 : expr2 ("\+"^ expr2)*
;expr2 : expr3 ("\*"^ expr3)*
;expr3 : ID
-------------------------------------------------------------------------------
Sample output from this program:
a=b=c=d
( = <#2> a <#1> ( = <#4> b <#3> ( = <#6> c <#5> d <#7> ))) NEWLINE <#8>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
a+b*c
( \+ <#2> a <#1> ( \* <#4> b <#3> c <#5> )) NEWLINE <#6>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
a*b+c
( \+ <#4> ( \* <#2> a <#1> b <#3> ) c <#5> ) NEWLINE <#6>
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
zzd_ast called for
Page 66
===============================================================================
Example 3: Syntactic Predicates
===============================================================================
Not completed.
===============================================================================
Example 4: DLG input function
===============================================================================
This example demonstrates the use of a DLG input function to work
around a limitation of DLG. In this example the user wants to
recognize an exclamation mark as the first character of a line and
treat it differently from an exclamation mark elsewhere. The
workaround is for the input function to return a non-printing
character (binary 1) when it finds an "!" in column 1. If it reads a
genuine binary 1 in column 1 of the input text it returns a "?".
The parse is started by:
int DLGchar (void);
...
ANTLRf (expr(&root),DLGchar);
...
-------------------------------------------------------------------------------
#token BANG "!"
#token BANG_COL1 "\01"
#token WhiteSpace "[\ \t]" <>
#token ID "[a-z A-Z]*"
#token NEWLINE "\n"
expr! : (bang <>
| bang1 <>
| id <>
)* "@"
;bang! : BANG ID NEWLINE
;bang1! : BANG_COL1 ID NEWLINE
;id! : ID NEWLINE
;
-------------------------------------------------------------------------------
Page 67
#include
/*
Antlr DLG input function - See page 18 of pccts 1.00 manual
*/
static int firstTime=1;
static int c;
int DLGchar (void) {
if (feof(stdin)) {
return EOF;
};
if (firstTime || c=='\n') {
firstTime=0;
c=fgetc(stdin);
if (c==EOF) return (EOF);
if (c=='!') return ('\001');
if (c=='\001') return ('?');
return (c);
} else {
c=fgetc(stdin);
return (c);
};
};
Page 68
===============================================================================
Example 5: Maintaining a Stack of DLG Modes
===============================================================================
Contributed by David Seidel
When placed in a #lexaction or a separate file then the modifier "static"
must be dropped from the declaration of zzauto (line 61) in "dlgauto.h".
These routines have now been incorporated in pccts version 1.30b4. They
are defined in pccts/h/err.h and are guarded by #ifdef USER_ZZMODE_STACK.
This example will be dropped if they are still part of 1.31 upon its official
release.
-------------------------------------------------------------------------------
#define MAX_MODE ???
#define ZZMAXSTK (MAX_MODE * 2)
static int zzmstk[ZZMAXSTK] = { -1 };
static int zzmdep = 0;
static char msgArea[100];
void
#ifdef __STDC__
zzmpush( int m )
#else
zzmpush( m )
int m;
#endif
{
if(zzmdep == ZZMAXSTK - 1)
{ sprintf(msgArea, "Mode stack overflow ");
zzerr(msgArea);
}
else
{ zzmstk[zzmdep++] = zzauto;
zzmode(m);
}
}
void
zzmpop()
{
if(zzmdep == 0)
{ sprintf(msgArea, "Mode stack underflow ");
zzerr(msgArea);
}
else
{ zzmdep--;
zzmode(zzmstk[zzmdep]);
}
}
Page 69
-------------------------------------------------------------------------------
A modified version of the above routine which allows the user to pass a
a routine to be executed when the mode is popped from the stack.
When placed in a #lexaction or a separate file then the modifier "static"
must be dropped from the declaration of zzauto (line 61) in "dlgauto.h".
-------------------------------------------------------------------------------
#define ZZMAXSTK ????
static int zzmstk[ZZMAXSTK] = { -1 }; /* stack of DLG modes */
static void (*zzfuncstk[ZZMAXSTK])(); /* stack of pointer to functions */
static int zzmdep = 0;
static char msgArea[100];
void pushMode( int m ,void (*func)())
{
if(zzmdep == ZZMAXSTK - 1)
{ sprintf(msgArea, "Mode stack overflow ");
zzerr(msgArea);
}
else
{ zzmstk[zzmdep] = zzauto;
zzfuncstk[zzmdep] = func;
zzmdep++;
zzmode(m);
}
}
void popMode()
{
void (*thisFunc)();
if(zzmdep == 0)
{ sprintf(msgArea, "Mode stack underflow ");
zzerr(msgArea);
}
else
{ zzmdep--;
thisFunc=zzfuncstk[zzmdep];
zzmode(zzmstk[zzmdep]);
zzmstk[zzmdep]=0;
zzfuncstk[zzmdep]=0;
/* this call might result in indirect recursion of popMode() */
if (thisFunc!=0) {
(*thisFunc)();
};
}
}
void resetModeStack() {
zzmdep=0;
zzmstk[0]=0;
zzfuncstk[0]=0;
}
/* if the lookahead character is a semi-colon then keep on popping */
void popOnSC() {
if (zzchar==';') popMode();
}
Page 70
===============================================================================
Example 6: Debug code for create_ast, mk_ast, delete_ast to locate lost ASTs
===============================================================================
This is an example of code which tries to keep track of lost ASTs using
a doubly linked list of all ASTs maintained by calls from create_ast()
and mk_ast() to zzastnew_userhook(). When ASTs are deleted by calls
to zzastdelete_userhook() from the user's AST delete routines they are
removed from the doubly linked list. Any ASTs left over after zzfree_ast()
must be considered lost.
This method does not monitor ASTs created by zzdup_ast() because it does
not call the create_ast() or mk_ast() routines.
-------------------------------------------------------------------------------
The #header section must include a definition of AST_FIELDS with the
equivalent of:
struct _ast *flink, *blink;
-------------------------------------------------------------------------------
int main() {
...
again:
...
reset_ASTlistHead(); /* <======================== */
ANTLR (sourcecode(&root),stdin);
treewalk(root);
zzfree_ast(root);
root=NULL;
print_lost_ast(); /* <======================= */
printf ("\n");}
...
goto again;
...
}
-------------------------------------------------------------------------------
#ifndef H_ZZNEWAST_USERHOOK
#define H_ZZNEWAST_USERHOOK
void reset_ASTlistHead(void);
void zzunhook_tree(void);
void zzastnew_userhook(AST *newNode);
void zzastdelete_userhook (AST *singleNode);
void print_lost_ast (void);
void treewalk(AST *tree);
#endif
-------------------------------------------------------------------------------
#include "stdpccts.h"
#include "stdlib.h"
#include "zzastnew_userhook.h"
static AST ASTlistHead;
static int ASTserialNumber;
void reset_ASTlistHead(void) {
while (ASTlistHead.flink!=0 && ASTlistHead.flink!= &ASTlistHead) {
zzfree_ast(ASTlistHead.flink);
};
ASTlistHead.flink=&ASTlistHead;
ASTlistHead.blink=&ASTlistHead;
ASTserialNumber=1;
return;
}
Page 71
/* Stop tracking ASTs in a tree without actually deleting them */
void zzunhook_tree (AST * tree) {
while (tree != 0) {
zzunhook_tree (tree->down);
zzastdelete_userhook (tree);
tree=tree->right;
};
return;
}
/* Track new AST */
void zzastnew_userhook(AST *newNode) {
AST *prev;
prev=ASTlistHead.blink;
prev->flink=newNode;
ASTlistHead.blink=newNode;
newNode->blink=prev;
newNode->flink=&ASTlistHead;
newNode->serialNumber=ASTserialNumber;
ASTserialNumber++;
return;
}
/* Stop tracking an AST */
void zzastdelete_userhook (AST *singleNode) {
AST *fnode;
AST *bnode;
if (singleNode!=0) {
fnode=singleNode->flink;
bnode=singleNode->blink;
fnode->blink=bnode;
bnode->flink=fnode;
singleNode->serialNumber=0;
singleNode->flink=0;
singleNode->blink=0;
};
return;
}
/* Print ASTs that are still on list */
void print_lost_ast () {
AST *node;
for (node=ASTlistHead.flink;
node!=0 && node!= &ASTlistHead;
node=node->flink) {
printf ("**** Start of lost AST listing **** %d\n",node->serialNumber);
treewalk (node); /* user supplied routine */
printf ("\n**** End of lost AST listing ****\n");
};
}
Page 72
-------------------------------------------------------------------------------
These routines print out the AST tree. This will be application dependent.
-------------------------------------------------------------------------------
#include "stdpccts.h"
#include "stdlib.h"
static int treenest=0;
void treeindent(int nesting) {
int i;
for (i=0;i
printf (" ");
};
return;
}
void treewalk1 (AST *tree) {
while (tree != NULL) {
treeindent(treenest);
printf ("%s",zztokens[tree->token]);
if (tree->text != NULL) {
printf (" %s",tree->text);
};
printf ("\n");
treenest++;
treewalk1 (tree->down);
treenest--;
tree=tree->right;
};
return;
}
void treewalk (AST *tree) {
treenest=0;
treewalk1(tree);
return;
}
Page 73
===============================================================================
Example 7: Difference Between Various Types of Lookahead in Antlr/DLG
===============================================================================
The following grammar with k=1 and standard lookahead is meant to show how
zzlextext and LATEXT(i) differ for the case k=1 and k=3 (see later
examples).
The use of LA(1) and LATEXT(1) in semantic predicates is OK, but their use
in actions is NOT recommended because, as the examples below show, there is
a variation in what LATEXT(1) means when it appears in an action.
Use attributes to refer to tokens already encountered.
-------------------------------------------------------------------------------
#header <<
#include "charbuf.h"
#define ZZCOL
>>
<<
/* Can't put quoted strings in semantic predicates in version 1.23 */
#define Semantic_Predicate_Of_1 "Semantic Predicate Of 1"
int AntlrCount=0;
int main() {
again: ANTLR (statement(),stdin);
return 0;
}
#define LANL(i) (*LATEXT(i) == '\n' ? "NL" : LATEXT(i))
#define LAINFNL(i) (*ZZINF_LATEXT(i) == '\n' ? "NL" : ZZINF_LATEXT(i))
void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d)\n",label,AntlrCount);
printf ("\tValue of zzbegcol: %d\n",zzbegcol);
printf ("\tLATEXT(0..1)={%s,%s}\n",
LANL(0),LANL(1));
printf ("\tzzlextext=%s\n",(zzlextext[0]=='\n' ? "NL" : zzlextext) );
#ifdef ZZINF_LOOK
printf ("\tZZINF_LATEXT(0..1)={%s,%s}\n",
LAINFNL(0),LAINFNL(1));
#endif
return;
}
>>
#lexaction <<
int DLGcount=0;
>>
Page 74
#token ID "[a-z]*"
<
DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ \t]*"
<>
#token NL "\n"
<
DLGcount,zzbegcol);
zzendcol=0;
zzline++;>>
statement : (formats) * "@"
;formats
: format1
| format2
;format1 :
<<(laDump(Semantic_Predicate_Of_1),1)>>?
ID
<>
ID
<>
ID
<>
NL
< Format 1 After: ID ID ID NL");>>
;format2 :
ID ID ID;
-------------------------------------------------------------------------------
The input data file:
-------------------------------------------------------------------------------
a b c
d e f
Page 75
-------------------------------------------------------------------------------
The output from the standard and the interactive parser were identical in
this case.
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 3
LATEXT(0..1)={b,b}
zzlextext=b
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 5
LATEXT(0..1)={c,c}
zzlextext=c
DLGcount: 6 Col 6 NL
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 6
LATEXT(0..1)={NL,NL}
zzlextext=NL
DLGcount: 7 Col 1 ID=(d)
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
DLGcount: 8 Col 2 WS
Page 76
-------------------------------------------------------------------------------
The same grammar and input file when compiled with -DZZINF_LOOK
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
DLGcount: 7 Col 1 ID=(d)
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..1)={a,a}
zzlextext=a
ZZINF_LATEXT(0..1)={a,b}
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..1)={b,b}
zzlextext=b
ZZINF_LATEXT(0..1)={b,c}
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 1
LATEXT(0..1)={c,c}
zzlextext=c
ZZINF_LATEXT(0..1)={c,NL}
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 1
LATEXT(0..1)={NL,NL}
zzlextext=NL
ZZINF_LATEXT(0..1)={NL,d}
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..1)={d,d}
zzlextext=d
ZZINF_LATEXT(0..1)={d,e}
Page 77
-------------------------------------------------------------------------------
The following grammar with k=3 is meant to show aspects of lookahead choices.
-------------------------------------------------------------------------------
#header <<
#include "charbuf.h"
#define ZZCOL
>>
<<
/* Can't put quoted strings in semantic predicates in version 1.23 */
#define Semantic_Predicate_Of_1 "Semantic Predicate Of 1"
int AntlrCount=0;
int main() {
again: ANTLR (statement(),stdin);
return 0;
}
#define LANL(i) (*LATEXT(i) == '\n' ? "NL" : LATEXT(i))
#define LAINFNL(i) (*ZZINF_LATEXT(i) == '\n' ? "NL" : ZZINF_LATEXT(i))
void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d)\n",label,AntlrCount);
printf ("\tValue of zzbegcol: %d\n",zzbegcol);
printf ("\tLATEXT(0..3)={%s,%s,%s,%s}\n",
LANL(0),LANL(1),LANL(2),LANL(3));
printf ("\tzzlextext=%s\n",(zzlextext[0]=='\n' ? "NL" : zzlextext) );
#ifdef ZZINF_LOOK
printf ("\tZZINF_LATEXT(0..3)={%s,%s,%s,%s}\n",
LAINFNL(0),LAINFNL(1),LAINFNL(2),LAINFNL(3));
#endif
return;
}
>>
#lexaction <<
int DLGcount=0;
>>
#token ID "[a-z]*"
<
DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ \t]*"
<>
#token NL "\n"
<
DLGcount,zzbegcol);
zzendcol=0;
zzline++;>>
Page 78
statement : (formats) * "@"
;formats
: format1
| format2
;format1 :
<<(laDump(Semantic_Predicate_Of_1),1)>>?
ID
<>
ID
<>
ID
<>
NL
< Format 1 After: ID ID ID NL");>>
;format2 :
ID ID ID NL < Format 2: ID ID ID");>>
;
-------------------------------------------------------------------------------
The input data file:
-------------------------------------------------------------------------------
a b c
d e f
Page 79
-------------------------------------------------------------------------------
When built with version 1.23 and "standard" options: AFLAGS = -k 3
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
DLGcount: 7 Col 1 ID=(d)
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..3)={d,b,c,NL}
zzlextext=b
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 3
LATEXT(0..3)={e,c,NL,d}
zzlextext=c
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 5
LATEXT(0..3)={f,NL,d,e}
zzlextext=NL
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 6
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
Page 80
-------------------------------------------------------------------------------
When built with version 1.23 and "interactive" options: AFLAGS = -k 3 -gk
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..3)={,a,,}
zzlextext=
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 5
LATEXT(0..3)={,a,b,c}
zzlextext=
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 5
LATEXT(0..3)={,a,b,c}
zzlextext=
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 5
LATEXT(0..3)={a,b,c,}
zzlextext=
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 5
LATEXT(0..3)={b,c,,a}
zzlextext=
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 5
LATEXT(0..3)={c,,a,b}
zzlextext=
DLGcount: 6 Col 6 NL
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 6
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
DLGcount: 7 Col 1 ID=(d)
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..3)={NL,d,b,c}
zzlextext=b
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
Recognized: Semantic Predicate Of 1 (AntlrCount=9)
Value of zzbegcol: 5
LATEXT(0..3)={NL,d,e,f}
zzlextext=NL
Recognized: Semantic Predicate Of 1 (AntlrCount=10)
Value of zzbegcol: 5
LATEXT(0..3)={NL,d,e,f}
zzlextext=NL
Recognized: After first ID of 1 (AntlrCount=11)
Value of zzbegcol: 5
LATEXT(0..3)={d,e,f,NL}
zzlextext=NL
Page 81
-------------------------------------------------------------------------------
When built with version 1.23 and infinite lookahead options:
AFLAGS = -k 3
CFLAGS = -DZZINF_LOOK
-------------------------------------------------------------------------------
DLGcount: 1 Col 1 ID=(a)
DLGcount: 2 Col 2 WS
DLGcount: 3 Col 3 ID=(b)
DLGcount: 4 Col 4 WS
DLGcount: 5 Col 5 ID=(c)
DLGcount: 6 Col 6 NL
DLGcount: 7 Col 1 ID=(d)
DLGcount: 8 Col 2 WS
DLGcount: 9 Col 3 ID=(e)
DLGcount: 10 Col 4 WS
DLGcount: 11 Col 5 ID=(f)
DLGcount: 12 Col 6 NL
Recognized: Semantic Predicate Of 1 (AntlrCount=1)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: Semantic Predicate Of 1 (AntlrCount=2)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: Semantic Predicate Of 1 (AntlrCount=3)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: After first ID of 1 (AntlrCount=4)
Value of zzbegcol: 1
LATEXT(0..3)={NL,a,b,c}
zzlextext=a
ZZINF_LATEXT(0..3)={a,b,c,NL}
Recognized: After second ID of 1 (AntlrCount=5)
Value of zzbegcol: 1
LATEXT(0..3)={d,b,c,NL}
zzlextext=b
ZZINF_LATEXT(0..3)={b,c,NL,d}
Recognized: After third ID of 1 (AntlrCount=6)
Value of zzbegcol: 1
LATEXT(0..3)={e,c,NL,d}
zzlextext=c
ZZINF_LATEXT(0..3)={c,NL,d,e}
Recognized: -> Format 1 After: ID ID ID NL (AntlrCount=7)
Value of zzbegcol: 1
LATEXT(0..3)={f,NL,d,e}
zzlextext=NL
ZZINF_LATEXT(0..3)={NL,d,e,f}
Recognized: Semantic Predicate Of 1 (AntlrCount=8)
Value of zzbegcol: 1
LATEXT(0..3)={NL,d,e,f}
zzlextext=d
ZZINF_LATEXT(0..3)={d,e,f,NL}
Page 82
===============================================================================
Example 8: Preserving whitespace during lexing
===============================================================================
The following program passes whitespace through DLG to the parser by
combining the whitespace with the token which follows it. It is up to the
user to determine how to handle the leading whitespace during attribute
and AST creation.
In this example whitespace ("#token WS") includes only the space character:
it does not include tab or newline. Maintaining accurate column
information when using zzmore() requires some extra work (as mentioned
in a note in the section on lexical issues.
The routines in "charbuf.h" assume that tokens are no longer than
"D_TextSize" characters. The value can be changed from its default value
of 30 by "#define D_TextSize ..." in the #header prior to the #include of
"charbuf.h".
It was built with k=1.
-------------------------------------------------------------------------------
#header <<
#include "charbuf.h"
#define ZZCOL
>>
<<
int AntlrCount=0;
int main() {
again: ANTLR (statement(),stdin);
return 0;
}
static char xlateBuf[100];
char * xlate (char * s) {
char * p=s;
char * q=xlateBuf;
if (*p == 0) {
*q='@';q++;
};
while (*p != 0) {
if (*p == ' ') {
*q='-';q++;
} else if (*p == '\t') {
*q='\\';q++;*q='t';q++;
} else if (*p == '\n') {
*q='\\';q++;*q='n';q++;
} else {
*q=*p;q++;
};
p++;
};
*q=0;
return (xlateBuf);
}
Page 83
void laDump(char * label) {
AntlrCount++;
printf ("\tRecognized: %s (AntlrCount=%d) ",label,AntlrCount);
printf ("zzlextext=(%s)\n",xlate(zzlextext));
return;
}
>>
#lexaction <<
int DLGcount=0;
>>
#token ID "[a-z]*"
<
DLGcount,zzbegcol,zzlextext);>>
#token WS "[\ ]*"
<
zzmore();>>
#token NL "\n"
<
DLGcount,zzbegcol);
zzendcol=0;
zzline++;
>>
statement : (line) * "@"
;line : (ID <> ) * NL
;
Page 84
===============================================================================
Example 9: Passing column information through DLG using a kludge
===============================================================================
The following demonstrates a kludge which allows one to pass column
information through DLG for for use with attributes (or ASTs) even when
using modes with lookahead with LL_K>1 or using infinite lookahead
mode. This technique is probably not necessary with C++ mode.
-------------------------------------------------------------------------------
#header <<
#include "col_charbuf.h"
#define ZZCOL
#include "shiftr.h"
#define COL_BITS_PER_BYTE 6
#define COL_BITS_MASK ( (1 << COL_BITS_PER_BYTE) - 1 )
>>
<<
int main() {
again: ANTLR (statement(),stdin);
return 0;
}
void create_attr (Attrib *a,int tok,char *t) {
char * p;
char * q;
int i=0;
a->col=0;
for (p=t;*p != '\001' && *p != 0;p++) {
if (i < D_TextSize-1) {
a->text[i]=*p;
i++;
};
};
a->text[i]=0;
if (*p == '\001') {
a->col=p[1] & COL_BITS_MASK +
( (p[2] & COL_BITS_MASK) << COL_BITS_PER_BYTE );
};
printf ("create_attr: Col %d text=(%s)\n",a->col,a->text);
return;
}
>>
Page 85
#lexaction <<
int DLGcount=0;
char encodedCol[5];
void record() {
encodedCol[0]='\001';
encodedCol[1]=zzbegcol & COL_BITS_MASK;
encodedCol[2]=(zzbegcol SHIFTR COL_BITS_PER_BYTE) & COL_BITS_MASK;
encodedCol[4]=0;
/***
**** if (strlen(zzlextext) > ZZLEXBUFSIZE - sizeof(encodedCol) ) {...}
***/
strcat(zzlextext,encodedCol);
return;
}
>>
#token ID "[a-z A-Z 0-9]*"
<
DLGcount,zzbegcol,zzlextext);record();>>
#token WS "[\ \t]*"
<
DLGcount,zzbegcol);zzskip();>>
#token NL "\n"
<
DLGcount,zzbegcol);
zzendcol=0;
zzline++;
zzskip();>>
statement : (formats) * "@" ;
formats : ( ID ) * NL ;
-------------------------------------------------------------------------------
File: col_charbuf.h
-------------------------------------------------------------------------------
#ifndef ZZCHARBUF_H
#define ZZCHARBUF_H
#include
#ifndef D_TextSize
#define D_TextSize 30
#endif
typedef struct {
char text[D_TextSize];
int col;
} Attrib;
void create_attr(Attrib *a,int tok,char *t);
#define zzcr_attr(a,tok,t) create_attr(a,tok,t)
#endif
-------------------------------------------------------------------------------
File: shiftr.h
-------------------------------------------------------------------------------
#ifndef SHIFTR
#define SHIFTR >>
#endif
Page 86
===============================================================================
Example 10: Use of #lexclass
===============================================================================
The user has a grammar in which an asterisk ("*") is normally used to indicate
multiplication. However, if "*" is the first token appearing in a statement
then it indicates a comment. Comments are terminated by a newline. Statements
are separated by semi-colons (";"). How does one use #lexclass to separate
the different lexical analysis required for comments and arithmetic
statements ?
For this example the recognized tokens have been reduced to identifiers and "*".
This code requires many #token actions to have the statement:
foundToken=1;
If this is inconvenient the user can modify dlgauto.h as outlined in
"Section on ANTLR/DLG Internals" to call a user-supplied routine (defined
inside the #lexaction) just after each call to the #token action routine.
-------------------------------------------------------------------------------
#header <<
#include "charbuf.h"
>>
<<
int main() {
again: ANTLR (program(),stdin);
return 0;
}
>>
#lexaction <<
int foundToken=0;
>>
#lexclass START
#token ID "[a-z A-Z]*" <>
#token SC ";" <>
#token WS "[\ \t]*" <>
#token NL "\n" <>
#token STAR "\*" <
zzmode(LC_COMMENT);
zzmore();};
>>
#lexclass LC_COMMENT
#token COMMENT "~[\n]*" <
zzmode(START);
>>
program : (statement) * "@"
;statement
: COMMENT <>
| (ID | STAR ) * SC <>
;
Page 87
===============================================================================
Example 11: Use of zzchar and #lexclass
===============================================================================
Consider the problem of distinguishing floating point numbers from
range expressions such as those used in Pascal:
range: 1..23
range: a..z
float: 1.23
As a first effort one might try:
#token ID "[a-z]*"
#token Int "[0-9]*"
#token Range ".."
#token Float "[0-9]*.[0-9]*"
The problem is that "1..23" looks like the floating point number "1." with
an illegal "." at the end. DLG always takes the longest matching string,
so "1." will always look more appetizing than "1". What one needs to do
is to look at the character following "1." to see if it is another ".",
and if it is to assume that it is a range expression. The flex lexer has
trailing context, but DLG doesn't - except for the single character in
zzchar.
A solution in DLG is to write the #token Float action routine to look
at what's been accepted and at zzchar in order to decide what to do:
------------------------------------------------------------------------
#header <<#include "int.h">>
#token Range ".."
#token Int "[0-9]*"
#token Float "[0-9]*.[0-9]*"
<
zzchar == '.') {
NLA=Int;
zzmode(LC_Range);
};
>>
#token WS "\ " <>
#token NL "\n" <>
#lexclass LC_Range
// consume second "." of range token ("..") and return to normal mode
#token Range "." <>
<< int main() {
ANTLR (rule(),stdin);
}
>>
rule: ( Range <>
| Int <>
| Float <>
)*
;
Page 88
===============================================================================
Example 12: Rewriting a grammar so it be handled by Antlr
===============================================================================
The original grammar was in this form:
command := SET var BECOMES expr
| SET var BECOMES QUOTE QUOTE
| SET var BECOMES QUOTE expr QUOTE
| SET var BECOMES QUOTE command QUOTE
expr := QUOTE anyCharButQuote QUOTE
| expr AddOp expr
| expr MulOp expr
The repetition of "SET var BECOMES" for command would require k=4 to
get to the interesting part. The first step is to left-factor command:
command := SET var BECOMES
( expr
| QUOTE QUOTE
| QUOTE expr QUOTE
| QUOTE command QUOTE
)
The definition of expr uses left recursion which must be eliminated
when using Antlr:
op := AddOp
| MulOp
expr := QUOTE anyCharButQuote QUOTE (op expr)*
Since expr begins with QUOTE and all the alternatives of the sub-rule
of command also start with QUOTE this too can be left-factored:
command := SET var BECOMES QUOTE
( expr_suffix
| QUOTE
| expr QUOTE
| command QUOTE
)
expr_suffix := anyCharButQuote QUOTE (op expr)*
expr := QUOTE expr_suffix
The final grammar can be built by Antlr with k=2.
Page 89
#header <<#include "charbuf.h">>
<<
int main() {
ANTLR(repeat(),stdin);
return 0;
}
>>
#token Q "\""
#token SVB "svb"
#token Qbar "[a-z A-Z]*"
#token AddOp "\+"
#token MulOp "\*"
#token WS "\ " <>
#token NL "\n" <>
repeat : ( command )+ "@";
command : SVB Q ( expr_suffix
| expr Q
| Q <>
| command Q <>
);
expr_suffix : Qbar Q <>
{ op expr };
expr : Q expr_suffix;
op : AddOp | MulOp ;
-------------------------------------------------------------------------------
pccts/NOTES.visual.C++ 644 1377 31 10003 5655551641 7721 How to port PCCTS 1.10 (and 1.20 hopefully) to Visual C++
By
John Hall
Here is how to compile an ANTLR grammar in Visual C++. These steps
describe how to have your ANTLR grammar parse the input file the user
selects when they choose File Open in your Windows application. (Even
if you aren't using Visual C++, the steps should be portable enough to
other compilers.)
* Make sure that ANTLR and DLG generate ANSI code (use the -ga
switch).
* Set the following compiler flags in Visual C++ (these are in the
Memory Model category of the compiler options in the Project
Options menu):
FLAG MEANING
==== ==============================================================
/AL Large memory model (multiple data segments; data items must be
smaller than 64K).
/Gtn Allocates all items whose size is greater than or equal to n
in a new data segment. (I let n be 256: /Gt256.)
/Gx- All references to data items are done with far addressing in
case they are placed in a far segment.
* Add the following member variable to the attributes section of your
derived CDocument class (you will need to make sure you also
include stdio.h):
FILE *fp;
* Add the following method to your derived CDocument class:
BOOL CAppDoc::OnOpenDocument(const char* pszPathName)
{
// Call CDocument's OnOpenDocument to do housekeeping for us
// DON'T add anything to the loading section of Serialize
if (!CDocument::OnOpenDocument(pszPathName))
return FALSE;
// Open input file
if ((fp = fopen(pszPathName, "r")) == NULL)
return FALSE;
// Parse input file
ANTLR(start(), fp);
// Close input file
fclose(fp);
return TRUE;
}
(Note: additional code may be necessary, depending on your parser.
For example, if your parser uses PCCTS's symbol table library, you
will need to insert calls to zzs_init and zzs_done.)
* Compile the generated C files as C++ files. (I renamed the files
to have a .CPP extension to fool Visual C++ into thinking they were
C++ files. One might also use the /Tp switch, but that switch
requires you separately include the filename.) [I used this step
as an easy out for all the external linking errors I was getting
that I couldn't fix by declaring things extern "C".]
* Make sure the __STDC__ portion of the generated files gets
compiled. (Either define __STDC__ yourself or else change all
occurrences of __STDC__ to __cplusplus in the generated files. You
can define __STDC__ in the Preprocessor category of the compiler
options.)
That last step is important for Visual C++, but may not apply to other
compilers. For C++ compilers, whether __STDC__ is defined is
implementation dependent (ARM, page 379). Apparently, Visual C++ does
not to define it; it also does not support "old style" C function
definitions (which is okay, according to page 404 of the ARM). Those
two things together caused problems when trying to port the code.
When it saw this:
#ifdef __STDC__
void
globals(AST **_root)
#else
globals(_root)
AST **_root;
#endif
it skipped the __STDC__ section and tried to process the "old style"
function definition, where it choked.
When you finally get your parser to compile and link without error,
you may get General Protection Fault errors at run time. The problem
I had was that a NULL was passed to a variable argument function
without an explicit cast. The function grabbed a pointer (32-bits)
off the stack using va_arg, but the NULL was passed silently as the
integer 0 (16 bits), making the resulting pointer was invalid. (This
was in PCCTS's sample C parser.)
There is one other thing I might suggest to help you avoid a run-time
error. Make sure you redefine the default error reporting function,
zzsyn. To do this, put "#define USER_ZZSYN" in your #header section
and put your own zzsyn somewhere. You can then pop up a MessageBox or
print the error to some output window.
ls" to call a user-supplied routine (defined
inside the #lexaction) just after each call to the #token action routine.
-------------------------------------------------------------------------------
#header <<
#include "charbuf.h"
>>
<<
int main() {
again: ANTLR (program(),stdin);
return 0;
}
>>
#lexaction <<
int foundToken=0;
>>
#lexclass START
#token ID "[a-z A-Z]*" <>
#token SC ";" <>
#token WS "[\ \t]*" <
Terence Parr
Parr Research Corporation
5517 Pleasant Ave
Minneapolis MN 55419
[email protected]
612 825-1901
Joe/Jane PCCTS user
1 Easy Street
World At Large
Dear PCCTS user,
As the primary author of the tools in the Purdue Compiler Construction
Tool Set (PCCTS), it has been mainly my responsibility to design,
develop, and maintain these public-domain tools. To support myself, I
have been doing translation work for the Army High Performance
Computer Research Center as a postdoctoral fellow. Unfortunately, it
has become increasingly difficult to satisfy both my employers and the
PCCTS community; moreover, funding for my fellowship has been reduced.
As of August 1, 1994 I plan to leave academia for the private sector
so that I may more fully support PCCTS. Parr Research Corporation
will continue to provide all tools, that are currently in the
public-domain, totally free of charge and without copyright
restrictions; i.e., ANTLR, DLG, and SORCERER. My goal is to foster
growth in the PCCTS community---I am committed to providing
sophisticated language tools.
As the corporation grows, I hope to provide real documentation (in the
form of a book), a graphical user interface for developing and
debugging large language applications, and better user support (via a
``help'' line).
To support the corporation (and the development of PCCTS), I will rely
on consulting fees, seminar fees, contract work, and ``maintenance
contracts'' with industrial affiliates. Pursuant to this, if you would
be interested in having Parr Research perform one of these services
for you or would just like to talk about the possibility, please
contact me via email, phone, or normal mail. Parr Research would also
like to form ``strategic partner'' relationships with other organizations.
Thanks for your interest in PCCTS. May your troubles be few and your
programs bug-free.
Best Regards,
Terence Parr
BOOL CAppDoc::OnOpenDocument(const char* pszPathName)
{
// Call CDocument's OnOpenDocument to do housekeeping for us
// DON'T add anything to the loading section of Serialize
if (pccts/README 644 1377 31 15531 5655551640 6167
Welcome to PCCTS 1.30
November 1, 1994
Parr Research Corporation
with
Purdue University Electrical Engineering
and
University of Minnesota, AHPCRC
Terence Parr
Russell Quong
Will Cohen
Hank Dietz
INSTALLATION
This document describes the installation of PCCTS 1.30 on UNIX
and non-UNIX machines. The UNIX installation is trivial while the
non-UNIX folks have a bit more work to do as an install script
explicitly for there machine will not exist--they will have to
interpret the install script.
PCCTS 1.30 includes a number of different programs and examples
in the software release package -- most of which like to live in their
own directories. The install script will build a standard hierarchy.
Or, if you get the tar file off the ftp site, the hierarchy will be
constructed automatically by tar.
The PCCTS executables (antlr, dlg) may be placed anywhere the user
wishes but the install script places them in the bin directory created
during installation.
1.0. UNIX USERS
This section is for UNIX users and describes the most convenient
installation procedure.
1.1. FORMAT: pccts.tar
To begin installation, place the pccts.tar file into the directory
where you want to place a pccts subdirectory. Untar the file with
tar xvf pccts.tar
and cd into it. To install PCCTS, simply type
make
which will build the standard PCCTS directory hierarchy (under the
directory where you ran the install script) and build executable
versions of antlr and dlg.
1.2. FORMAT: pccts.bag
To begin installation, the user should create a directory (usually
called pccts) where the PCCTS source subtree is to be created. Place
the pccts.bag file and the install script into this directory and cd
into it. To install PCCTS, simply type
sh install
which will build the standard PCCTS directory hierarchy (under the
directory where you ran the install script), "unbag" all of the files
and build executable versions of antlr and dlg.
If you do not have the 'sh' shell, you'll need the install.unbag.reqd
file.
2.0. NON-UNIX USERS
ANTLR was written using portable (we hope), vanilla K&R-style C,
ANSI C, and C++. It has been successfully ported to a variety of
environments. We do not provide an installation script explicitly for
non-Unix users. You must interpret the install script and perform the
analogous operations on your machine. There is an install script,
install.mpw, for Macintosh programmers.
IMPORTANT NOTE: For PC users: You must create the parser.dlg and
"touch" scan.c in antlr and dlg directories or the
makefiles will try to execute antlr and dlg, which
don't exist yet. The first time, you want only to
compile the C files in order to obtain an executable
for antlr and dlg. From this point, a change in
antlr.g or dlg_p.g will force antlr/dlg to regenerate
themselves.
You must define symbol PC if you want things to work
out right for use on a DOS, OS/2, Windows machine.
This affects the config.h file, which you can change
as you wish.
For Mac programmers using MPW (Macintosh Programmer's Workshop),
define symbol MPW to get the correct config.h stuff included.
3.0. EMAIL VERSION RECIPIENTS
If you received PCCTS via email response from
[email protected] you have one additional installation step to
perform over the ftp folks (and pccts.tar is unavailable). You will
have received a number of bite-size chunks of pccts which are small
enough to be emailed (~1500 lines each). You must reconstruct the
PCCTS files before you can begin installation. In order to rebuild an
original file, you must have "one.c" which will take the chunks and
pack them together. If you are a non-UNIX type, you must have the
"unbag.c" file which unbags the bags created by our mail archiver.
UNIX folks use the shell to unbag as they would for shar files (this
will be done automatically by the install script).
To install PCCTS, place all PCCTS mail messages into a pccts
directory, remove the mail headers from one.c. Then compile one.c
with:
cc -o one one.c
and then type:
./one f1 f2 ... fn
where f1..fn are the parts of PCCTS source sent as chunks (i.e. these
files will be all the files you received NOT including one.c, unbag.c,
README, install and the request acknowledge banner). There is no need
to remove mail headers from the chunk files and they may appear in any
order. The subject line of the mail will identify it as a chunk and a
chunk of what file. The "one" program should be used to put pccts.bag
back together. You are now in a position to begin normal PCCTS
installation. All files you receive should go into a pccts directory.
Note that all files which arrive in "chunks" must be put back
together using "one". Beware that you do not mix chunks from more
than one original file. For instance, do not specify all chunks that
you collect from the PCCTS mailbot on the "one" command line unless
you have requested only one original file that was split into multiple
files. Each chunk knows which original file it is a part of, where it
goes in that file and how many total chunks are required to rebuild
that original.
4.0. WORD SIZE AND PC USERS
The config.h file now sets up the word size for your compiler
automatically.
TUTORIAL
The advanced tutorial should be placed in a directory at the
same level as antlr, dlg, support etc... Do a
sh advtut.bag
to unbag (or use the unbag program) and then type
make -s all
which will create executables called tut1-tut4. Naturally, if you got
the tutorials from the ftp site, the tar format of the tutorials can
be obtained for easier installation.
Unfortunately, the tutorials have changed little since the 1.06
release. With luck, these will be enhanced and an AST tutorial will
appear.
NEW FEATURES
o Element labels
o Parser exception handling
MACHINE COMPATIBILITY
PCCTS is known to compile "out of the box" on the following machines
and/or operating systems: [didn't have time to retest on all these
machines, but seems to be highly portable still].
o DECSTATION 5000
o SGI, Running IRIX 4.0.5
o Sun SparcStation (cc, gcc, g++, Cfront, acc)
o VAX C under VMS
o Linux SLS 0.99, gcc/g++
o 386 PC, NetBSD 0.9, gcc 2.4.5
o HP 9000/755, HP-UX 9.01, HP cc
o 486 PC, OS/2 2.1 (w/long filenames), IBM C Set++ 2.1
INCOMPATIBILITIES
Please see the release notes.
CREDITS
Please see the history.ps or history.txt.
l script.
PCCTS 1.30 includes a number of different programs and examples
in the software release package -- most of which like to live in their
own directories.pccts/RIGHTS 644 1377 31 2163 5655551672 6214
SOFTWARE RIGHTS
We reserve no LEGAL rights to the Purdue Compiler Construction Tool
Set (PCCTS) -- PCCTS is in the public domain. An individual or
company may do whatever they wish with source code distributed with
PCCTS or the code generated by PCCTS, including the incorporation of
PCCTS, or its output, into commerical software.
We encourage users to develop software with PCCTS. However, we do ask
that credit is given to us for developing PCCTS. By "credit", we mean
that if you incorporate our source code into one of your programs
(commercial product, research project, or otherwise) that you
acknowledge this fact somewhere in the documentation, research report,
etc... If you like PCCTS and have developed a nice tool with the
output, please mention that you developed it using PCCTS. In
addition, we ask that this header remain intact in our source code.
As long as these guidelines are kept, we expect to continue enhancing
this system and expect to make other tools available as they are
completed.
ANTLR 1.30
Terence Parr
Parr Research Corporation
with Purdue University and AHPCRC, University of Minnesota
1989-1994
ill be
constructed automatically by tar.
The PCCTS executables (antlr, dlg) may be placed anywhere the user
wishes but the install script places them in the bin directory created
during installation.
1.0. UNIX USERS
This section is for UNIX users and describes the most convenient
installation procedure.
1.1. FORMAT: pccts.tar
To begin installation, place the pccts.tar file into the pccts/UPDAT106.ps 644 1377 31 237761 5655551664 7020 %!PS-Adobe-1.0
%%Creator: bug.ecn.purdue.edu:pccts (Purdue Compiler-Construction Tool Set,,,,Ex;ee;hankd;)
%%Title: stdin (ditroff)
%%CreationDate: Mon Dec 7 17:34:40 1992
%%EndComments
% Start of psdit.pro -- prolog for ditroff translator
% Copyright (c) 1985,1987 Adobe Systems Incorporated. All Rights Reserved.
% GOVERNMENT END USERS: See Notice file in TranScript library directory
% -- probably /usr/lib/ps/Notice
% RCS: $Header: /home/aquarium/prm/usr/src/usr.lib/ps/lib/RCS/psdit.pro,v 1.2 89/02/24 09:57:06 prm Exp $
/$DITroff 180 dict def $DITroff begin
%% Psfig additions
/DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecap
currentlinejoin currentdash currentgray currentmiterlimit ] cvx def
/startFig {
/SavedState save def
userdict maxlength dict begin
currentpoint transform
DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap
setlinewidth setmatrix
itransform moveto
/ury exch def
/urx exch def
/lly exch def
/llx exch def
/y exch 72 mul resolution div def
/x exch 72 mul resolution div def
currentpoint /cy exch def /cx exch def
/sx x urx llx sub div def % scaling for x
/sy y ury lly sub div def % scaling for y
sx sy scale % scale by (sx,sy)
cx sx div llx sub
cy sy div ury sub translate
/DefFigCTM matrix currentmatrix def
/initmatrix {
DefFigCTM setmatrix
} def
/defaultmatrix {
DefFigCTM exch copy
} def
/initgraphics {
DocumentInitState setmiterlimit setgray setdash
setlinejoin setlinecap setlinewidth setmatrix
DefFigCTM setmatrix
} def
/showpage {
initgraphics
} def
} def
% Args are llx lly urx ury (in figure coordinates)
/clipFig {
currentpoint 6 2 roll
newpath 4 copy
4 2 roll moveto
6 -1 roll exch lineto
exch lineto
exch lineto
closepath clip
newpath
moveto
} def
% doclip, if called, will always be just after a `startfig'
/doclip { llx lly urx ury clipFig } def
/endFig {
end SavedState restore
} def
/globalstart {
% Push details about the enviornment on the stack.
fontnum fontsize fontslant fontheight firstpage
mh my resolution slotno currentpoint
pagesave restore gsave
} def
/globalend {
grestore moveto
/slotno exch def /resolution exch def /my exch def
/mh exch def /firstpage exch def /fontheight exch def
/fontslant exch def /fontsize exch def /fontnum exch def
F
/pagesave save def
} def
%% end XMOD additions
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def
/xi {0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F
/pagesave save def}def
/PB{save /psv exch def currentpoint translate
resolution 72 div dup neg scale 0 0 moveto}def
/PE{psv restore}def
/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def
/tan{dup sin exch cos div}bind def
/point{resolution 72 div mul}bind def
/dround {transform round exch round exch itransform}bind def
/xT{/devname exch def}def
/xr{/mh exch def /my exch def /resolution exch def}def
/xp{}def
/xs{docsave restore end}def
/xt{}def
/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not
{fonts slotno fontname findfont put fontnames slotno fontname put}if}def
/xH{/fontheight exch def F}bind def
/xS{/fontslant exch def F}bind def
/s{/fontsize exch def /fontheight fontsize def F}bind def
/f{/fontnum exch def F}bind def
/F{fontheight 0 le {/fontheight fontsize def}if
fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore
fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if
makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}bind def
/X{exch currentpoint exch pop moveto show}bind def
/N{3 1 roll moveto show}bind def
/Y{exch currentpoint pop exch moveto show}bind def
/S /show load def
/ditpush{}def/ditpop{}def
/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}bind def
/AN{4 2 roll moveto 0 exch ashow}bind def
/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}bind def
/AS{0 exch ashow}bind def
/MX{currentpoint exch pop moveto}bind def
/MY{currentpoint pop exch moveto}bind def
/MXY /moveto load def
/cb{pop}def % action on unknown char -- nothing for now
/n{}def/w{}def
/p{pop showpage pagesave restore /pagesave save def}def
/abspoint{currentpoint exch pop add exch currentpoint pop add exch}def
/dstroke{currentpoint stroke moveto}bind def
/Dl{2 copy 2 copy gsave 0 eq exch 0 eq and
{rlineto currentlinecap 1 setlinecap stroke setlinecap}
{rlineto stroke}
ifelse grestore rmoveto}bind def
/arcellipse{oldmat currentmatrix pop
currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def
rad 0 rad -180 180 arc oldmat setmatrix}def
/Dc{gsave dup /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/De{gsave /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/Da{currentpoint /by exch def /bx exch def /fy exch def /fx exch def
/cy exch def /cx exch def /rad cx cx mul cy cy mul add sqrt def
/ang1 cy neg cx neg atan def /ang2 fy fx atan def cx bx add cy by add
2 copy rad ang1 ang2 arcn stroke exch fx add exch fy add moveto}def
/Barray 200 array def % 200 values in a wiggle
/D~{mark}def
/D~~{counttomark Barray exch 0 exch getinterval astore /Bcontrol exch def pop
/Blen Bcontrol length def Blen 4 ge Blen 2 mod 0 eq and
{Bcontrol 0 get Bcontrol 1 get abspoint /Ycont exch def /Xcont exch def
Bcontrol 0 2 copy get 2 mul put Bcontrol 1 2 copy get 2 mul put
Bcontrol Blen 2 sub 2 copy get 2 mul put
Bcontrol Blen 1 sub 2 copy get 2 mul put
/Ybi /Xbi currentpoint 3 1 roll def def 0 2 Blen 4 sub
{/i exch def
Bcontrol i get 3 div Bcontrol i 1 add get 3 div
Bcontrol i get 3 mul Bcontrol i 2 add get add 6 div
Bcontrol i 1 add get 3 mul Bcontrol i 3 add get add 6 div
/Xbi Xcont Bcontrol i 2 add get 2 div add def
/Ybi Ycont Bcontrol i 3 add get 2 div add def
/Xcont Xcont Bcontrol i 2 add get add def
/Ycont Ycont Bcontrol i 3 add get add def
Xbi currentpoint pop sub Ybi currentpoint exch pop sub rcurveto
}for dstroke}if}def
end
/ditstart{$DITroff begin
/nfonts 60 def % NFONTS makedev/ditroff dependent!
/fonts[nfonts{0}repeat]def
/fontnames[nfonts{()}repeat]def
/docsave save def
}def
% character outcalls
/oc {/pswid exch def /cc exch def /name exch def
/ditwid pswid fontsize mul resolution mul 72000 div def
/ditsiz fontsize resolution mul 72 div def
ocprocs name known{ocprocs name get exec}{name cb}
ifelse}def
/fractm [.65 0 0 .6 0 0] def
/fraction
{/fden exch def /fnum exch def gsave /cf currentfont def
cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto
fnum show rmoveto currentfont cf setfont(\244)show setfont fden show
grestore ditwid 0 rmoveto} def
/oce {grestore ditwid 0 rmoveto}def
/dm {ditsiz mul}def
/ocprocs 50 dict def ocprocs begin
(14){(1)(4)fraction}def
(12){(1)(2)fraction}def
(34){(3)(4)fraction}def
(13){(1)(3)fraction}def
(23){(2)(3)fraction}def
(18){(1)(8)fraction}def
(38){(3)(8)fraction}def
(58){(5)(8)fraction}def
(78){(7)(8)fraction}def
(sr){gsave .05 dm .16 dm rmoveto(\326)show oce}def
(is){gsave 0 .15 dm rmoveto(\362)show oce}def
(->){gsave 0 .02 dm rmoveto(\256)show oce}def
(<-){gsave 0 .02 dm rmoveto(\254)show oce}def
(==){gsave 0 .05 dm rmoveto(\272)show oce}def
end
% DIThacks fonts for some special chars
50 dict dup begin
/FontType 3 def
/FontName /DIThacks def
/FontMatrix [.001 0.0 0.0 .001 0.0 0.0] def
/FontBBox [-220 -280 900 900] def% a lie but ...
/Encoding 256 array def
0 1 255{Encoding exch /.notdef put}for
Encoding
dup 8#040/space put %space
dup 8#110/rc put %right ceil
dup 8#111/lt put %left top curl
dup 8#112/bv put %bold vert
dup 8#113/lk put %left mid curl
dup 8#114/lb put %left bot curl
dup 8#115/rt put %right top curl
dup 8#116/rk put %right mid curl
dup 8#117/rb put %right bot curl
dup 8#120/rf put %right floor
dup 8#121/lf put %left floor
dup 8#122/lc put %left ceil
dup 8#140/sq put %square
dup 8#141/bx put %box
dup 8#142/ci put %circle
dup 8#143/br put %box rule
dup 8#144/rn put %root extender
dup 8#145/vr put %vertical rule
dup 8#146/ob put %outline bullet
dup 8#147/bu put %bullet
dup 8#150/ru put %rule
dup 8#151/ul put %underline
pop
/DITfd 100 dict def
/BuildChar{0 begin
/cc exch def /fd exch def
/charname fd /Encoding get cc get def
/charwid fd /Metrics get charname get def
/charproc fd /CharProcs get charname get def
charwid 0 fd /FontBBox get aload pop setcachedevice
40 setlinewidth
newpath 0 0 moveto gsave charproc grestore
end}def
/BuildChar load 0 DITfd put
%/UniqueID 5 def
/CharProcs 50 dict def
CharProcs begin
/space{}def
/.notdef{}def
/ru{500 0 rls}def
/rn{0 750 moveto 500 0 rls}def
/vr{20 800 moveto 0 -770 rls}def
/bv{20 800 moveto 0 -1000 rls}def
/br{20 770 moveto 0 -1040 rls}def
/ul{0 -250 moveto 500 0 rls}def
/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def
/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def
/sq{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def
/bx{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def
/ci{355 333 rmoveto currentpoint newpath 333 0 360 arc
50 setlinewidth stroke}def
/lt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def
/lb{20 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def
/rt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def
/rb{20 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def
/lk{20 800 moveto 20 300 -280 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/rk{20 800 moveto 20 300 320 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/lf{20 800 moveto 0 -1000 rlineto s4 0 rls}def
/rf{20 800 moveto 0 -1000 rlineto s4 neg 0 rls}def
/lc{20 -200 moveto 0 1000 rlineto s4 0 rls}def
/rc{20 -200 moveto 0 1000 rlineto s4 neg 0 rls}def
end
/Metrics 50 dict def Metrics begin
/.notdef 0 def
/space 500 def
/ru 500 def
/br 0 def
/lt 250 def
/lb 250 def
/rt 250 def
/rb 250 def
/lk 250 def
/rk 250 def
/rc 250 def
/lc 250 def
/rf 250 def
/lf 250 def
/bv 250 def
/ob 350 def
/bu 350 def
/ci 750 def
/bx 750 def
/sq 750 def
/rn 500 def
/ul 500 def
/vr 0 def
end
DITfd begin
/s2 500 def /s4 250 def /s3 333 def
/a4p{arcto pop pop pop pop}def
/2cx{2 copy exch}def
/rls{rlineto stroke}def
/currx{currentpoint pop}def
/dround{transform round exch round exch itransform} def
end
end
/DIThacks exch definefont pop
ditstart
(psc)xT
576 1 1 xr
1(Times-Roman)xf 1 f
2(Times-Italic)xf 2 f
3(Times-Bold)xf 3 f
4(Times-BoldItalic)xf 4 f
5(Helvetica)xf 5 f
6(Helvetica-Bold)xf 6 f
7(Courier)xf 7 f
8(Courier-Bold)xf 8 f
9(Symbol)xf 9 f
10(DIThacks)xf 10 f
10 s
1 f
xi
%%EndProlog
%%Page: 1 1
10 s 0 xH 0 xS 1 f
8 s
15 s
1237 704(The)N
1453(Purdue)X
1823(Compiler)X
2308(Construction)X
2960(Tool)X
3217(Set)X
13 s
1872 960(Version)N
2228(1.06)X
2436(Update)X
2 f
11 s
1981 1216(December)N
2363(1,)X
2451(1992)X
3 f
576 1600(1.)N
686(Enhancements)X
1 f
776 1756(This)N
961(section)X
1239(describes)X
1594(the)X
1730(update)X
1993(of)X
2094(PCCTS)X
2392(Version)X
2698(1.00)X
2880(to)X
2977(Version)X
3284(1.06)X
3467(\(1.01-1.05)X
3862(were)X
576 1884(internal)N
873(releases\).)X
1251(The)X
1415(list)X
1551(of)X
1651(changes)X
1961(here)X
2139(is)X
2225(not)X
2365(complete)X
2716(since)X
2924(many)X
3147(``little'')X
3453(\256xes)X
3645(were)X
3841(made)X
576 2012(\(actually,)N
933(the)X
1067(predicated)X
1460(parsing)X
1745(feature)X
2015(is)X
2100(major\).)X
2406(Here,)X
2625(we)X
2754(concentrate)X
3187(on)X
3302(the)X
3437(enhancements)X
3963(to)X
576 2140(the)N
716(system;)X
1018(\256le)X
7 f
1194(BUGS100)X
1 f
1597(contains)X
1923(a)X
1994(list)X
2135(of)X
2240(the)X
2380(bug)X
2543(\256xes)X
2740(incorporated)X
3216(in)X
3316(the)X
3455(1.06)X
3640(release.)X
3959(In)X
576 2268(addition,)N
916(note)X
1096(that)X
1257(the)X
1393(manual)X
1681(has)X
1826(not)X
1967(been)X
2161(updated)X
2468(and)X
2623(will)X
2789(not)X
2931(be)X
3043(until)X
3235(the)X
3372(next)X
3553(major)X
3788(release)X
576 2396(\(or)N
700(until)X
885(we)X
1009(get)X
1139(around)X
1405(to)X
1496(it\).)X
3 f
576 2652(1.1.)N
752(Predicated)X
1180(Parsing)X
1491(\320)X
1601(ALPHA)X
1931(Version)X
1 f
776 2808(Normally,)N
1158(parsing)X
1439(is)X
1520(a)X
1582(function)X
1899(of)X
1995(syntax)X
2248(alone.)X
2506(Semantics)X
2892(\(meaning/value)X
3464(of)X
3560(the)X
3691(input\))X
3925(are)X
576 2936(not)N
738(taken)X
978(into)X
1165(account)X
1488(when)X
1727(parsing)X
2035(decisions)X
2412(are)X
2568(made\320context-free)X
3320(parsing.)X
3671(Typically,)X
576 3064(languages,)N
973(such)X
1157(as)X
1253(C++,)X
1457(have)X
1646(some)X
1855(rules)X
2049(which)X
2287(require)X
2559(the)X
2690(lexical)X
2949(analyzer)X
3270(to)X
3362(consult)X
3640(the)X
3772(symbol)X
576 3192(table)N
779(to)X
879(determine)X
1263(what)X
1465(token)X
1691(\(e.g.)X
1877(classname)X
2269(verses)X
2518(enumerated)X
2959(name)X
3180(verses)X
3429(typedef)X
3723(name\))X
3973(is)X
576 3320(given)N
802(to)X
901(the)X
1039(parser.)X
1327(However,)X
1700(lexical)X
1966(analyzers)X
2328(have)X
2525(no)X
2644(context)X
2935(information)X
3383(except)X
3644(the)X
3783(current)X
576 3448(token)N
811(of)X
923(lookahead)X
1324(and)X
1490(must)X
1701(be)X
1823(coerced)X
2135(via)X
2282(\257ags)X
2487(to)X
2595(yield)X
2811(the)X
2958(various)X
3256(token)X
3491(types.)X
3760(Ad)X
3905(hoc)X
576 3576(approaches)N
995(become)X
1293(increasingly)X
1748(dif\256cult)X
2052(to)X
2145(implement)X
2549(as)X
2647(the)X
2780(number)X
3074(of)X
3172(ambiguities)X
3610(\(due)X
3791(to)X
3885(lack)X
576 3704(of)N
671(semantic)X
1007(information\))X
1475(in)X
1566(a)X
1627(grammar)X
1967(rises.)X
776 3860(Context)N
1080(dictates)X
1374(the)X
1506(scope)X
1730(of)X
1827(variables)X
2169(in)X
2262(programming)X
2766(languages.)X
3186(Because)X
3503(only)X
3685(the)X
3818(parser)X
576 3988(has)N
718(context)X
1003(information,)X
1467(it)X
1542(is)X
1626(reasonable)X
2027(to)X
2121(assume)X
2405(that)X
2563(the)X
2696(parser)X
2935(is)X
3019(the)X
3151(correct)X
3419(place)X
3629(to)X
3722(maintain)X
576 4116(and)N
727(access)X
975(the)X
1107(symbol)X
1391(table;)X
1612(there)X
1812(are)X
1943(other)X
2148(situtations)X
2536(in)X
2629(which)X
2868(it)X
2942(is)X
3025(useful)X
3264(to)X
3357(have)X
3547(context)X
3831(direct)X
576 4244(parsing.)N
914(Unfortunately,)X
1465(most)X
1672(parser)X
1921(generators)X
2322(do)X
2445(not)X
2593(allow)X
2824(grammar)X
3177(actions)X
3462(to)X
3566(in\257uence)X
3924(the)X
576 4372(parse;)N
822(i.e.)X
966(parsing)X
1261(is)X
1356(a)X
1431(function)X
1762(of)X
1872(syntax)X
2139(alone.)X
2411(Because)X
2741(PCCTS)X
3048(generates)X
3417(recursive-descent)X
576 4500(LL\(k\))N
813(parsers)X
1088(in)X
1184(C,)X
1292(allowing)X
1628(user-de\256ned)X
2089(C)X
2175(actions)X
2452(to)X
2548(in\257uence)X
2898(parsing)X
3184(is)X
3270(a)X
3336(straightforward)X
3905(and)X
576 4628(natural)N
843(addition)X
1155(to)X
1246(the)X
1376(PCCTS)X
1669(description)X
2084(meta-language.)X
2670(Although)X
3026(bottom-up)X
3417(parsing)X
3699(strategies)X
576 4756(can)N
729(allow)X
956(actions)X
1237(to)X
1337(direct)X
1569(parsing,)X
1881(bottom-up)X
2280(parser)X
2524(have)X
2720(much)X
2946(less)X
3108(semantic)X
3452(information;)X
3924(i.e.)X
576 4884(LR)N
729(and)X
897(LALR)X
1168(techniques)X
1586(allow)X
1823(only)X
2 f
2021(S)X
1 f
(-attributed)S
2474(grammars)X
2867(whereas)X
3195(LL)X
3344(allows)X
2 f
3615(L)X
1 f
3664(-attributed)X
576 5012(grammars)N
968(\(for)X
1139(example,)X
1500(LL)X
1648(always)X
1932(knows)X
2201(which)X
2455(set)X
2592(of)X
2704(rules)X
2914(it)X
3003(is)X
3101(currently)X
3458(trying)X
3708(to)X
3816(match)X
576 5140(whereas)N
885(LALR)X
1137(does)X
1320(not,)X
1477(in)X
1568(general;)X
1874(see)X
2008(your)X
2191(favorite)X
2487(book)X
2685(on)X
2795(parsing)X
3076(theory\).)X
776 5296(In)N
871(this)X
1021(section,)X
1315(we)X
1439(introduce)X
1794(a)X
1855(rudimentary)X
2308(version)X
2590(of)X
2686(predicates,)X
3088(with)X
3268(a)X
3330(full)X
3476 0.2885(implementation)AX
576 5424(to)N
683(appear)X
955(in)X
1062(future)X
1310(releases.)X
1670(To)X
1806(support)X
2108(context-sensitive)X
2744(parsing)X
3041(PCCTS)X
3349(1.06)X
3541(allows)X
3809(a)X
3886(new)X
576 5552(action)N
814(type)X
988(called)X
2 f
1221(predicate)X
1 f
1576(\()X
7 f
1605(-pr)X
1 f
1786(must)X
1980(be)X
2085(used\),)X
2319(which)X
2556(is)X
2637(denoted:)X
7 f
9 s
576 5716(<>?)N
2 p
%%Page: 2 2
9 s 0 xH 0 xS 7 f
1 f
2244 376(-)N
2286(2)X
2340(-)X
11 s
576 704(or,)N
693(optionally,)X
7 f
9 s
576 868 -0.1947(<>?[fail_action])AN
1 f
11 s
576 1072(where)N
825(the)X
968(second)X
1248(notation)X
1574(``passes'')X
1950(an)X
2069(argument)X
2438(of)X
2547(an)X
2666(action)X
2918(to)X
3023(the)X
3167(predicate)X
3526(operator)X
3855(``?'',)X
576 1200(which)N
821(is)X
910(executed)X
1253(upon)X
1459(predicate)X
1812(failure.)X
2115(A)X
2207(predicate)X
2559(is)X
2647(a)X
2715(C)X
2803(action)X
3048(that)X
3210(evaluates)X
3567(to)X
3665(either)X
3895(true)X
576 1328(\(success\))N
926(or)X
1028(false)X
1223(\(failure\))X
1540(and)X
1696(can)X
1847(be)X
1959(used)X
2149(for)X
2280(both)X
2 f
2466(semantic)X
2808(validation)X
1 f
3196(and)X
3352(for)X
2 f
3483(disambiguating)X
1 f
576 1456(syntactic)N
912(con\257icts)X
1233(in)X
1324(the)X
1454(underlying)X
1858(grammar.)X
776 1612(Validation)N
1174(predicates)X
1556(are)X
1688(used)X
1874(as)X
1972(simple)X
2233(tests)X
2415(and)X
2567(are)X
2699(functionally)X
3151(equivalent)X
3544(to)X
3639(the)X
3773(follow-)X
576 1740(ing)N
711(normal)X
983(action:)X
7 f
9 s
576 1904(if)N
705(\()X
791(!predicate)X
1264(\))X
1350({)X
2 f
1393(error)X
1563(message;)X
1849(exit)X
1971(rule)X
7 f
2087(})X
1 f
11 s
576 2108(or,)N
693(when)X
905(a)X
966(fail)X
1106(action)X
1344(is)X
1425(present:)X
7 f
9 s
576 2272(if)N
705(\()X
791(!predicate)X
1264(\))X
1350({fail_action})X
1 f
11 s
576 2476(For)N
720(example,)X
7 f
9 s
576 2640(a)N
748(:)X
920(A)X
1006(<>?)X
1436(B)X
748 2728(;)N
1 f
11 s
576 2932(Matches)N
7 f
941(A)X
1 f
994(,)X
1052(evaluates)X
7 f
1447(pred)X
1 f
1659(,)X
1717(and)X
1880(matches)X
7 f
2237(B)X
1 f
2327(if)X
7 f
2449(pred)X
1 f
2698(is)X
2794(true)X
2968(else)X
3142(an)X
3262(error)X
3469(is)X
3565(reported)X
3895(\(i.e.)X
576 3060(``)N
7 f
634(failed)X
1014(predicate)X
1553('pred')X
1 f
1871(''\))X
1989(and)X
2147(rule)X
7 f
2346(a)X
1 f
2430(is)X
2520(exited)X
2766(before)X
3020(matching)X
7 f
3410(B)X
1 f
3463(.)X
3537(To)X
3665(generate)X
3993(a)X
576 3188(more)N
779(useful)X
1016(error)X
1208(message,)X
1550(the)X
1680(user)X
1848(may)X
2022(specify)X
2298(a)X
2359(fail)X
2499(action:)X
7 f
9 s
576 3352(a)N
748(:)X
920(A)X
1006(<>?[fail])X
1694(B)X
748 3440(;)N
1 f
11 s
576 3644(which)N
813(executes)X
7 f
1169(fail)X
1 f
1403(when)X
7 f
1646(pred)X
1 f
1880(evaluates)X
2230(to)X
2321(false.)X
776 3800(A)N
867(predicate)X
1218(which)X
1461(validates)X
1803(a)X
1870(production)X
2280(can,)X
2452(at)X
2544(the)X
2680(same)X
2889(time,)X
3097(be)X
3208(used)X
3397(to)X
3494(disambiguate)X
3993(a)X
576 3928(syntactically)N
1055(ambiguous)X
1474(grammar)X
1824(structure.)X
2208(To)X
2338(be)X
2452(a)X
2522(candidate,)X
2913(a)X
2983(predicate)X
3337(must)X
3540(appear)X
3805(on)X
3924(the)X
576 4056(extreme)N
887(left)X
1032(edge)X
1226(of)X
1327(a)X
1394(production.)X
1848(Disambiguating)X
2440(predicates)X
2825(are)X
2960(used)X
3149(in)X
3246(the)X
3382(alternative)X
3783(predic-)X
576 4184(tion)N
743(expressions)X
1182(to)X
1280(enable)X
1539(or)X
1641(disable)X
1920(certain)X
2189(alternative)X
2591(productions)X
3035(of)X
3136(a)X
3203(block)X
3427(\(rule)X
3621(or)X
3722(subrule\).)X
576 4312(Parsing)N
862(in)X
953(this)X
1103(new)X
1271(environment)X
1739(can)X
1883(be)X
1988(viewed)X
2264(in)X
2355(this)X
2505(way:)X
2 f
576 4468(step)N
740(1:)X
835(Disable)X
1131(invalid)X
1399(productions)X
1 f
776 4596(An)N
2 f
905(invalid)X
1 f
1173(production)X
1577(is)X
1658(a)X
1719(production)X
2123(whose)X
2369(disambiguating)X
2936(predicate)X
3281(evaluates)X
3631(to)X
3722(false.)X
2 f
576 4752(step)N
740(2:)X
835(Parse)X
1062(as)X
1162(normal)X
1438(block)X
1 f
776 4880(Once)N
983(a)X
1044(list)X
1175(of)X
2 f
1270(valid)X
1 f
1469(productions)X
1907(has)X
2046(been)X
2234(found,)X
2483(they)X
2657(are)X
2786(parsed)X
3037(as)X
3132(a)X
3193(normal)X
3465(rule)X
3624(or)X
3719(subrule.)X
576 5036(Essentially,)N
1018(disambiguating)X
1595(predicates)X
1985(``gate'')X
2281(alternative)X
2687(productions)X
3136(in)X
3238(and)X
3398(out)X
3544(depending)X
3944(on)X
576 5164(their)N
819(``applicability''.)X
1503(Productions)X
2005(without)X
2356(predicates)X
2794(have)X
3041(an)X
3205(implied)X
3556(predicate)X
3959(of)X
7 f
576 5292(<>?)N
1 f
1053(;)X
1100(i.e.)X
1230(they)X
1404(are)X
1533(always)X
1799(valid.)X
776 5448(A)N
881(single)X
1134(predicate)X
1499(can)X
1663(be)X
1788(used)X
1991(as)X
2106(both)X
2305(a)X
2386(validation)X
2782(and)X
2951(a)X
3033(disambiguating)X
3621(predicate\320)X
576 5576(ANTLR)N
893(determines)X
1303(which)X
1541(way)X
1710(to)X
1802(use)X
1942(them)X
2142 0.2404(automatically.)AX
2691(The)X
2851(role)X
3011(taken)X
3225(by)X
3336(a)X
3398(predicate)X
3744(depends)X
576 5704(on)N
693(its)X
806(location)X
1120(in)X
1218(the)X
1355(grammar.)X
1746(Predicates)X
2137(are)X
2274(all)X
2393(considered)X
2804(validation)X
3188(predicates)X
3575(as)X
3678(they)X
3860(must)X
576 5832(always)N
853(evaluate)X
1180(to)X
1282(true)X
1452(for)X
1587(parsing)X
1879(of)X
1985(the)X
2126(enclosing)X
2497(production)X
2912(to)X
3014(continue.)X
3395(However,)X
3771(when)X
3993(a)X
3 p
%%Page: 3 3
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(3)X
2348(-)X
576 704(grammatical)N
1042(ambiguity)X
1425(is)X
1508(discovered,)X
1935(ANTLR)X
2252(searches)X
2573(for)X
2 f
2699(visible)X
1 f
2954(predicates)X
3335(to)X
3428(disambiguate)X
3924(the)X
576 832(construct.)N
973(A)X
1066(visible)X
1332(predicate)X
1685(is)X
1774(one)X
1931(which)X
2176(can)X
2328(be)X
2441(evaluated)X
2809(in)X
2908(a)X
2976(production)X
3387(prediction)X
3774(expres-)X
576 960(sion)N
759(without)X
1065(consuming)X
1488(a)X
1563(token)X
1795(or)X
1904(executing)X
2283(an)X
2403(action)X
2656(\(except)X
2952 0.3317(initialization)AX
3438(actions\);)X
3779(e.g.)X
3943(all)X
576 1088(disambiguating)N
1149(predicates)X
1534(appear)X
1796(on)X
1912(the)X
2048(left)X
2194(edge)X
2388(of)X
2489(some)X
2702(production.)X
3155(Fail)X
3320(actions)X
3597(are)X
3731(not)X
3871(used)X
576 1216(in)N
678(prediction)X
1070(expressions)X
1514(because)X
1826(a)X
1899(failed)X
2134(predicate)X
2491(disables)X
2809(a)X
2882(production;)X
3323(it)X
3407(does)X
3602(not)X
3749(report)X
3993(a)X
576 1344(syntax)N
841(error)X
1045(unless)X
1299(no)X
1421(other)X
2 f
1636(viable)X
1 f
1886(predicates)X
2277(are)X
2418(present;)X
2731(a)X
2804(viable)X
3054(production)X
3470(is)X
3563(one)X
3724(which)X
3973(is)X
576 1472(predicted)N
939(by)X
1062(the)X
1205(lookahead.)X
1646(The)X
1818(action)X
2069(of)X
2178(moving)X
2484(a)X
2559(predicate)X
2918(into)X
3092(a)X
3167(prediction)X
3561(expression)X
3973(is)X
576 1600(called)N
2 f
822(hoisting)X
1 f
1107(;)X
1167(currently,)X
1542(at)X
1641(most)X
1848(one)X
2010(predicate)X
2368(can)X
2525(be)X
2643(hoisted)X
2932(per)X
3078(ambiguous)X
3499(production.)X
3959(In)X
576 1728(general,)N
879(predicates)X
1258(may)X
1432(only)X
1611(be)X
1716(a)X
1777(function)X
2093(of:)X
576 1884(User)N
763(variables)X
776 2012(This)N
964(is)X
1054(dangerous)X
1446(as)X
1550(hoisting)X
1866(may)X
2049(evaluate)X
2374(the)X
2513(predicate)X
2867(in)X
2967(a)X
3038(scope)X
3270(where)X
3516(the)X
3656(variable\(s\))X
776 2140(does)N
971(not)X
1118(exist;)X
1344(e.g.)X
1505(using)X
1730(rule)X
1901(parameters)X
2321(can)X
2476(be)X
2592(a)X
2664(problem)X
2991(if)X
3078(a)X
3150(predicate)X
3506(that)X
3672(references)X
776 2268(them)N
975(is)X
1056(hoisted)X
1333(outside)X
1610(of)X
1705(the)X
1835(rule.)X
576 2424(Attributes)N
776 2552(Only)N
979(attributes)X
1336(in)X
1433(the)X
1569(left)X
1715(context)X
2003(can)X
2153(be)X
2264(used;)X
2478(i.e.)X
2614(attributes)X
2971(of)X
3072(rules/tokens)X
3526(created)X
3808(before)X
776 2680(the)N
906(predicate)X
1251(is)X
1332(evaluated.)X
576 2836(Lookahead)N
776 2964(The)N
935(next)X
2 f
1109(k)X
1 f
1170(tokens)X
1422(of)X
1517(lookahead)X
1901(can)X
2045(be)X
2150(tested)X
2378(via)X
7 f
2539(LA\(i\))X
1 f
2804(,)X
7 f
2879(LATEXT\(i\))X
1 f
3356(.)X
576 3120(Also,)N
3 f
793(predicates)X
1208(may)X
1398(not)X
1549(have)X
1754(side-effects)X
1 f
2197(\(user)X
2401(must)X
2602(undo)X
2807(anything)X
3145(that)X
3307(was)X
3473(changed)X
3796(if)X
3880(they)X
576 3248(do;)N
712(in)X
804(other)X
1008(words,)X
1267(they)X
1442(must)X
1637(``backtrack''\).)X
2191(See)X
2340(the)X
2470(Future)X
2722(Work)X
2944(section)X
3216(for)X
3340(information)X
3779(regard-)X
576 3376(ing)N
711(the)X
841(use)X
980(of)X
1075(predicates)X
1454(and)X
1603(extremely)X
1978(large)X
2176(lookahead)X
2560(buffers.)X
776 3532(Consider)N
1116(the)X
1246(following)X
1611(simple)X
1869(grammar:)X
7 f
9 s
576 3696(a)N
748(:)X
920(<>?)X
1393(A)X
1479(B)X
9 f
748 3784(|)N
7 f
891(<>?)X
1364(A)X
1450(C)X
748 3872(;)N
1 f
11 s
576 4076(This)N
755(grammar)X
1095(is)X
1176(LL\(2\))X
1408(\()X
7 f
1437(-k)X
1596(2)X
1 f
1649(\))X
1700(and)X
1849(ANTLR)X
2164(would)X
2406(not)X
2541(report)X
2773(an)X
2878(ambiguity.)X
3303(However,)X
3668(it)X
3740(is)X
3822(LL\(1\))X
576 4204(ambiguous)N
985(\()X
7 f
1014(-k)X
1173(1)X
1 f
1226(\))X
1277(and)X
7 f
1457(antlr)X
1775(t.g)X
1 f
1956(would)X
2198(generate)X
2518(a)X
2579(warning)X
2889(message:)X
7 f
9 s
576 4368(t.g,)N
791(line)X
1006(1:)X
1135(warning:)X
1522(alts)X
1737(1)X
1823(and)X
1995(2)X
2081(of)X
2210(rule)X
2425(ambiguous)X
2855(upon)X
3070({)X
3156(A)X
3242(})X
1 f
11 s
576 4572(Now,)N
799(if)X
884(we)X
1017(allow)X
1244(predicates)X
1632(to)X
1732(be)X
1846(used)X
2038(with)X
7 f
2257(antlr)X
2575(-pr)X
2787(t.g)X
1 f
2946(,)X
2999(then)X
3182(ANTLR)X
3507(\256nds)X
3710(that)X
3875(both)X
576 4700(predicates)N
970(are)X
1114(visible)X
1387(and)X
1551(can)X
1710(be)X
1830(used)X
2028(to)X
2133(disambiguate)X
2640(the)X
2784(production;)X
3227(it)X
3313(is)X
3408(up)X
3532(to)X
3637(the)X
3781(user)X
3963(to)X
576 4828(ensure)N
833(that)X
994(the)X
1130(predicates)X
1515(do,)X
1654(in)X
1752(fact,)X
1935(disambiguate)X
2435(the)X
2572(predicate.)X
2968(ANTLR)X
3290(would)X
3539(generate)X
3866(code)X
576 4956(similar)N
844(to)X
935(the)X
1065(following:)X
7 f
9 s
576 5120(a\(\))N
576 5208({)N
748 5296(if)N
877(\()X
963(pred1)X
1221(&&)X
1350(LA\(1\)==A)X
1737(\))X
1823({)X
748 5384(})N
748 5472(else)N
963(if)X
1092(\()X
1178(pred2)X
1436(&&)X
1565(LA\(1\)==A)X
1952(\))X
2038({)X
748 5560(})N
748 5648(else)N
2 f
963(error)X
7 f
1115(;)X
576 5736(})N
4 p
%%Page: 4 4
9 s 0 xH 0 xS 7 f
1 f
2244 376(-)N
2286(4)X
2340(-)X
11 s
576 704(The)N
737(following)X
1104(grammars)X
1480(are)X
1611(syntactically)X
2082(and)X
2233(semantically)X
2704(equivalent)X
3096(to)X
3189(the)X
3321(above)X
3555(grammar,)X
3919(but)X
576 832(the)N
706(predicates)X
1085(are)X
1214(not)X
1349(hoisted)X
1626(trivially:)X
7 f
9 s
576 996(a)N
748(:)X
920(\()X
1006(<>?)X
1479(A)X
1565(B)X
1651(\))X
9 f
748 1084(|)N
7 f
891(<>?)X
1364(A)X
1450(C)X
748 1172(;)N
1 f
11 s
576 1376(ANTLR)N
907(looks)X
1136(inside)X
1385(the)X
1531(subrule)X
1829(of)X
1941(production)X
2362(one)X
2528(and)X
2694(\256nds)X
2904(that)X
7 f
3107(pred1)X
1 f
3411(can)X
3572(be)X
3694(evaluated)X
576 1504(before)N
834(executing)X
1211(an)X
1328(action)X
1578(and)X
1738(before)X
1995(matching)X
2357(a)X
2429(token;)X
2683(it)X
2766(is)X
2858(hoisted)X
3146(for)X
3281(use)X
3431(in)X
3533(the)X
3674(prediction)X
576 1632(expression)N
974(of)X
1069(rule)X
7 f
1259(a)X
1 f
1312(.)X
1378(Predicates)X
1762(can)X
1906(be)X
2011(hoisted)X
2288(from)X
2481(other)X
2684(rules)X
2877(as)X
2972(well:)X
7 f
9 s
576 1796(a)N
748(:)X
920(b)X
9 f
748 1884(|)N
7 f
891(c)X
748 1972(;)N
576 2148(b)N
748(:)X
920(<>?)X
1393(A)X
1479(B)X
748 2236(;)N
576 2412(c)N
748(:)X
920(<>?)X
1393(A)X
1479(C)X
748 2500(;)N
1 f
11 s
576 2704(Rule)N
7 f
810(a)X
1 f
899(would)X
1155(still)X
1325(have)X
1527(the)X
1671(same)X
1889(production)X
2308(prediction)X
2703(expression.)X
3160(The)X
3334(following)X
3714(grammar)X
576 2832(does)N
759(not)X
894(have)X
1082(predicates)X
1461(that)X
1616(can)X
1760(be)X
1865(hoisted)X
2142(to)X
2233(disambiguate)X
2726(the)X
2856(prediction:)X
7 f
9 s
576 2996(a)N
748(:)X
920(A)X
1006(<>?)X
1479(B)X
2081(/*)X
2210(cannot)X
2511(hoist)X
2769(past)X
2984(token)X
3242(*/)X
9 f
748 3084(|)N
7 f
891(<>)X
1364(<>?)X
1837(A)X
1923(C)X
2052(/*)X
2181(cannot)X
2482(hoist)X
2740(past)X
2955(action)X
3256(*/)X
748 3172(;)N
1 f
11 s
776 3376(Now,)N
992(consider)X
1314(how)X
1489(a)X
1552(simpli\256ed)X
1930(version)X
2213(of)X
2310(K&R)X
2525(C)X
2608(variable)X
2916(and)X
3067(function)X
3385(declarations)X
3836(could)X
576 3504(be)N
681(speci\256ed:)X
7 f
9 s
576 3668(decl:)N
920(/*)X
1049(variable)X
1436(definition,)X
1952(function)X
2339 -0.1964(DECLARATION/DEFINITION)AX
3328(*/)X
920 3756(type)N
1135(declarator)X
1608(\()X
1694(func_body)X
9 f
2124(|)X
7 f
2181(";")X
2353(\))X
9 f
748 3844(|)N
7 f
891(/*)X
1020(function)X
1407(DEFINITION)X
1880(*/)X
920 3932(declarator)N
1393(func_body)X
748 4020(;)N
576 4196(type:)N
920("int")X
9 f
748 4284(|)N
7 f
891("float")X
9 f
748 4372(|)N
7 f
891(WORD)X
748 4460(;)N
576 4636(declarator)N
748 4724(:)N
920(WORD)X
1135({)X
1221("\\\(")X
1436(args)X
1651("\\\)")X
1866(})X
748 4812(;)N
576 4988(func_body)N
748 5076(:)N
920(\()X
1006(decl)X
1221(\)*)X
1350("\\{")X
1565(\(decl\)*)X
1909(\(stat\)*)X
2253("\\}")X
748 5164(;)N
1 f
11 s
576 5368(unfortunately,)N
1098(rule)X
7 f
1291(decl)X
1 f
1528(is)X
1612(totally)X
1865(ambiguous)X
2278(in)X
2373(the)X
2507(LL\(1\))X
2743(sense)X
2959(\(and)X
3141(in)X
3236(the)X
3370(LL\(k\))X
3606(sense\))X
3851(since)X
7 f
576 5496(WORD)N
1 f
820(can)X
974(begin)X
1202(both)X
1390(alternatives)X
1828(of)X
1932(rule)X
7 f
2131(decl)X
1 f
2343(.)X
2418(Increasing)X
2815(the)X
2954(lookahead)X
3347(to)X
3447(two)X
3610(tokens)X
3871(does)X
576 5624(not)N
730(help)X
923(as)X
1037(the)X
1186(alternatives)X
1634(are)X
1782(ambiguous)X
2211(upon)X
7 f
2460(WORDWORD)X
1 f
2884(.)X
2970(Alternative)X
3409(one)X
3578(could)X
3816(match)X
7 f
576 5752(my_type)N
1000(var)X
1 f
1188(and)X
1344(alternative)X
1746(two)X
1907(could)X
2132(match)X
7 f
2408(func)X
2673(my_type)X
1 f
3044(;)X
3098(hence,)X
3354(the)X
3491(second)X
3763(alterna-)X
576 5880(tive)N
745(matches)X
1070(at)X
1170(least)X
1368(one)X
1531(invalid)X
1813(sentence.)X
2196(This)X
2389(is)X
2484(because)X
2799(the)X
7 f
2975(\()X
3081(decl)X
3346(\)*)X
1 f
3489(subrule)X
3785(of)X
3895(rule)X
5 p
%%Page: 5 5
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(5)X
2348(-)X
7 f
576 704(func_body)N
1 f
1053(,)X
1098(which)X
1336(would)X
1579(match)X
1818(the)X
1949(second)X
7 f
2247(WORD)X
1 f
2482(of)X
7 f
2609(WORD)X
2874(WORD)X
1 f
3086(,)X
3131(does)X
3314(not)X
3449(know)X
3666(if)X
3742(an)X
3847(argu-)X
576 832(ment)N
775(list)X
906(was)X
1064(seen)X
1242(previously)X
1636(or)X
1731(not.)X
1910(The)X
2069(question)X
2391(of)X
2487(whether)X
2793(to)X
2885(match)X
3124(a)X
3186(parameter)X
3561(de\256nition)X
3923(list)X
576 960(after)N
766(a)X
834(declarator)X
1215(is)X
1303(context-sensitive)X
1929(because)X
2235(a)X
2302(function)X
2624(header)X
2886(may)X
3066(or)X
3167(may)X
3347(not)X
3488(have)X
3682(been)X
3876(seen)X
576 1088 0.3187(immediately)AN
1041(beforehand.)X
776 1244(One)N
954(way)X
1132(in)X
1233(which)X
1480(this)X
1640(subset)X
1892(could)X
2120(be)X
2235(recognized)X
2653(is)X
2744(to)X
2845(recognize)X
3219(a)X
3290(large)X
3498(superset)X
3818(of)X
3924(the)X
576 1372(language)N
916(and)X
1065(then,)X
1261(using)X
1474(actions,)X
1768(verify)X
2000(that)X
2155(the)X
2285(input)X
2489(was)X
2647(valid:)X
7 f
9 s
576 1536(decl:)N
920({type})X
1221(declarator)X
1694(\()X
1780(func_body)X
9 f
2210(|)X
7 f
2267(";")X
2439(\))X
748 1624(;)N
1 f
11 s
576 1828(But,)N
760(jamming)X
1109(everything)X
1520(together)X
1843(makes)X
2102(action)X
2352(introduction)X
2818(more)X
3033(complicated.)X
3544(It)X
3633(is)X
3727(better)X
3963(to)X
576 1956(specify)N
852(the)X
982(input)X
1186(language)X
1526(exactly)X
1803(with)X
1982(predicates.)X
776 2112(To)N
903(overcome)X
1279(the)X
1416(ambiguity)X
1804(in)X
1902(rule)X
7 f
2099(decl)X
1 f
2340(and)X
2496(to)X
2594(ensure)X
2852(that)X
3014(only)X
3200(a)X
3268(function)X
3591(declarator)X
3973(is)X
576 2240(followed)N
911(by)X
1021(a)X
1082(parameter)X
1456(de\256nition,)X
1839(we)X
1963(augment)X
2289(the)X
2419(grammar)X
2759(as)X
2854(follows:)X
7 f
9 s
576 2404(decl:)N
920(<
1178(is_func;>>)X
920 2580(/*)N
1049(variable)X
1436(definition,)X
1952(function)X
2339 -0.1964(DECLARATION/DEFINITION)AX
3328(*/)X
920 2668(type)N
1135(declarator)X
1608(>)X
1694([is_func])X
920 2756(\()N
1092 -0.1942(<>?[printf\("warning:)AX
2382(declarator)X
2855(not)X
3027(func\\n"\);])X
1092 2844(func_body)N
9 f
920 2932(|)N
7 f
1063(";")X
920 3020(\))N
9 f
748 3196(|)N
7 f
891(/*)X
1020(function)X
1407(DEFINITION)X
1880(*/)X
920 3284(declarator)N
1393(>)X
1479([is_func])X
920 3372 -0.1942(<>?[printf\("warning:)AN
2210(expecting)X
2640(func)X
2855(header)X
3156(not)X
3328(%s\\n",)X
3629(LATEXT\(1\)\);])X
920 3460(func_body)N
748 3548(;)N
576 3724(type:)N
920("int")X
9 f
748 3812(|)N
7 f
891("float")X
9 f
748 3900(|)N
7 f
891(<
1493(?)X
1579 -0.1992(isTYPE\(LATEXT\(1\)\))AX
2353(:)X
2439(1>>?)X
920 3988(WORD)N
748 4076(;)N
576 4252(declarator)N
1049(>)X
1135([int)X
1350(is_func])X
748 4340(:)N
920(<
1522(?)X
1608 -0.1985(!isTYPE\(LATEXT\(1\)\))AX
2425(:)X
2511(1>>?)X
920 4428(WORD)N
1135(\()X
1221("\\\(")X
1436(<<$is_func=1;>>)X
2124(args)X
2339("\\\)")X
9 f
2554(|)X
7 f
2611(<<$is_func=0;>>)X
3299(\))X
748 4516(;)N
576 4692(func_body)N
748 4780(:)N
920(\()X
1006(decl)X
1221(\)*)X
1350("\\{")X
1565(\(decl\)*)X
1909(\(stat\)*)X
2253("\\}")X
748 4868(;)N
1 f
11 s
576 5072(In)N
675(rule)X
7 f
869(type)X
1 f
1081(,)X
1129(we)X
1257(add)X
1410(a)X
1475(predicate)X
1824(that)X
1983(ensures)X
2272(that,)X
2453(if)X
2533(the)X
2667(lookahead)X
3055(is)X
3140(a)X
7 f
3236(WORD)X
1 f
3448(,)X
3496(that)X
3655(the)X
7 f
3820(WORD)X
1 f
576 5200(is,)N
692(in)X
796(fact,)X
985(a)X
1059(user-de\256ned)X
1528(type;)X
1740(nothing)X
2045(can)X
2202(be)X
2320(said)X
2497(if)X
2586(the)X
2729(lookahead)X
3126(is)X
3220(something)X
3623(else,)X
3817(so)X
3930(we)X
576 5328(return)N
813(success)X
1103(in)X
1199(that)X
1359(case;)X
1562(i.e.)X
1697(the)X
1833(predicate)X
2184(does)X
2373(not)X
2514(apply)X
2738(for)X
2868(that)X
3029(lookahead)X
3419(\(context\).)X
3809(If)X
3895(rule)X
7 f
576 5456(declarator)N
1 f
1135(is)X
1223(called,)X
1485(a)X
1553(failure)X
1812(of)X
1914(the)X
2051(predicate)X
2403(will)X
2570(report)X
2809(a)X
2877(semantic)X
3220(error.)X
3463(In)X
3565(our)X
3711(example,)X
576 5584(the)N
711(predicate)X
1061(is)X
1147(also)X
1317(hoisted)X
1600(for)X
1730(use)X
1875(as)X
1976(a)X
2043(disambiguating)X
2616(predicate)X
2967(in)X
3064(rule)X
7 f
3260(decl)X
1 f
3472(.)X
3544(The)X
3709(predicate)X
576 5712(in)N
676(rule)X
7 f
875(declarator)X
1 f
1436(ensures)X
1730(that,)X
1915(if)X
1999(the)X
2137(lookahead)X
2529(is)X
2618(a)X
7 f
2718(WORD)X
1 f
2930(,)X
2982(that)X
3145(the)X
7 f
3314(WORD)X
1 f
3556(is)X
3645(not)X
3788(a)X
3857(user-)X
576 5840(de\256ned)N
857(type.)X
1075(As)X
1194(before,)X
1462(it)X
1534(is)X
1615(also)X
1779(hoisted)X
2056(to)X
2147(rule)X
7 f
2337(decl)X
1 f
2571(to)X
2662(disambiguate)X
3156(the)X
3287(second)X
3554(production)X
3959(of)X
6 p
%%Page: 6 6
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(6)X
2348(-)X
576 704(that)N
744(rule.)X
960(Both)X
1167(productions)X
1617(of)X
1724(rule)X
7 f
1926(decl)X
1 f
2172(have)X
2372(predicates)X
2763(that)X
2930(are)X
3071(hoisted)X
3360(into)X
3532(the)X
3674(prediction)X
576 832(expressions)N
1033(for)X
1182(those)X
1415(productions;)X
1903(ANTLR)X
2243(assumes)X
2583(that)X
2763(the)X
2918(hoisted)X
3221(predicates)X
3 f
3626(completely)X
1 f
576 960(disambiguate)N
1071(the)X
1203(decision,)X
1543(which)X
1782(is)X
1864(true)X
2024(in)X
2116(our)X
2256(case.)X
2474(The)X
2634(\256rst)X
2794(predicate)X
3140(physically)X
3526(present)X
3803(in)X
3895(rule)X
7 f
576 1088(decl)N
1 f
818(ensures)X
1111(that,)X
1296(if)X
1380(a)X
1449(function)X
1773(body)X
1979(is)X
2068(coming)X
2363(up,)X
2503(the)X
2641(declarator)X
3024(was)X
3191(a)X
3261(function)X
3586(header.)X
3895(The)X
576 1216(second)N
853(predicate)X
1209(in)X
1311(rule)X
7 f
1512(decl)X
1 f
1757(again)X
1981(ensures)X
2277(that)X
2443(a)X
2515(function)X
2842(header)X
3108(was)X
3276(seen)X
3464(before)X
3720(trying)X
3963(to)X
576 1344(match)N
814(a)X
875(function)X
1191(body.)X
1433(The)X
1592(variable)X
7 f
1929(is_func)X
1 f
2322(is)X
2403(set)X
2523(to)X
2615(the)X
2746(return)X
2979(value)X
3193(of)X
3289(rule)X
7 f
3480(declarator)X
1 f
4010(,)X
576 1472(which)N
813(is)X
894(set)X
1014(by)X
1124(two)X
1278(simple)X
1536(actions)X
1808(in)X
7 f
1930(declarator)X
1 f
2460(.)X
776 1628(Currently,)N
1184(the)X
1340(context)X
1649(under)X
1898(which)X
2162(predicates)X
2568(are)X
2724(evaluated)X
3111(may)X
3312(not)X
3474(be)X
3606(correct;)X
3924(i.e.)X
576 1756(currently)N
916(ANTLR)X
1231(does)X
1414(not)X
1549(compute)X
1875(the)X
2005(context)X
2287(from)X
2480(which)X
2717(it)X
2789(hoists)X
3017(a)X
3078(predicate.)X
3467(For)X
3611(example,)X
7 f
9 s
576 1920(a)N
748(:)X
920(b)X
1006(B)X
9 f
748 2008(|)N
7 f
891(\(X)X
1020(Y)X
9 f
1106(|)X
7 f
1163(A)X
1249(C\))X
748 2096(;)N
576 2272(b)N
748(:)X
920(<>?)X
1350(A)X
748 2360(;)N
1 f
11 s
576 2564(The)N
741(predicate)X
7 f
1124(pred)X
1 f
1365(will)X
1532(be)X
1644(hoisted)X
1928(for)X
2059(use)X
2205(in)X
2303(disambiguating)X
2877(rule)X
7 f
3074(a)X
1 f
3127(.)X
3200(However,)X
3572(the)X
3709(predicate)X
576 2692(will)N
745(be)X
859(evaluate)X
1184(regardless)X
1571(of)X
1675(whether)X
7 f
2020(A)X
1 f
2073(,)X
2126(which)X
2372(is)X
2462(its)X
2577(context,)X
2890(or)X
7 f
3025(X)X
1 f
3109(is)X
3199(on)X
3318(the)X
3457(input)X
3669(stream.)X
3978(It)X
576 2820(may)N
753(be)X
861(invalid)X
1132(to)X
1226(apply)X
1447(the)X
1580(predicate)X
1928(when)X
2143(the)X
2277(lookahead)X
2665(is)X
7 f
2781(X)X
1 f
2834(.)X
2904(The)X
3067(user)X
3239(may)X
3417(overcome)X
3790(this)X
3944(by)X
576 2948(changing)N
7 f
952(pred)X
1 f
1186(thus:)X
7 f
9 s
576 3112(a)N
748(:)X
920(b)X
1006(B)X
9 f
748 3200(|)N
7 f
891(\(X)X
1020(Y)X
9 f
1106(|)X
7 f
1163(A)X
1249(C\))X
748 3288(;)N
576 3464(b)N
748(:)X
920(<
1393(?)X
1479(pred)X
1694(:)X
1780(TRUE>>?)X
2124(A)X
748 3552(;)N
1 f
11 s
576 3756(which)N
813(will)X
973(ensure)X
1224(that)X
1379(the)X
1509(predicate)X
1854(is)X
1935(only)X
2114(evaluated)X
2474(when)X
7 f
2717(A)X
1 f
2792(is)X
2873(seen)X
3051(on)X
3161(the)X
3291(input)X
3495(stream.)X
776 3912(Another)N
1088(problem)X
1406(area)X
1576(lies)X
1723(in)X
1816(that)X
1973(hoisting)X
2282(can)X
2428(occur)X
2647(in)X
2740(situations)X
3104(that)X
3262(will)X
3425(break)X
3645(the)X
3778(seman-)X
576 4040(tics.)N
765(For)X
909(example:)X
7 f
9 s
576 4204(a)N
748(:)X
920(b[3])X
9 f
748 4292(|)N
7 f
891(A)X
748 4380(;)N
576 4556(b[int)N
834(i])X
748 4644(:)N
834(<>?)X
1307(A)X
748 4732(;)N
1 f
11 s
576 4936(The)N
751(predicate)X
7 f
1143(f\(i\))X
1 f
1393(will)X
1569(be)X
1690(hoisted)X
1983(to)X
2090(rule)X
7 f
2296(a)X
1 f
2387(where)X
2639(the)X
2785(parameter)X
7 f
3206(i)X
1 f
3297(is)X
3394(not)X
3546(even)X
3751(de\256ned.)X
576 5064(Either)N
816(do)X
927(not)X
1063(do)X
1174(this)X
1325(or)X
1421(put)X
1557(a)X
1619(predicate)X
1965(\(dummy)X
2287(or)X
2383(otherwise\))X
2777(between)X
3093(the)X
3224(decision)X
3541(and)X
3691(the)X
3822(predi-)X
576 5192(cate)N
740(you)X
894(do)X
1004(not)X
1139(wish)X
1327(to)X
1418(be)X
1523(hoisted:)X
7 p
%%Page: 7 7
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2244 376(-)N
2286(7)X
2340(-)X
7 f
576 712(a)N
748(:)X
920(<<1>>?)X
1221(b[3])X
9 f
748 800(|)N
7 f
891(A)X
748 888(;)N
576 1064(b[int)N
834(i])X
748 1152(:)N
834(<>?)X
1307(A)X
748 1240(;)N
1 f
11 s
776 1444(This)N
956(is)X
1038(an)X
1144(alpha)X
1358(release)X
1625(feature)X
1892(in)X
1984(that)X
2140(it)X
2213(is)X
2295(not)X
2431(anywhere)X
2795(near)X
2969(what)X
3164(we)X
3290(want)X
3485(it)X
3559(to)X
3652(do)X
3764(and)X
3915(has)X
576 1572(NOT)N
788(been)X
986(thoroughly)X
1405(tested.)X
1687(User)X
1884(beware.)X
2213(We)X
2367(do)X
2487(not)X
2632(guarantee)X
3006(that)X
3171(the)X
3310(syntax)X
3571(of)X
3675(predicates)X
576 1700(will)N
744(stay)X
916(this)X
1074(way;)X
1275(however,)X
1630(the)X
1769(semantics)X
2148(will)X
2317(not)X
2461(change.)X
2785(We)X
2938(want)X
3140(users)X
3351(to)X
3451(play)X
3634(with)X
3822(predi-)X
576 1828(cates)N
774(to)X
865(\256nd)X
1024(new,)X
1214(better)X
1437(or)X
1532(different)X
1857(ways)X
2059(of)X
2154(doing)X
2377(things.)X
2659(We)X
3 f
2803(really)X
1 f
3041(want)X
3234(user)X
3402(feedback)X
3741(on)X
3851(these)X
576 1956(critters)N
849(before)X
1101(a)X
1168(full)X
1319 0.2885(implementation)AX
1903(is)X
1990(developed.)X
2424(For)X
2575(example,)X
2925(how)X
3105(do)X
3222(you)X
3383(want)X
3583(the)X
3720(parser)X
3963(to)X
576 2084(respond)N
876(if)X
952(no)X
1062(valid,)X
1283(viable)X
1521(production)X
1925(is)X
2006(found?)X
7 f
9 s
576 2248(a)N
748(:)X
920(<>?)X
1264(A)X
9 f
748 2336(|)N
7 f
891(<>?)X
1235(A)X
9 f
748 2424(|)N
7 f
891(B)X
748 2512(;)N
1 f
11 s
576 2716(If)N
656(the)X
786(input)X
990(were)X
7 f
1213(C)X
1 f
1266(,)X
1310(a)X
1371(correct)X
1637(error)X
1829(message)X
2149(would)X
2391(be)X
2496(reported:)X
7 f
9 s
576 2880(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("C")X
1780(missing)X
2124({)X
2210(A)X
2296(B)X
2382(})X
1 f
11 s
576 3084(This)N
765(is)X
856(the)X
996(correct)X
1272(message)X
1602(because)X
1912(it)X
1994(is)X
2085(truly)X
2284(a)X
2355(syntax,)X
2639(as)X
2744(opposed)X
3069(to)X
3170(semantic,)X
3538(error.)X
3784(On)X
3924(the)X
576 3212(other)N
780(hand,)X
996(upon)X
1195(input)X
7 f
1431(A)X
1 f
1484(,)X
1529(when)X
1742(predicates)X
7 f
2152(p1)X
1 f
2280(and)X
7 f
2460(p2)X
1 f
2588(are)X
2717(false,)X
2927(the)X
3057(parser)X
3293(reports)X
3559(the)X
3689(following)X
576 3340(bizarre)N
842(message:)X
7 f
9 s
576 3504(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A")X
1 f
11 s
576 3708(which)N
814(is)X
896(not)X
1032(very)X
1211(meaningful.)X
1680(The)X
1840(fail)X
1981(function,)X
7 f
2351(zzFAIL)X
1 f
2669(,)X
2715(found)X
2944(that,)X
3123(in)X
3216(fact,)X
7 f
3425(A)X
1 f
3502(is)X
3585(syntactically)X
576 3836(valid)N
778(and)X
930(got)X
1068(confused)X
1410(because)X
1713(an)X
1821(error)X
2016(was)X
2177(raised;)X
2437(this)X
2590(is)X
2674(because)X
2977(the)X
3109(fail)X
3251(routine)X
3525(has)X
3666(no)X
3778(seman-)X
576 3964(tic)N
700(information.)X
1196(A)X
1294(suitable)X
1604(de\256nition)X
1978(of)X
2086(error)X
2292(reporting)X
2651(in)X
2756(the)X
2900(predicate)X
3259(environment)X
3741(must)X
3949(be)X
576 4092(created.)N
776 4248(Please)N
1159(send)X
1478(any)X
1763(suggestions/questions)X
2691(to)X
7 f
2950 0.1974([email protected])AX
1 f
4010(,)X
7 f
576 4376 0.1974([email protected])AN
1 f
1811(or)X
2059(use)X
2351(the)X
2633(email)X
3004(server)X
3392(mechanism)X
3968(at)X
7 f
576 4504 0.1974([email protected])AN
1 f
1665(\(send)X
1884(a)X
7 f
1983(Subject:)X
1 f
2436(line)X
2598(of)X
2700(``question)X
3086(antlr'')X
3335(and)X
3491(\256ll)X
3619(in)X
3718(the)X
3856(body)X
576 4632(of)N
671(the)X
801(email)X
1020(with)X
1199(your)X
1382(suggestion/question\).)X
3 f
576 4888(1.2.)N
752(1.06)X
928(Is)X
1018(Written)X
1338(in)X
1434(1.00)X
1 f
776 5044(The)N
938(grammar)X
1281(for)X
1408(the)X
1541(PCCTS)X
1836(meta-language)X
2380(\(\256le)X
2547(format\))X
2836(has)X
2979(been)X
3171(implemented)X
3659(in)X
3754(Version)X
576 5172(1.00,)N
777(making)X
1067(heavy)X
1301(use)X
1442(of)X
7 f
1570(#lexclass)X
1 f
2071(directives.)X
2482(File)X
7 f
2675(lexhelp.c)X
1 f
3176(has)X
3317(been)X
3507(eliminated)X
3905(due)X
576 5300(to)N
667(the)X
797(superiority)X
1201(of)X
1296(1.00)X
1472(to)X
1563(1.00B.)X
8 p
%%Page: 8 8
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(8)X
2348(-)X
3 f
576 704(1.3.)N
752(ANTLR)X
1081(Compiles)X
1455(Under)X
1716(ANSI)X
1947(C)X
1 f
776 860(Because)N
1100(of)X
1204(the)X
1343(rewrite)X
1623(of)X
1727(the)X
1866(grammar)X
2215(and)X
2373(some)X
2591(rewrites)X
2906(of)X
3011(ANTLR)X
3336(code,)X
3556(ANTLR)X
3881(now)X
576 988(compiles)N
948(with)X
1158(ANSI)X
1415(compilers)X
1816(without)X
2139(a)X
2231(wimper)X
2553(\(except)X
2864(for)X
3018(two)X
3202(``)X
7 f
3260(unknown)X
3714(escape)X
576 1116(sequence)N
1 f
1000('')X
1080(warnings\).)X
1497(Your)X
1699(mileage)X
2001(may)X
2175(vary.)X
3 f
576 1372(1.4.)N
752(Grammar)X
1155(Files)X
1354(Distributed)X
7 f
776 1528(antlr.g)N
1 f
1175(and)X
7 f
1362(dlg_p.g)X
1 f
1762(are)X
1898(now)X
2078(included)X
2411(in)X
2509(the)X
2646(source)X
2904(distribution)X
3341(for)X
3472(1.06.)X
3699(Note)X
3899(that)X
576 1656(the)N
710(1.00)X
890(PCCTS)X
1186(\(both)X
1398(ANTLR)X
1717(and)X
1870(DLG\))X
2104(are)X
2236(required)X
2554(to)X
2648(process)X
2936(these)X
3142(grammar)X
3485(\256les.)X
3701(DO)X
3852(NOT)X
576 1784(DESTROY)N
1003(YOUR)X
1273(OLD)X
1475(COPY)X
1731(OF)X
1865(1.00)X
2041(PCCTS)X
2333(\(at)X
2448(least)X
2632(save)X
2810(the)X
2940(executables\).)X
3 f
576 2040(1.5.)N
752(Script)X
1004(Generates)X
1407(Make\256les)X
1791(for)X
1925(PCCTS)X
2235(Projects)X
1 f
776 2196(A)N
877(C)X
974(program)X
1310(called)X
7 f
1590(genmk.c)X
1 f
1999(is)X
2096(available)X
2453(in)X
2560(the)X
7 f
2737(support)X
1 f
3146(directory)X
3503(of)X
3615(the)X
3762(PCCTS)X
576 2324(release)N
842(which)X
1079(has)X
1218(the)X
1348(following)X
1713(usage:)X
7 f
576 2480(genmk)N
894(project)X
1318(f1.g)X
1583(f2.g)X
1848(...)X
2060(fn.g)X
1 f
576 2636(It)N
658(generates)X
1018(a)X
1085(make\256le)X
1418(that)X
1580(creates)X
1853(an)X
1965(executable,)X
7 f
2424(project)X
1 f
2795(,)X
2846(from)X
3046(a)X
3114(set)X
3241(of)X
3343(grammar)X
3690(\256les.)X
3910(For)X
576 2764(example,)N
7 f
950(genmk)X
1268(t)X
1374(t.g)X
1 f
1555(generates:)X
7 f
9 s
576 2928(#)N
576 3016(#)N
662(PCCTS)X
920(makefile)X
1307(for:)X
1522(t.g)X
576 3104(#)N
576 3192(DLG_FILE)N
963(=)X
1049(parser.dlg)X
576 3280(ERR_FILE)N
963(=)X
1049(err.c)X
576 3368(HDR_FILE)N
963(=)X
1049(stdpccts.h)X
576 3456(TOK_FILE)N
963(=)X
1049(tokens.h)X
576 3544(K)N
662(=)X
748(1)X
576 3632(ANTLR_H)N
920(=)X
1006(.)X
576 3720(BIN)N
748(=)X
834(.)X
576 3808(ANTLR)N
834(=)X
920($\(BIN\)/antlr)X
576 3896(DLG)N
748(=)X
834($\(BIN\)/dlg)X
576 3984(CFLAGS)N
877(=)X
963(-I.)X
1135(-I$\(ANTLR_H\))X
576 4072(AFLAGS)N
877(=)X
963(-fe)X
1135(err.c)X
1393(-fh)X
1565(stdpccts.h)X
2038(-fl)X
2210(parser.dlg)X
2683(-ft)X
2855(tokens.h)X
3242(-k)X
3371($\(K\))X
576 4160(-gk)N
576 4248(DFLAGS)N
877(=)X
963(-C2)X
1135(-i)X
576 4336(GRM)N
748(=)X
834(t.g)X
576 4424(SRC)N
748(=)X
834(scan.c)X
1135(t.c)X
1307(err.c)X
576 4512(OBJ)N
748(=)X
834(scan.o)X
1135(t.o)X
1307(err.o)X
576 4724(t:)N
705($\(OBJ\))X
1006($\(SRC\))X
920 4812(cc)N
1049(-o)X
1178(t)X
1264($\(CFLAGS\))X
1694($\(OBJ\))X
576 4988(t.c)N
748(parser.dlg)X
1221(:)X
1307(t.g)X
920 5076($\(ANTLR\))N
1307($\(AFLAGS\))X
1737(t.g)X
576 5252(scan.c)N
877(:)X
963(parser.dlg)X
920 5340($\(DLG\))N
1221($\(DFLAGS\))X
1651(parser.dlg)X
2124(scan.c)X
1 f
11 s
576 5544(This)N
775(program)X
1115(is)X
1216(handy)X
1474(when)X
1707(beginning)X
2103(a)X
2185(new)X
2374(PCCTS)X
2687(project)X
2975(or)X
3091(when)X
3324(\256rst)X
3504(learning)X
3836(about)X
576 5672(PCCTS.)N
9 p
%%Page: 9 9
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(9)X
2348(-)X
3 f
576 704(1.6.)N
752(DLG)X
965(Supports)X
1329(Case)X
1531(Insensitive)X
1954(Scanners)X
1 f
776 860(DLG)N
983(has)X
1127(two)X
1286(new)X
1459(options)X
1746(which)X
1988(provide)X
2284(control)X
2562(over)X
2746(the)X
2882(case)X
3061(sensitivity)X
3453(of)X
3554(the)X
3690(generated)X
576 988(scanner.)N
918(Speci\256cally,)X
1387(case)X
1568(insensitivity)X
2031(implies)X
2322(that)X
2485(when)X
2705(a)X
2774(character)X
3126(is)X
3215(referenced)X
3615(in)X
3714(a)X
3783(regular)X
576 1116(expression,)N
996(DLG)X
1198(behaves)X
1503(as)X
1598(if)X
1674(the)X
1804(user)X
1972(had)X
2121(typed)X
2339(both)X
2518(upper)X
2740(and)X
2889(lower)X
3111(case)X
3284(versions)X
3600(of)X
3696(that)X
3852(char-)X
576 1244(acter;)N
794(i.e.)X
7 f
955(\()X
2 f
1008(a)X
7 f
9 f
(|)S
2 f
1070(A)X
7 f
1124(\))X
1 f
1199(where)X
2 f
1435(a)X
1 f
1501(is)X
1582(some)X
1790(character.)X
2178(The)X
2337(new)X
2505(options)X
2787(are:)X
7 f
576 1400(-ci)N
1 f
776(Make)X
998(lexical)X
1256(analyzer)X
1576(case)X
1749(insensitive)X
7 f
576 1556(-cs)N
1 f
776(Make)X
998(lexical)X
1256(analyzer)X
1576(case)X
1749(sensitive)X
2080(\(default\).)X
3 f
576 1812(1.7.)N
752(Delayed)X
1077(Lookahead)X
1520(Fetches)X
1825(in)X
1921(Generated)X
2339(Parser)X
1 f
776 1968(Currently,)N
1158(PCCTS)X
1450(generates)X
1804(parsers)X
2074(which)X
2311(always)X
2577(have)X
2 f
2765(k)X
1 f
2826(tokens)X
3078(of)X
3173(lookahead.)X
3601(This)X
3780(is)X
3861(done)X
576 2096(by)N
704(following)X
1087(the)X
1235(strategy)X
1554(that)X
1727(another)X
2031(token)X
2267(is)X
2366(fetched)X
2665(\()X
7 f
2694(zzCONSUME)X
1 f
3171(\))X
3240(when)X
3469(one)X
3635(is)X
3733(matched)X
576 2224(\()N
7 f
605(zzmatch)X
1 f
976(\).)X
1092(This)X
1292(can)X
1457(be)X
1583(a)X
1665(problem)X
2002(for)X
2147(actions)X
2440(that)X
2616(need)X
2825(to)X
2938(occur)X
3177(after)X
3382(a)X
3465(token)X
3705(has)X
3866(been)X
576 2352(matched,)N
937(but)X
1090(before)X
1354(the)X
1502(next)X
1694(token)X
1930(of)X
2043(lookahead)X
2445(is)X
2544(fetched.)X
2887(This)X
3083(is)X
3181(somewhat)X
3577(overcome)X
3963(in)X
576 2480(PCCTS)N
868(1.00)X
1044(by)X
1154(delaying)X
1480(the)X
1610(fetch)X
1808(if)X
1884(an)X
1989(action)X
2227(is)X
2308(found)X
2535 0.3187(immediately)AX
3000(after)X
3183(a)X
3244(token)X
3462(reference.)X
3855(With)X
576 2608(the)N
724(new)X
910(delayed)X
1224(lookahead)X
1626(scheme,)X
1952(the)X
2100(next)X
2292(token)X
2528(is)X
2627(not)X
2780(consumed)X
3177(until)X
3380(the)X
3527(next)X
3718(match)X
3973(is)X
576 2736(required.)N
936(This)X
1116(means)X
1364(that)X
1520(any)X
1670(action)X
1909(before)X
2156(the)X
2287(next)X
2462(match)X
2701(\(not)X
2866(necessarily)X
3280(adjacent)X
3597(to)X
3690(the)X
3822(previ-)X
576 2864(ous)N
724(match\))X
995(will)X
1159(be)X
1268(executed)X
1607(before)X
1857(a)X
1922(lookahead)X
2310(fetch)X
2512(occurs.)X
2811(Turn)X
3008(on)X
3121(ANTLR)X
3439(option)X
7 f
3721(-gk)X
1 f
3905(and)X
576 2992(DLG)N
785(option)X
7 f
1071(-i)X
1 f
1206(to)X
1304(enable)X
1563(this)X
1720(feature.)X
2037(This)X
2223(feature)X
2496(appears)X
2793(to)X
2891(work)X
3100(with)X
3287(AST's)X
3546(and)X
3703(attributes)X
576 3120(with)N
769(the)X
913(constraints)X
1330(mentioned)X
1738(below)X
1988(in)X
2092(the)X
2235 0.2891(incompatibilities)AX
2866(section)X
3151(\(e.g.)X
3342(use)X
3494(of)X
7 f
3633(LA\()X
2 f
3792(i)X
7 f
3817(\))X
1 f
3905(and)X
7 f
576 3248(LATEXT\()N
2 f
947(i)X
7 f
972(\))X
1 f
1047(has)X
1186(been)X
1374(restricted\).)X
1797(It)X
1874(has)X
2014(been)X
2203(tested)X
2432(with)X
2612(the)X
2743(C)X
2825(\()X
2 f
2854(k>)X
1 f
2952(1)X
3019(and)X
3169(Pascal)X
3417(\()X
2 f
3446(k==)X
1 f
3603(1\))X
3699(examples)X
576 3376(provided)N
911(in)X
1002(the)X
1132(release)X
1398(and)X
1547(with)X
1726(several)X
1997(other)X
2200(large)X
2398(grammars.)X
776 3532(This)N
956(feature)X
1223(is)X
1305(primarily)X
1657(useful)X
1895(for)X
2020(developers)X
2425(of)X
2522(interactive)X
2919(tools.)X
3159(Previously,)X
3582(it)X
3656(was)X
3 f
3816(really)X
1 f
576 3660(hard)N
766(to)X
869(get)X
1010(PCCTS)X
1313(to)X
1415(generate)X
1746(truly)X
1946(interactive)X
2352(tools.)X
2601(It)X
2688(appeared)X
3038(as)X
3144(if)X
3231(the)X
3372(parser)X
3619(was)X
3788(always)X
576 3788(waiting)N
863(on)X
973(a)X
1034(token)X
1252(fetch)X
1450(rather)X
1677(than)X
1851(executing)X
2216(an)X
2321(appropriate)X
2744(action.)X
3026(E.g.)X
3190(in)X
3281(PCCTS)X
3573(1.00,)X
7 f
9 s
576 3952(a)N
662(:)X
748(\()X
834("A")X
1006("B")X
1178("C")X
1350("\\n")X
1565(\))X
1651(<
2253(it\\n"\);>>)X
662 4040(;)N
1 f
11 s
576 4244(would)N
827(not)X
971(print)X
7 f
1201(got)X
1413(it)X
1 f
1551(until)X
1746(one)X
1905(token)X
2133(after)X
2326(the)X
2466(newline)X
2777(had)X
2936(been)X
3134(typed.)X
3406(PCCTS)X
3708(1.06)X
3894(will)X
576 4372(generate)N
903(parsers)X
1180(that)X
1342(print)X
1538(the)X
1675(message)X
2002 0.3187(immediately)AX
2474(upon)X
2679(newline)X
2987(and)X
3142(will)X
3308(exit)X
3469(without)X
3767(waiting)X
576 4500(for)N
700(another)X
986(token)X
1204(as)X
1299(there)X
1497(are)X
1626(no)X
1736(token)X
1954(references)X
2336(following)X
2701(the)X
2831(action.)X
776 4656(Another)N
1090(way)X
1262(in)X
1357(which)X
1598(delayed)X
1898(lookahead)X
2286(is)X
2371(useful)X
2612(lies)X
2761(in)X
2856(translators)X
3249(which)X
3490(add)X
3643(symbols)X
3963(to)X
576 4784(the)N
716(symbol)X
1008(table)X
1212(which)X
1459(must)X
1663(be)X
1778(examined)X
2153(by)X
2272(a)X
2342(lexical)X
2609(action.)X
2900(If)X
2989(a)X
3059(lookahead)X
3452(fetch)X
3659(occurs)X
3919(too)X
576 4912(fast,)N
747(the)X
877(lexical)X
1135(action)X
1373(may)X
1547(miss)X
1731(the)X
1861(introduction)X
2315(of)X
2410(a)X
2471(symbol)X
2753(into)X
2913(the)X
3043(symbol)X
3325(table.)X
776 5068(This)N
955(feature)X
1221(is)X
1302(a)X
1363(bit)X
1479(\257aky)X
1677(for)X
1801(the)X
1931(moment\320)X
7 f
2309(LA\()X
2 f
2468(i)X
7 f
2493(\))X
1 f
2568(and)X
7 f
2748(LATEXT\()X
2 f
3119(i)X
7 f
3144(\))X
1 f
3219(will)X
3379(generally)X
3730(not)X
3866(have)X
576 5196(the)N
713(same)X
923(values)X
1177(as)X
1279(when)X
1498(the)X
7 f
1665(-gk)X
1 f
1852(option)X
2106(is)X
2193(not)X
2334(used)X
2523(\(for)X
2 f
2682(k)X
1 f
2721(>=2\).)X
2966(Use)X
3130(attributes)X
3487(to)X
3584(access)X
3836(token)X
576 5324(values;)N
856(the)X
994(lookahead)X
1386(buffer)X
1630(is)X
1719(not)X
1862(really)X
2093(a)X
2162(user)X
2338(object.)X
2628(If)X
2716(you)X
2878(insist)X
3095(upon)X
3301(accessing)X
3668(the)X
3807(looka-)X
576 5452(head)N
772(buffer,)X
1038(use)X
7 f
1216(LA\(0\))X
1 f
1511(and)X
7 f
1699(LATEXT\(0\))X
1 f
2176(,)X
2227(which)X
2471(typically)X
2810(access)X
3063(the)X
3200(last)X
3352(token)X
3577(matched)X
3905(and)X
576 5580(last)N
722(text)X
878(matched)X
1201(respectively;)X
1676(this)X
1828(is)X
1911(distinguished)X
2406(from)X
7 f
2632(LA\(1\))X
1 f
2897(,)X
2943(which)X
3182(means)X
3431(the)X
3563(next)X
3739(token)X
3959(of)X
576 5708(lookahead.)N
1009(Accessing)X
1397(the)X
1532(next)X
1711(token)X
1934(of)X
2034(lookahead)X
2423(is)X
2509(invalid)X
2782(because)X
3087(it)X
3164(will)X
3328(not)X
3467(be)X
3576(fetched)X
3861(from)X
576 5836(the)N
706(input)X
910(stream)X
1167(until)X
1352(needed)X
1623(\(just)X
1802(before)X
2048(the)X
2178(next)X
2352(decision)X
2668(or)X
2763(match\).)X
10 p
%%Page: 10 10
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(10)X
2370(-)X
3 f
576 704(1.8.)N
752(Tutorials)X
1122(Available)X
1 f
776 860(With)N
982(release)X
1255(1.06,)X
1460(we)X
1592(are)X
1729(distributing)X
2167(both)X
2354(a)X
2423(beginning)X
2806(and)X
2963(advanced)X
3325(tutorial.)X
3655(They)X
3866(have)X
576 988(not)N
711(been)X
899(thoroughly)X
1308(``debugged'')X
1788(much)X
2006(are)X
2135(much)X
2353(better)X
2576(than)X
2750(nothing:)X
576 1144(Beginning)N
776 1272(This)N
955(tutorial)X
1233(introduces)X
1622(the)X
1752(basic)X
1955(functionality)X
2429(of)X
2525(PCCTS)X
2818(by)X
2929(example.)X
3295(The)X
3455(user)X
3624(need)X
3813(not)X
3949(be)X
776 1400(familiar)N
1079(with)X
1259(parsing)X
1541(theory)X
1789(or)X
1885(other)X
2089(compiler)X
2426(tools,)X
2643(but)X
2778(any)X
2927(familiarity)X
3323(reduces)X
3613(the)X
3743(learning)X
776 1528(curve)N
993(substantially.)X
576 1684(Advanced)N
776 1812(Constructing)N
1268(a)X
1343(translator)X
1713(can)X
1872(be)X
1992(viewed)X
2283(as)X
2393(an)X
2513(iterative)X
2840(re\256nement)X
3254(process)X
3554(moving)X
3861(from)X
776 1940(language)N
1119(recognition)X
1546(to)X
1640(intermediate-form)X
2307(transformation.)X
2895(This)X
3077(tutorial)X
3358(presents)X
3671(one)X
3822(possi-)X
776 2068(ble)N
914(sequence)X
1266(of)X
1369(re\256nements.)X
1854(It)X
1938(uses)X
2119(as)X
2222(many)X
2448(features)X
2756(of)X
2860(PCCTS)X
3161(as)X
3265(is)X
3355(reasonable)X
3762(without)X
776 2196(regards)N
1071(to)X
1177 0.3313(optimality.)AX
1623(It)X
1714(develops)X
2064(a)X
2139(compiler)X
2489(for)X
2627(a)X
2702(simple)X
2974(string)X
3211(manipulation)X
3714(language)X
776 2324(called)N
2 f
1009(sc)X
1 f
1082(.)X
1148(The)X
1307(resulting)X
1638(compiler)X
1974(generates)X
2328(code)X
2516(for)X
2640(a)X
2701(simple)X
2959(stack)X
3162(machine.)X
3 f
576 2580(1.9.)N
752(Error)X
994(Messages)X
1367(for)X
2 f
1501(k>)X
1 f
1599(1)X
776 2736(Previous)N
1110(versions)X
1429(of)X
1528(PCCTS)X
1824(did)X
1963(not)X
2102(handle)X
2363(error)X
2559(message)X
2883(correctly)X
3222(for)X
2 f
3350(k>)X
1 f
3448(1.)X
3562(For)X
3711(example,)X
576 2864(with)N
755(two)X
909(tokens)X
1161(of)X
1256(lookahead)X
1640(and)X
1789(the)X
1919(following)X
2284(grammar:)X
7 f
9 s
576 3028(a)N
662(:)X
748("A")X
920("B")X
1092("D")X
9 f
662 3116(|)N
7 f
719("A")X
891("C")X
1063("E")X
662 3204(;)N
1 f
11 s
576 3408(an)N
681(incorrect)X
1016(input)X
1220(of)X
1315(A)X
1400(D)X
1485(D)X
1570(would)X
1812(yield:)X
7 f
9 s
576 3572(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A")X
1780(missing)X
2124(A)X
1 f
11 s
576 3776(which)N
823(is)X
914(wrong)X
1170(\(and)X
1358(incredibly)X
1748(confusing\).)X
2200(The)X
2369(new)X
2547(error)X
2749(mechanism)X
3183(generates)X
3548(the)X
3689(following)X
576 3904(error)N
768(message)X
1088(upon)X
1286(the)X
1416(same)X
1619(incorrect)X
1954(input:)X
7 f
9 s
576 4068(line)N
791(1:)X
920(syntax)X
1221(error)X
1479(at)X
1608("A)X
1737(D";)X
1909("D")X
2081(not)X
2253(in)X
2382({)X
2468(B)X
2554(C)X
2640(})X
1 f
11 s
576 4272(which)N
815(is)X
898(in\256nitely)X
1242(superior.)X
1598(Unfortunately,)X
2138(situations)X
2501(may)X
2677(arise)X
2868(when)X
3083(even)X
3274(this)X
3427(method)X
3717(will)X
3880(give)X
576 4400(an)N
685(invalid)X
957(message.)X
1325(This)X
1508(may)X
1686(occur)X
1907(when)X
2123(alternatives)X
2556(have)X
2748(lookahead)X
3136(sequences)X
3518(which)X
3759(are)X
3891(per-)X
576 4528(mutations)N
947(of)X
1042(the)X
1172(same)X
1375(tokens.)X
776 4684(The)N
939(de\256nition)X
1304(of)X
1403(the)X
1537(standard)X
1861(error)X
2057(reporting)X
2406(function,)X
7 f
2779(zzsyn\(\))X
1 f
3176(has)X
3319(been)X
3511(modi\256ed.)X
3895(The)X
576 4812(parameter)N
950(list)X
1081(is)X
1162(now:)X
7 f
9 s
576 4976(void)N
576 5064(zzsyn\(char)N
1049(*text,)X
834 5152(int)N
1006(tok,)X
834 5240(char)N
1049(*egroup,)X
834 5328(unsigned)N
1221(*eset,)X
834 5416(int)N
1006(etok,)X
834 5504(int)N
1006(k,)X
834 5592(char)N
1049(*bad_text\);)X
11 p
%%Page: 11 11
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(11)X
2370(-)X
576 704(Users)N
804(can)X
955(ignore)X
1209(this)X
1366(as)X
1468(it)X
1547(is)X
1635(transparent)X
2056(to)X
2155(them;)X
2387(unless,)X
2659(of)X
2762(course,)X
3043(the)X
3181(standard)X
3509(error)X
3709(reporting)X
576 832(must)N
770(be)X
875(modi\256ed.)X
1255(In)X
1350(addition,)X
7 f
1715(zzFAIL)X
1 f
2055(is)X
2136(now)X
2309(a)X
2370(function)X
2686(rather)X
2913(than)X
3087(a)X
3148(macro.)X
3 f
576 1088(1.10.)N
796(Trace)X
1038(Facility)X
1345(has)X
1494(Exit)X
1673(Macro)X
1 f
776 1244(Previously,)N
1215(only)X
1413(an)X
1537(entry)X
1759(trace)X
1971(macro)X
2232(was)X
2409(inserted)X
2729(in)X
2839(parsers)X
3128(when)X
3359(the)X
7 f
3539(-gd)X
1 f
3739(ANTLR)X
576 1372(option)N
847(was)X
1028(used.)X
1277(An)X
1428(exit)X
1605(macro)X
1869(has)X
2030(been)X
2240(de\256ned)X
2543(which)X
2802(resulted)X
3125(in)X
7 f
3269(zzTRACE)X
1 f
3684(becoming)X
7 f
576 1500(zzTRACEIN)N
1 f
1053(.)X
1126(Also,)X
1344(a)X
1413(default)X
1688(trace)X
1889(macro)X
2139(prints)X
2370(out)X
2513(``)X
7 f
2571(enter)X
2889(rule)X
2 f
3154(rule)X
1 f
3296('')X
3384(if)X
3468(no)X
3586(default)X
3861(trace)X
576 1628(macros)N
863(are)X
1003(de\256ned.)X
1339(To)X
1470(de\256ne)X
1718(your)X
1912(own,)X
2118(the)X
2259(macro)X
2512(de\256nitions)X
2918(must)X
3123(appear)X
3389(in)X
3490(the)X
7 f
3661(#header)X
1 f
576 1756(action.)N
863(As)X
987(before,)X
1260(the)X
1395(sole)X
1565(argument)X
1926(to)X
2023(the)X
2159(trace)X
2358(routines)X
2670(is)X
2757(a)X
2824(string)X
3053(representing)X
3516(the)X
3652(rule)X
3817(which)X
576 1884(has)N
715(been)X
903(entered)X
1184(or)X
1279(is)X
1360(about)X
1578(to)X
1669(be)X
1774(exited.)X
3 f
576 2140(1.11.)N
796(Resource)X
1164(Limitation)X
1 f
776 2296(Occasionally,)N
1293(ANTLR)X
1621(is)X
1715(unable)X
1985(to)X
2090(analyze)X
2395(a)X
2470(grammar)X
2824(submitted)X
3209(by)X
3333(the)X
3477(user.)X
3703(This)X
3896(rare)X
576 2424(situation)N
909(can)X
1059(only)X
1244(occur)X
1467(when)X
1684(the)X
1819(grammar)X
2164(is)X
2250(large)X
2453(and)X
2607(the)X
2742(amount)X
3034(of)X
3134(lookahead)X
3523(is)X
3609(greater)X
3880(than)X
576 2552(one.)N
773(A)X
862(nonlinear)X
1221(analysis)X
1531(algorithm)X
1901(is)X
1986(used)X
2173(by)X
2287(PCCTS)X
2583(to)X
2678(handle)X
2939(the)X
3073(general)X
3358(case)X
3535(of)X
2 f
3635(LL\(k\))X
1 f
3857(pars-)X
576 2680(ing.)N
761(The)X
926(average)X
1227(complexity)X
1653(of)X
1753(analysis,)X
2086(however,)X
2437(is)X
2523(near)X
2701(linear)X
2929(due)X
3083(to)X
3179(some)X
3392(fancy)X
3614(footwork)X
3963(in)X
576 2808(the)N
706 0.2885(implementation)AX
1284(which)X
1521(reduces)X
1811(the)X
1941(number)X
2232(of)X
2327(calls)X
2511(to)X
2602(the)X
2732(full)X
2 f
2877(LL\(k\))X
1 f
3094(algorithm.)X
776 2964(To)N
899(avoid)X
1120(the)X
1253(situation)X
1583(where)X
1822(ANTLR)X
2140(takes)X
2346(23)X
2459(hours)X
2679(of)X
2778(CPU)X
2975(time)X
3159(and)X
3312(then)X
3490(runs)X
3667(out)X
3806(of)X
3905(vir-)X
576 3092(tual)N
746(memory,)X
1099(use)X
1253(the)X
7 f
1429(-rl)X
2 f
1641(n)X
1 f
1722(resource)X
2055(limit)X
2260(option)X
2522(where)X
2 f
2772(n)X
1 f
2852(is)X
2947(the)X
3091(maximum)X
3486(number)X
3791(of)X
3900(tree)X
576 3220(nodes)N
810(to)X
908(be)X
1020(used)X
1210(by)X
1327(the)X
1464(analysis)X
1778(algorithm.)X
2196(An)X
2333(error)X
2533(message)X
2861(will)X
3029(be)X
3142(displayed,)X
3532(if)X
3616(this)X
3774(limit)X
3973(is)X
576 3348(reached,)N
899(which)X
1142(indicates)X
1484(which)X
1726(grammar)X
2071(construct)X
2421(was)X
2584(being)X
2807(analyzed)X
3147(when)X
3364(ANTLR)X
3684(hit)X
3805(a)X
3871(non-)X
576 3476(linearity.)N
944(Use)X
1109(this)X
1266(option)X
1521(if)X
1604(ANTLR)X
1926(seems)X
2170(to)X
2268(go)X
2385(off)X
2516(to)X
2614(lunch)X
2839(and)X
2995(your)X
3185(disk)X
3361(start)X
3542(swapping;)X
3934(try)X
2 f
576 3604(n)N
1 f
(=10000)S
918(to)X
1015(start.)X
1239(Once)X
1452(the)X
1587(offending)X
1956(construct)X
2306(has)X
2450(been)X
2643(identi\256ed,)X
3026(try)X
3151(to)X
3247(remove)X
3538(the)X
3673(ambiguity)X
576 3732(that)N
738(ANTLR)X
1060(was)X
1225(trying)X
1465(to)X
1563(overcome)X
1939(with)X
2125(large)X
2330(lookahead)X
2721(analysis.)X
3078(Future)X
3337(versions)X
3659(of)X
3762(PCCTS)X
576 3860(may)N
750(incorporate)X
1173(a)X
1234(known)X
1495(algorithm)X
1861(that)X
2016(does)X
2199(not)X
2334(exhibit)X
2602(this)X
2752(exponential)X
3186(behavior.)X
3 f
576 4116(1.12.)N
796(Rule)X
994(Pre\256x)X
1241(Option)X
1 f
776 4272(An)N
909(ANTLR)X
1228(option)X
1480(has)X
1623(been)X
1815(added)X
2051(that)X
2210(pre\256xes)X
2514(all)X
2630(functions)X
2985(corresponding)X
3515(to)X
3611(rules)X
3809(with)X
3993(a)X
576 4400(pre\256x.)N
848(This)X
1028(can)X
1173(be)X
1279(used)X
1463(to)X
1554(provide)X
1845(symbol)X
2127(hiding)X
2375(in)X
2466(your)X
2649(project)X
2916(to)X
3007(isolate)X
3260(the)X
3390(parser.)X
3670(It)X
3746(can)X
3890(also)X
576 4528(be)N
681(used)X
864(to)X
955(allow)X
1173(rule)X
1332(names)X
1579(that)X
1734(correspond)X
2146(to)X
2237(C)X
2318(keywords)X
2681(such)X
2864(as)X
2959(if)X
3035(and)X
7 f
3215(typedef)X
1 f
3586(.)X
3 f
576 4784(1.13.)N
796(Standard)X
1170(PCCTS)X
1480(Header)X
1 f
776 4940(Two)N
965(new)X
1139(ANTLR)X
1460(options)X
1748(have)X
1942(been)X
2136(added)X
2374(that)X
2536(control)X
2815(the)X
2952(creation)X
3265(of)X
3367(a)X
3435(standard)X
3762(PCCTS)X
576 5068(header)N
842(\256le)X
987(\320)X
7 f
1138(stdpccts.h)X
1 f
1668(.)X
1743(Option)X
7 f
2050(-gh)X
1 f
2240(instructs)X
2570(ANTLR)X
2894(to)X
2994(create)X
3235(a)X
3305(\256le,)X
7 f
3502(stdpccts.h)X
1 f
576 5196(unless)N
7 f
849(-fh)X
1 f
1031(is)X
1113(used,)X
1319(which)X
1557(contains)X
1874(all)X
1986(header)X
2243(information)X
2683(needed)X
2955(by)X
3066(non-PCCTS)X
3520(generated)X
3885(\256les)X
576 5324(that)N
736(want)X
934(to)X
1030(access)X
1281(PCCTS)X
1578(symbols.)X
1943(For)X
2092(example,)X
2440(it)X
2517(indicates)X
2858(the)X
2 f
2993(k)X
1 f
3059(of)X
3159(the)X
3294(parser,)X
3557(whether)X
3866(trees)X
576 5452(are)N
711(being)X
935(constructed,)X
1391(whether)X
1702(lookahead)X
2092(is)X
2179(to)X
2276(be)X
2387(delayed,)X
2711(and)X
2866(indicates)X
3208(what)X
3407(the)X
3544(user)X
3719(speci\256ed)X
576 5580(in)N
671(the)X
7 f
836(#header)X
1 f
1233(action)X
1475(in)X
1570(the)X
1703(grammar)X
2046(\256le.)X
2228(Previously,)X
2652(the)X
2785(user)X
2956(had)X
3108(to)X
3202(manually)X
3556(construct)X
3904(this)X
576 5708(information)N
1018(from)X
1214(the)X
1347(grammar)X
1690(\256le)X
1828(in)X
1922(order)X
2132(to)X
2226(place)X
2437(the)X
2570(information)X
3012(in)X
3106(a)X
3170(non-PCCTS)X
3627(C)X
3712(\256le.)X
3895(The)X
7 f
576 5836(-fh)N
1 f
757(option)X
1005(is)X
1086(merely)X
1353(used)X
1536(to)X
1627(rename)X
7 f
1939(stdpccts.h)X
1 f
2469(.)X
12 p
%%Page: 12 12
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(12)X
2370(-)X
3 f
576 704(1.14.)N
796(Doubly-Linked)X
1391(AST's)X
1 f
776 860(A)N
870(new)X
1047(function)X
1372(is)X
1462(available)X
1812(in)X
7 f
1943(ast.c)X
1 f
2239(which)X
2485(will)X
2654(doubly-link)X
3097(any)X
3255(tree)X
3419(that)X
3584(is)X
3675(passed)X
3941(in.)X
576 988(To)N
703(use)X
849(this)X
1006(option,)X
1282(the)X
1418(user)X
1592(must)X
1792(de\256ne)X
2035(zzAST_DOUBLE)X
2707(in)X
2804(the)X
7 f
2971(#header)X
1 f
3370(directive)X
3707(or)X
3808(on)X
3924(the)X
576 1116(command-line)N
1118(of)X
1223(the)X
1363(C)X
1454(compile.)X
1815(This)X
2004(de\256nes)X
7 f
2316(left)X
1 f
2560(and)X
7 f
2750(up)X
1 f
2888(\256elds)X
3111 0.2604(automatically)AX
3625(in)X
3726(the)X
3866(AST)X
576 1244(node)N
770(typedef.)X
1101(ANTLR)X
1417(generated)X
1782(parsers,)X
2075(normally,)X
2438(only)X
2617(construct)X
2962(singly-linked)X
3450(trees.)X
3682(The)X
3841(\256elds)X
576 1372(can)N
720(be)X
825(\256lled)X
1029(in)X
1120(via)X
1250(code)X
1438(similar)X
1706(to)X
1797(the)X
1927(following:)X
7 f
9 s
576 1536(#header)N
920(<<)X
576 1624(#define)N
920(AST_FIELDS)X
2 f
1476(user-\256elds)X
7 f
1776(;)X
576 1712(>>)N
576 1888(<<)N
576 1976(main\(\))N
576 2064({)N
756 2152(AST)N
928(*root)X
1186(=)X
1272(NULL;)X
756 2328 -0.1979(ANTLR\(start\(&root\),)AN
1616(stdin\);)X
756 2416 -0.1979(zzdouble_link\(root,)AN
1616(NULL,)X
1874(NULL\);)X
576 2504(})N
1 f
11 s
576 2708(where)N
812(the)X
942(function)X
1258(is)X
1339(de\256ned)X
1620(as:)X
7 f
9 s
576 2872 -0.1992(zzdouble_link\(AST)AN
1350(*t,)X
1522(AST)X
1694(*left,)X
1995(AST)X
2167(*up\);)X
3 f
11 s
576 3176(1.15.)N
796(C++)X
981(Compatible)X
1443(Parsers)X
1 f
776 3332(PCCTS)N
1070(parsers)X
1342(may)X
1518(now)X
1693(be)X
1800(compiled)X
2153(with)X
2334(C++)X
2517(compilers;)X
2914(i.e.)X
3046(the)X
3178(output)X
3428(is)X
3511(more)X
3716(ANSI)X
3944(C-)X
576 3460(like)N
738(than)X
919(before.)X
1216(It)X
1299(has)X
1445(been)X
1639(successfully)X
2097(compiled)X
2454(with)X
2639(GCC)X
2848(2.2,)X
3008(but)X
3149(not)X
3290(with)X
3475(GCC)X
3684(1.37.)X
3910(We)X
576 3588(do)N
688(not)X
825(guarantee)X
1191(anything.)X
1568(To)X
1690(be)X
1797(safe,)X
1984(use)X
2125(the)X
7 f
2288(-ga)X
1 f
2471(option)X
2721(so)X
2823(that)X
2980(PCCTS)X
3275(generates)X
3632(ANSI-style)X
576 3716(prototypes)N
970(for)X
1094(functions)X
1444(generated)X
1808(from)X
2001(rules.)X
2238(As)X
2357(a)X
2418(simple)X
2676(example,)X
3019(consider:)X
7 f
9 s
576 3880(#header)N
920(<<)X
576 3968(#include)N
963("charbuf.h")X
576 4056(/*)N
705(stdio.h)X
1049(is)X
1178(included,)X
1608(by)X
1737(default,)X
2124(but)X
2296(doesn't)X
2640(seem)X
2855(to)X
2984(bother)X
3285(stream.h)X
3672(*/)X
576 4144(#include)N
963()X
576 4232(#include)N
963()X
576 4320(>>)N
576 4496(#token)N
877("[\\)X
1049(\\t\\n]")X
1350(<>)X
576 4672(<<)N
576 4760(main\(\))N
576 4848({)N
920 4936(ANTLR\(a\(\),)N
1393(stdin\);)X
920 5024(cout)N
1135(<<)X
1264("end)X
1479(of)X
1608(C++)X
1780(test\\n";)X
576 5112(})N
576 5200(>>)N
576 5376(a)N
920(:)X
1264("A")X
1436("B")X
1608(<<)X
1737(cout)X
1952(<<)X
2081($1.text)X
2425(<<)X
2554($2.text)X
2898(<<)X
3027("\\n";)X
3285(>>)X
920 5464(;)N
1 f
11 s
576 5668(which)N
813(does)X
996(not)X
1131(do)X
1241(much:)X
13 p
%%Page: 13 13
11 s 0 xH 0 xS 1 f
9 s
2226 376(-)N
2268(13)X
2358(-)X
7 f
576 712(%)N
662(t)X
576 800(A)N
662(B)X
576 888(AB)N
576 976(end)N
748(of)X
877(C++)X
1049(test)X
576 1064(%)N
1 f
11 s
576 1268(but)N
719(it)X
799(does)X
990(compile)X
1305(with)X
1492(G++)X
1685(2.2)X
1825(except)X
2086(that)X
2250(a)X
2320(warning)X
2639(is)X
2729(generated)X
3102(concerning)X
7 f
3555(strncpy\(\))X
1 f
576 1396(not)N
714(being)X
935(declared)X
1258(before)X
1507(use.)X
1693(This)X
1875(is)X
1958(trivial)X
2194(to)X
2287(\256x,)X
2426(of)X
2523(course)X
2776(\320)X
2888(by)X
3000(modifying)X
3392(the)X
7 f
3555(charbuf.h)X
1 f
576 1524(\256le.)N
755(We)X
899(compiled)X
1250(this)X
1400(with:)X
7 f
9 s
576 1688(antlr)N
834(-k)X
963(2)X
1049(-gk)X
1221(-ga)X
1393(t.g)X
576 1776(Antlr)N
834(parser)X
1135(generator)X
1651(Version)X
1995(1.06)X
2296(1989-1992)X
576 1864(dlg)N
748(-C2)X
920(-i)X
1049(parser.dlg)X
1522(scan.c)X
576 1952(dlg)N
791(Version)X
1135(1.06)X
1436(1989-1992)X
576 2040(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(scan.c)X
576 2128(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(t.c)X
576 2216(t.c:)N
791(In)X
920(function)X
1307(`struct)X
1651(Attrib)X
1952(zzconstr_attr)X
2554(\(int,)X
2812(char)X
3027(*\)':)X
576 2304(t.c:19:)N
920(warning:)X
1307(implicit)X
1694(declaration)X
2210(of)X
2339(function)X
2726(`strncpy')X
576 2392(g++)N
748(-I.)X
920(-I../1.06/h)X
1436(-g)X
1565(-c)X
1694(err.c)X
576 2480(g++)N
748(-o)X
877(t)X
963(-I.)X
1135(-I../1.06/h)X
1651(-g)X
1780(scan.o)X
2081(t.o)X
2253(err.o)X
1 f
11 s
576 2684(We)N
720(anticipate)X
1086(a)X
1147(rewrite)X
1418(to)X
1509(be)X
1614(more)X
1817(C++)X
1998(sometime)X
2364(in)X
2455(the)X
2585(future.)X
3 f
576 2940(2.)N
686(Acknowledgements)X
1 f
776 3096(We)N
928(acknowledge)X
1422(Dan)X
1598(Lawrence)X
1974(of)X
2077(MDBS)X
2356(for)X
2488(the)X
2627(new)X
2804(error)X
3005(reporting)X
3359(facility)X
3641(concerning)X
576 3224(greater)N
844(than)X
1020(one)X
1171(token)X
1391(of)X
1488(lookahead;)X
1899(Dana)X
2108(Hoggatt,)X
2438(also)X
2604(of)X
2701(MDBS,)X
2996(suggested)X
3366(the)X
3497(rule)X
3657(pre\256x)X
3885(idea)X
576 3352(\()N
7 f
605(-gp)X
1 f
817(option\))X
1125(and)X
1305(beta)X
1505(tested)X
1764(1.06.)X
2015(We)X
2190(thank)X
2439(Ed)X
2590(Harfmann)X
3000(of)X
3127(MDBS)X
3430(for)X
3586(creating)X
3924(the)X
7 f
576 3480(makefile.os2)N
1 f
1241(\256les)X
1417(and)X
1573(porting)X
1857(it)X
1936(to)X
2034(the)X
2171(PC.)X
2352(We)X
2503(acknowledge)X
2995(the)X
3131(following)X
3502(beta)X
3677(testers)X
3930(for)X
576 3608(1.06)N
827(\(alphabetically\):)X
1525(Thomas)X
1906(Buehlman)X
2366(\([email protected]\),)X
3582(Peter)X
3861(Dahl)X
576 3736(\([email protected]\),)N
1715(Chris)X
2055(Song)X
2385(\([email protected]\),)X
3384(Ariel)X
3714(Tamches)X
576 3864(\([email protected]\).)N
1575(We)X
1723(reference)X
2075(Russell)X
2361(Quong)X
2626(\([email protected]\))X
3548(of)X
3648(Purdue)X
3924(EE)X
576 3992(for)N
784(his)X
993(work)X
1279(with)X
1541(us)X
1724(on)X
1917(de\256ning)X
2311(and)X
2543(re\256ning)X
2922(predicates.)X
3428(Ariel)X
3714(Tamches)X
576 4120(\([email protected]\))N
1537(deserves)X
1871(attention)X
2213(for)X
2347(hacking)X
2658(on)X
2778(the)X
2918(particulars)X
3322(of)X
3427(the)X
3568(alpha-release)X
576 4248(predicates.)N
3 f
576 4504(3.)N
686(Machine)X
1036(Compatibility)X
1 f
776 4660(PCCTS)N
1068(Version)X
1368(1.06)X
1544(has)X
1683(been)X
1871(tested)X
2099(on)X
2209(the)X
2339(following)X
2704(platforms:)X
576 4816(Sun)N
735(3/60)X
576 4972(Sun)N
735(SPARC)X
1036(I,)X
1109(II)X
576 5128(Encore)N
847(Multimax)X
1218(running)X
1514(Umax)X
1751(4.3)X
576 5284(Sun)N
735(sparcstation)X
1178(IPX)X
576 5440(NeXTstation)N
576 5596(Decstation)N
975(3100)X
1173(running)X
1469(Ultrix)X
1702(4.2)X
14 p
%%Page: 14 14
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(14)X
2370(-)X
576 704(DEC)N
774(5000)X
576 860(Linux)N
809(on)X
919(386PC)X
576 1016(Microsoft)N
945(C)X
1026(6.0)X
1158(on)X
1268(PC)X
1398(OS/2,)X
1623(DOS)X
576 1172(CSET/2)N
883(C)X
964(compiler)X
1300(on)X
1410(PC)X
1540(OS/2)X
576 1328(IBM)N
764(RS6000)X
576 1484(MIPS)N
803(r2000)X
3 f
576 1740(4.)N
686(Incompatibilities)X
1 f
776 1896(Due)N
945(to)X
1037(the)X
1168(bug)X
1324(\256xes)X
1514(in)X
1607(1.06,)X
1807(``new'')X
2093(ambiguities)X
2530(may)X
2706(appear)X
2964(in)X
3057(your)X
3242(grammar.)X
3628(These)X
3862(were)X
576 2024(always)N
842(there\320ANTLR)X
1421(simply)X
1684(did)X
1819(not)X
1954(\256nd)X
2113(them.)X
2356(The)X
2515(analysis)X
2821(is)X
2902(more)X
3105(correct.)X
776 2180(Calls)N
996(to)X
7 f
1134(zzTRACE)X
1 f
1543(are)X
1688(no)X
1814(longer)X
2078(generated)X
2459(by)X
2586(the)X
7 f
2764(-gd)X
1 f
2962(option.)X
3271(Now,)X
7 f
3533(zzTRACEIN)X
1 f
4010(,)X
7 f
576 2308(zzTRACEOUT)N
1 f
1128(are)X
1257(called)X
1490(at)X
1576(the)X
1706(beginning)X
2081(and)X
2230(end)X
2379(of)X
2474(functions,)X
2846(respectively.)X
776 2464(The)N
948(way)X
1129(in)X
1233(which)X
1483(PCCTS)X
1788(translates)X
2156(actions)X
2441(has)X
2593(been)X
2795(changed;)X
3149(before)X
3409(they)X
3597(were)X
3803(parsed)X
576 2592(with)N
760(a)X
826(C)X
912(function,)X
1255(now)X
1433(the)X
7 f
1599(#lexclass)X
1 f
2103(facility)X
2381(is)X
2467(being)X
2690(used.)X
2921(Some)X
3148(differences)X
3564(in)X
3659(translation)X
576 2720(may)N
758(be)X
871(discovered;)X
1307(e.g.)X
1464(a)X
1533(character)X
1885(may)X
2067(need)X
2263(to)X
2362(be)X
2475(escaped)X
2783(with)X
7 f
3001(\\)X
1 f
3084(whereas)X
3402(before)X
3657(the)X
3796(simple)X
576 2848(character)N
920(was)X
1078(suf\256cient.)X
776 3004(The)N
942(user)X
1117(should)X
1381(no)X
1498(longer)X
1752(set)X
1879(the)X
2016(next)X
2197(token)X
2422(of)X
2524(lookahead)X
2915(or)X
3017(the)X
3154(text)X
3316(of)X
3418(the)X
3555(next)X
3737(token)X
3963(in)X
576 3132(the)N
727(lexical)X
1006(analyzer)X
1347(using)X
7 f
1612(LA\(1\))X
1 f
1920(and)X
7 f
2121(LATEXT\(1\))X
1 f
2598(.)X
2685(This)X
2885(is)X
2987(incompatible)X
3492(with)X
3692(the)X
7 f
3873(-gk)X
1 f
576 3260(option;)N
849(hence,)X
7 f
1129(NLA)X
1 f
1310(and)X
7 f
1490(NLATEXT)X
1 f
1883(should)X
2140(be)X
2245(used)X
2428(instead)X
2700(where)X
2936(the)X
7 f
3097(N)X
1 f
3172(means)X
3419(``next''.)X
776 3416(The)N
7 f
967(-ga)X
1 f
1149(does)X
1333(not)X
1469(generate)X
1791(anything)X
2124(different)X
2451(as)X
2548(the)X
2680(code)X
2870(generator)X
3226(now)X
3401(dumps)X
3660(both)X
3841(K&R)X
576 3544(and)N
725(ANSI)X
951(with)X
7 f
1161(#ifdef)X
1 f
1479('s)X
1564(around)X
1830(the)X
1960(ANSI)X
2186(code.)X
776 3700(Previously,)N
1203(no)X
1319(prototype)X
1685(was)X
1849(given)X
2073(when)X
7 f
2322(-ga)X
1 f
2509(was)X
2673(off.)X
2847(Now,)X
3067(prototypes)X
3467(are)X
3603(always)X
3876(gen-)X
576 3828(erated)N
839(\(with)X
1073(the)X
1229(appropriated)X
7 f
1753(#ifdef)X
1 f
2071('s\).)X
2255(These)X
2513(prototypes)X
2933(can)X
3103(con\257ict)X
3416(with)X
3621(the)X
3777(outside)X
576 3956(environment)N
1050(if)X
1132(the)X
1269(rule)X
1435(names)X
1689(are)X
1825(things)X
2070(like)X
7 f
2263(if)X
1 f
2398(and)X
7 f
2585(stat)X
1 f
2826(\(which)X
3099(is)X
3187(a)X
3255(system)X
3529(call\).)X
3759(Use)X
3924(the)X
7 f
576 4084(-gp)N
2 f
788(pre\256x)X
1 f
1010(option)X
1258(to)X
1349(pre\256x)X
1576(all)X
1687(functions)X
2037(corresponding)X
2562(to)X
2653(rules)X
2846(with)X
3025(a)X
3086(string)X
3309(of)X
3404(your)X
3587(choice.)X
3 f
576 4340(5.)N
686(Future)X
967(Work:)X
1 f
776 4496(Predicates)N
1175(are)X
1319(still)X
1490(under)X
1727(development.)X
2264(We)X
2424(expect)X
2692(an)X
2813(enhanced)X
3183(version)X
3480(of)X
3591(PCCTS)X
3899(that)X
576 4624(computes)N
936(context)X
1218(and)X
1367(hoists)X
1595(more)X
1798(aggressively.)X
776 4780(Often)N
1004(a)X
1071(grammar)X
1417(construct)X
1768(cannot)X
2031(be)X
2142(left)X
2288(factored)X
2604(to)X
2701(remove)X
2993(an)X
3104(ambiguity.)X
3536(This)X
3722(typically)X
576 4908(arises)N
805(in)X
903(the)X
1040(situation)X
1373(that)X
1534(the)X
1670(common)X
2007(pre\256x)X
2240(can)X
2390(be)X
2501(arbitrarily)X
2882(long.)X
3111(Fortunately,)X
3568(input)X
3778(is)X
3865(typi-)X
576 5036(cally)N
782(\256nite)X
998(and)X
1159(one)X
1320(could)X
1550(scan)X
1740(past)X
1916(these)X
2132(constructs)X
2524(given)X
2755(enough)X
3049(lookahead.)X
3490(This)X
3682(is)X
3776(not)X
3924(the)X
576 5164(same)N
782(thing)X
989(as)X
1087(backtracking)X
1567(as)X
1665(the)X
1798(parser)X
2037(never)X
2257(backs)X
2482(up;)X
2619(it)X
2693(simply)X
2958(looks)X
3173(ahead)X
3402(really)X
3627(far)X
3748(to)X
3841(make)X
576 5292(a)N
637(decision.)X
997(This)X
1176(can)X
1320(easily)X
1548(be)X
1653(handled)X
1954(with)X
2133(a)X
2194(predicate)X
2539(of)X
2634(the)X
2764(form:)X
7 f
9 s
576 5456 -0.1964(<
2 f
1522(context)X
7 f
1730(\)>>?)X
1 f
11 s
576 5660(which)N
816(would)X
1061(look)X
1243(ahead)X
1473(in)X
1567(the)X
1700(lookahead)X
2087(buffer)X
2326(to)X
2420(see)X
2558(if)X
2638(the)X
2 f
2772(context)X
1 f
3053(occurred)X
3386(within)X
3638(some)X
3850(\256nite)X
576 5788(number)N
875(of)X
978(tokens.)X
1282(This)X
1469(concept)X
1773(is)X
1862(very)X
2047(similar)X
2322(to)X
2420(LR-Regular)X
2870(\(LRR\))X
3129(parsers)X
3406(for)X
3537(those)X
3752(familiar)X
15 p
%%Page: 15 15
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(15)X
2370(-)X
576 704(with)N
766(parsing)X
1058(theory.)X
1360(Note)X
1564(that)X
1731(this)X
1893(is)X
1986(a)X
2059(very)X
2249(fast,)X
2432(cheap)X
2671(way)X
2851(to)X
2954(get)X
3096(something)X
3498(resembling)X
3924(the)X
576 832(power)N
817(of)X
912(backtracking.)X
776 988(Attribute)N
1131(names)X
1392(are)X
1535(expected)X
1884(to)X
1989(be)X
2108(enhanced.)X
2521(For)X
2680(example,)X
3038(instead)X
3325(of)X
3435($i,)X
3563($)X
2 f
(token_name)S
1 f
576 1116(could)N
794(be)X
899(used:)X
7 f
9 s
576 1280(a)N
662(:)X
748(WORD)X
963(TYPE)X
1178(<
1737(%s\\n",)X
2038($WORD,)X
2339($TYPE\);>>)X
662 1368(;)N
1 f
11 s
776 1572(We)N
920(expect)X
1172(to)X
1263(have)X
1451(a)X
1512(graphical)X
1862(user)X
2030(interface)X
2360(to)X
2451(PCCTS)X
2743(sometime)X
3109(in)X
3200(the)X
3331(future)X
3564(which)X
3802(allows)X
576 1700(entry)N
781(of)X
878(grammars)X
1254(using)X
1469(syntax)X
1723(diagram)X
2036(notation.)X
2394(The)X
2555(interface)X
2887(is)X
2970(expected)X
3307(to)X
3400(run)X
3541(under)X
3765(X)X
3851(Win-)X
576 1828(dows.)N
776 1984(We)N
940(anticipate)X
1327(a)X
1409(version)X
1711(that)X
1887(supports)X
2228(object-oriented)X
2805(programming)X
3328(and)X
3498(generates)X
3873(C++)X
576 2112(instead)N
858(of)X
963(ANSI)X
1199(C.)X
1334(For)X
1488(the)X
1627(moment,)X
1970(PCCTS)X
2271(is)X
2361(compatible)X
2785(with)X
2973(C++,)X
3185(but)X
3329(future)X
3570(versions)X
3894(will)X
576 2240(support)N
862(C++.)X
776 2396(Future)N
1067(versions,)X
1443(both)X
1661(C)X
1781(and)X
1970(C++,)X
2213(will)X
2413(be)X
2558(able)X
2767(to)X
2898(refer)X
3125(to)X
3256(PCCTS)X
3588(symbols)X
3944(by)X
7 f
576 2524(pccts.)N
2 f
894(symbol)X
1 f
1165(instead)X
1437(of)X
7 f
1563(zz)X
2 f
1669(symbol)X
1 f
1918(.)X
1984(E.g.)X
7 f
2179(zzskip\(\))X
1 f
2625(will)X
2785(become)X
7 f
3112(pccts.skip\(\))X
1 f
3748(.)X
776 2680(DLG)N
993(will)X
1168(soon)X
1371(use)X
1525(lookahead)X
1924(of)X
2034(its)X
2155(own)X
2343(to)X
2450(allow)X
2684(the)X
2830(recognition)X
3270(of)X
3381(more)X
3600(complicated)X
576 2808(expressions;)N
1039(speci\256cally,)X
1491(those)X
1705(which)X
1948(have)X
2142(left)X
2288(substrings)X
2673(in)X
2770(common)X
3106(with)X
3290(other)X
3498(regular)X
3774(expres-)X
576 2936(sions.)N
776 3092(We)N
932(expect)X
1196(future)X
1440(versions)X
1767(of)X
1874(PCCTS)X
2178(to)X
2281(dump)X
2516(grammar)X
2868(analysis)X
3186(and)X
3347(parser)X
3596(construction)X
576 3220(statistics)N
903(such)X
1086(as)X
1181(how)X
1354(many)X
1572(rules)X
1765(required)X
2080(1)X
2146(token)X
2364(of)X
2459(lookahead,)X
2865(how)X
3038(many)X
3256(ambiguities)X
3691(etc...)X
15 p
%%Trailer
xt
xs
14
11 s 0 xH 0pccts/UPDAT110.ps 644 1377 31 421545 5655551666 7010 %!PS-Adobe-1.0
%%Creator: garage.ecn.purdue.edu:pccts (Purdue Compiler-Construction Tool Set,,,,Ex;ee;hankd;)
%%Title: stdin (ditroff)
%%CreationDate: Mon Aug 30 14:57:01 1993
%%EndComments
% Start of psdit.pro -- prolog for ditroff translator
% Copyright (c) 1985,1987 Adobe Systems Incorporated. All Rights Reserved.
% GOVERNMENT END USERS: See Notice file in TranScript library directory
% -- probably /usr/lib/ps/Notice
% RCS: $Header: /home/aquarium/prm/usr/src/usr.lib/ps/lib/RCS/psdit.pro,v 1.2 89/02/24 09:57:06 prm Exp $
/$DITroff 180 dict def $DITroff begin
%% Psfig additions
/DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecap
currentlinejoin currentdash currentgray currentmiterlimit ] cvx def
/startFig {
/SavedState save def
userdict maxlength dict begin
currentpoint transform
DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap
setlinewidth setmatrix
itransform moveto
/ury exch def
/urx exch def
/lly exch def
/llx exch def
/y exch 72 mul resolution div def
/x exch 72 mul resolution div def
currentpoint /cy exch def /cx exch def
/sx x urx llx sub div def % scaling for x
/sy y ury lly sub div def % scaling for y
sx sy scale % scale by (sx,sy)
cx sx div llx sub
cy sy div ury sub translate
/DefFigCTM matrix currentmatrix def
/initmatrix {
DefFigCTM setmatrix
} def
/defaultmatrix {
DefFigCTM exch copy
} def
/initgraphics {
DocumentInitState setmiterlimit setgray setdash
setlinejoin setlinecap setlinewidth setmatrix
DefFigCTM setmatrix
} def
/showpage {
initgraphics
} def
} def
% Args are llx lly urx ury (in figure coordinates)
/clipFig {
currentpoint 6 2 roll
newpath 4 copy
4 2 roll moveto
6 -1 roll exch lineto
exch lineto
exch lineto
closepath clip
newpath
moveto
} def
% doclip, if called, will always be just after a `startfig'
/doclip { llx lly urx ury clipFig } def
/endFig {
end SavedState restore
} def
/globalstart {
% Push details about the enviornment on the stack.
fontnum fontsize fontslant fontheight firstpage
mh my resolution slotno currentpoint
pagesave restore gsave
} def
/globalend {
grestore moveto
/slotno exch def /resolution exch def /my exch def
/mh exch def /firstpage exch def /fontheight exch def
/fontslant exch def /fontsize exch def /fontnum exch def
F
/pagesave save def
} def
%% end XMOD additions
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def
/xi {0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F
/pagesave save def}def
/PB{save /psv exch def currentpoint translate
resolution 72 div dup neg scale 0 0 moveto}def
/PE{psv restore}def
/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def
/tan{dup sin exch cos div}bind def
/point{resolution 72 div mul}bind def
/dround {transform round exch round exch itransform}bind def
/xT{/devname exch def}def
/xr{/mh exch def /my exch def /resolution exch def}def
/xp{}def
/xs{docsave restore end}def
/xt{}def
/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not
{fonts slotno fontname findfont put fontnames slotno fontname put}if}def
/xH{/fontheight exch def F}bind def
/xS{/fontslant exch def F}bind def
/s{/fontsize exch def /fontheight fontsize def F}bind def
/f{/fontnum exch def F}bind def
/F{fontheight 0 le {/fontheight fontsize def}if
fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore
fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if
makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}bind def
/X{exch currentpoint exch pop moveto show}bind def
/N{3 1 roll moveto show}bind def
/Y{exch currentpoint pop exch moveto show}bind def
/S /show load def
/ditpush{}def/ditpop{}def
/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}bind def
/AN{4 2 roll moveto 0 exch ashow}bind def
/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}bind def
/AS{0 exch ashow}bind def
/MX{currentpoint exch pop moveto}bind def
/MY{currentpoint pop exch moveto}bind def
/MXY /moveto load def
/cb{pop}def % action on unknown char -- nothing for now
/n{}def/w{}def
/p{pop showpage pagesave restore /pagesave save def}def
/abspoint{currentpoint exch pop add exch currentpoint pop add exch}def
/dstroke{currentpoint stroke moveto}bind def
/Dl{2 copy 2 copy gsave 0 eq exch 0 eq and
{rlineto currentlinecap 1 setlinecap stroke setlinecap}
{rlineto stroke}
ifelse grestore rmoveto}bind def
/arcellipse{oldmat currentmatrix pop
currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def
rad 0 rad -180 180 arc oldmat setmatrix}def
/Dc{gsave dup /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/De{gsave /diamv exch def /diamh exch def arcellipse dstroke
grestore diamh 0 rmoveto}def
/Da{currentpoint /by exch def /bx exch def /fy exch def /fx exch def
/cy exch def /cx exch def /rad cx cx mul cy cy mul add sqrt def
/ang1 cy neg cx neg atan def /ang2 fy fx atan def cx bx add cy by add
2 copy rad ang1 ang2 arcn stroke exch fx add exch fy add moveto}def
/Barray 200 array def % 200 values in a wiggle
/D~{mark}def
/D~~{counttomark Barray exch 0 exch getinterval astore /Bcontrol exch def pop
/Blen Bcontrol length def Blen 4 ge Blen 2 mod 0 eq and
{Bcontrol 0 get Bcontrol 1 get abspoint /Ycont exch def /Xcont exch def
Bcontrol 0 2 copy get 2 mul put Bcontrol 1 2 copy get 2 mul put
Bcontrol Blen 2 sub 2 copy get 2 mul put
Bcontrol Blen 1 sub 2 copy get 2 mul put
/Ybi /Xbi currentpoint 3 1 roll def def 0 2 Blen 4 sub
{/i exch def
Bcontrol i get 3 div Bcontrol i 1 add get 3 div
Bcontrol i get 3 mul Bcontrol i 2 add get add 6 div
Bcontrol i 1 add get 3 mul Bcontrol i 3 add get add 6 div
/Xbi Xcont Bcontrol i 2 add get 2 div add def
/Ybi Ycont Bcontrol i 3 add get 2 div add def
/Xcont Xcont Bcontrol i 2 add get add def
/Ycont Ycont Bcontrol i 3 add get add def
Xbi currentpoint pop sub Ybi currentpoint exch pop sub rcurveto
}for dstroke}if}def
end
/ditstart{$DITroff begin
/nfonts 60 def % NFONTS makedev/ditroff dependent!
/fonts[nfonts{0}repeat]def
/fontnames[nfonts{()}repeat]def
/docsave save def
}def
% character outcalls
/oc {/pswid exch def /cc exch def /name exch def
/ditwid pswid fontsize mul resolution mul 72000 div def
/ditsiz fontsize resolution mul 72 div def
ocprocs name known{ocprocs name get exec}{name cb}
ifelse}def
/fractm [.65 0 0 .6 0 0] def
/fraction
{/fden exch def /fnum exch def gsave /cf currentfont def
cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto
fnum show rmoveto currentfont cf setfont(\244)show setfont fden show
grestore ditwid 0 rmoveto} def
/oce {grestore ditwid 0 rmoveto}def
/dm {ditsiz mul}def
/ocprocs 50 dict def ocprocs begin
(14){(1)(4)fraction}def
(12){(1)(2)fraction}def
(34){(3)(4)fraction}def
(13){(1)(3)fraction}def
(23){(2)(3)fraction}def
(18){(1)(8)fraction}def
(38){(3)(8)fraction}def
(58){(5)(8)fraction}def
(78){(7)(8)fraction}def
(sr){gsave .05 dm .16 dm rmoveto(\326)show oce}def
(is){gsave 0 .15 dm rmoveto(\362)show oce}def
(->){gsave 0 .02 dm rmoveto(\256)show oce}def
(<-){gsave 0 .02 dm rmoveto(\254)show oce}def
(==){gsave 0 .05 dm rmoveto(\272)show oce}def
end
% DIThacks fonts for some special chars
50 dict dup begin
/FontType 3 def
/FontName /DIThacks def
/FontMatrix [.001 0.0 0.0 .001 0.0 0.0] def
/FontBBox [-220 -280 900 900] def% a lie but ...
/Encoding 256 array def
0 1 255{Encoding exch /.notdef put}for
Encoding
dup 8#040/space put %space
dup 8#110/rc put %right ceil
dup 8#111/lt put %left top curl
dup 8#112/bv put %bold vert
dup 8#113/lk put %left mid curl
dup 8#114/lb put %left bot curl
dup 8#115/rt put %right top curl
dup 8#116/rk put %right mid curl
dup 8#117/rb put %right bot curl
dup 8#120/rf put %right floor
dup 8#121/lf put %left floor
dup 8#122/lc put %left ceil
dup 8#140/sq put %square
dup 8#141/bx put %box
dup 8#142/ci put %circle
dup 8#143/br put %box rule
dup 8#144/rn put %root extender
dup 8#145/vr put %vertical rule
dup 8#146/ob put %outline bullet
dup 8#147/bu put %bullet
dup 8#150/ru put %rule
dup 8#151/ul put %underline
pop
/DITfd 100 dict def
/BuildChar{0 begin
/cc exch def /fd exch def
/charname fd /Encoding get cc get def
/charwid fd /Metrics get charname get def
/charproc fd /CharProcs get charname get def
charwid 0 fd /FontBBox get aload pop setcachedevice
40 setlinewidth
newpath 0 0 moveto gsave charproc grestore
end}def
/BuildChar load 0 DITfd put
%/UniqueID 5 def
/CharProcs 50 dict def
CharProcs begin
/space{}def
/.notdef{}def
/ru{500 0 rls}def
/rn{0 750 moveto 500 0 rls}def
/vr{20 800 moveto 0 -770 rls}def
/bv{20 800 moveto 0 -1000 rls}def
/br{20 770 moveto 0 -1040 rls}def
/ul{0 -250 moveto 500 0 rls}def
/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def
/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def
/sq{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def
/bx{80 0 rmoveto currentpoint dround newpath moveto
640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def
/ci{355 333 rmoveto currentpoint newpath 333 0 360 arc
50 setlinewidth stroke}def
/lt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def
/lb{20 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def
/rt{20 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def
/rb{20 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def
/lk{20 800 moveto 20 300 -280 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/rk{20 800 moveto 20 300 320 300 s4 arcto pop pop 1000 sub
currentpoint stroke moveto
20 300 4 2 roll s4 a4p 20 -200 lineto stroke}def
/lf{20 800 moveto 0 -1000 rlineto s4 0 rls}def
/rf{20 800 moveto 0 -1000 rlineto s4 neg 0 rls}def
/lc{20 -200 moveto 0 1000 rlineto s4 0 rls}def
/rc{20 -200 moveto 0 1000 rlineto s4 neg 0 rls}def
end
/Metrics 50 dict def Metrics begin
/.notdef 0 def
/space 500 def
/ru 500 def
/br 0 def
/lt 250 def
/lb 250 def
/rt 250 def
/rb 250 def
/lk 250 def
/rk 250 def
/rc 250 def
/lc 250 def
/rf 250 def
/lf 250 def
/bv 250 def
/ob 350 def
/bu 350 def
/ci 750 def
/bx 750 def
/sq 750 def
/rn 500 def
/ul 500 def
/vr 0 def
end
DITfd begin
/s2 500 def /s4 250 def /s3 333 def
/a4p{arcto pop pop pop pop}def
/2cx{2 copy exch}def
/rls{rlineto stroke}def
/currx{currentpoint pop}def
/dround{transform round exch round exch itransform} def
end
end
/DIThacks exch definefont pop
ditstart
(psc)xT
576 1 1 xr
1(Times-Roman)xf 1 f
2(Times-Italic)xf 2 f
3(Times-Bold)xf 3 f
4(Times-BoldItalic)xf 4 f
5(Helvetica)xf 5 f
6(Helvetica-Bold)xf 6 f
7(Courier)xf 7 f
8(Courier-Bold)xf 8 f
9(Symbol)xf 9 f
10(DIThacks)xf 10 f
10 s
1 f
xi
%%EndProlog
%%Page: 1 1
10 s 0 xH 0 xS 1 f
15 s
1237 680(The)N
1453(Purdue)X
1823(Compiler)X
2308(Construction)X
2960(Tool)X
3217(Set)X
13 s
1726 784(Version)N
2082(1.10)X
2290(Release)X
2639(Notes)X
3 f
1909 992(ANTLR)N
1 f
2298(and)X
3 f
2474(DLG)X
2 f
11 s
2016 1200(August)N
2283(31,)X
2415(1993)X
2068 1408(Terence)N
2373(Parr)X
1 f
1345 1512(Army)N
1572(High)X
1770(Performance)X
2241(Computing)X
2661(Research)X
3005(Center,)X
1989 1616(University)N
2383(of)X
2478(MN)X
10 s
1965 1720(\()N
7 f
1992([email protected])X
1 f
(\))S
2 f
11 s
1817 1928(Will)N
1987(Cohen)X
2239(and)X
2393(Hank)X
2605(Dietz)X
1 f
1727 2032(School)N
1994(of)X
2089(Electrical)X
2450(Engineering)X
1982 2136(Purdue)N
2253(University)X
10 s
1773 2240(\()N
7 f
1800([email protected])X
1 f
(\))S
1797 2344(\()N
7 f
1824([email protected])X
1 f
(\))S
3 f
11 s
576 2656(1.)N
686(Introduction)X
1 f
776 2816(This)N
958(document)X
1331(describes)X
1683(the)X
1816(changes/enhancements)X
2648(in)X
2742(PCCTS)X
3037(since)X
3243(version)X
3528(1.06.)X
3752(As)X
3875(with)X
576 2920(the)N
725(1.06)X
920(release)X
1205(notes,)X
1454(these)X
1676(notes)X
1903(do)X
2032(not)X
2186(constitute)X
2571(the)X
2720(complete)X
3084(reference)X
3450(manual.)X
3794(Unfor-)X
576 3024(tunately,)N
906(the)X
1037(reference)X
1386(manual)X
1669(is)X
1751(in)X
1843(the)X
1974(same)X
2179(condition)X
2537(as)X
2634(it)X
2708(was)X
2868(for)X
2994(the)X
3126(1.00)X
3304(release)X
3572(in)X
3665(the)X
3797(Spring)X
576 3128(of)N
673(1992.)X
917(We)X
1063(are)X
1194(working)X
1511(on)X
1623(a)X
1686(total)X
1868(rewrite)X
2141(of)X
2238(the)X
2370(manual,)X
2676(which)X
2914(might)X
3144(end)X
3294(up)X
3405(in)X
3497(a)X
3559(book)X
3758(consist-)X
576 3232(ing)N
730(of)X
844(the)X
993(theory)X
1259(behind)X
1540(practical)X
2 f
10 s
1883(k)X
1 f
11 s
1919(-token)X
2185(lookahead)X
2588(for)X
2 f
10 s
2729(k)X
2778(>)X
1 f
(1)S
11 s
2913(\(Terence)X
3266(Parr's)X
3516(Ph.D.)X
3780(thesis\),)X
576 3336(ANTLR)N
891 0.2885(implementation)AX
1469(notes,)X
1699(and)X
1848(the)X
1978(PCCTS)X
2270(user's)X
2501(manual.)X
776 3468(The)N
955(1.10)X
1151(release)X
1438(of)X
1554(PCCTS)X
1867(has)X
2027(four)X
2216(main)X
2436(enhancements:)X
3003(fully)X
3213(implemented)X
3718(semantic)X
576 3572(predicates)N
966(\()X
7 f
995(<<...>>?)X
1 f
1419(\),)X
1503(in\256nite)X
1787(lookahead)X
2182(\(plus)X
2391(selective)X
2732(backtracking)X
3219(that)X
3384(uses)X
3567(it\),)X
3700(increased)X
576 3676(ANTLR)N
891(\(see)X
7 f
1085(-ck)X
1 f
1266(and)X
7 f
1446(ZZUSE_MACROS)X
1 f
2104(sections\))X
2439(and)X
2588(DLG)X
2790(speed,)X
3034(and)X
3183(the)X
3313(ability)X
3562(to)X
3654(link)X
3815(multi-)X
576 3780(ple)N
709(ANTLR)X
1027(parsers)X
1300(together.)X
1658(A)X
1746(number)X
2040(of)X
2138(bug)X
2294(\256xes)X
2484(have)X
2674(been)X
2864(incorporated)X
3333(as)X
3430(well.)X
3650(The)X
3811(tutori-)X
576 3884(als)N
696(have)X
884(not)X
1019(been)X
1207(updated)X
1508(much)X
1726(for)X
1850(this)X
2000(release.)X
776 4016(To)N
897(better)X
1121(support)X
1408(our)X
1548(user's,)X
1803(we)X
1929(have)X
2119(established)X
2535(a)X
2598(mailing)X
2893(list)X
3026(called)X
7 f
3292(pccts-users)X
1 f
3899(that)X
576 4120(you)N
739(can)X
892(subscribe)X
1255(to)X
1354(by)X
1472(sending)X
1776(email)X
2003(to)X
7 f
2133 0.1937([email protected])AX
1 f
3806(with)X
3993(a)X
576 4224(body)N
798(of)X
917(``)X
7 f
975(subscribe)X
1529(pccts-users)X
2 f
2158(your-name)X
1 f
2538(''.)X
2687(Users)X
2933(that)X
3113(have)X
3326(registered)X
3720(with)X
3924(the)X
576 4328(PCCTS)N
883(mail)X
1077(server)X
1327(at)X
7 f
1458 0.1974([email protected]due.edu)AX
1 f
2554(have)X
3 f
2756(not)X
1 f
2914(been)X
3116 0.2604(automatically)AX
3634(subscribed.)X
576 4432(Once)N
788(you)X
947(have)X
1140(subscribed,)X
1565(posting)X
1852(a)X
1918(message)X
2243(to)X
2340(the)X
2476(PCCTS)X
2774(community)X
3205(is)X
3292(as)X
3393(simple)X
3657(as)X
3758(sending)X
576 4536(email)N
810(to)X
7 f
947 0.1950([email protected])AX
1 f
2362(\(with)X
2585(any)X
2749(Subject:)X
3097(and)X
3260(body\).)X
3545(You)X
3732(can)X
3890(also)X
576 4640(send)N
760(a)X
822(body)X
1021(of)X
7 f
1148(help)X
1 f
1383(to)X
7 f
1506 0.1932([email protected])AX
1 f
3331(to)X
3423(get)X
3554(help)X
3729(on)X
3841(using)X
576 4744(the)N
706(mailing)X
999(list)X
1130(server.)X
776 4876(We)N
927(have)X
1122(\256nally)X
1377(agreed)X
1641(on)X
1759(a)X
1828(numbering)X
2240(scheme)X
2534(for)X
2666(PCCTS)X
2966(releases:)X
2 f
10 s
3317(x.yz)X
1 f
11 s
3470(where)X
2 f
10 s
3712(x)X
1 f
11 s
3778(re\257ects)X
576 4980(the)N
724(major)X
970(release)X
1254(number)X
1563(\(new)X
1778(tool)X
1956(additions\),)X
2 f
10 s
2369(y)X
1 f
11 s
2445(re\257ects)X
2739(major)X
2984(new)X
3169(feature)X
3452(additions,)X
3837(and)X
2 f
10 s
4001(z)X
1 f
11 s
576 5084(re\257ects)N
852(bug)X
1006(\256xes)X
1194(and)X
1343(minor)X
1576(feature)X
1842(additions)X
2188(\(minor)X
2450(releases\).)X
9 s
10 f
576 5480(hhhhhhhhhhhhhhhh)N
1 f
576 5568(Partial)N
783(support)X
1018(for)X
1121(this)X
1244(work)X
1412(has)X
1528(come)X
1704(from)X
1864(the)X
1972(Army)X
2160(Research)X
2444(Of\256ce)X
2644(contract)X
2896(number)X
3136(DAAL03-89-C-0038)X
576 5656(with)N
722(the)X
828(Army)X
1014(High)X
1176(Performance)X
1562(Computing)X
1904(Research)X
2186(Center)X
2396(at)X
2466(the)X
2572(U)X
2642(of)X
2720(MN.)X
2 p
%%Page: 2 2
9 s 0 xH 0 xS 1 f
11 s
2231 416(-)N
2282(2)X
2348(-)X
3 f
576 704(2.)N
686(Semantic)X
1055(Predicates)X
1 f
776 860(The)N
938(fundamental)X
1404(idea)X
1576(behind)X
1841(semantic)X
2180(predicates)X
2562(has)X
2704(not)X
2842(changed)X
3160(since)X
3366(the)X
3499(1.06)X
3678(release)X
3944(\320)X
576 988(semantic)N
917(predicates)X
1301(indicate)X
1608(the)X
1743(semantic)X
2083(validity)X
2380(of)X
2479(continuing)X
2883(with)X
3066(the)X
3200(parse)X
3411(or)X
3510(of)X
3609(predicting)X
3993(a)X
576 1116(particular)N
941(production.)X
1394(However,)X
1764(we)X
1893(now)X
2071(collect)X
3 f
2334(all)X
1 f
2455(predicates)X
2839(visible)X
3102(to)X
3198(a)X
3264(syntactically)X
3738(ambigu-)X
576 1244(ous)N
724(parsing)X
1008(decision)X
1327(rather)X
1557(than)X
1734(just)X
1887(the)X
2020(\256rst)X
2182(one)X
2334(encountered)X
2789(as)X
2887(in)X
2981(1.06.)X
3204(In)X
3302(addition,)X
3639(the)X
3772(context)X
576 1372(of)N
677(the)X
813(predicate)X
1164(can)X
1314(be)X
1425(computed)X
1801(and)X
1956(hoisted)X
2239(with)X
2425(the)X
2562(predicates;)X
2973(helpful)X
3252(warning)X
3569(are)X
3705(also)X
3876(gen-)X
576 1500(erated)N
815(for)X
941(incompletely)X
1427(disambiguated)X
1966(parser)X
2204(decisions.)X
2600(The)X
2761(only)X
2942(backward)X
3306 0.2891(incompatibilities)AX
3925(are)X
576 1628(that)N
739(parsing)X
1028(does)X
1219(not)X
1362(halt)X
1525 0.2604(automatically)AX
2037(if)X
2121(a)X
2190(semantic)X
2534(validation)X
2918(predicate)X
3272(fails)X
3455(and)X
3613(the)X
7 f
3783(-pr)X
1 f
3973(is)X
576 1756(obsolete)N
892(\320)X
1003(the)X
1134(speci\256cation)X
1603(of)X
1699(a)X
1761(predicate)X
2107(implies)X
2391(that)X
2547(it)X
2620(may)X
2795(be)X
2901(used)X
3085(by)X
3196(ANTLR)X
3512(to)X
3603(validate)X
3905(and)X
576 1884(disambiguate)N
1069(as)X
1164(it)X
1236(sees)X
1404(\256t.)X
1544(In)X
1639(this)X
1789(section)X
2061(we)X
2185(discuss)X
2461(all)X
2572(of)X
2667(these)X
2870(issues.)X
3 f
576 2140(2.1.)N
752(Visible)X
1034(Semantic)X
1403(Predicates)X
1 f
776 2296(Given)N
1021(a)X
1091(syntactically)X
1569(ambiguous)X
1987(parser)X
2232(decision)X
2557(\(or,)X
2712(more)X
2924(accurately,)X
3339(a)X
3409(non-deterministic)X
576 2424(decision\),)N
947(ANTLR)X
1266(attempts)X
1592(to)X
1686(resolve)X
1965(it)X
2040(with)X
2222(semantic)X
2561(information)X
3000(\320)X
3113(ANTLR)X
3431(searches)X
3753(for)X
2 f
3880(visi-)X
576 2552(ble)N
1 f
713(predicates.)X
1143(A)X
1235(visible)X
1500(predicate)X
1852(is)X
1940(a)X
2009(semantic)X
2353(predicate)X
2706(that)X
2869(could)X
3095(be)X
3208(evaluated)X
3576(without)X
3876(con-)X
576 2680(suming)N
867(an)X
981(input)X
1194(token)X
1421(or)X
1525(executing)X
1898(a)X
1967(user)X
2143(action)X
2389(\(except)X
2678 0.3317(initialization)AX
3157(actions,)X
3459(which)X
3704(generally)X
576 2808(de\256ne)N
818(variables\).)X
1236(All)X
1376(visible)X
1639(predicates)X
2023(reside)X
2260(on)X
2375(the)X
2510(left)X
2655(edge)X
2848(of)X
2949(productions;)X
3418(predicates)X
3803(not)X
3944(on)X
576 2936(the)N
710(left)X
854(edge)X
1046(can)X
1194(only)X
1377(function)X
1697(as)X
2 f
1796(validation)X
1 f
2181(predicates)X
2564(\(see)X
2731(1.06)X
2911(release)X
3181(notes\).)X
3466(Consider)X
3810(a)X
3875(sim-)X
576 3064(ple)N
706(example:)X
7 f
9 s
576 3228(a)N
776(:)X
976(<<)X
2 f
10 s
1062(pred)X
1 f
7 s
1218 3244(1)N
7 f
9 s
1252 3228(>>?)N
1467(ID)X
10 s
9 f
1596(a)X
9 s
776 3316(|)N
7 f
976(<<)X
2 f
10 s
1062(pred)X
1 f
7 s
1218 3332(2)N
7 f
9 s
1252 3316(>>?)N
1467(ID)X
10 s
9 f
1596(b)X
9 s
7 f
776 3404(;)N
1 f
11 s
576 3608(Assuming)N
965(that)X
1130(lookahead)X
1524(information)X
1973(is)X
2065(insuf\256cient)X
2495(to)X
2597(predict)X
2875(productions)X
3324(of)X
3430(rule)X
7 f
3631(a)X
1 f
3684(,)X
3739(ANTLR)X
576 3736(would)N
823(incorporate)X
2 f
10 s
1249(pred)X
1 f
7 s
1405 3752(1)N
11 s
1466 3736(into)N
1631(the)X
1766(prediction)X
2151(expression)X
2554(for)X
2683(the)X
2818(\256rst)X
2982(production)X
3391(and)X
2 f
10 s
3543(pred)X
1 f
7 s
3699 3752(2)N
11 s
3760 3736(into)N
3924(the)X
576 3864(second)N
843(prediction)X
1224(expression.)X
1667(Multiple)X
1995(predicates)X
2375(can)X
2520(be)X
2626(hoisted)X
2904(\(which)X
3171(may)X
3346(or)X
3442(may)X
3617(not)X
3754(be)X
3861(what)X
576 3992(you)N
730(want\):)X
7 f
9 s
576 4156(decl:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 4172(1)N
7 f
9 s
1212 4156(>>?)N
1384(var)X
9 f
756 4244(|)N
7 f
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 4260(2)N
7 f
9 s
1212 4244(>>?)N
1384(ID)X
756 4332(;)N
576 4420(var)N
756(:)X
936 -0.1964(<>?)AX
1925(ID)X
756 4508(;)N
1 f
11 s
576 4712(In)N
681(this)X
841(case,)X
1046(the)X
1186(prediction)X
1576(expression)X
1984(for)X
2118(production)X
2532(one)X
2691(of)X
2796(rule)X
7 f
2997(decl)X
1 f
3242(would)X
3495(resemble)X
3846(\(with)X
576 4840(context)N
858(computation)X
1322(turned)X
1569(off)X
1693(\320)X
1803(see)X
1937(below\):)X
7 f
9 s
576 5004(if)N
705(\()X
2 f
10 s
791(pred)X
1 f
7 s
947 5020(1)N
7 f
9 s
1024 5004(&&)N
1153 -0.1992(is_var\(LATEXT\(1\)\))AX
1927(&&)X
2056(LA\(1\)==ID)X
2486(\))X
2572({)X
756 5092(var\(\);)N
576 5180(})N
619 5268(...)N
1 f
11 s
576 5472(Here,)N
795(two)X
954(visible)X
1217(predicates)X
1601(were)X
1798(found)X
2030(to)X
2126(disambiguate)X
2625(the)X
2761(prediction)X
3147(of)X
3248(the)X
3384(\256rst)X
3549(production)X
3959(of)X
576 5600(rule)N
7 f
766(decl)X
1 f
1000(whereas)X
1309(only)X
1488(one)X
1637(was)X
1795(found)X
2022(for)X
2146(the)X
2276(prediction)X
2656(of)X
2751(the)X
2881(second)X
3147(production.)X
3 p
%%Page: 3 3
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(3)X
2348(-)X
776 704(The)N
938(action)X
1179(of)X
1277(evaluating)X
1670(a)X
1734(predicate)X
2082(in)X
2176(a)X
2241(decision)X
2561(is)X
2646(called)X
2 f
2883(hoisting)X
1 f
3168(.)X
3238(In)X
3337(the)X
3471(\256rst)X
3634(example)X
3959(of)X
576 832(this)N
739(section,)X
1046(predicates)X
1438(were)X
1643(not)X
1791(moved)X
2066(since)X
2282(they)X
2469(reside)X
2714(at)X
2813(the)X
2956(decision)X
3285(point)X
3502(in)X
3606(rule)X
7 f
3809(a)X
1 f
3862(,)X
3919(but)X
576 960(technically)N
996(we)X
1130(say)X
1279(that)X
1444(they)X
1628(were)X
1830(hoisted)X
2117(into)X
2287(the)X
2427(decision.)X
2797(In)X
2903(the)X
3044(second)X
3321(example,)X
2 f
10 s
3673(pred)X
1 f
7 s
3829 976(1)N
11 s
3896 960(was)N
576 1088(hoisted)N
866(from)X
7 f
1103(decl)X
1 f
1350(and)X
7 f
1543 0.1992(is_var\(LATEXT\(1\)\))AX
1 f
2479(was)X
2650(hoisted)X
2940(from)X
3146(rule)X
7 f
3349(var)X
1 f
3542(to)X
3645(predict)X
3924(the)X
576 1216(\256rst)N
735(production)X
1139(of)X
7 f
1265(decl)X
1 f
1477(.)X
3 f
576 1472(2.2.)N
752(Context)X
1071(of)X
1166(Semantic)X
1535(Predicates)X
1 f
776 1628(In)N
875(release)X
1145(1.06,)X
1347(predicates)X
1730(were)X
1927(hoisted)X
2209(without)X
2506(computing)X
2911(and)X
3065(hoisting)X
3377(the)X
3512(context)X
3799(of)X
3899(that)X
576 1756(predicate.)N
989(Context)X
1314(is)X
1418(important)X
1807(because,)X
2152(as)X
2270(we)X
2417(saw)X
2598(in)X
2712(the)X
2865(last)X
3033(section,)X
3350(predicates)X
3752(may)X
3949(be)X
576 1884(evaluated)N
940(in)X
1035(totally)X
1288(different)X
1617(rules.)X
1858(Imagine)X
2173(a)X
2238(rule)X
2401(that)X
2560(had)X
2713(many)X
2935(alternative)X
3335(productions,)X
3800(two)X
3959(of)X
576 2012(which)N
813(were)X
1005(syntactically)X
1474(nondeterministic)X
2090(because)X
2390(of)X
2485(a)X
2546(common)X
2877(lookahead)X
3261(of)X
7 f
3387(ID)X
1 f
3515(\(assuming)X
3899(that)X
576 2140(only)N
755(one)X
904(symbol)X
1186(of)X
1281(lookahead)X
1665(is)X
1746(available)X
2087(for)X
2211(simplicity\).)X
7 f
9 s
576 2304(a)N
756(:)X
936(A)X
1022(...)X
9 f
756 2392(|)N
7 f
936(B)X
1022(...)X
9 f
756 2480(|)N
7 f
936(classname)X
9 f
756 2568(|)N
7 f
936(C)X
1022(...)X
9 f
756 2656(|)N
7 f
936(varname)X
9 f
756 2744(|)N
7 f
936(D)X
1022(...)X
756 2832(;)N
576 2920(classname)N
756 3008(:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 3024(1)N
7 f
9 s
1212 3008(>>?)N
1384(ID)X
756 3096(;)N
576 3184(varname)N
756 3272(:)N
936(<<)X
2 f
10 s
1022(pred)X
1 f
7 s
1178 3288(2)N
7 f
9 s
1212 3272(>>?)N
1384(ID)X
756 3360(;)N
1 f
11 s
576 3564(Simply)N
863(incorporating)X
2 f
10 s
1367(pred)X
7 s
1514 3580(i)N
1 f
11 s
1568 3564(into)N
1738(the)X
1878(production)X
2292(prediction)X
2682(expressions)X
3124(for)X
3258(alternatives)X
3697(three)X
3905(and)X
576 3692(\256ve)N
730(is)X
811(not)X
946(safe)X
1109(for)X
1233(two)X
1387(reasons:)X
576 3848([1])N
776(Evaluation)X
1185(of)X
2 f
10 s
1282(pred)X
7 s
1429 3864(i)N
1 f
11 s
1477 3848(may)N
1655(cause)X
1876(a)X
1941(program)X
2266(execution)X
2636(error)X
2833(if)X
2914(evaluated)X
3279(on)X
3394(the)X
3529(wrong)X
3780(type)X
3959(of)X
776 3976(data.)N
2 f
10 s
989(pred)X
7 s
1136 3992(i)N
1 f
11 s
1182 3976(will)N
1344(be)X
1451(evaluated)X
1813(on)X
1925(any)X
2076(input,)X
2304(which)X
2543(is)X
7 f
2657({A,)X
2871(B,)X
3032(C,)X
3193(D,)X
3354(ID})X
1 f
3537(in)X
3630(our)X
3771(case)X
3944(\320)X
2 f
10 s
776 4104(pred)N
7 s
923 4120(i)N
1 f
11 s
967 4104(may)N
1141(``core'')X
1430(if)X
1506(fed)X
1640(non-)X
7 f
1801(ID)X
1 f
1929(token)X
2147(types.)X
576 4260([2])N
2 f
10 s
776(pred)X
7 s
923 4276(i)N
1 f
11 s
974 4260(may)N
1156(give)X
1338(misleading)X
1756(results)X
2016(even)X
2212(if)X
2296(it)X
2376(does)X
2567(not)X
2710(``core''.)X
2 f
10 s
3049(pred)X
7 s
3196 4276(i)N
1 f
11 s
3248 4260(may)N
3430(return)X
3670(false)X
3866(even)X
776 4388(though)N
1043(the)X
1173(production)X
1577(is)X
1658(not)X
1793(dependent)X
2177(on)X
2287(the)X
2417(predicate)X
2762(for)X
2886(that)X
3041(token)X
3259(type.)X
3477(For)X
3621(example:)X
7 f
9 s
776 4552(a)N
948(:)X
1120(\(var)X
9 f
1335(|)X
7 f
1392(NUM\))X
1607(...)X
9 f
948 4640(|)N
7 f
1091 -0.1960(<>?)AX
2166(ID)X
2295(...)X
948 4728(;)N
776 4816(var)N
948(:)X
1120 -0.1964(<>?)AX
2195(ID)X
948 4904(;)N
1 f
11 s
776 5108(The)N
958(\256rst)X
1141(production)X
1569(will)X
3 f
1753(never)X
1 f
2009(match)X
2271(a)X
7 f
2387(NUM)X
1 f
2592(because)X
7 f
2947 0.1992(is_var\(LATEXT\(1\)\))AX
1 f
3894(will)X
776 5236(always)N
1046(evaluate)X
1366(to)X
1461(false)X
1653(for)X
1781(that)X
1939(token)X
2160(type)X
2337(since)X
2543(numbers)X
2871(are)X
3003(not)X
3141(variables)X
3484(ever)X
3660(\(the)X
3822(predi-)X
776 5364(cate)N
940(in)X
7 f
1062(var)X
1 f
1243(is)X
1324(hoisted)X
1601(for)X
1725(use)X
1864(in)X
1955(the)X
2085(decision)X
2401(for)X
2525(rule)X
7 f
2715(a)X
1 f
2768(\).)X
576 5520(The)N
735(way)X
903(to)X
994(solve)X
1202(both)X
1381(problems)X
1731(is)X
1812(to)X
1903(change)X
2 f
10 s
2172(pred)X
7 s
2319 5536(i)N
1 f
11 s
2363 5520(to:)N
7 f
9 s
576 5684(LA\(1\)==ID)N
1006(?)X
2 f
10 s
1092(pred)X
7 s
1239 5700(i)N
7 f
9 s
1304 5684(:)N
1390(1)X
4 p
%%Page: 4 4
9 s 0 xH 0 xS 7 f
11 s
1 f
2231 416(-)N
2282(4)X
2348(-)X
576 704(The)N
7 f
767(1)X
1 f
843(merely)X
1111(indicates)X
1448(that)X
1604(if)X
1682(the)X
1814(lookahead)X
2200(is)X
2283(not)X
2420(an)X
7 f
2558(ID)X
1 f
2688(then)X
2864(enable)X
3118(the)X
3250(production)X
3656(for)X
3782(normal)X
576 832(parsing)N
857(\320)X
972(we)X
1101(have)X
1293(no)X
1407(semantic)X
1747(information)X
2190(that)X
2349(establishes)X
2757(the)X
2891(validity)X
3188(or)X
3287(invalidity)X
3653(of)X
3752(the)X
3886(pro-)X
576 960(duction.)N
776 1116(Context)N
1081(computation)X
1548(similar)X
1819(to)X
1913(this)X
2067(is)X
2152(can)X
2300(now)X
2477(be)X
2586(done)X
2783 0.2604(automatically)AX
3291(\()X
7 f
3320(-prc)X
3589(on)X
1 f
3695(\).)X
3794(Unfor-)X
576 1244(tunately,)N
914(as)X
1018(mentioned)X
1422(previously)X
1825(in)X
1925(this)X
2084(document,)X
2485(computing)X
2894(full)X
2 f
10 s
3046(LL)X
1 f
3147(\()X
2 f
3174(k)X
1 f
3216(\))X
11 s
3274(lookahead)X
3666(is,)X
3777(in)X
3876(gen-)X
576 1372(eral,)N
766(an)X
886(exponential)X
1335(problem;)X
1691(hence,)X
1955(for)X
2094(large)X
2307(grammars)X
2696(you)X
2865(may)X
3054(want)X
3262(to)X
3368(keep)X
3571(this)X
3736(off)X
3875(with)X
7 f
576 1500(-prc)N
842(off)X
1 f
1024(\(default\))X
1350(and)X
1500(include)X
1783(context)X
2066(tests)X
2246(manually)X
2598(in)X
2690(your)X
2874(predicates.)X
3298(The)X
3458(old)X
7 f
3625(-pr)X
1 f
3806(option)X
576 1628(to)N
669(turn)X
835(on)X
947(parsing)X
1230(with)X
1412(predicates)X
1794(is)X
1878(now)X
2054(ignored)X
2348(as)X
2446(the)X
2579(speci\256cation)X
3050(of)X
3148(a)X
3212(predicate)X
3560(indicates)X
3899(that)X
576 1756(it)N
648(should)X
905(be)X
1010(used.)X
776 1912(ANTLR)N
1097(does)X
1286(its)X
1398(best)X
1568(to)X
1665(warn)X
1868(the)X
2004(user)X
2178(when)X
2396(a)X
2464(possibly)X
2787(incompletely)X
3278(disambiguated)X
3822(gram-)X
576 2040(mar)N
736(has)X
876(been)X
1065(speci\256ed.)X
1445(In)X
1541(other)X
1745(words,)X
2004(when)X
2217(a)X
2279(syntactically)X
2749(ambiguous)X
3158(decision)X
3474(is)X
3555(resolved)X
3875(with)X
576 2168(semantic)N
918(predicates,)X
1325(all)X
1442(mutually)X
1785(ambiguous)X
2200(productions)X
2644(must)X
2844(have)X
3039(at)X
3132(least)X
3323(one)X
3479(semantic)X
3822(predi-)X
576 2296(cate)N
740(associated)X
1124(with)X
1303(it.)X
1419(For)X
1563(example:)X
7 f
9 s
576 2460(a)N
748(:)X
920(<<)X
2 f
10 s
1006(pred)X
7 f
9 s
1153(>>?)X
1368(ID)X
1497(...)X
9 f
748 2548(|)N
7 f
891(ID)X
1020(...)X
748 2636(;)N
1 f
11 s
576 2840(This)N
763(grammar)X
1111(will)X
1279(yield)X
1486(a)X
1555(warning)X
1873(when)X
2094(run)X
2242(through)X
2547(ANTLR)X
2871(with)X
7 f
3090(-w2)X
1 f
3280(set)X
3409(because)X
3718(semantic)X
576 2968(information)N
1015(was)X
1173(not)X
1308(provided)X
1643(to)X
1734(indicate)X
2036(the)X
2166(validity)X
2459(of)X
2554(the)X
2684(second)X
2950(production:)X
7 f
8 s
576 3132(t.g,)N
766(line)X
956(1:)X
1070(warning:)X
1412(alt)X
1564(2)X
1640(of)X
1754(the)X
1906(rule)X
2096(itself)X
2362(has)X
2514(no)X
2628 -0.4219(predicate)AX
3008(to)X
3122(resolve)X
3426 -0.4219(ambiguity)AX
1 f
11 s
576 3336(However,)N
960(rule)X
7 f
1169(a)X
1 f
1264(will)X
1444(behave)X
1735(correctly)X
2090(because)X
2410(if)X
2 f
10 s
2504(pred)X
1 f
11 s
2693(fails,)X
2909(the)X
3059(second)X
3345(production)X
3769(will)X
3949(be)X
576 3464(attempted)N
969(as)X
1086(the)X
1238(default)X
1527(case)X
1722(\(remember)X
2151(that)X
2327(a)X
2409(missing)X
2727(semantic)X
3084(predicate)X
3450(is)X
3552(equivalent)X
3963(to)X
7 f
576 3592(<<1>>?)N
1 f
894(\).)X
992(Adding)X
1281(a)X
1345(third)X
1537(production)X
1944(that)X
2102(began)X
2337(with)X
7 f
2550(ID)X
1 f
2681(would)X
2926(not)X
3064(behave)X
3338(correctly)X
3676(as)X
3775(the)X
3909(last)X
7 f
576 3720(ID)N
1 f
682(-pre\256xed)X
1021(production)X
1425(would)X
1667(never)X
1884(be)X
1989(matched.)X
776 3876(As)N
906(a)X
978(more)X
1192(complicated)X
1657(example,)X
2011(consider)X
2342(the)X
2483(following)X
2859(incorrectly)X
3274(disambiguated)X
3822(gram-)X
576 4004(mar:)N
7 f
9 s
576 4168(a)N
748(:)X
920(b)X
9 f
748 4256(|)N
7 f
891(<<)X
2 f
10 s
977(pred)X
1 f
7 s
1133 4272(1)N
7 f
9 s
1167 4256(>>?)N
1339(ID)X
9 f
748 4344(|)N
7 f
891(<<)X
2 f
10 s
977(pred)X
1 f
7 s
1133 4360(2)N
7 f
9 s
1167 4344(>>?)N
1339(NUM)X
748 4432(;)N
576 4608(b)N
748(:)X
920(<<)X
2 f
10 s
1006(pred)X
1 f
7 s
1162 4624(3)N
7 f
9 s
1196 4608(>>?)N
1368(ID)X
9 f
748 4696(|)N
7 f
891(NUM)X
748 4784(;)N
1 f
11 s
576 4988(Rule)N
7 f
801(a)X
1 f
881(cannot)X
1143(predict)X
1415(which)X
1657(production)X
2066(to)X
2163(match)X
2407(upon)X
2611(lookahead)X
7 f
3032(ID)X
1 f
3166(or)X
7 f
3298(NUM)X
1 f
3457(.)X
3529(Alternatives)X
3988(2)X
576 5116(and)N
737(3)X
815(have)X
1015(been)X
1215(disambiguated,)X
1786(but)X
1933(the)X
2075(\256rst)X
2246(production)X
2662(hoists)X
2902(a)X
2975(predicate)X
3331(that)X
3497(only)X
3687(``covers'')X
7 f
576 5244(ID)N
1 f
682('s.)X
811(As)X
930(a)X
991(result,)X
1231(the)X
1361(following)X
1726(message)X
2046(is)X
2127(generated)X
2491(by)X
2601(ANTLR:)X
7 f
8 s
576 5408(t.g,)N
766(line)X
956(1:)X
1070(warning:)X
1412(alt)X
1564(1)X
1640(of)X
1754(the)X
1906(rule)X
2096(itself)X
2362(has)X
2514(no)X
2628 -0.4219(predicate)AX
3008(to)X
3122(resolve)X
3426 -0.4219(ambiguity)AX
3806(upon)X
3996({)X
4072(NUM)X
4224(})X
1 f
11 s
576 5612(This)N
755(detection)X
1101(is)X
1182(a)X
1243(great)X
1441(help)X
1615(during)X
1867(grammar)X
2207(development.)X
5 p
%%Page: 5 5
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(5)X
2348(-)X
776 704(Ambiguity)N
1187(warnings)X
1537(are)X
1672(now)X
1851(turned)X
2104(off)X
2234(for)X
2365(decisions)X
2722(that)X
2884(have)X
3079(semantic)X
3422(predicates)X
3808(cover-)X
576 832(ing)N
711(all)X
822(ambiguous)X
1231(lookahead)X
1615(sequences.)X
3 f
576 1088(2.3.)N
752(Failure)X
1049(of)X
1144(predicates)X
1 f
776 1244(Predicates)N
1162(that)X
1319(are)X
1450(not)X
1588(used)X
1774(in)X
1868(disambiguating)X
2438(parsing)X
2722(decisions)X
3075(are)X
3207(called)X
3443(validation)X
3822(predi-)X
576 1372(cates.)N
824(Previously,)X
1251(validation)X
1633(predicates)X
2017(that)X
2177(failed)X
2405(during)X
2662(parsing)X
2948(printed)X
3225(out)X
3365(a)X
3431(message)X
3756(and)X
3910(ter-)X
576 1500(minated)N
883(the)X
1013(parser:)X
7 f
9 s
576 1664(if)N
705(\()X
791(!)X
2 f
10 s
834(pred)X
7 f
9 s
1024(\))X
1110({fprintf\(stderr,)X
1841("failed)X
2185(predicate:)X
2658('pred'\\n\);)X
3131(exit\(1\);})X
1 f
11 s
576 1868(The)N
758(latest)X
990(release)X
1279(of)X
1397(ANTLR)X
1735(generates)X
2112(a)X
2197(call)X
2371(to)X
2486(a)X
2571(macro)X
2837(that)X
3016(the)X
3170(user)X
3362(may)X
3560(de\256ne)X
3821(called)X
7 f
576 1996(zzfailed_pred\(\))N
1 f
1371(,)X
1415(which)X
1652(is)X
1733(passed)X
1989(a)X
2050(string)X
2273(representing)X
2730(the)X
2860(predicate)X
3205(that)X
3360(failed:)X
7 f
9 s
576 2160(if)N
705(\()X
791(!)X
2 f
10 s
834(pred)X
7 f
9 s
1024(\))X
1110 -0.1957({zzfailed_pred\("pred"\);})AX
1 f
11 s
576 2364(while)N
794(this)X
944(solution)X
1251(is)X
1332(not)X
1467(ideal,)X
1683(it)X
1755(is)X
1836(much)X
2054(better)X
2277(than)X
2451(before.)X
3 f
576 2620(3.)N
686(In\256nite)X
982(lookahead)X
1391(and)X
1555(Backtracking)X
1 f
776 2776(There)N
1009(are)X
1144(a)X
1211(number)X
1508(of)X
1609(grammatical)X
2079(constructs)X
2464(that)X
2626(normal)X
2 f
10 s
2903(LL)X
1 f
3004(\()X
2 f
3031(k)X
1 f
3073(\))X
11 s
3129(recursive-descent)X
3773(parsing)X
576 2904(cannot)N
850(handle.)X
1168(The)X
1344(most)X
1555(obvious)X
1873(example)X
2211(would)X
2470(be)X
2592(left-recursion,)X
3126(but)X
3277(left-recursion)X
3789(can)X
3949(be)X
576 3032(removed)N
907(by)X
1018(well-known)X
1461(algorithms.)X
1906(The)X
2066(nastiest)X
2354(grammar)X
2695(construct)X
3041(is)X
3124(one)X
3275(in)X
3368(which)X
3607(two)X
3763(alterna-)X
576 3160(tive)N
734(productions)X
1175(cannot)X
1435(be)X
1543(distinguished)X
2039(without)X
2334(examining)X
2731(all)X
2844(or)X
2941(most)X
3137(of)X
3234(the)X
3366(production.)X
3816(While)X
576 3288(left-factoring)N
1069(can)X
1219(handle)X
1483(many)X
1708(of)X
1810(these)X
2020(cases,)X
2256(some)X
2471(cannot)X
2735(be)X
2847(handled)X
3155(due)X
3311(to)X
3409(things)X
3654(like)X
3816(action)X
576 3416(placement,)N
991(non-identical)X
1487(left-factors,)X
1925(or)X
2028(alternatives)X
2465(productions)X
2911(that)X
3074(cannot)X
3338(be)X
3450(reorganized)X
3894(into)X
576 3544(the)N
711(same)X
919(rule.)X
1127(The)X
1291(solution)X
1604(to)X
1701(the)X
1837(arbitrarily-large)X
2423(common)X
2760(left-factor)X
3140(problem)X
3462(is)X
3549(simply)X
3818(to)X
3915(use)X
576 3672(arbitrary)N
910(lookahead;)X
1328(i.e.,)X
1489(as)X
1593(much)X
1820(lookahead)X
2213(as)X
2317(necessary)X
2689(to)X
2789(uniquely)X
3129(determine)X
3513(which)X
3759(produc-)X
576 3800(tion)N
736(to)X
827(apply.)X
776 3956(ANTLR)N
1102(1.10)X
1289(provides)X
1625(two)X
1790(mechanisms)X
2259(for)X
2394(using)X
2618(``in\256nite'')X
3018(amounts)X
3350(of)X
3456(lookahead.)X
3895(The)X
576 4084(\256rst)N
736(is)X
818(to)X
910(use)X
1050(semantic)X
1387(predicates)X
1767(in)X
1859(conjunction)X
2299(with)X
2479(a)X
2540(user-de\256ned)X
2996(function)X
3312(that)X
3467(scans)X
3679(arbitrarily)X
576 4212(ahead)N
810(using)X
1031(a)X
1100(set)X
1228(of)X
1331(macros)X
1615(provided)X
1958(in)X
2057(this)X
2215(release.)X
2533(The)X
2700(second)X
2974(is)X
3063(a)X
3132(more)X
3343 0.4732(implicit)AX
3650(scheme)X
3944(by)X
576 4340(which)N
823(the)X
963(user)X
1141(can)X
1295(annotate)X
1625(those)X
1842(sections)X
2157(of)X
2261(the)X
2400(grammar,)X
2771(which)X
3017(defy)X
3204(normal)X
3485(LL\(k\))X
3726(analysis,)X
576 4468(with)N
2 f
768(syntactic)X
1117(predicates)X
1 f
1484(.)X
1563(ANTLR)X
1891(will)X
2064(then)X
2251(generate)X
2584(code)X
2785(that)X
2953(simply)X
3229(tries)X
3416(out)X
3564(the)X
3708(indicated)X
576 4596(alternative)N
977(production)X
1387(to)X
1484(see)X
1624(if)X
1706(it)X
1783(would)X
2030(match)X
2273(a)X
2339(portion)X
2621(of)X
2721(the)X
2856(remaining)X
3241(input.)X
3494(If)X
3579(not,)X
3741(the)X
3876(gen-)X
576 4724(erated)N
815(parser)X
1053(would)X
1297(try)X
1419(the)X
1551(next)X
1727(viable)X
1967(alternative)X
2364(production.)X
2814(This)X
2995(scheme)X
3283(is)X
3366(a)X
3429(form)X
3625(of)X
3723(selective)X
576 4852(backtracking)N
1068(\(and,)X
1282(hence,)X
1545(can)X
1703(recognize)X
2081(the)X
2225(class)X
2432(of)X
2541(context)X
2837(free)X
3009(languages\))X
3426(where)X
3676(most)X
3884(of)X
3993(a)X
576 4980(parser)N
828(is)X
925(deterministic)X
1425(and)X
1590(only)X
1785(the)X
1931(``hard'')X
2241(parts)X
2450(are)X
2596(done)X
2806(using)X
3036(trial-and-error.)X
3617(As)X
3753(a)X
3831(direct)X
576 5108(consequence,)N
1079(ANTLR)X
1403(can)X
1556(now)X
1738(generate)X
2067(parsers)X
2346(with)X
2534(the)X
2673(semantic)X
3018(\257exibility)X
3394(of)X
3498(LL\(k\),)X
3761(that)X
3925(are)X
576 5236(stronger)N
894(than)X
1076(full)X
1229(LR\(k\))X
1474(\(in)X
1602(theory\),)X
1908(and)X
2065(are)X
2202(nearly)X
2452(linear)X
2683(in)X
2782(complexity;)X
3235(note)X
3417(that)X
3580(the)X
3718(semantic)X
576 5364(predicates)N
967(\(\256rst)X
1167(introduced)X
1578(in)X
1681(the)X
1823(1.06)X
2011(release\))X
2318(can)X
2474(take)X
2654(ANTLR-generated)X
3351(parsers)X
3632(beyond)X
3924(the)X
576 5492(context-free)N
1023(language)X
1363(limit)X
1554(into)X
1714(the)X
1844(context-sensitive.)X
776 5648(We)N
927(begin)X
1153(this)X
1311(section)X
1591(by)X
1709(introducing)X
2146(the)X
2284(notion)X
2540(of)X
2643(in\256nite)X
2924(lookahead)X
3316(through)X
3620(an)X
3733(example)X
576 5776(problem)N
909(that)X
1081(we)X
1222(solve)X
1447(with)X
1643(semantic)X
1996(and)X
2162(then)X
2353(with)X
2549(syntactic)X
2902(predicates.)X
3341(Following)X
3742(this,)X
3930(we)X
6 p
%%Page: 6 6
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(6)X
2348(-)X
576 704(describe)N
896(in)X
992(detail)X
1216(the)X
1351(syntax)X
1608(and)X
1763(use)X
1908(of)X
2009(syntactic)X
2351(predicates,)X
2758(which)X
3001(employ)X
3294(in\256nite)X
3573(lookahead)X
3963(to)X
576 832(perform)N
881(selective)X
1212(backtracking.)X
3 f
576 1088(3.1.)N
752(Examples)X
1 f
776 1244(This)N
963(section)X
1243(presents)X
1561(a)X
1630(simple)X
1896(grammar)X
2244(whose)X
2498(productions)X
2945(have)X
3142(common)X
3482(left-factors)X
3899(that)X
576 1372(we)N
708(assume,)X
1019(for)X
1150(the)X
1287(sake)X
1472(of)X
1574(demonstration)X
2108(purposes,)X
2471(to)X
2569(be)X
2681(non)X
2842(left-factorable.)X
3414(With)X
3620(nothing)X
3919(but)X
576 1500(the)N
716(grammar,)X
1088(ANTLR)X
1413(would)X
1666(be)X
1782(unable)X
2050(to)X
2152(construct)X
2508(a)X
2580(deterministic)X
3075(parser.)X
3366(We)X
3521(\256rst)X
3691(provide)X
3993(a)X
576 1628(solution)N
890(by)X
1007(writing)X
1291(a)X
1359(function)X
1682(that)X
1844(explicitly)X
2208(accesses)X
2534(the)X
2671(in\256nite)X
2950(lookahead)X
3340(buffer)X
3582(to)X
3679(determine)X
576 1756(which)N
822(production)X
1235(should)X
1501(be)X
1615(attempted.)X
2039(This)X
2227(solution)X
2543(is)X
2633(ef\256cient,)X
2975(but)X
3119(would)X
3370(become)X
3675(somewhat)X
576 1884(tedious)N
859(for)X
988(the)X
1123(programmer)X
1585(if)X
1666(it)X
1743(had)X
1897(to)X
1993(be)X
2103(done)X
2301(for)X
2430(each)X
2618(such)X
2806(problem)X
3127(in)X
3223(a)X
3289(large)X
3492(grammar.)X
3881(For-)X
576 2012(tunately,)N
911(an)X
1022(easier)X
1255(and)X
1410(more)X
1619(concise)X
1911(solution)X
2224(is)X
2311(provided)X
2652(by)X
2768(syntactic)X
3110(predicates,)X
3517(which)X
3760(we)X
3890(also)X
576 2140(demonstrate)N
1029(using)X
1242(the)X
1372(same)X
1575(grammar.)X
776 2296(Consider)N
1116(ML)X
1270(which)X
1507(has)X
1646(multiple)X
1964(assignment)X
2383(and)X
2532(list)X
2663(statements.)X
3102(E.g.,)X
7 f
9 s
576 2460(stat:)N
920(list)X
1135(Assign)X
1436(list)X
1651(";")X
1952(<
2597(=)X
2683(list\\n"\);>>)X
9 f
748 2548(|)N
7 f
891(list)X
1106(";")X
1923 -0.1969(<>)AX
748 2636(;)N
1 f
11 s
576 2840(This)N
762(grammar)X
1109(is)X
1198(not)X
2 f
10 s
1339(LL)X
1 f
1440(\()X
2 f
1467(k)X
1 f
1509(\))X
11 s
1566(for)X
1698(any)X
2 f
10 s
1853(k)X
1 f
11 s
1919(as)X
7 f
2053(list)X
1 f
2295(can)X
2447(be)X
2560(arbitrarily)X
2943(long.)X
3174(The)X
3341(following)X
3714(grammar)X
576 2968(using)N
790(semantic)X
1127(predicates)X
1507(to)X
1599(access)X
1846(the)X
1977(in\256nite)X
2251(lookahead)X
2636(buffer)X
2873(to)X
2965(explicitly)X
3323(compute)X
3649(which)X
3886(pro-)X
576 3096(duction)N
863(will)X
1023(be)X
1128(matched.)X
7 p
%%Page: 7 7
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2244 376(-)N
2286(7)X
2340(-)X
7 f
576 712(/*)N
705(example)X
1049(use)X
1221(of)X
1350(the)X
1522(infinite)X
1909(lookahead)X
2339(buffer)X
2640(macros)X
619 800(*)N
705(compile)X
1049(with:)X
619 888(*)N
936(antlr)X
1194(list.g)X
619 976(*)N
936(dlg)X
1108(parser.dlg)X
1581(scan.c)X
619 1064(*)N
936(cc)X
1065(-I)X
2 f
1151(antlr_includes)X
7 f
1610(-DZZINF_LOOK)X
2169(-o)X
2298(list)X
2513(list.c)X
2814(scan.c)X
3115(err.c)X
619 1152(*/)N
576 1240(#header)N
920(<<#include)X
1393("charbuf.h">>)X
576 1416(<<)N
576 1504(main\(\))N
877({)X
963(ANTLR\(stat\(\),)X
1565(stdin\);)X
1909(})X
576 1680(/*)N
705(Scan)X
920(for)X
1092(a)X
1178("=",)X
1393(but)X
1565(only)X
1780(before)X
2081(a)X
2167(";")X
2339(--)X
2468(return)X
2769(1)X
2855(if)X
2984(found,)X
3285(else)X
3500(0)X
705 1768(This)N
920(performs)X
1307(the)X
1479(same)X
1694(function)X
2081(as)X
2210(using)X
2468(the)X
2640(syntactic)X
3070(predicate:)X
920 1856(\(list)N
1178(Assign)X
1479(list)X
1694(";"\)?)X
705 1944(but)N
877(uses)X
1092(a)X
1178(semantic)X
1565(predicate)X
1995(coupled)X
2339(with)X
2554(the)X
2726 -0.1985(infinite-lookahead)AX
3543(feature.)X
705 2032(It)N
834(is)X
963(somewhat)X
1350(faster)X
1651(as)X
1780(it)X
1909(does)X
2124(not)X
2296(actually)X
2683(*parse*)X
3027(the)X
3199("list)X
3457(=",)X
3629(it)X
3758(just)X
705 2120(scans)N
963(ahead.)X
705 2296(MUST)N
920(HAVE)X
1135("ZZINF_LOOK")X
1694(PREPROCESSOR)X
2253(FLAG)X
2468(DEFINED)X
705 2384(\(in)N
877(#header)X
1221(or)X
1350(on)X
1479(compiler)X
1866(command)X
2210(line\))X
705 2472(*/)N
576 2560(which\(\))N
576 2648({)N
748 2736(int)N
920(i;)X
748 2912(for)N
920(\(i=1;)X
1178 -0.1985(ZZINF_LA_VALID\(i\);)AX
1995(i++\))X
748 3000({)N
920 3088(if)N
1049(\()X
1135(ZZINF_LA\(i\))X
1651(==)X
1780(Assign)X
2081(\))X
2167(return)X
2468(1;)X
920 3176(else)N
1135(if)X
1264(\()X
1350(ZZINF_LA\(i\))X
1866(==)X
1995(Semi)X
2210(\))X
2296(return)X
2597(0;)X
748 3264(})N
748 3352(return)N
1049(0;)X
576 3440(})N
576 3528(>>)N
576 3704(#token)N
1296("[\\)X
1468(\\t]+")X
2027(<>)X
576 3792(#token)N
1296("\\n")X
2027(<
2543(zzline++;>>)X
576 3880(#token)N
877(Assign)X
1296("=")X
576 3968(#token)N
877(Semi)X
1296(";")X
576 4144(stat:)N
877(<>?)X
1436(list)X
1651(Assign)X
1952(list)X
2167(";")X
2339(<
2984(=)X
3070(list\\n"\);>>)X
9 f
748 4232(|)N
7 f
891(list)X
1106(";")X
2310 -0.1969(<>)AX
748 4320(;)N
576 4496(list:)N
920("\\\(")X
1135(elem)X
1350(\(",")X
1565(elem\)*)X
1866("\\\)")X
748 4584(;)N
576 4760(elem:)N
920(ID)X
9 f
748 4848(|)N
7 f
891(INT)X
748 4936(;)N
576 5112(#token)N
877(ID)X
1296("[a-zA-Z]+")X
576 5200(#token)N
877(INT)X
1296("[0-9]+")X
1 f
11 s
576 5404(The)N
735(in\256nite)X
1008(lookahead)X
1392(buffer)X
1628(may)X
1802(be)X
1907(accessed)X
2236(with)X
2415(the)X
2545(following)X
2910(macros:)X
7 f
576 5560(ZZINF_LA\()N
2 f
10 s
1053(i)X
7 f
11 s
1075(\))X
1 f
776 5688(Return)N
1100(the)X
2 f
10 s
1290(i)X
7 s
1321 5656(th)N
1 f
11 s
1455 5688(token)N
1736(of)X
1894(lookahead)X
2341(relative)X
2691(to)X
2845(the)X
3038(current)X
3372(position.)X
3786(Hence,)X
7 f
776 5816(ZZINF_LA\(1\))N
1 f
1359(..)X
7 f
(ZZINF_LA\()S
2 f
10 s
1880(k)X
7 f
11 s
1916(\))X
1 f
1995(are)X
2128(equivalent)X
2521(to)X
7 f
2646(LA\(1\))X
1 f
2911(..)X
7 f
(LA\()S
2 f
10 s
3114(k)X
7 f
11 s
3150(\))X
1 f
3203(.)X
3272(The)X
3434(difference)X
3815(is)X
3899(that)X
8 p
%%Page: 8 8
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(8)X
2348(-)X
2 f
10 s
776 704(i)N
1 f
11 s
836(can)X
996(range)X
1229(from)X
1438(the)X
1584(current)X
1871(token)X
2105(of)X
2216(lookahead)X
2616(until)X
2818(the)X
2965(last)X
3127(token)X
3362(of)X
3474(lookahead)X
3875(with)X
7 f
776 832(ZZINF_LA\()N
2 f
10 s
1253(i)X
7 f
11 s
1275(\))X
1 f
1328(.)X
7 f
576 988(ZZINF_LATEXT\()N
2 f
10 s
1265(i)X
7 f
11 s
1287(\))X
1 f
776 1116(Identical)N
1107(to)X
7 f
1229(ZZINF_LA\()X
2 f
10 s
1706(i)X
7 f
11 s
1728(\))X
1 f
1803(except)X
2055(that)X
2210(the)X
2340(text)X
2495(of)X
2590(the)X
2 f
10 s
2718(i)X
7 s
2749 1084(th)N
1 f
11 s
2821 1116(token)N
3039(is)X
3120(returned.)X
7 f
576 1272(ZZINF_LA_VALID\()N
2 f
10 s
1371(i)X
7 f
11 s
1393(\))X
1 f
776 1400(Returns)N
1072(1)X
1138(if)X
2 f
10 s
1212(i)X
1 f
11 s
1256(if)X
1332(at)X
1418(least)X
2 f
10 s
1600(i)X
1 f
11 s
1644(non-EOF)X
1993(tokens)X
2245(are)X
2374(left)X
2514(in)X
2605(the)X
2735(input)X
2939(stream)X
3196(else)X
3355(it)X
3427(returns)X
3693(0.)X
576 1556(Naturally,)N
959(the)X
1095(use)X
1240(of)X
1342(in\256nite)X
1622(lookahead)X
2013(by)X
2130(de\256ning)X
7 f
2479(ZZINF_LOOK)X
1 f
3038(is)X
3126(inconsistent)X
3577(with)X
3763(interac-)X
576 1684(tive)N
731(parsers)X
1001(as)X
1096(the)X
1226(entire)X
1449(input)X
1653(stream)X
1910(is)X
1991(read)X
2164(in)X
2255(before)X
2501(parsing)X
2782(begins.)X
776 1840(As)N
896(mentioned)X
1292(above,)X
1547(this)X
1699(method)X
1988(could)X
2208(be)X
2315(tedious)X
2594(for)X
2720(large)X
2920(grammars,)X
3318(hence,)X
3569(ANTLR)X
3886(pro-)X
576 1968(vides)N
796(a)X
869(more)X
1084(elegant)X
1372(solution.)X
1734(The)X
1904(same)X
2118(problem)X
2445(can)X
2600(be)X
2716(solved)X
2979(with)X
3169(a)X
3241(syntactic)X
3588(predicate)X
3944(by)X
576 2096(changing)N
921(rule)X
7 f
1111(stat)X
1 f
1345(in)X
1436(the)X
1566(following)X
1931(way:)X
7 f
9 s
576 2260(stat:)N
920(\()X
1006(list)X
1221(Assign)X
1522(list)X
1737(";")X
1909(\)?)X
2296(<
2941(=)X
3027(list\\n"\);>>)X
9 f
748 2348(|)N
7 f
891(list)X
1106(";")X
2267 -0.1969(<>)AX
748 2436(;)N
1 f
11 s
576 2640(Using)N
824(this)X
990 0.4732(implicit)AX
1305(method,)X
1630(the)X
1776(need)X
1981(for)X
2122(the)X
2269(semantic)X
2622(predicate)X
2984(and)X
3150(the)X
7 f
3328(which\(\))X
1 f
3738(function)X
576 2768(disappears.)N
776 2924(Let's)N
982(now)X
1159(consider)X
1483(a)X
1548(small)X
1766(chunk)X
2007(of)X
2106(the)X
2240(vast)X
2408(C++)X
2593(declaration)X
3011(syntax.)X
3311(Can)X
3479(you)X
3637(tell)X
3777(exactly)X
576 3052(what)N
769(type)X
943(of)X
1038(object)X
7 f
1307(f)X
1 f
1382(is)X
1463(after)X
1646(having)X
1908(seen)X
2086(the)X
2216(left)X
2356(parenthesis?)X
7 f
9 s
576 3216(int)N
748(f\()X
1 f
11 s
576 3420(The)N
739(answer)X
1013(is)X
1098(``no.''.)X
1394(Object)X
7 f
1686(f)X
1 f
1765(could)X
1988(be)X
2098(an)X
2208(integer)X
2480 0.3187(initialized)AX
2862(to)X
2958(some)X
3171(previously)X
3570(de\256ned)X
3856(sym-)X
576 3548(bol)N
7 f
742(a)X
1 f
795(:)X
7 f
9 s
576 3712(int)N
748(f\(a\);)X
1 f
11 s
576 3916(or)N
671(a)X
732(function)X
1048(prototype)X
1408(or)X
1503(de\256nition:)X
7 f
9 s
576 4080(int)N
748(f\(float)X
1092(a\))X
1221({...})X
1 f
11 s
576 4284(The)N
735(following)X
1100(is)X
1181(a)X
1242(greatly)X
1509(simpli\256ed)X
1885(grammar)X
2225(for)X
2349(these)X
2552(two)X
2706(declaration)X
3120(types:)X
7 f
9 s
576 4448(decl:)N
936(type)X
1151(ID)X
1280("\\\(")X
1495(expr_list)X
1925("\\\)")X
2140(";")X
9 f
756 4536(|)N
7 f
936(type)X
1151(ID)X
1280("\\\(")X
1495(arg_decl_list)X
2097("\\\)")X
2312(func_def)X
756 4624(;)N
1 f
11 s
576 4828(One)N
755(notices)X
1038(that)X
1205(left-factoring)X
7 f
1735(type)X
2012(ID)X
2183("\\\(")X
1 f
2429(would)X
2683(be)X
2800(trivial)X
3046(because)X
3358(our)X
3509(grammar)X
3861(is)X
3954(so)X
576 4956(small)N
795(and)X
949(the)X
1084(left-pre\256xes)X
1536(are)X
1670(identical.)X
2046(However,)X
2415(if)X
2495(a)X
2560(user)X
2732(action)X
2974(were)X
3170(required)X
3489(before)X
3739(recogni-)X
576 5084(tion)N
736(of)X
831(the)X
961(reference)X
1309(to)X
1400(rule)X
7 f
1590(type)X
1 f
1802(,)X
1846(left-factoring)X
2333(would)X
2575(not)X
2710(be)X
2815(possible:)X
7 f
9 s
576 5248(decl:)N
936(<
1151(dummy)X
1409(init)X
1624(action)X
1925(so)X
2054(next)X
2269(action)X
2570(is)X
2699(not)X
2871(taken)X
3129(as)X
3258(init)X
3473(*/>>)X
936 5336(<
1538(init\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(expr_list)X
3086("\\\)")X
3301(";")X
9 f
756 5424(|)N
7 f
936(<
1581(def\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(arg_decl_list)X
3258("\\\)")X
3473(func_def)X
756 5512(;)N
1 f
11 s
576 5716(The)N
738(solution)X
1048(to)X
1142(the)X
1275(problem)X
1594(involves)X
1919(looking)X
2215(arbitrarily)X
2594(ahead)X
2825(\()X
7 f
2854(type)X
1 f
3092(could)X
3314(be)X
3423(arbitrarily)X
3802(big,)X
3963(in)X
576 5844(general\))N
907(to)X
1018(determine)X
1413(what)X
1626(appears)X
1936(after)X
2139(the)X
2289(left-parenthesis.)X
2918(This)X
3117(problem)X
3453(is)X
3554(easily)X
3802(solved)X
9 p
%%Page: 9 9
11 s 0 xH 0 xS 1 f
2231 416(-)N
2282(9)X
2348(-)X
576 704 0.4306(implicitly)AN
944(by)X
1054(using)X
1267(the)X
1397(new)X
7 f
1596(\(...\)?)X
2 f
1936(syntactic)X
2272(predicate)X
1 f
2605(:)X
7 f
9 s
576 868(decl:)N
936(\()X
1108(<<;>>)X
1366(<
1968(init\\n"\);>>)X
2484(type)X
2699(ID)X
2828("\\\(")X
3043(expr_list)X
3473("\\\)")X
3688(";")X
3946(\)?)X
9 f
756 956(|)N
7 f
936(<
1581(def\\n"\);>>)X
2097(type)X
2312(ID)X
2441("\\\(")X
2656(arg_decl_list)X
3258("\\\)")X
3473(func_def)X
756 1044(;)N
1 f
11 s
576 1248(The)N
7 f
770(\(...\)?)X
1 f
1114(says)X
1291(that)X
1450(it)X
1526(is)X
1611(impossible)X
2020(to)X
2116(decide,)X
2395(from)X
2593(the)X
2728(left)X
2873(edge)X
3066(of)X
3166(rule)X
7 f
3361(decl)X
1 f
3600(with)X
3784(a)X
3850(\256nite)X
576 1376(amount)N
874(of)X
980(lookahead,)X
1397(which)X
1645(production)X
2059(to)X
2160(predict.)X
2481(Any)X
2664(grammar)X
3014(construct)X
3369(inside)X
3612(a)X
7 f
3714(\(...\)?)X
1 f
576 1504(block)N
804(is)X
895(attempted)X
1276(and,)X
1457(if)X
1543(it)X
1625(fails,)X
1831(the)X
1971(next)X
2155(alternative)X
2560(production)X
2974(that)X
3139(could)X
3368(match)X
3617(the)X
3758(input)X
3973(is)X
576 1632(attempted.)N
1000(This)X
1188(represents)X
1575(selective)X
1915(backtracking)X
2401(and)X
2559(is)X
2648(similar)X
2924(to)X
3023(allowing)X
3362(ANTLR)X
3685(parsers)X
3963(to)X
576 1760(guess)N
795(without)X
1090(being)X
1311(``penalized'')X
1790(for)X
1917(being)X
2138(wrong.)X
2431(Note)X
2627(that)X
2785(the)X
2918(\256rst)X
3080(action)X
3321(of)X
3419(any)X
3571(block)X
3792(is)X
3876(con-)X
576 1888(sidered)N
859(an)X
971(init)X
1118(action)X
1362(and,)X
1539(hence,)X
1794(cannot)X
2057(be)X
2168(disabled)X
2490(\(by)X
2635(placing)X
2923(it)X
3001(inside)X
7 f
3271({...})X
1 f
3536(\))X
3593(since)X
3802(it)X
3880(may)X
576 2016(de\256ne)N
813(variables;)X
1178(the)X
1308(\256rst)X
1467(action)X
1705(of)X
1800(the)X
1930(block)X
2148(is)X
2229(a)X
2290(dummy)X
2582(action.)X
776 2172(At)N
890(this)X
1045(point,)X
1276(some)X
1489(readers)X
1769(may)X
1948(argue)X
2170(that)X
2330(scanning)X
2670(ahead)X
2902(arbitrarily)X
3282(far,)X
3428(using)X
3646(the)X
3781(in\256nite)X
576 2300(lookahead)N
970(via)X
1110(a)X
1181(semantic)X
1527(or)X
1632(syntactic)X
1978(predicate,)X
2355(renders)X
2644(the)X
2783(parser)X
3028(non-linear)X
3421(in)X
3521(nature.)X
3816(While)X
576 2428(this)N
726(is)X
807(true,)X
988(the)X
1118(slowdown)X
1501(is)X
1582(negligible)X
1958(as)X
2053(the)X
2183(parser)X
2419(is)X
2500(mostly)X
2763(linear.)X
3030(Further,)X
3333(it)X
3406(is)X
3488(better)X
3712(to)X
3804(have)X
3993(a)X
576 2556(capability)N
947(that)X
1102(is)X
1183(slightly)X
1471(inef\256cient)X
1851(than)X
2025(not)X
2160(to)X
2251(have)X
2439(the)X
2569(capability)X
2940(at)X
3026(all.)X
3 f
576 2812(3.2.)N
752(Syntactic)X
1121(Predicates)X
1 f
776 2968(Just)N
947(as)X
1054(semantic)X
1402(predicates)X
1793(indicate)X
2107(when)X
2331(a)X
2404(production)X
2821(is)X
2915(valid,)X
2 f
3149(syntactic)X
1 f
3498(predicates)X
3890(also)X
576 3096(indicate)N
879(when)X
1092(a)X
1154(production)X
1559(is)X
1641(a)X
1703(candidate)X
2064(for)X
2189(recognition.)X
2658(The)X
2818(difference)X
3197(lies)X
3342(in)X
3433(the)X
3563(type)X
3737(of)X
3832(infor-)X
576 3224(mation)N
855(used)X
1049(to)X
1152(predict)X
1431(alternative)X
1838(productions.)X
2332(Semantic)X
2695(predicates)X
3086(employ)X
3385(information)X
3836(about)X
576 3352(the)N
708(``meaning'')X
1152(of)X
1249(the)X
1381(input)X
1587(\(e.g.,)X
1789(symbol)X
2073(table)X
2269(information\))X
2739(whereas)X
3050(syntactic)X
3387(predicates)X
3767(employ)X
576 3480(structural)N
937(information)X
1382(like)X
1543(normal)X
2 f
10 s
1819(LL)X
1 f
1920(\()X
2 f
1947(k)X
1 f
1989(\))X
11 s
2044(parsing)X
2331(decisions.)X
2731(Syntactic)X
3088(predicates)X
3473(specify)X
3755(a)X
3822(gram-)X
576 3608(matical)N
866(construct)X
1218(that)X
1380(must)X
1580(be)X
1691(seen)X
1875(on)X
1991(the)X
2127(input)X
2337(stream)X
2600(for)X
2730(a)X
2797(production)X
3207(to)X
3304(be)X
3415(valid.)X
3664(Moreover,)X
576 3736(this)N
738(construct)X
1095(may)X
1281(match)X
1531(input)X
1747(streams)X
2050(that)X
2217(are)X
2358(arbitrarily)X
2745(long;)X
2961(normal)X
2 f
10 s
3244(LL)X
1 f
3345(\()X
2 f
3372(k)X
1 f
3414(\))X
11 s
3476(parsers)X
3759(are)X
3901(res-)X
576 3864(tricted)N
827(to)X
921(using)X
1137(the)X
1270(next)X
2 f
10 s
1445(k)X
1 f
11 s
1506(symbols)X
1825(of)X
1923(lookahead.)X
2354(This)X
2536(section)X
2811(describes)X
3163(the)X
3296(form)X
3492(and)X
3643(use)X
3784(of)X
3881(syn-)X
576 3992(tactic)N
790(predicates)X
1169(as)X
1264(well)X
1438(as)X
1533(their)X
1717 0.2679(implementation.)AX
3 f
576 4248(3.2.1.)N
818(Syntactic)X
1187(Predicate)X
1566(Form)X
1 f
776 4404(Syntactic)N
1127(predictions)X
1541(have)X
1729(the)X
1859(form)X
7 f
9 s
576 4568(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
10 s
9 f
884(b)X
1 f
11 s
576 4772(or,)N
693(the)X
823(shorthand)X
1192(form)X
7 f
9 s
576 4936(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
1 f
11 s
576 5140(which)N
813(is)X
894(identical)X
1221(to)X
7 f
9 s
576 5304(\()N
10 s
9 f
662(a)X
9 s
7 f
755(\)?)X
10 s
9 f
884(a)X
1 f
11 s
576 5508(where)N
10 s
9 f
818(a)X
11 s
1 f
898(and)X
10 s
9 f
1054(b)X
11 s
1 f
1129(are)X
1267(arbitrary)X
1601(Extended)X
1965(BNF)X
2167(\(EBNF\))X
2481(grammar)X
2830(fragments)X
3213(that)X
3377(do)X
3496(not)X
3640(de\256ne)X
3886(new)X
576 5636(nonterminals.)N
1108(The)X
1272(notation)X
1589(is)X
1675(similar)X
1948(to)X
2043(the)X
7 f
2208(\()X
10 s
9 f
2261(a)X
11 s
7 f
2311(\)*)X
1 f
2443(and)X
7 f
2627(\()X
10 s
9 f
2680(a)X
11 s
7 f
2730(\)+)X
1 f
2862(closure)X
3142(blocks)X
3398(already)X
3683(present)X
3963(in)X
576 5764(PCCTS.)N
920(The)X
1087(meaning)X
1421(of)X
1524(the)X
1662(long)X
1849(form)X
2050(syntactic)X
2394(predicate)X
2747(is:)X
2883(``)X
3 f
2941(If)X
10 s
9 f
3033(a)X
3035(a)X
11 s
3 f
3116(is)X
3206(matched)X
3559(on)X
3683(the)X
3831(input)X
10 p
%%Page: 10 10
11 s 0 xH 0 xS 3 f
1 f
2209 416(-)N
2260(10)X
2370(-)X
3 f
576 704(stream,)N
878(attempt)X
1192(to)X
1287(recognize)X
10 s
9 f
1664(b)X
1666(b)X
11 s
3 f
1710(.)X
1 f
('')S
1812(Note)X
2005(the)X
2135(similarity)X
2497(to)X
2588(the)X
2 f
2718(semantic)X
3053(predicate)X
1 f
3386(:)X
7 f
9 s
576 868(<<)N
10 s
9 f
662(a)X
9 s
7 f
712(>>?)X
10 s
9 f
884(b)X
1 f
11 s
576 1072(which)N
813(means:)X
1085(``)X
3 f
1143(If)X
10 s
9 f
1226(a)X
1228(a)X
11 s
3 f
1300(evaluates)X
1669(to)X
1764(true)X
1942(at)X
2037(parser)X
2303(run-time,)X
2679(attempt)X
2993(to)X
3088(match)X
10 s
9 f
3342(b)X
3344(b)X
1 f
11 s
3388(.'')X
776 1228(Decisions,)N
1173(which)X
1416(are)X
1551(nondeterministic)X
2173(\(non-)X
2 f
10 s
2363(LL)X
1 f
2464(\()X
2 f
2491(k)X
1 f
2533(\))X
11 s
2588(for)X
2718(\256nite)X
2 f
10 s
2926(k)X
1 f
11 s
2962(\),)X
3041(are)X
3176(resolved)X
3502(via)X
7 f
3669(\(..\)?)X
1 f
3963(in)X
576 1356(the)N
706(following)X
1071(manner:)X
7 f
9 s
576 1520(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 1536(1)N
7 f
9 s
9 f
748 1608(|)N
10 s
891(g)X
1 f
7 s
924 1624(2)N
7 f
9 s
705 1696(...)N
9 f
748 1784(|)N
7 f
891(\()X
10 s
9 f
977(a)X
2 f
7 s
1027 1800(i)N
7 f
9 s
1092 1784(\)?)N
10 s
9 f
1221(g)X
2 f
7 s
1254 1800(i)N
7 f
9 s
705 1872(...)N
9 f
748 1960(|)N
10 s
891(g)X
2 f
7 s
928 1976(j)N
7 f
9 s
705 2048(...)N
9 f
748 2136(|)N
10 s
891(g)X
2 f
7 s
924 2152(n)N
7 f
9 s
748 2224(;)N
1 f
11 s
576 2428(where)N
826(productions)X
2 f
10 s
1276(i)X
1 f
11 s
1334(and)X
2 f
10 s
1501(j)X
1 f
11 s
1559(are)X
1702(mutually)X
2053(nondistinguishable)X
2756(from)X
2963(the)X
3107(left-edge.)X
3500(If)X
3594(production)X
2 f
10 s
4010(i)X
1 f
11 s
576 2556(fails,)N
779(production)X
2 f
10 s
1194(j)X
1 f
11 s
1245(will)X
1412(be)X
1524(attempted.)X
1946(Typically,)X
2336(the)X
2472(number)X
2769(of)X
2870(syntactic)X
3212(predicates)X
3597(employed)X
3973(is)X
2 f
10 s
576 2684(n)N
9 f
629(-)X
1 f
673(1)X
11 s
741(where)X
2 f
10 s
981(n)X
1 f
11 s
1049(is)X
1136(the)X
1272(number)X
1569(of)X
1671(mutually)X
2015(nondeterministic)X
2638(productions)X
3083(in)X
3181(a)X
3249(decision;)X
3597(the)X
3734(last)X
3886(pro-)X
576 2812(duction)N
863(is)X
944(attempted)X
1315(by)X
1425(default.)X
776 2968(When)N
1011(a)X
1075(production)X
1483(to)X
1578(be)X
1687(predicted)X
2041(must)X
2239(be)X
2348(predicted)X
2702(with)X
2885(itself)X
3088(\(nothing)X
3413(less)X
3571(sophisticated)X
576 3096(is)N
657(suf\256cient\))X
1036(or)X
1131(when)X
1343(ef\256ciency)X
1712(is)X
1793(not)X
1928(a)X
1989(major)X
2217(concern,)X
2539(the)X
2669(short)X
2867(form)X
3060(is)X
3141(used:)X
7 f
9 s
576 3260(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 3276(1)N
7 f
9 s
9 f
748 3348(|)N
10 s
891(g)X
1 f
7 s
924 3364(2)N
7 f
9 s
705 3436(...)N
9 f
748 3524(|)N
7 f
891(\()X
10 s
9 f
977(g)X
2 f
7 s
1010 3540(i)N
7 f
9 s
1075 3524(\)?)N
705 3612(...)N
9 f
748 3700(|)N
10 s
891(g)X
2 f
7 s
928 3716(j)N
7 f
9 s
705 3788(...)N
9 f
748 3876(|)N
10 s
891(g)X
2 f
7 s
924 3892(n)N
7 f
9 s
748 3964(;)N
3 f
11 s
576 4268(3.2.2.)N
818(Modi\256ed)X
2 f
10 s
1176(LL)X
1 f
1277(\()X
2 f
1304(k)X
1 f
1346(\))X
3 f
11 s
1395(Parsing)X
1706(Scheme)X
1 f
776 4424(Decisions)N
1146(that)X
1302(are)X
1432(not)X
1568(augmented)X
1978(with)X
2158(syntactic)X
2495(predicates)X
2875(are)X
3005(parsed)X
3257 0.2305(deterministically)AX
3875(with)X
576 4552(\256nite)N
783(lookahead)X
1170(up)X
1283(to)X
1377(depth)X
2 f
10 s
1596(k)X
1 f
11 s
1657(as)X
1755(is)X
1839(normal)X
2114(for)X
2241(PCCTS-generated)X
2906(parsers.)X
3222(When)X
3456(at)X
3544(least)X
3730(one)X
3881(syn-)X
576 4680(tactic)N
790(predicate)X
1135(is)X
1216(present)X
1492(in)X
1583(a)X
1644(decision,)X
1982(rule)X
2141(recognition)X
2565(proceeds)X
2899(as)X
2994(follows:)X
576 4964([1])N
776(Find)X
967(the)X
1104(\256rst)X
2 f
1270(viable)X
1 f
1515(production;)X
1952(i.e.)X
2090(the)X
2228(\256rst)X
2395(production)X
2807(in)X
2906(the)X
3044(alternative)X
3447(list)X
3586(predicted)X
3944(by)X
776 5092(the)N
939(current)X
1242(\256nite)X
1478(lookahead,)X
1916(according)X
2317(to)X
2440(the)X
2602(associated)X
3018(\256nite-lookahead)X
3645(prediction-)X
776 5220(expression.)N
576 5376([2])N
776(If)X
856(the)X
986(\256rst)X
1145(element)X
1447(in)X
1538(that)X
1693(production)X
2097(is)X
2178(not)X
2313(a)X
2374(syntactic)X
2710(predicate,)X
3077(predict)X
3344(that)X
3500(production)X
3905(and)X
776 5504(go)N
886(to)X
977([4])X
1101(else)X
1260(attempt)X
1548(to)X
1639(match)X
1877(its)X
1983(predicting)X
2363(grammar)X
2703(fragment.)X
576 5660([3])N
776(If)X
866(the)X
1006(grammar)X
1356(fragment)X
1706(is)X
1797(matched,)X
2150(predict)X
2427(the)X
2567(associated)X
2962(production)X
3377(and)X
3537(go)X
3658(to)X
3760([4])X
3895(else)X
776 5788(\256nd)N
935(the)X
1065(next)X
1239(viable)X
1477(production)X
1881(and)X
2030(go)X
2140(to)X
2231([2].)X
11 p
%%Page: 11 11
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(11)X
2370(-)X
576 704([4])N
776(Proceed)X
1081(with)X
1260(the)X
1390(normal)X
1662(recognition)X
2086(of)X
2181(the)X
2311(production)X
2715(predicted)X
3065(in)X
3156([2])X
3280(or)X
3375([3].)X
576 988(For)N
720(successful)X
1103(predicates,)X
1504(both)X
1683(the)X
1813(predicting)X
2193(grammar)X
2533(fragment)X
2873(and)X
3022(the)X
3152(remainder)X
3532(of)X
3628(the)X
3759(produc-)X
576 1116(tion)N
750(are)X
892(actually)X
1207(matched,)X
1563(hence,)X
1825(the)X
1968(short)X
2179(form,)X
7 f
2438(\()X
10 s
9 f
2491(a)X
11 s
7 f
2541(\)?)X
1 f
2647(,)X
2704(actually)X
3019(matches)X
10 s
9 f
3341(a)X
11 s
1 f
3426(twice)X
3639(\320)X
3762(once)X
3963(to)X
576 1244(predict)N
843(and)X
992(once)X
1180(to)X
1271(apply)X
10 s
9 f
1487(a)X
11 s
1 f
1559(normally.)X
3 f
576 1500(3.2.3.)N
818(Syntactic)X
1187(Predicate)X
1566(Placement)X
1 f
776 1656(Syntactic)N
1128(predicates)X
1508(may)X
1683(only)X
1864(appear)X
2122(as)X
2219(the)X
2351(\256rst)X
2512(element)X
2816(of)X
2913(a)X
2976(production)X
3382(because)X
3684(that)X
3841(is)X
3924(the)X
576 1784(only)N
760(place)X
973(decisions)X
1328(are)X
1462(required.)X
1826(For)X
1975(example,)X
2323(the)X
7 f
2489(\(..\)?)X
1 f
2781(block)X
3004(in)X
3100(the)X
3235(\256rst)X
3398(production)X
3806(of)X
3905(fol-)X
576 1912(lowing)N
843(grammar)X
1183(has)X
1322(little)X
1508(utility.)X
7 f
9 s
576 2076(a)N
748(:)X
10 s
9 f
920(g)X
1 f
7 s
953 2092(1)N
7 f
9 s
1030 2076(\()N
10 s
9 f
1116(a)X
9 s
7 f
1209(\)?)X
10 s
9 f
1338(b)X
9 s
748 2164(|)N
10 s
891(g)X
1 f
7 s
924 2180(2)N
7 f
9 s
705 2252(...)N
9 f
748 2340(|)N
10 s
891(g)X
2 f
7 s
924 2356(n)N
7 f
9 s
748 2428(;)N
1 f
11 s
576 2632(There)N
808(is)X
894(no)X
1009(question)X
1335(that)X
10 s
9 f
1493(b)X
11 s
1 f
1564(is)X
1650(to)X
1746(be)X
1856(matched)X
2182(after)X
10 s
9 f
2368(g)X
7 s
1 f
2401 2648(1)N
11 s
2463 2632(and)N
2618(trying)X
2857(to)X
2954(predict)X
3227(this)X
3383(situation)X
3716(is)X
3803(redun-)X
576 2760(dant.)N
776 2916(Syntactic)N
1131(predicates)X
1514(may)X
1692(appear)X
1953(on)X
2068(the)X
2203(left)X
2348(edge)X
2541(of)X
2641(any)X
2795(production)X
3204(within)X
3457(any)X
3611(subrule,)X
3919(not)X
576 3044(just)N
726(in)X
817(productions)X
1255(at)X
1341(the)X
1471(rule)X
1630(block)X
1848(level.)X
3 f
576 3300(3.2.4.)N
818(Nested)X
1093(Syntactic)X
1462(Predicate)X
1841(Invocation)X
1 f
776 3456(Because)N
1106(syntactic)X
1457(predicates)X
1851(may)X
2041(reference)X
2405(any)X
2570(de\256ned)X
2867(nonterminal)X
3332(and)X
3497(because)X
3813(of)X
3924(the)X
576 3584(recursive)N
933(nature)X
1188(of)X
1296(grammars,)X
1704(it)X
1788(is)X
1881(possible)X
2204(for)X
2340(the)X
2482(parser)X
2730(to)X
2833(return)X
3077(to)X
3180(a)X
3253(point)X
3469(in)X
3572(the)X
3714(grammar)X
576 3712(which)N
830(had)X
996(already)X
1294(requested)X
1671(backtracking.)X
2210(This)X
2407(nested)X
2672(invocation)X
3085(poses)X
3320(no)X
3448(problem)X
3782(from)X
3993(a)X
576 3840(theoretical)N
971(point)X
1175(of)X
1270(view,)X
1485(but)X
1620(can)X
1764(cause)X
1981(unexpected)X
2404(parsing)X
2685(delays)X
2932(in)X
3023(practice.)X
3 f
576 4096(3.2.5.)N
818(Grammar)X
1221(Fragments)X
1648(within)X
1910(Syntactic)X
2279(Predicates)X
1 f
776 4252(The)N
949(grammar)X
1303(fragments)X
1691(within)X
7 f
1984(\()X
10 s
9 f
2037(a)X
11 s
7 f
2087(\)?)X
1 f
2229(may)X
2417(be)X
2536(any)X
2699(valid)X
2912(PCCTS)X
3218(production)X
3636(right-hand-)X
576 4380(side;)N
767(i.e.)X
899(any)X
1050(expression)X
1450(except)X
1704(new)X
1874(nonterminal)X
2325(de\256nitions.)X
10 s
9 f
2764(a)X
11 s
1 f
2837(may)X
3012(contain)X
3295(semantic)X
3632(actions)X
3905(and)X
576 4508(semantic)N
912(predicates,)X
1313(although)X
1644(only)X
1823(the)X
1953(semantic)X
2289(predicates)X
2668(will)X
2828(be)X
2933(executed)X
3268(during)X
3520(prediction.)X
3 f
576 4764(3.2.6.)N
818(Ef\256ciency)X
1 f
776 4920(In)N
875(terms)X
1097(of)X
1196(ef\256ciency,)X
1591(the)X
1725(order)X
1936(of)X
2035(alternative)X
2434(productions)X
2876(in)X
2971(a)X
3036(decision)X
3356(is)X
3442(signi\256cant.)X
3881(Pro-)X
576 5048(ductions)N
911(in)X
1015(a)X
1089(PCCTS)X
1394(grammar)X
1747(are)X
1889(always)X
2168(attempted)X
2552(in)X
2656(the)X
2799(order)X
3019(speci\256ed.)X
3411(For)X
3568(example,)X
3924(the)X
576 5176(parsing)N
865(strategy)X
1174(outline)X
1450(above)X
1690(indicates)X
2035(that)X
2199(the)X
2338(following)X
2712(rule)X
2880(is)X
2970(most)X
3173(ef\256cient)X
3493(when)X
10 s
9 f
3712(g)X
7 s
1 f
3745 5192(1)N
11 s
3810 5176(is)N
3900(less)X
576 5304(complex)N
902(than)X
10 s
9 f
1074(g)X
7 s
1 f
1107 5320(2)N
11 s
1141 5304(.)N
7 f
9 s
576 5468(a)N
756(:)X
928(\()X
10 s
9 f
971(g)X
1 f
7 s
1004 5484(1)N
7 f
9 s
1038 5468(\)?)N
9 f
748 5556(|)N
10 s
891(g)X
1 f
7 s
924 5572(2)N
7 f
9 s
756 5644(;)N
12 p
%%Page: 12 12
9 s 0 xH 0 xS 7 f
11 s
1 f
2209 416(-)N
2260(12)X
2370(-)X
776 704(Any)N
953(parsing)X
1238(decisions)X
1592(made)X
1809(inside)X
2047(a)X
7 f
2144(\(..\)?)X
1 f
2436(block)X
2659(are)X
2793(made)X
3011 0.2305(deterministically)AX
3633(unless)X
3880(they)X
576 832(themselves)N
990(are)X
1119(pre\256xed)X
1429(with)X
1608(syntactic)X
1944(predicates.)X
2367(For)X
2511(example,)X
7 f
9 s
576 996(a)N
756(:)X
936(\()X
1022(\(A\)+)X
1237(X)X
9 f
1323(|)X
7 f
1380(\(B\)+)X
1595(X)X
1681(\)?)X
9 f
756 1084(|)N
7 f
936(\(A\)*)X
1151(Y)X
756 1172(;)N
1 f
11 s
576 1376(speci\256es)N
901(that)X
1056(the)X
1186(parser)X
1422(should)X
1679(attempt)X
1967(to)X
2058(match)X
2296(the)X
2426(nonpredicated)X
2947(subrule)X
7 f
9 s
756 1540(\()N
936(\(A\)+)X
1151(X)X
9 f
756 1628(|)N
7 f
936(\(B\)+)X
1151(X)X
756 1716(\))N
1 f
11 s
576 1920(using)N
803(normal)X
1089(the)X
1233(normal)X
1519(\256nite-lookahead)X
2128(parsing)X
2423(strategy.)X
2782(If)X
2876(a)X
2952(sentence)X
3292(recognizable)X
3779(by)X
3904(this)X
576 2048(grammar)N
919(fragment)X
1262(is)X
1346(found)X
1576(on)X
1689(the)X
1822(input)X
2029(stream,)X
2310(then)X
2486(restore)X
2749(the)X
2881(state)X
3067(of)X
3164(the)X
3296(parser)X
3534(to)X
3627(what)X
3822(it)X
3896(was)X
576 2176(before)N
824(the)X
956(predicate)X
1303(invocation)X
1700(and)X
1852(parse)X
2062(the)X
2195(grammar)X
2538(fragment)X
2881(again;)X
3122(else,)X
3306(if)X
3385(the)X
3518(attempt)X
3809(failed,)X
576 2304(apply)N
794(the)X
924(next)X
1098(production)X
1502(in)X
1593(the)X
1723(outer)X
1926(block:)X
7 f
9 s
576 2468(\(A\)*)N
791(Y)X
3 f
11 s
576 2772(3.2.7.)N
818(Resolving)X
1207(Ambiguous)X
1659(C++)X
1844(Statements)X
1 f
776 2928(Quoting)N
1090(from)X
1286(Ellis)X
1474(and)X
1626(Stroustrup)X
2018([``The)X
2267(Annotated)X
2659(C++)X
2843(Reference)X
3224(Manual,'')X
3599(Margaret)X
3947(A.)X
576 3056(Ellis)N
782(and)X
952(Bjarne)X
1230(Stroustrup,)X
1662(Addison)X
2003(Wesley)X
2310(Publishing)X
2731(Company;)X
3141(Reading,)X
3499(Massachusetts;)X
576 3184(1990],)N
776 3340(``There)N
1064(is)X
1148(an)X
1256(ambiguity)X
1640(in)X
1735(the)X
1869(grammar)X
2213(involving)X
2 f
2578(expression-statements)X
1 f
3381(and)X
2 f
3534(declara-)X
776 3468(tions)N
1 f
948(...)X
1041(The)X
1205(general)X
1491(cases)X
1702(cannot)X
1963(be)X
2072(resolved)X
2396(without)X
2692(backtracking...)X
3239(In)X
3338(particular,)X
3724(the)X
776 3596(lookahead)N
1160(needed)X
1431(to)X
1522(disambiguate)X
2015(this)X
2165(case)X
2338(is)X
2419(not)X
2554(limited.'')X
576 3752(The)N
735(authors)X
1016(use)X
1155(the)X
1285(following)X
1650(examples)X
2005(to)X
2096(make)X
2309(their)X
2493(point:)X
7 f
9 s
576 3916(T\(*a\)->m=7;)N
1264(//)X
2 f
1393(expression-statement)X
7 f
576 4004(T\(*a\)\(int\);)N
1264(//)X
2 f
1393(declaration)X
1 f
11 s
576 4208(Clearly,)N
880(the)X
1010(two)X
1164(types)X
1372(of)X
1467(statements)X
1862(are)X
1991(not)X
2126(distinguishable)X
2683(from)X
2876(the)X
3006(left)X
3146(as)X
3241(an)X
3346(arbitrary)X
3671(amount)X
3959(of)X
576 4336(symbols)N
893(may)X
1068(be)X
1174(seen)X
1353(before)X
1600(a)X
1661(decision)X
1977(can)X
2121(be)X
2226(made;)X
2464(here,)X
2659(the)X
7 f
2820(->)X
1 f
2948(symbol)X
3230(is)X
3311(the)X
3441(\256rst)X
3600(clue)X
3769(that)X
3924(the)X
576 4464(\256rst)N
735(example)X
1056(is)X
1137(a)X
1198(statement.)X
1603(Quoting)X
1914(Ellis)X
2099(and)X
2248(Stroustrup)X
2637(further,)X
776 4620(``In)N
929(a)X
990(parser)X
1226(with)X
1405(backtracking)X
1882(the)X
2012(disambiguating)X
2579(rule)X
2738(can)X
2882(be)X
2987(stated)X
3215(very)X
3393(simply:)X
776 4748([1])N
900(If)X
980(it)X
1052(looks)X
1265(like)X
1420(a)X
2 f
1481(declaration)X
1 f
1888(,)X
1932(it)X
2004(is;)X
2110(otherwise)X
776 4876([2])N
900(if)X
976(it)X
1048(looks)X
1261(like)X
1416(an)X
2 f
1521(expression)X
1 f
1897(,)X
1941(it)X
2013(is;)X
2119(otherwise)X
776 5004([3])N
900(it)X
972(is)X
1053(a)X
1114(syntax)X
1366(error.'')X
576 5160(The)N
735(solution)X
1042(in)X
1133(PCCTS)X
1425(using)X
1638(syntactic)X
1974(predicates)X
2353(is)X
2434(simply:)X
7 f
9 s
576 5324(stat:)N
920(\(declaration\)?)X
9 f
748 5412(|)N
7 f
891(expression)X
748 5500(;)N
1 f
11 s
576 5704(The)N
734(semantics)X
1103(of)X
1197(rule)X
7 f
1386(stat)X
1 f
1619(are)X
1747(exactly)X
2023(that)X
2177(of)X
2271(the)X
2401(quoted)X
2663(solution.)X
3014(The)X
3173(production)X
7 f
3608(declara-)X
576 5832(tion)N
1 f
816(will,)X
1004(however,)X
1356(be)X
1467(recognized)X
1881(twice)X
2100(upon)X
2304(a)X
2371(valid)X
2576(declaration)X
2996(and)X
3150(once)X
3343(upon)X
3546(an)X
3656(expression)X
13 p
%%Page: 13 13
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(13)X
2370(-)X
576 704(to)N
667(decide)X
919(that)X
1074(it)X
1146(is)X
1227(not)X
1362(a)X
1423(declaration.)X
3 f
576 960(3.2.8.)N
818(Revisiting)X
1217(the)X
1356(ML)X
1520(Example)X
1 f
776 1116(To)N
902(illustrate)X
1240(the)X
1376(utility)X
1617(of)X
1718(the)X
1854(full)X
2005(form)X
2204(of)X
2305(syntactic)X
2647(predicates,)X
3054(reconsider)X
3448(the)X
3584(grammar)X
3930(for)X
576 1244(the)N
706(ML-style)X
1056(statements)X
1451(provided)X
1786(in)X
1877(the)X
2007(example)X
2328(section)X
2600(above:)X
7 f
9 s
576 1408(stat:)N
936(list)X
1151("=")X
1323(list)X
1538(";")X
9 f
756 1496(|)N
7 f
936(list)X
1151(";")X
756 1584(;)N
1 f
11 s
576 1788(Rule)N
7 f
799(stat)X
1 f
1036(is)X
1120(not)X
2 f
10 s
1256(LL)X
1 f
11 s
1369(because)X
7 f
1703(list)X
1 f
1940(could)X
2162(be)X
2271(arbitrarily)X
2650(long)X
2833(and,)X
3008(hence,)X
3261(predicting)X
3645(which)X
3886(pro-)X
576 1916(duction)N
866(to)X
960(apply)X
1181(beforehand)X
1601(is)X
1685(impossible)X
2093(with)X
2275(a)X
2339(\256nite)X
2546(lookahead)X
2933(depth.)X
3197(There)X
3426(are)X
3557(two)X
3713(solutions)X
576 2044(in)N
670(using)X
886(syntactic)X
1225(predicates,)X
1630(one)X
1783(more)X
1990(ef\256cient)X
2305(than)X
2483(the)X
2617(other.)X
2868(The)X
3031(\256rst)X
3194(method)X
3485(is,)X
3592(as)X
3691(before,)X
3963(to)X
576 2172(specify:)N
7 f
9 s
576 2336(stat:)N
936(\(list)X
1194("=")X
1366(list)X
1581(";"\)?)X
9 f
756 2424(|)N
7 f
936(list)X
1151(";")X
756 2512(;)N
1 f
11 s
576 2716(However,)N
946(this)X
1102(speci\256cation)X
1576(unnecessarily)X
2083(matches)X
2400(the)X
7 f
2567(list)X
1 f
2807(following)X
3178(the)X
3314(assignment)X
3739(operator)X
576 2844(twice.)N
833(A)X
918(more)X
1121(ef\256cient,)X
1454(but)X
1589(functionally)X
2038(equivalent,)X
2450(speci\256cation)X
2918(is)X
2999(as)X
3094(follows:)X
7 f
9 s
576 3008(stat:)N
936(\(list)X
1194("="\)?)X
1452(list)X
1667("=")X
1839(list)X
2054(";")X
9 f
756 3096(|)N
7 f
936(list)X
1151(";")X
756 3184(;)N
1 f
11 s
576 3388(This)N
756(description)X
1171(indicates)X
1508(that,)X
1686(as)X
1782(soon)X
1971(as)X
2067(the)X
7 f
2229("=")X
1 f
2411(has)X
2551(been)X
2740(seen,)X
2941(the)X
3073(\256rst)X
3234(production)X
3640(is)X
3723(uniquely)X
576 3516(predicted.)N
3 f
576 3772(3.2.9.)N
818(Syntactic)X
1187(Predicates)X
1600(Effect)X
1846(on)X
1961(Grammar)X
2364(Analysis)X
1 f
776 3928(ANTLR)N
1097(still)X
1259(constructs)X
1644(normal)X
2 f
10 s
1921(LL)X
1 f
2022(\()X
2 f
2049(k)X
1 f
2091(\))X
11 s
2147(decisions)X
2504(throughout)X
2920(predicated)X
3316(parsers.)X
3637(Only)X
3842(when)X
576 4056(necessary)N
948(are)X
1086(arbitrary)X
1420(lookahead)X
1812(predictors)X
2194(used.)X
2429(Constructing)X
2 f
10 s
2913(LL)X
1 f
3014(\()X
2 f
3041(k)X
1 f
3083(\))X
11 s
3140(parsers)X
3418(is)X
3507(an)X
3620(exponential)X
576 4184(problem)N
895(that)X
1053(ANTLR)X
1371(goes)X
1557(to)X
1651(great)X
1852(lengths)X
2132(to)X
2226(avoid)X
2447(or)X
2545(reduce)X
2804(in)X
2898(size)X
3060(on)X
3173(average.)X
3516(Unfortunately,)X
576 4312(for)N
706(large)X
910(grammars)X
1290(and)X
2 f
10 s
1443(k)X
1 f
11 s
1507(values)X
1760(of)X
1860(more)X
2068(than)X
2247(2)X
2318(or)X
2418(3)X
2489(ANTLR)X
2809(can)X
2958(take)X
3132(an)X
3242(impractical)X
3667(amount)X
3959(of)X
576 4440(time.)N
800(Part)X
964(of)X
1059(the)X
1189(bene\256t)X
1451(of)X
7 f
1577(\(..\)?)X
1 f
1864(blocks)X
2116(is)X
2197(that,)X
2374(by)X
2484(de\256nition,)X
2867(they)X
3041(defy)X
2 f
10 s
3217(LL)X
1 f
3318(\()X
2 f
3345(k)X
1 f
3387(\))X
11 s
3436(analysis.)X
3786(Hence,)X
576 4568(the)N
716(exponential,)X
1182(full)X
2 f
10 s
1335(LL)X
1 f
1436(\()X
2 f
1463(k)X
1 f
1505(\))X
11 s
1564(grammar)X
1914(analysis)X
2230(is)X
2321(turned)X
2578(off)X
2712(for)X
2846(any)X
3005(production)X
3419(beginning)X
3804(with)X
3993(a)X
576 4696(syntactic)N
917(predicate.)X
1311(In)X
1411(its)X
1522(place,)X
1757(a)X
1823(linear)X
2051(approximation)X
2594(to)X
2 f
10 s
2689(LL)X
1 f
2790(\()X
2 f
2817(k)X
1 f
2859(\))X
11 s
2914(analysis,)X
3248(called)X
2 f
10 s
3485(LL)X
1 f
7 s
3582 4664(1)N
10 s
3616 4696(\()N
2 f
3643(k)X
1 f
3685(\))X
11 s
3712(,)X
3762(is)X
3849(used.)X
576 4824(This)N
756(reduces)X
1047(the)X
1178(number)X
1470(of)X
1566(times)X
1781(that)X
1937(arbitrary)X
2263(lookahead)X
7 f
2679(\(..\)?)X
1 f
2967(blocks)X
3220(are)X
3349(attempted)X
3720(unneces-)X
576 4952(sarily,)N
816(though)X
1083(no)X
1193(\256nite)X
1397(lookahead)X
1781(decision)X
2097(is)X
2178(actually)X
2480(required)X
2795(as)X
2890(the)X
3020(arbitrary)X
3345(lookahead)X
3729(mechan-)X
576 5080(ism)N
726(will)X
886(accurately)X
1270(predict)X
1537(the)X
1667(production.)X
776 5236(If)N
865(the)X
1004(current)X
1284(\256nite)X
1497(lookahead)X
1890(can)X
2043(predict)X
2319(which)X
2565(production)X
2978(to)X
3079(apply,)X
3329(syntactic)X
3675(predicates)X
576 5364(are)N
722(not)X
874(evaluated.)X
1294(For)X
1454(example,)X
1813(referring)X
2158(to)X
2265(the)X
2411(C++)X
2608(declaration)X
3038(versus)X
3300(expression)X
3714(grammar)X
576 5492(example)N
902(above,)X
1161(if)X
1243(the)X
1379(current)X
1656(input)X
1866(token)X
2090(were)X
7 f
2319(42)X
1 f
2425(,)X
2475(rule)X
7 f
2671(stat)X
1 f
2911(would)X
3159 0.3187(immediately)AX
3630(attempt)X
3924(the)X
576 5620(second)N
852(production)X
1256(\320)X
7 f
1407(expression)X
1 f
1937(.)X
2013(On)X
2152(the)X
2292(other)X
2504(hand,)X
2728(if)X
2813(the)X
2952(current)X
3232(input)X
3445(token)X
3672(were)X
7 f
3904(ID)X
1 f
4010(,)X
576 5748(then)N
753(the)X
7 f
917(declaration)X
1 f
1525(rule)X
1687(would)X
1933(be)X
2042(attempted)X
2417(before)X
2667(attempting)X
7 f
3103(expression)X
1 f
3633(.)X
3703(If)X
3787(neither)X
576 5876(productions)N
1014(successfully)X
1466(match)X
1704(the)X
1834(input,)X
2060(a)X
2121(syntax)X
2373(occurs.)X
14 p
%%Page: 14 14
11 s 0 xH 0 xS 1 f
2209 416(-)N
2260(14)X
2370(-)X
776 704(When)N
1009(constructing)X
1468(\256nite)X
1673(lookahead)X
2058(sets,)X
2235(the)X
2367(grammar)X
2709(fragment)X
3051(within)X
3301(the)X
7 f
3464(\(..\)?)X
1 f
3753(block)X
3973(is)X
576 832(ignored.)N
911(In)X
1006(other)X
1209(words,)X
2 f
10 s
1465(FIRST)X
7 s
1674 848(k)N
1 f
10 s
1705 832(\(\()N
9 f
1759(a)X
1 f
1809(\)?)X
9 f
1892(b)X
1 f
1936(\))X
11 s
1985(is)X
2 f
10 s
2064(FIRST)X
7 s
2273 848(k)N
1 f
10 s
2304 832(\()N
9 f
2331(b)X
1 f
2375(\))X
11 s
2402(.)X
3 f
576 1088(3.2.10.)N
862(The)X
1031(Effect)X
1277(of)X
1372(Nondeterminism)X
2024(upon)X
2237(Translation)X
2700(and)X
2864(Semantic)X
3233(Predicates)X
1 f
776 1244(Syntactic)N
1137(predicates)X
1526(are,)X
1687(by)X
1807(de\256nition,)X
2200(not)X
2346(guaranteed)X
2765(to)X
2867(match)X
3116(the)X
3257(current)X
3539(input.)X
3798(There-)X
576 1372(fore,)N
766(actions)X
1043(with)X
1227(side-effects,)X
1680(for)X
1808(which)X
2049(no)X
2163(``undo'')X
2481(exists,)X
2730(cannot)X
2991(be)X
3100(executed)X
3439(during)X
3695(nondeter-)X
576 1500(ministic)N
892(syntactic)X
1236(prediction)X
1624(\(``guess'')X
1994(mode\).)X
2293(This)X
2480(section)X
2760(describes)X
3118(how)X
3300(ANTLR)X
3624(handles)X
3924(the)X
576 1628(execution)N
941(of)X
1036(user-supplied)X
1532(actions)X
1804(and)X
1953(semantic)X
2289(predicates.)X
3 f
576 1884(3.2.10.1.)N
928(The)X
1097(Effect)X
1343(upon)X
1556(User)X
1753(Actions)X
1 f
776 2040(PCCTS)N
1072(language)X
1416(speci\256cations)X
1922(do)X
2036(not)X
2175(allow)X
2397(the)X
2531(execution)X
2900(of)X
2999(any)X
3152(semantic)X
3493(action)X
3736(during)X
3993(a)X
576 2168(syntactic)N
918(prediction)X
1304(as)X
1405(no)X
1521(undo)X
1725(mechanism)X
2155(exists;)X
2409(this)X
2564(conservative)X
3036(scheme)X
3327(avoids)X
3584(affecting)X
3924(the)X
576 2296(parser)N
812(state)X
996(in)X
1087(an)X
1192(irreversible)X
1615(manner.)X
1945(The)X
2104(only)X
2283(exception)X
2648(to)X
2739(this)X
2890(rule)X
3050(is)X
3132(that)X
3288 0.3317(initialization)AX
3760(actions,)X
576 2424(which)N
819(usually)X
1102(de\256ne)X
1345(variables)X
1691(visible)X
1955(to)X
2052(the)X
2187(entire)X
2415(rule/function,)X
2920(are)X
3054(not)X
3194(enclosed)X
3529(in)X
7 f
3656(if)X
3820({..})X
1 f
576 2552(statements)N
974(to)X
1068(``gate'')X
1356(them)X
1558(out;)X
1721(hence,)X
1973 0.3317(initialization)AX
2447(actions)X
2722(with)X
2904(side)X
3072(effects)X
3332(must)X
3530(be)X
3639(avoided)X
3944(by)X
576 2680(the)N
706(PCCTS)X
998(user.)X
3 f
576 2936(3.2.10.2.)N
928(The)X
1097(Effect)X
1343(upon)X
1556(Semantic)X
1925(Predicates)X
1 f
776 3092(Semantic)N
1146(predicates)X
1544(are)X
1692(always)X
1977(evaluated)X
2356(because)X
2675(they)X
2868(are)X
3016(restricted)X
3385(to)X
3496(side-effect-free)X
576 3220(expressions.)N
1066(During)X
1350(arbitrary)X
1688(lookahead)X
2085(prediction,)X
2500(the)X
2643(semantic)X
2992(predicates)X
3384(that)X
3552(are)X
3694(evaluated)X
576 3348(must)N
774(be)X
883(functions)X
1237(of)X
1336(values)X
1587(computed)X
1961(when)X
2177(actions)X
2453(were)X
2649(turned)X
2900(on.)X
3058(For)X
3206(example,)X
3553(if)X
3634(your)X
3822(gram-)X
576 3476(mar)N
738(has)X
880(a)X
944(predicate)X
1291(that)X
1448(examines)X
1805(the)X
1937(symbol)X
2221(table,)X
2439(all)X
2552(symbols)X
2870(needed)X
3143(to)X
3236(direct)X
3461(the)X
3593(parse)X
3802(during)X
576 3604(prediction)N
967(must)X
1172(be)X
1288(entered)X
1581(into)X
1753(the)X
1895(table)X
2101(before)X
2359(prediction)X
2751(has)X
2902(begun.)X
3195(Consider)X
3547(the)X
3689(following)X
576 3732(grammar)N
916(fragment)X
1256(which)X
1493(recognizes)X
1891(simpli\256ed)X
2267(C)X
2348(declarations.)X
7 f
9 s
576 3896(decl:)N
936("typedef")X
1366(type)X
1581(declarator)X
2054(";")X
3096(/*)X
3225(define)X
3526(new)X
3698(type)X
3913(*/)X
9 f
756 3984(|)N
7 f
936(\()X
1022(type)X
1237(declarator)X
1710("\\{")X
1925(\)?)X
2054(type)X
2269(declarator)X
2742(func_body)X
3276(/*)X
3405(define)X
3706(function)X
4093(*/)X
9 f
756 4072(|)N
7 f
936(type)X
1151(declarators)X
1667(";")X
3096(/*)X
3225(def/decl)X
3612(var\(s\))X
3913(*/)X
756 4160(;)N
576 4336(type:)N
936(built_in_type)X
9 f
756 4424(|)N
7 f
936 -0.1960(<>?)AX
1968(ID)X
756 4512(;)N
576 4688(declarator)N
756 4776(:)N
936(...)X
936 4864(/*)N
1065(recognizes)X
1538(a)X
1624(declarator)X
2097(such)X
2312(as)X
2441(``array[3]'')X
3000(*/)X
936 4952(/*)N
1065(add)X
1237(symbols,)X
1624(both)X
1839(types)X
2097(and)X
2269(vars,)X
2527(to)X
2656(the)X
2828(symbol)X
3129(table)X
3387(*/)X
756 5040(;)N
1 f
11 s
576 5244(This)N
757(rule)X
918(is)X
1001(unnecessarily)X
1504(inef\256cient,)X
1908(but)X
2045(will)X
2207(illustrate)X
2541(the)X
2674(evaluation)X
3067(of)X
3165(semantic)X
3504(predicates)X
3886(dur-)X
576 5372(ing)N
718(nondeterministic)X
1341(prediction.)X
1772(For)X
1922(the)X
2058(purposes)X
2398(of)X
2499(our)X
2644(discussion,)X
3061(we)X
3191(restrict)X
3464(new)X
3638(types)X
3852(to)X
3949(be)X
576 5500(introduced)N
979(using)X
1196(a)X
7 f
1292(typedef)X
1 f
1689(\(structures)X
2086(and)X
2239(unions)X
2500(are)X
2633(not)X
2772(allowed\).)X
3150(Consider)X
3495(the)X
3630(recognition)X
576 5628(of)N
671(the)X
801(two)X
955(sentences:)X
15 p
%%Page: 15 15
11 s 0 xH 0 xS 1 f
9 s
7 f
1 f
2226 376(-)N
2268(15)X
2358(-)X
7 f
576 712(typedef)N
920(int)X
1092(My_int;)X
576 800(My_int)N
877(i;)X
1 f
11 s
576 1004(The)N
739(\256rst)X
902(production)X
1310(of)X
1409(rule)X
7 f
1603(decl)X
1 f
1841(will)X
2005(match)X
2247(the)X
2382(\256rst)X
2546(sentence,)X
2898(adding)X
7 f
3196(My_int)X
1 f
3541(to)X
3637(the)X
3772(symbol)X
576 1132(table)N
778(as)X
881(a)X
950(type)X
1132(name.)X
1397(Production)X
1813(two)X
1974(of)X
7 f
2107(decl)X
1 f
2348(attempts)X
2677(to)X
2775(match)X
3020(the)X
3157(second)X
3430(sentence)X
3762(with)X
3948(its)X
576 1260(syntactic)N
918(predicate.)X
1313(Rule)X
7 f
1539(type)X
1 f
1779(is)X
1866(entered,)X
2175(which)X
2418(evaluates)X
7 f
2806 0.1985(is_type\(LATEXT\(1\)\))AX
1 f
3789(\(where)X
7 f
576 1388(is_type\(\))N
1 f
1075(is)X
1156(some)X
1364(user-de\256ned)X
1820(function)X
2136(that)X
2291(looks)X
2504(up)X
2614(its)X
2720(symbol)X
3002(argument)X
3357(in)X
3448(the)X
3578(symbol)X
3860(table)X
576 1516(and)N
729(returns)X
999(true)X
1162(if)X
1242(that)X
1401(symbol)X
1687(is)X
1772(de\256ned)X
2057(and)X
2210(is)X
2295(a)X
2360(type\).)X
2611(Because)X
2930(the)X
3065(text)X
3225(of)X
3325(the)X
3460(current)X
3736(token)X
3959(of)X
576 1644(lookahead,)N
7 f
1015(My_int)X
1 f
1333(,)X
1379(is)X
1462(a)X
1525(valid)X
1725(type,)X
1922(the)X
2053(predicate)X
2399(evaluates)X
2750(to)X
2842(true.)X
3046(Production)X
3456(two)X
3611(of)X
7 f
3738(type)X
1 f
3973(is)X
576 1772(applicable)N
973(semantically)X
1455(and)X
1617(is,)X
1733(therefore,)X
2107(applied.)X
2446(After)X
2666(consuming)X
7 f
3119(My_int)X
1 f
3437(,)X
3494(the)X
3637(parser)X
3886(suc-)X
576 1900(cessfully)N
915(applies)X
7 f
1222(declarator)X
1 f
1778(to)X
7 f
1904(i)X
1 f
1957(.)X
2027(The)X
2190(next)X
2368(input)X
2576(token)X
2797(is)X
7 f
2912(;)X
1 f
2990(which)X
3230(does)X
3416(not)X
3554(match)X
3826(.)X
3895(The)X
576 2028(nondeterministic)N
1192(prediction)X
1572(fails)X
1746(and)X
1895(production)X
2299(three)X
2497(is)X
2578(predicted)X
2928(by)X
3038(default)X
3305(and)X
3454(is)X
3535(applied.)X
776 2184(The)N
935(second)X
1201(production)X
1605(of)X
1700(rule)X
7 f
1890(decl)X
1 f
2124(could)X
2342(not)X
2477(be)X
2582(rewritten)X
2922(as)X
7 f
9 s
576 2348(\()N
662(type)X
877(declarator)X
1350(func_body)X
1836(\)?)X
2016(/*)X
2145(define)X
2446(function)X
2833(*/)X
1 f
11 s
576 2552(because,)N
901(presumably,)X
1359(a)X
1423(func_body)X
1825(could)X
2047(de\256ne)X
2288(new)X
2460(types.)X
2716(The)X
2879(actions)X
3155(that)X
3314(add)X
3467(these)X
3674(new)X
3846(types)X
576 2680(to)N
673(the)X
809(symbol)X
1097(table)X
1297(would)X
1545(not)X
1686(be)X
1796(executed,)X
2158(however,)X
2509(as)X
2609(the)X
2744(parser)X
2985(would)X
3232(be)X
3342(in)X
3438(nondeterministic)X
576 2808(mode.)N
846(Although)X
1209(the)X
1347(semantic)X
1691(predicates)X
2079(would)X
2330(be)X
2444(evaluated)X
2813(correctly,)X
3179(the)X
3318(symbol)X
3609(table)X
3812(would)X
576 2936(not)N
713(hold)X
894(the)X
1026(information)X
1467(necessary)X
1832(to)X
1925(parse)X
2134(the)X
2266(function)X
2583(body)X
2782(during)X
3035(nondeterministic)X
3652(prediction.)X
576 3064(Also,)N
789(this)X
942(revision)X
1251(is)X
1335(very)X
1516(inef\256cient)X
1899(as)X
1997(it)X
2072(would)X
2317(match)X
2559(the)X
2693(entire)X
2920(function,)X
3262(which)X
3503(could)X
3725(be)X
3834(large,)X
576 3192(twice.)N
3 f
576 3448(3.2.11.)N
862(Comparing)X
1314(the)X
1453(Use)X
1611(of)X
1706(Semantic)X
2075(and)X
2239(Syntactic)X
2608(Predicates)X
1 f
776 3604(Language)N
1152(constructs)X
1538(exists)X
1768(that)X
1930(are)X
2066(totally)X
2322(ambiguous)X
2738(syntactically,)X
3236(but)X
3379(easily)X
3615(distinguish-)X
576 3732(able)N
751(semantically.)X
1270(For)X
1420(example,)X
1769(array)X
1977(references)X
2365(and)X
2520(function)X
2842(calls)X
3032(in)X
3129(Fortran)X
3415(are)X
3549(identical)X
3881(syn-)X
576 3860(tactically,)N
950(but)X
1090(very)X
1273(different)X
1603(semantically.)X
2121(The)X
2285(associated)X
2675(grammatical)X
3145(description)X
3565(is)X
3652(non-)X
2 f
10 s
3813(LL)X
1 f
3914(\()X
2 f
3941(k)X
1 f
3983(\))X
11 s
4010(,)X
576 3988(non-)N
2 f
10 s
737(LALR)X
1 f
936(\()X
2 f
963(k)X
1 f
1005(\))X
11 s
1032(,)X
1091(and)X
1255(non-context-free;)X
1903(not)X
2053(even)X
2256(backtracking)X
2748(or)X
2857(in\256nite)X
3144(lookahead)X
3542(will)X
3716(help)X
3904(this)X
576 4116(problem.)N
7 f
9 s
576 4280(expratom:)N
1092(ID)X
1221("\\\(")X
1436(expr_list)X
1866("\\\)")X
9 f
920 4368(|)N
7 f
1063(ID)X
1192("\\\(")X
1407(expr_list)X
1837("\\\)")X
877 4456(...)N
920 4544(;)N
1 f
11 s
576 4748(where)N
7 f
846(expr_list)X
1 f
1348(is)X
1432(some)X
1643(rule)X
1806(matching)X
2161(a)X
2226(comma-separated)X
2873(expression)X
3275(list.)X
3454(Putting)X
7 f
3767(\(..\)?)X
1 f
576 4876(around)N
852(the)X
992(\256rst)X
1161(alternative)X
1566(production)X
1980(will)X
2150(not)X
2295(change)X
2576(the)X
2715(fact)X
2878(that)X
3042(both)X
3230(productions)X
3677(match)X
3924(the)X
576 5004(same)N
795(sentence.)X
1180(However,)X
1561(semantic)X
1913(predicates)X
2308(may)X
2498(be)X
2620(used)X
2820(to)X
2928(semantically)X
3414(disambiguate)X
3924(the)X
576 5132(rule:)N
7 f
9 s
576 5296(expratom:)N
1092 -0.1969(<>?)AX
2167(ID)X
2296("\\\(")X
2511(expr_list)X
2941("\\\)")X
9 f
920 5384(|)N
7 f
1063 -0.1964(<>?)AX