Proposal for SentinelInputRange
Dmitry Olshansky
dmitry.olsh at gmail.com
Thu Feb 28 08:48:44 PST 2013
28-Feb-2013 20:33, Walter Bright пишет:
> On 2/28/2013 7:38 AM, Dmitry Olshansky wrote:
>> 28-Feb-2013 14:44, Walter Bright пишет:
>>> On 2/28/2013 12:25 AM, Jacob Carlborg wrote:
>>>> On 2013-02-28 08:23, Walter Bright wrote:
>>>>
>>>>> There is always a terminating 0, even if the file ends in 0x1a.
>>>>>
>>>>> (The 0x1A comes from some old editors that end a file with a
>>>>> control Z.)
>>>>
>>>> http://dlang.org/lex.html, "End of File" shows this:
>>>>
>>>> EndOfFile:
>>>> physical end of the file
>>>> \u0000
>>>> \u001A
>>>>
>>>> Doesn't that mean that the input is empty if the file is empty, \u0000
>>>> or \u001A
>>>> is encountered?
>>>>
>>>
>>
>>
>>> Please follow the source code from file to input to the lexer.
>>
>> Source as spec is no good. Either change the spec or admit that
>> having a tuple
>> of sentinels as manifest constant is fine. In any case constant tuples
>> are
>> easily unrolled into case statements.
>
> The spec is correct, so is the code, and tuple sentinels are entirely
> unnecessary.
>
line 300:
case 0x1A: // ^Z means end of file
case 0:
break;
On the lines you noted it claimed that that 0x1a is outdate. Along with
the fact that you allocate filesize+2 and fill the last 2 bytes with zeros.
In any case I see 0 and 0x1a as 2 values that act like sentinels i.e. a
tuple. And this is what spec says - any one of them is a sentinel.
Correct me if I'm wrong.
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list