std.d.lexer: pre-voting review / discussion

Martin Nowak code at dawg.eu
Thu Sep 12 13:03:30 PDT 2013


On 09/12/2013 05:39 PM, Timon Gehr wrote:
>
> Lookahead is realized as follows in the parser:
>
> (assume 'code' is the circular buffer range.)
>
> auto saveState(){muteerr++; return code.pushAnchor();} // saves the
> state and mutes all error messages until the state is restored
>
> void restoreState(Anchor state){ muteerr--; code.popAnchor(state); }
>
> The 'Anchor' is a trivial wrapper around a size_t. The circular buffer
> grows automatically to keep around tokens still reachable by an anchor.
> (The range only needs small constant space besides the buffer to support
> this functionality, though it is unable to detect usage errors.)

Do you think it's possible to use CircularBufferRange itself as anchor.
Then calling save() would return a CircularBufferRange and you canould 
scratch the two functions above. I had some promising experiments in 
that direction, but the implicit save on copy is annoying because you 
end up with anchors from temporary copies.


More information about the Digitalmars-d mailing list