Re: Further C++ operators for position

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
hi Matthew,

> Le 5 nov. 2019 à 02:10, Matthew Fernandez <[email protected]> a écrit :
> 
>> On Nov 4, 2019, at 12:16, Hans Åberg <[email protected]> wrote:
>> 
>>> On 4 Nov 2019, at 18:12, Akim Demaille <[email protected]> wrote:
>>> 
>>> In addition, think of C where you also have main.c that #include "foo.h" somewhere, which results in main.c:1 (i.e., line 1) < foo.h:1 < ... < foo.h:42 < ... < main.c:3.
> 
> The language I am parsing has no #include mechanism, so I did not consider two positions with different filenames to be comparable. I don’t think you could immediately handle comparing positions with different filenames using the present data structures because, e.g., you could #include the same file twice.

Which is also part of my point :)


>>> If we want a total order here, it's actually easy: positions should have a counter somewhere which is the *total* "offset" since the first byte of the first file.  Or something like that.
> 
> Is it? What if you parsed two separate input sources? It makes no sense to order a position in one file with respect to a position in the other.

Maybe I should have used the word "offset" here, which was to read together with the "*total*" before it.

What I mean is a unique counter you increment each time you read a char, whatever the file.  Printed after @ below.

main.c:1@1 < foo.h:1@16 < ... < foo.h:42@1010 < ... < main.c:3@2020.

etc.

Cheers!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.