nim-lang / c2nim

c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process.
MIT License
502 stars 62 forks source link

Capture comments by providing the parent node #231

Closed planetis-m closed 2 years ago

planetis-m commented 2 years ago

Currently c2nim skips comments after a constant expression, at the end of an enum (without a comma):

// Shader attribute data types
typedef enum {
    SHADER_ATTRIB_FLOAT = 0,           // Shader attribute type: float
    SHADER_ATTRIB_VEC2 = 1,            // Shader attribute type: vec2 (2 float)
    SHADER_ATTRIB_VEC3 = 2,            // Shader attribute type: vec3 (3 float)
    SHADER_ATTRIB_VEC4 =  3            // Shader attribute type: vec4 (4 float) <- warning: skipped comment ...
} ShaderAttributeDataType;

not sure if that's an acceptable solution but it can be extended for #define as well

Araq commented 2 years ago

It's good.