line splicing

Issue #95 new
Daniel Bauer created an issue

Hi *.

In 'Wiki / Script API / Notes about line splicing' following is written:

"... Due to the internal mechanisms of the parser, the line splicing freezes the line counter and forces the column counter to continue until the last line in the spliced block. ..."

But following code

#define test {                    \
               for(i=0; i<2;i++)  \
               {                  \
                 i = i*2;         \
               }                  \
             }

will produce following output via 'vera++.exe --rule DUMP test.cpp' (vera 1.3.0 win32):

1/0     pp_define       #define
1/7     space
1/8     identifier      test
1/12    space
1/13    leftbrace       {
1/14    space
2/49    for     for
2/52    leftparen       (
2/53    identifier      i
2/54    assign  =
2/55    intlit  0
2/56    semicolon       ;
2/57    space
2/58    identifier      i
2/59    less    <
2/60    intlit  2
2/61    semicolon       ;
2/62    identifier      i
2/63    plusplus        ++
2/65    rightparen      )
2/66    space
3/83    leftbrace       {
3/84    space
4/119   identifier      i
4/120   space
4/121   assign  =
4/122   space
4/123   identifier      i
4/124   star    *
4/125   intlit  2
4/126   semicolon       ;
4/127   space
5/151   rightbrace      }
5/152   space
6/183   rightbrace      }
6/184   newline

7/0     eof

As you can see the line counter is not frozen, but ongoing, as it is the column counter. This eliminates lots of checking possibilities. Additionally the presence of the raw line and column numbers of a token would be very helpful for a wide range of checks.

Proposal:

  • token.line => line number w/ considering line splicing (to be adjusted as described)
  • token.column => column numer w/ considering line splicing
  • token.line_raw => line number w/o considering line splicing (to be added)
  • token.column_raw => column number w/o considering line splicing (to be added)

Regards, Daniel

Comments (1)

  1. Log in to comment