#66 Wtkprerocess changed parsing behavior with //# prefix

closed-rejected
nobody
None
5
2007-09-13
2007-09-11
Anonymous
No

Wtkprerocess changed parsing behavior, breaking backward-compability

Antenna 0.9.5 uses '//#' token to distinguish preprocessor directives.
Instead of this, in 1.0.0 preprocessor allows whitespace between comment '//' and '#' sign, thus breaking compilation of such code:

1) commented out C-style preprocessor
// #if !defined(FLAG)
2) normal comments starting with '#'
// #r for CR, #n for LF

=====================================================
From CVS:

Preprocessor v1
antenna/src/antenna/preprocessor/v1/PreprocessorLine.java
---------------------------------------------------------
157 space = s.substring(0, p);
158 s = s.substring(p);
159
160 if (s.startsWith("//#")) {
161 type = parseCommand(s);
162 }
163 else {
...

Preprocessor v2
antenna.preprocessor/src/antenna/preprocessor/v2/parser/APP.g
-------------------------------------------------------------
52 PREFIX : "//" (WS)* "#";

antenna.preprocessor/src/antenna/preprocessor/v2/parser/HELPER.g
----------------------------------------------------------------
36 PREFIX : "//" (WS)* "#";

Discussion

  • Omry Yadan
    Omry Yadan
    2007-09-13

    Logged In: YES
    user_id=126268
    Originator: NO

    This is by design:

    when you format your code with the eclipse formatter with the default
    settings, it puts a whitespace between the // and #.

    for example, this:

    //#if !FOO
    int x = 0;
    //#endif

    would turn into this after formatting the code:
    // #if !FOO
    int x = 0;

    // #endif

    I can only suggest that you use /* */ comments for that very special
    case where your comment begins with #, or just use a different first
    character. for example, instead of:

    // #r for CR, #n for LF

    you can have:

    // Use #r for CR, #n for LF

     
  • Omry Yadan
    Omry Yadan
    2007-09-13

    • status: open --> closed-rejected