pycparser parse error on multi-byte character

167 views Asked by At

I'm using pycparser to parse some C code. Specifically code that can contain Japanese character inside characters and string such as below:

int main()
{
    char ch = '本';
}

I have tried to compile this on Dev-c, and compiles properly. Is this possible with pycparser?

1

There are 1 answers

4
Eli Bendersky On

What issues are you observing? I think it's working:

$ cat /tmp/45.c
int main()
{
    char ch = '本';
}
$ python3 examples/dump_ast.py /tmp/45.c 
FileAST: 
  FuncDef: 
    Decl: main, [], [], []
      FuncDecl: 
        TypeDecl: main, []
          IdentifierType: ['int']
    Compound: 
      Decl: ch, [], [], []
        TypeDecl: ch, []
          IdentifierType: ['char']
        Constant: char, '本'