Skip to content

parser for {#enum#} renamings is too strict #113

@dmwit

Description

@dmwit

Here is a minimal test case showing the problem. Two files are needed, enum.h looks like this:

enum annoying { annoying_0 };

and Enum.chs looks like this:

module Enum where
#include "enum.h"
{# enum annoying as Annoying {0 as Zero} with prefix = "annoying" #}

It seems the parser for the alias list {0 as Zero} doesn't like C identifiers that start with numbers:

% c2hs Enum.chs
c2hs: CHS module contains errors:

Enum.chs:3: (column 33) [ERROR]  >>> Syntax error!
  The phrase `as' is not allowed here.
Enum.chs:3: (column 31) [ERROR]  >>> Lexical error!
  The character '0' does not fit here; skipping it.

zsh: exit 1     c2hs Enum.chs

It's probably true that C identifiers really aren't allowed to start with numbers, but the real C identifier here doesn't start with a number, it starts with the prefix "annoying_".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions