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

Method definitions #28

Open
mbsquared opened this issue Nov 13, 2022 · 3 comments
Open

Method definitions #28

mbsquared opened this issue Nov 13, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@mbsquared
Copy link

When declaring a struct or class, it seems to only be possible to declare functions such as void Test::TestFunc(){ } using the addinternalfunction method. It does not seem to work in code?

@mbsquared
Copy link
Author

So, narrowing it down best I can at the moment...

It seems to be an issue with the Parser not accepting '::' after a defined type

It returns a syntax error

@mbsquared
Copy link
Author

mbsquared commented Nov 14, 2022

So... I have a hacky work around... Changing in ParserInput

private int[] retTypes = { 296, 297, 298, 299, 302, 303, 306, 307, 285 };
        private bool IsReturnType(Token tok)
        {
            for (int i = 0; i < retTypes.Length; i++)
            {
                if (tok.Kind == retTypes[i])
                    return true;
            }

            return false;
        }

        public Token CurrentToken
        {
            get
            {
                if(Tokens[index].Kind == TokenKind.IDENTIFIER && typedefs.Contains(Tokens[index].StringValue))
                {
                    if(index > 0 && index + 1 < Tokens.Length)
                    {
                        if (Tokens[index+1].Kind == TokenKind.COLONCOLON && IsReturnType(Tokens[index - 1]))
                        {
                            return Tokens[index];
                        }
                    }else
                    {
                        return Tokens[index].AsKind(TokenKind.TYPE_NAME);
                    }
                    return Tokens[index].AsKind(TokenKind.TYPE_NAME);
                } else
                    return Tokens[index];

                
            }
        }

@praeclarum
Copy link
Owner

Oh nasty bug :-(

I'm working on improving this parsing support. Your hack is amazing but I think I can improve the grammar.

@praeclarum praeclarum added the bug Something isn't working label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants