Re: I need answer to a simple YACC question.

megatest!djones@decwrl.dec.com (Dave Jones)
24 Feb 89 23:08:15 GMT

          From comp.compilers

Related articles
I need answer to a simple YACC question. hp-sdd!najmi@hpcuhb.HP.COM (1989-02-03)
Re: I need answer to a simple YACC question. djones@megatest.uucp (1989-02-07)
Re: I need answer to a simple YACC question. oakhill!epsilon!steve@cs.utexas.edu (1989-02-16)
Re: I need answer to a simple YACC question. megatest!djones@decwrl.dec.com (1989-02-24)
Re: I need answer to a simple YACC question. megatest!djones@decwrl.dec.com (1989-02-24)
| List of all articles for this month |

From: megatest!djones@decwrl.dec.com (Dave Jones)
Newsgroups: comp.compilers
Date: 24 Feb 89 23:08:15 GMT
References: <3359@ima.ima.isc.com>
Organization: Megatest Corporation, San Jose, Ca

Sorry to keep harping at this, but I thought I would add one more
point: The error in the proposed print-follow-set-on-syntax-error
routines posted is a serious one.


For example, consider the this mistake that a C programmer might
make when trying to write a Pascal program:




      program foo;
            int i;
------^--- Syntax error. Found IDENTIFIER. Expected "begin".
      begin
      end.




The hapless programmer will think that you can't declare
global variables in Pascal! Of course, it should have said,


        Expected "const", "function", "label", "procedure", "type",
        "var", or "begin".


What happened? There was a default reduction that "wrapped up"
the declaration section if a declaration keyword such as "var"
could not be shifted. The reduction was made, the compiler thinking
that "begin" just _has_ to be next, since none of the declaration
keywords is next.


Or how about this one?


      program foo;
          procedure bar; foward;
--------------------^--- Syntax error. Found IDENTIFIER. Expected "begin".


          [ stuff omited... ]
    begin
    end;


Having not found "forward", or a nonstandard directive such as
"external", it produced a procedure-header-with-semicolon. Oops.


Or this one?


      procedure blippy[ i: integer ];
-------------------^--- Syntax error. Found '['. Expected ';'.
      begin
      end;




Not finding an open-parenthesis, it decided there were no parameters,
and produced a procedure-header. A semicolon just _has_ to be
next now, right?


I could go on and on, but you get the idea.
[From megatest!djones@decwrl.dec.com (Dave Jones)]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.