Function list doesn't show correct VAR, CONST, TYPE in Pascal style

Function list doesn't show correct VAR, CONST, TYPE in Pascal style

7

    Mar 24, 2021#1

    Hello,

    CTAGs does not work properly with Pascal unfortunately, only functions and procedures are displayed here.

    That's why I wanted to adapt the function list accordingly, unfortunately I can't get it to work properly and can't find the right documentation for it.

    Apparently there are problems with the parser from UEStudio.

    Wordfile snippet:

    Code: Select all

    /TGBegin "Type"
    /TGFindStr = "^([a-z_0-9^$]+^)[ ^t]+=[ ^t^p]+record"
    /TGEnd
    /TGBegin "Const"
    /TGFindStr = "^([a-z_0-9^$]+^)[ ^t]+:[ ^t^p]^([a-z_0-9^$]+^)[ ^t]+=[ ^t^p];++"
    /TGFindBEnd = ";"
    /TGEnd
    /TGBegin "VAR"
    /TGFindStr = "^([a-z_0-9^$]+^)[ ^t]+:[ ^t^p]^([a-z_0-9^$]+^)[ ^t]+=[ ^t^p];++"
    /TGFindBEnd = ";"
    /TGEnd
    
    This code is shown to me as CONST, that would be correct, but unfortunately also as VAR.

    Code: Select all

    CONST
      // Flankenauswertung
      RTrick : boolean = false; // RTRICK
      FTrick : boolean = true; // FTRICK
    Thorsten
    20210324_AVRco.zip (9.48 KiB)   0

    6,633551
    Grand MasterGrand Master
    6,633551

      Mar 25, 2021#2

      I don't know why you think you should get something different displayed in function list view. The regular expressions for the function group with name Const is exactly the same as for the function group with name VAR. The name of a function group has nothing to do with the block to parse in syntax highlighted file. The two /TGFindBEnd = ";" do not make sense at all in AVRco.uew.

      I can perhaps help you with function string definitions to list as subgroup of a function or of a procedure the constants and variables defined inside the function/procedure. But I would need a Pascal source code file and the Pascal syntax rules as I am not a Pascal programmer.
      Best regards from an UC/UE/UES for Windows user from Austria

      7

        Mar 26, 2021#3

        Hello Mofi,

        ok, that means the "/TGBegin" VAR "" only stands for the heading in the list, it is not the beginning of the VAR block.

        I once created a short block of Pascal source code for you.

        In principle one should be able to tell the parser somehow that when "VAR" comes, all entries are to be understood as VARs, as long as another
        identifier comes, like "begin", "type", "const", "Procedure", " Function "etc.
        Is that possible?

        Thorsten
        TestUeStudio.pas (5.7 KiB)   0

        6,633551
        Grand MasterGrand Master
        6,633551

          Mar 29, 2021#4

          Here is version 1 of the wordfile AVRco.uew. Duplicate words are removed and the remaining words are sorted. The function strings are rewritten for Perl syntax. Please let me know if you want more improvements.
          wordfile_AVRco_v1.zip (9.36 KiB)   0
          Version 1 of the wordfile AVRco.uew
          Best regards from an UC/UE/UES for Windows user from Austria

          7

            Mar 30, 2021#5

            Hello Mofi,

            thank you, that looks really great!

            Now I only have one problem, if I now use UNITs, this would have to be used in the same way as with the "Program".
            I copied the "Program" block and adjusted it with "Unit".

            Code: Select all

            ...
            /TGBegin "Unit"
            /TGFindStr = "^unit[\t ]+([a-z_][0-9a-z_$]*)"
            /TGBegin "Constants"
            /TGFindStr = "([a-z_][0-9a-z_$]*)[\t ]+(:)[\r\n\t ]([a-z_][0-9a-z_]*)[ \t]+=[ \t\r\n];?"
            /TGFindBStart = "^const"
            /TGFindBEnd = "^(?:function|procedure|task|type|userdevice|var)"
            /TGEnd
            /TGBegin "Types"
            /TGFindStr = "^[\t ]*([a-z_][0-9a-z_$]*)[\t ]+=[\r\n\t ]+(?:array|record)"
            /TGFindBStart = "^type"
            /TGFindBEnd = "^(?:const|function|procedure|task|type|userdevice|var)"
            /TGEnd
            /TGBegin "Variables"
            /TGFindStr = "^[\t ]*([a-z_][0-9a-z_$]*)[\t ]+(?:\[[^\]]+\][\r\n\t ]*)?(:)[\r\n\t ]+(.+?);"
            /TGFindBStart = "^var"
            /TGFindBEnd = "^(?:const|function|procedure|task|type|userdevice)"
            /TGEnd
            /TGEnd
            ...
            
            
            It works and looks great, thanks again

            Thorsten

            6,633551
            Grand MasterGrand Master
            6,633551

              Mar 30, 2021#6

              That's fine. I think, it would be better to modify

              Code: Select all

              /TGBegin "Program"
              /TGFindStr = "^program[\t ]+([a-z_][0-9a-z_$]*)"
              
              to

              Code: Select all

              /TGBegin "Program/Unit"
              /TGFindStr = "^(program|unit)[\t ]+([a-z_][0-9a-z_$]*)"
              
              or

              Code: Select all

              /TGBegin "Program/Unit"
              /TGFindStr = "^(?:program|unit)[\t ]+([a-z_][0-9a-z_$]*)"
              
              Then UltraEdit/UEStudio would not need to run more Perl regular expression finds than really necessary and duplicate regular expressions in the wordfile would be avoided, too.
              Best regards from an UC/UE/UES for Windows user from Austria