bug-bash
[Top][All Lists]
Advanced

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

Re: Incorrect LINENO with exported nested functions with loops


From: Chet Ramey
Subject: Re: Incorrect LINENO with exported nested functions with loops
Date: Sat, 9 Oct 2021 15:47:36 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.2

On 10/7/21 5:06 PM, Tom Coleman wrote:
You are correct that FOR loops increment the word_top variable in the read_token_word function, but, ARITH_FOR_EXPRS loops do not. They are treated separately and do not increment the word_top variable from what I can see.

#define FOR 265
#define ARITH_FOR_EXPRS 286

The entire grammar production we're talking about here -- the one you're
modifying -- is

arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE

(for example; there are other rules in that production). The FOR token is
what causes the parser to increment word_top. The ARITH_FOR_EXPRS token
parses just one part of that production (the ((...;...;...)) part). It's
true that the function that parses the stuff between the double parens
doesn't use word_lineno[word_top], and maybe it should, but having
incremented word_top after seeing FOR, the action should decrement it after
parsing the complete statement.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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