Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

If I have not seen so far it is because I stood in giant's footsteps.


devel / comp.lang.c / Re: Get line number for a FILE *

SubjectAuthor
* Get line number for a FILE *Malcolm McLean
+* Get line number for a FILE *fir
|`* Get line number for a FILE *fir
| `* Get line number for a FILE *Malcolm McLean
|  `- Get line number for a FILE *fir
+* Get line number for a FILE *Bart
|`* Get line number for a FILE *Malcolm McLean
| +- Get line number for a FILE *fir
| `* Get line number for a FILE *Kaz Kylheku
|  `* Get line number for a FILE *Malcolm McLean
|   `* Get line number for a FILE *Ben Bacarisse
|    +* Get line number for a FILE *fir
|    |`- Get line number for a FILE *Ben Bacarisse
|    +* Get line number for a FILE *Malcolm McLean
|    |`* Get line number for a FILE *Kaz Kylheku
|    | `* Get line number for a FILE *Malcolm McLean
|    |  `- Get line number for a FILE *Kaz Kylheku
|    `* Get line number for a FILE *Malcolm McLean
|     `- Get line number for a FILE *Ben Bacarisse
+* Get line number for a FILE *fir
|`* Get line number for a FILE *fir
| `* Get line number for a FILE *fir
|  +- Get line number for a FILE *fir
|  `- Get line number for a FILE *fir
+- Get line number for a FILE *Scott Lurndal
+- Get line number for a FILE *Ben Bacarisse
`* Get line number for a FILE *Kaz Kylheku
 `- Get line number for a FILE *Spiros Bousbouras

Pages:12
Re: Get line number for a FILE *

<20230810083924.456@kylheku.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36624&group=comp.lang.c#36624

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Get line number for a FILE *
Date: Thu, 10 Aug 2023 15:40:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <20230810083924.456@kylheku.com>
References: <3f16229e-7043-4b52-a3bb-8b1428838a15n@googlegroups.com>
<ub2kn9$c6ds$2@dont-email.me>
<7a7790f8-0913-4d42-9376-73e885cd45afn@googlegroups.com>
Injection-Date: Thu, 10 Aug 2023 15:40:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c8ceb3884c73c57508aac2a066fd132c";
logging-data="453175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ua57Ax80K6PDlQj41aO9lWOCNvmfCHlk="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:VTFW8GH8QnISeTPQ/SemOiFOpr8=
 by: Kaz Kylheku - Thu, 10 Aug 2023 15:40 UTC

On 2023-08-10, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> On Thursday, 10 August 2023 at 13:21:12 UTC+1, Bart wrote:
>> Searching backwards from the token's offset, determines the line-number,
>> and offset with the line.
>>
> There's a strong case for doing that. If a file is read in as a string, then any IO
> erros can be dealt with in one place.

Only if you have lexical, syntax, type, semantic and all other error
checking that needs a line number all in one place, in one pass.

Re: Get line number for a FILE *

<53695cd3-146d-4288-9d84-f38e34bbf3cfn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36661&group=comp.lang.c#36661

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:2c07:0:b0:76c:69ac:a0f0 with SMTP id s7-20020a372c07000000b0076c69aca0f0mr6217qkh.4.1691722318098;
Thu, 10 Aug 2023 19:51:58 -0700 (PDT)
X-Received: by 2002:a05:6a00:1704:b0:687:41a1:640e with SMTP id
h4-20020a056a00170400b0068741a1640emr231020pfc.6.1691722317524; Thu, 10 Aug
2023 19:51:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 10 Aug 2023 19:51:56 -0700 (PDT)
In-Reply-To: <20230810083924.456@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:868:d0a4:2df0:ec16;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:868:d0a4:2df0:ec16
References: <3f16229e-7043-4b52-a3bb-8b1428838a15n@googlegroups.com>
<ub2kn9$c6ds$2@dont-email.me> <7a7790f8-0913-4d42-9376-73e885cd45afn@googlegroups.com>
<20230810083924.456@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <53695cd3-146d-4288-9d84-f38e34bbf3cfn@googlegroups.com>
Subject: Re: Get line number for a FILE *
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Injection-Date: Fri, 11 Aug 2023 02:51:58 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Fri, 11 Aug 2023 02:51 UTC

On Thursday, 10 August 2023 at 16:40:40 UTC+1, Kaz Kylheku wrote:
> On 2023-08-10, Malcolm McLean <malcolm.ar...@gmail.com> wrote:
> > On Thursday, 10 August 2023 at 13:21:12 UTC+1, Bart wrote:
> >> Searching backwards from the token's offset, determines the line-number,
> >> and offset with the line.
> >>
> > There's a strong case for doing that. If a file is read in as a string, then any IO
> > erros can be dealt with in one place.
> Only if you have lexical, syntax, type, semantic and all other error
> checking that needs a line number all in one place, in one pass.
>
The "lexer" is fgetc(). You can tell because the code makes large numbers of ungetc()
calls. I'm rewriting it any way. Maybe I should do a complete rewrite to have a
proper lexer with a "gettoken()" and "match()" function. Then, as you say, all calls
to fgetc() will be in the same place, and it becomes easy to count lines and columns.

The main problem with a lexer for XML is that the grammar specifies "anything except
a special characer" for the data between nodes. So either you have to have a special
mode, so the lexer isn't really a lexer any more, or the tokens have to be single characters
anyway.

IO errors are of a different nature to parse errors. By far the most likely IO error is
failure to open the file because the wrong name was provided. But any call to
fgetc() can return EOF. If you load all the data as a string in a first pass, then
you pick up any IO errors, and further ones are not possible.

Re: Get line number for a FILE *

<RGzeoTxZngQiZgoTG@bongo-ra.co>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=36662&group=comp.lang.c#36662

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.c
Subject: Re: Get line number for a FILE *
Date: Fri, 11 Aug 2023 05:38:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <RGzeoTxZngQiZgoTG@bongo-ra.co>
References: <3f16229e-7043-4b52-a3bb-8b1428838a15n@googlegroups.com> <20230810081407.945@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 11 Aug 2023 05:38:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3a8c36ec1363fec05f45e9485a21b02f";
logging-data="791953"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/e3Ka4SP6zO+37DIpAlX69"
Cancel-Lock: sha1:UclFZZPMZ8pz7gXmH4V75pTQZm0=
X-Organisation: Weyland-Yutani
In-Reply-To: <20230810081407.945@kylheku.com>
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Fri, 11 Aug 2023 05:38 UTC

On Thu, 10 Aug 2023 15:38:47 -0000 (UTC)
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> On 2023-08-10, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> > Just adding some better error reporting to my XML parser.
> >
> > I started out by keeping track of the line number as I went. But of
> > course that's very fiddly.
>
> It's only slightly fiddly if you have to recognize tokens that can
> contain embedded newlines.

I load the whole file into memory and , as I do so , I also recognise ends of
lines and create an array where line_numbers[i] = j means that the line
number i starts at byte j .So I can get from a byte number to a line number
by a binary search. All further parsing is done after I have the whole file
in memory.

> In a language in which a newline only occurs in a comment, or
> whitespace, you can have a couple of dedicated tokenizing rules
> which increment the line number.
>
> You attach the current line number to all token objects and then
> the parser can just refer to them.
>
> If you allow tokens with newlines like
>
> "multi
> line
> literal"
>
> by a single token match that gobbles newlines, you then need
> some slight fiddling, like walking the lexeme of that object after
> it is extracted and bumping the line number for each newline
> that occurs.

[...]

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor