TAL Comments

TAL Comments

1
NewbieNewbie
1

    May 07, 2009#1

    Hi, i have a problem with the single line comments and block comments because they use the same symbol.

    In TAL single line comments could be using -- or !, but block comments starts with ! and ends with ! or end of line.

    My syntax definition for comments: Line Comment = ! Line Comment Alt = -- Block Comment On = ! Block Comment Off = !

    So, when i have a single line comment like:

    Code: Select all

    !  Call the appropriate procedure to handle the Transaction message
    it works OK, but when i have a block Comments like:

    Code: Select all

    !2! CALL P30^RQST^FAIL^T0L1( STM, IDF, CPF );
    highlights all line as a comment.

    Thanks.

    6,686585
    Grand MasterGrand Master
    6,686585

      May 07, 2009#2

      So TAL has not really a block comment. It supports string commenting only within a line with ! as comment starting character and ! or LF as comment ending character. And a real line comment starting with -- also exists. From a programmers view it looks like the programmer who has written the interpreter for TAL has simply not developed a real block comment which can span over multiple lines (= block).

      Such a commenting method is not supported by the syntax highlighting engine of UltraEdit.


      For syntax highlighting with UltraEdit best would be not to use ! as line comment. Use for line comment always -- and use following definition:

      Line Comment = -- Block Comment On = ! Block Comment Off = !

      You can replace all existing line comments starting with ! in all your TAL files by using following regular expression in UltraEdit syntax:

      Find What: %^([~!^p]++^)!^([~!^p]+^)$
      Replace With: ^1--^2

      But please note that this expression will not work for something like:

      !2! CALL P30^RQST^FAIL^T0L1( STM, IDF, CPF ); !Test

      !Test is not changed to --Test in this line.

      With a second regular expression replace you could convert also line comments in lines which contain also exactly 1 "block" comment before.

      Find What: %^(*!*![~!^p]++^)!^([~!^p]+^)$
      Replace With: ^1--^2


      You could also play with Line Comment Num =, Line Comment Preceding Chars = and Line Comment Valid Columns =, but according to your explanation even when using these additional restrictions the highlighting will not work correct in some situations when you as writer are not use the same restrictions. For example following definition would highlight your example correct:

      Code: Select all

      Line Comment Num = 2!  Line Comment Alt = -- Block Comment On = ! Block Comment Off = !
      But now you must always have at least 1 space after ! used as line comment and always no space after ! used as "block" comment.


      In my point of view it is not abject to adapt the commenting style used to what can be interpreted by a syntax highlighting engine easily and do not use all the freedoms of the programming language when they can't be supported by 100% by the syntax highlighting engine.
      Best regards from an UC/UE/UES for Windows user from Austria