groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] condition: OR of two string comparisons


From: James K. Lowden
Subject: Re: [Groff] condition: OR of two string comparisons
Date: Sun, 16 Nov 2014 14:22:30 -0500

On Sun, 16 Nov 2014 15:17:14 +0100
Tadziu Hoffmann <address@hidden> wrote:

> > [...] maybe we should bear in mind having a .elif and .else
> > too that don't need the .ifx to be .iex.
> 
> I don't think that's possible.  Since the code can't look ahead,
> it will not know whether an else is coming or not, so the "if"
> has to know whether (.ie) or not (.if) to save the test outcome
> for a following "else".  

Maybe I'm missing something, but from here it looks possible.  True, you
need a stack, but not very much, and no look-ahead.  

Every time you hit an "if", put T/F on the stack indicating the value of
"else". When you hit an else, do or don't, according to the saved
value.  When you get to "end if", pop the value (whether or not an
"else" was found).  

> Else we needlessly fill up the stack, which is simply bad design.

Depends on "fill" and "needlessly".  Branches don't usually nest very
deeply, and "else" is useful functionality.  

--jkl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]