[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Texinfo command nesting and syntax checking: nested @ref
From: |
Gavin Smith |
Subject: |
Re: Texinfo command nesting and syntax checking: nested @ref |
Date: |
Wed, 18 Jan 2023 21:30:53 +0000 |
On Wed, Jan 18, 2023 at 11:52:33AM +0100, Patrice Dumas wrote:
> On Tue, Jan 17, 2023 at 09:26:54PM +0000, Gavin Smith wrote:
> > Disclaimer: this message is not immediately practical.
> >
> > One thing I've noticed is that direct nesting of @ref commands is diagnosed,
> > but indirect nesting is not:
>
> Indeed, this is a long-standing issue in texi2any, and should be,
> nowadays relatvely easy to implement because there are commands stacks.
> The reason why I did not start working on it is that I fear that it will
> have an impact on the performance, as it would mean that for each
> command, the stack of commands would be checked. I am not completely
> convinced that the performance penalty is worth it.
I don't see why it should be a huge performance barrier. Suppose
we want to forbid nested @footnote; then we would have a hash like
$self->{'nesting_context'} equal to {'footnote' => 0}, then when
we enter a @footnote, we increment $self->{'nesting_context'}->{'footnote'},
and decrement it on leaving. Whenever we see a @footnote, we check that
$self->{'nesting_context'}->{'footnote'} is equal to zero. This approach
would also work for nested cross-references. It would not require traversing
the list of currently open commands for every command.
For places where @anchor should be forbidden, we would use a counter like
$self->{'nesting_context'}->{'simple_text'} to mark that @anchor is
excluded throughout. Increment it on entering a @chapter argument and
decrement it at the end.
If there are other contexts where only a restricted subset of Texinfo
commands is valid, these could expressed with similar counters.
Obviously I haven't tried to implement this, so there would likely be
complications. I would be willing to work on the XS parser code for this,
as I have time, if it is agreed it is a good idea.
- Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/17
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref,
Gavin Smith <=
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/21
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/21
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/22
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/24
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/29
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/30
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/30
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/23
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/24