Jonathan,

Thank you! This makes perfect sense (and it looks like Willy Jensen basically 
coded this algorithm earlier in this thread!).

David

On Mon, 26 Feb 2024 17:42:55 +0000, Jonathan Scott 
<[email protected]> wrote:

>Ref:  Your note of Mon, 26 Feb 2024 08:22:00 -0500
>
>The difficult of inserting a length in a relocatable operand
>using macro logic depends on how sophisticated you want to make
>your code.  The key point is to start from the last character
>of the operand value, that is '&FIELD1'(K'&FIELD1,1).
>
>The general approach is:
>
>1. If rightmost character of first operand is not ")",
>   append "(2)".
>
>2. Otherwise, assume that it ends with a base register, so scan
>   back looking for "(" and insert "2," after it.
>
>To allow for bad input, remember to check whether the substring
>position is still positive before looking at that position.
>
>That covers all the normal cases, but if you need to cope with
>expressions like "A+(B-C*(D+E))" then you need a more complex
>algorithm, where the backscan keeps count of the nesting level
>and scans back to the parenthesis matching the last one, and you
>then need to look before it to see if there is an operator as
>the next character, in which case it is not a base register in
>parentheses.
>
>That gets more complicated if you need to allow for location
>counter references, that is "*", or even worse to the length of
>the location counter, "L'*", in which case you need to check for
>the previous character before the asterisk being an operator or
>apostrophe.
>
>If you want to support expressions containing character terms
>with embedded parentheses, such as "A+(C'B('-C)", then you're
>probably beyond help!
>
>Jonathan Scott, HLASM
>IBM Hursley, UK

Reply via email to