Re: what's a "T_VARIABLE" ?

From: Date: Sat, 09 Dec 2000 09:39:11 +0000
Subject: Re: what's a "T_VARIABLE" ?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-29440@lists.php.net to get a copy of this message
Chris Lee writes: > ok, ok, I forgot the '$' but whats the error mean ? > > Parse error: parse error, expecting `T_VARIABLE' in > > is a helluva way of saying > > you forgot the '$' > > Chris Lee > Mediawaveonline.com It's just the parser saying 'I was expecting to see a variable here, but saw something else instead'. I'm not a compiler writer, but a quick Google search turned up this apparently relevant short post: http://compilers.iecc.com/comparch/article/00-09-157 From: etetz@my-deja.com Newsgroups: comp.compilers Date: 21 Sep 2000 18:13:36 -0400 Organization: Deja.com - Before you buy. Keywords: yacc, errors, comment (This is pretty heady newsgroup, so I'm almost embarrassed to post this question here. If there is a more appropriate group for this type of question, please let me know. OK, onto the question...) I used Flex and Bison to write an interpreter for a simple c-like language. When Bison encounters a syntax error it spits out "parse error". I want to give more descriptive error messages, such as "expecting semicolon after line 3". How would I go about this? The best I can think of so far is to create productions in my grammar for every bogus syntax I can think of, and generate errors when they are recognized. Is there a better way using these tools? Thanks! Eric [Not really. Yacc doesn't give you much help at error recovery. People have tried to do better error reports over the years, see the comp.compilers archives. -John] Zeev or Andi or one of the other core guys would have to give the definitive answer to this--but I'm not sure that this is easily/elegantly/inexpensively solved. -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.general (#29440) next »