Example #1
0
        private AstItem ReadExternFuncDecl(TokenIterator tokens)
        {
            tokens.PopExpected(TokenKind.Ext);
            tokens.PopExpected(TokenKind.RoundBracketOpen);

            var libFnName = tokens.PopExpected(TokenKind.String);

            tokens.PopExpected(TokenKind.Comma);
            var libName = tokens.PopExpected(TokenKind.String);

            tokens.PopExpected(TokenKind.RoundBracketClose);

            var name = tokens.PopExpected(TokenKind.Word);

            tokens.PopExpected(TokenKind.RoundBracketOpen);

            var parameters = ReadFuncParameters(tokens);

            var      next       = tokens.Pop();
            DataType returnType = DataType.VOID;

            if (next.Kind == TokenKind.TypeOperator)
            {
                returnType = ReadDataType(tokens);
                tokens.PopExpected(TokenKind.SemiColon);
            }

            return(AstItem.ExternFunctionDecl(name.Value, returnType, parameters, libFnName.Value, libName.Value));
        }