[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnubol: problem 11



In a message dated 12/22/99 6:19:34 PM EST, tej@melbpc.org.au writes:

<< 
 /* problem 11. 
    - there is no natural delimiter in COBOL to handle panic mode
 error recovery from, like ';' '}' ')' in C
 
    solution 11
    - add in a magic token before any verb
 
 */
 
 %token tk_start_of_statement
  >>

This is a positively exquisite idea. 

I have two comments that you might consider. First, a verb is a unique enough 
token which is very likely to right the parser when it careens. If I 
understand information science well enough, your universal tk_start_of_stateme
nt actually has less content (less specificity)  then the verbs. You actually 
damage the cause. You want the next available token to have loads of content, 
you want it to bear real syntactic weight. You do not want it to be watered 
down.

Second, what if the error is that the verb is missing? (or misspelled?) But 
that question is just for fun.

I believe you really do not need this thing. The verbs themselves will do it 
for you. Furthermore, you are actually inserting a token into the stream; if 
I understand your comment. That has two implications, I think both are mildly 
bad.

There are a lot of verb occurences in a program, so you will be doing a lot 
of inserts.  That chews up CPU. The cache line(s) that have that leg of the 
parse tables are going to push other valuable material out of cache. 

During error recovery, bison is going to try to find three symbols in a row 
that parse. You are chewing up 1/3 of that with this insert.  I think that is 
a serious perturbation. That will take some figuring, but in effect I think 
you are reseting error recovery earlier that way - that is not necessarily 
wise.  (although the three in a row is a potshot, not especially aimed at a 
COBOL grammar).  

If there is any place that a specific verb is not a correct reset at position 
three in bison reset logic, you actually push it out of sight with this 
insert (that is you potentially create an horizon problem this way). Your 
magic token resets the parser, only to discover that VERBxyz should not 
follow.  There may be no such place, but if there is it is probably in the 
vicinity of disruption near a conditional clause and its potential implicit 
termination.  I think it would be hard to prove this particular extreme 
problem, but I don't think your token is necessary; and it carries some risk. 
 

It would be a silent operative, internally generated, pervasive, and I think 
it diminishes error recovery functionality.  I hope you will eventually 
entertain a suggestion to yank it.

Best Wishes
Bob Rayhawk
RKRayhawk@aol.com

--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.