Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border4.nntp.dca.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: laplante.p@gmail.com Newsgroups: comp.compilers Subject: Error message with bison and flex Date: Mon, 7 Apr 2014 22:36:46 -0700 (PDT) Organization: Compilers Central Lines: 17 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-04-005@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: miucha.iecc.com 1397139489 66628 2001:470:1f07:1126:0:676f:7373:6970 (10 Apr 2014 14:18:09 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 10 Apr 2014 14:18:09 +0000 (UTC) Keywords: yacc, errors Posted-Date: 10 Apr 2014 10:18:09 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Original-Bytes: 1623 Xref: csiph.com comp.compilers:1212 Sometime the text return from a syntax error is very short. I would like to output 5 lines before the error and 5 lines after the error. Is this possible without affecting the error message. If I used input to read the next 5 lins, the message won't be the same and I don't want to always accumulate the 5 lines before, it will add a lot of overhead to the lexical analyser. Tx [The way I'd do it would be to write my own YY_INPUT() that slurps in the whole file to a buffer when it starts and hands the input to the lexer a line at a time, so it knows what line it's on. If there's an error, it can then scan forward and backward in the file buffer to find the five lines each way. -John]