#1029 parsing constant expressions involving % (modulus)

closed-fixed
parsing (147)
5
2009-12-04
2009-07-08
Aamir M
No

SWIG does properly parse constant expression involving the % symbol (modulus operator), but it fails if the constant expression occurs between square brackets (constant length array size). So ...

int i = 12 % 6; works just fine

but

int array[ 12 % 6 ]; generates a parser error.

Attached interface file demonstrates the problem.

Discussion

  • Aamir M

    Aamir M - 2009-07-08

    example.i:12: Error: Syntax error in input(3).

     
    Attachments
  • Olly Betts

    Olly Betts - 2009-07-30
    • labels: 505206 --> parsing
    • assigned_to: nobody --> olly
     
  • Olly Betts

    Olly Betts - 2009-07-30

    This is a parsing bug, not code gen.

    SWIG doesn't really parse method bodies, so that is why that "works".

    If I add this to the start of the class:

    const int FOO = 12 % 6;

    Then I get:

    example.i:10: Error: Syntax error in input(3).

    I don't see why this fails from an initial inspection though. Assigning to myself for now, but if someone else wants to investigate, be my guest.

     
  • Olly Betts

    Olly Betts - 2009-12-04
    • status: open --> closed-fixed
     
  • Olly Betts

    Olly Betts - 2009-12-04

    Aha! There's MODULO and MODULUS tokens - the first is generated, but the grammar expects the second.

    Fixed in trunk r11774, so this fix should be in SWIG 1.3.41 when that is released.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks