Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this a parsing error? #223

Open
mantielero opened this issue Sep 25, 2021 · 0 comments
Open

Is this a parsing error? #223

mantielero opened this issue Sep 25, 2021 · 0 comments

Comments

@mantielero
Copy link

I think there might be a parsing error.

When there is comment starting like //! after an #ifndef. For example:

namespace Simple
{

#define DEFINE1 1

const int ConstGlobal1 = 1;

class CppClass
{
    int field3Value = 3;
public:
    int field1 = 1;
    int field2 = 2;
    int* field3;
    int field4[1] = {4};

    CppClass() {
        this->field3 = &this->field3Value;
    }
#ifndef HELLO
    //! Hello
#endif
    int method1(int arg)
    {
        return 1 + arg;
    }

    int method2(int arg)
    {
        return 2 + arg;
    }

    int method3()
    {
        return 3;
    }

    void method4(int& arg)
    {
        arg = 4;
    }

    class CppNestedClass
    {
    public:
        int nestedField1 = 1;
    };
};

enum CPP_ENUM
{
    CPP_ENUM_MEMBER_1 = 1,
    CPP_ENUM_MEMBER_2 = 2
};

inline int function1(CppClass instance)
{
    return 1 + instance.field1;
}

}

This fails when parsing in strict mode:

$ c2nim --cpp --header --strict simple.hpp 
/tmp/simple.hpp(22, 1) Error: identifier expected, but got: ! Hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant