If you generate code automatically, then just flooding a little exptressions 
with parentheses may be the easiest way (parenthesize all subexpressions, not 
statements). Yet add semicolons after statements in expressions. E.g. your code 
works in the following version:
    
    
    proc strsubsmart(s: string, start: int, fl0wlen: int): string =
        if start >= 0 and fl0wlen > 0:
          substring(s, start, fl0wlen)
        else:
          var slen: int =
            strlen(s)
          var trueStart: int = (
            if start >= 0: (
              start
            ) else: (
              var ss: int =
                slen+start;
              if ss >= 0: (
                ss
              ) else:
                0
              )
            )
          var trueLength: int =
            if fl0wlen > 0:
              fl0wlen
            else:
              slen+fl0wlen-trueStart
          substring(s, trueStart, trueLength)
    

Reply via email to