Path: csiph.com!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: Kaz Kylheku <221-501-9011@kylheku.com> Newsgroups: comp.programming Subject: Re: Parsing and reporting errors? Date: Fri, 30 Sep 2016 22:50:05 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 35 Message-ID: <20160930154423.991@kylheku.com> References: <20160930085057.781@kylheku.com> <20160930104315.851@kylheku.com> NNTP-Posting-Host: OGJi3KNpFOhM58UHZwXj0w.user.gioia.aioe.org X-Complaints-To: abuse@aioe.org User-Agent: slrn/pre1.0.0-18 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.programming:6957 On 2016-09-30, Dmitry A. Kazakov wrote: > On 2016-09-30 19:46, Kaz Kylheku wrote: >> On 2016-09-30, Dmitry A. Kazakov wrote: > >>> Not really, normally the parser simply matches the source against the >>> current table of alternatives expected: >>> switch (Statements.Match (Source)) >>> { >> >> "the source" constitutes lookahead: the matcher has to peek into the >> stream a number of characters, which stay there if there is no match. > > In the sense that a source character might be tested several times. But > the current line is read into memory anyway. Yes, and that part of the current line not read into the parser's memory is in some stream buffer, and stuff not in the stream buffer is in the TCP windows of the network connection, etc. Any of it is "lookahead" or none, depending on how you define the word. > If the table uses hash that could be counted as a look-ahead too. But > usually look-ahead means something more substantial. Usually "lookahead" in the context of parsing refers to something meaningful in the parsing algorithm, irrespective of underlying buffers and such. Specifically, "lookahead" refers to an item, or multiple items, which are understood to have been removed from the input stream and are under the control of the parsing algorithm. In many circumstances when the parsing algorithm must process more input, it must first process these lookahead items in preference to subsequent input. (That may be done by pushing back the lookahead items as characters back into the stream, if possible, or doing something else.)