コード例 #1
0
ファイル: expr.c プロジェクト: LH-Datarocks/tpcds-kit
/*
* Routine: MakeFunctionCall(int nKeyword, expr_t *pArgList)
* Purpose: 
* Algorithm:
* Data Structures:
*
* Params:
* Returns:
* Called By: 
* Calls: 
* Assumptions:
* Side Effects:
* TODO: None
*/
expr_t *
MakeFunctionCall(int nKeyword, list_t *pArgList)
{
	expr_t *pResult;
	int nFuncNum = -1,
		i;

	pResult = makeExpr();

	for (i=0; arFuncInfo[i].nKeyword >= 0; i++)
	{
		if (nKeyword == arFuncInfo[i].nKeyword)
			nFuncNum = i;
	}
	if (nFuncNum < 0)
		ReportError(QERR_BAD_NAME, NULL, 1);
	pResult->Value.nValue = nKeyword;
	pResult->nFlags = EXPR_FL_FUNC;
	pResult->nFlags |= arFuncInfo[nFuncNum].nDataType;
	pResult->nFlags |= arFuncInfo[nFuncNum].nAddFlags;
	pResult->ArgList = pArgList;

	if (ValidateParams(nFuncNum, pResult))
		ReportError(QERR_SYNTAX, "in MakeFunctionCall()", 1);

	return(pResult);
}
コード例 #2
0
ファイル: mmClient.cpp プロジェクト: ogx/Calculation2D
bool mmConsole::mmClient::Aggregate(wchar_t const p_cCurrent) {
    if(p_cCurrent == cNavTrigger1 || p_cCurrent == cNavTrigger2) {
        wchar_t v_cDirection = ::_getwch();
        if(v_cDirection == cNavUp && m_sPositionInHistory != m_sHistory.begin()) {
            m_bNavigate = true;

            EraseToPrompt();

            --m_sPositionInHistory;
            Write(m_sPositionInHistory->Print(cEndOfWord, cEscape));
        } else if(v_cDirection == cNavDown && m_sPositionInHistory != m_sHistory.end()) {
            m_bNavigate = true;

            EraseToPrompt();

            ++m_sPositionInHistory;
            if(m_sPositionInHistory != m_sHistory.end())
                Write(m_sPositionInHistory->Print(cEndOfWord, cEscape));
            else
                Write(m_sCommandLine.Print(cEndOfWord, cEscape));
        }
    } else {
        if(m_bNavigate) {
            if(m_sPositionInHistory != m_sHistory.end()) {
                m_sCommandLine = *m_sPositionInHistory;
                m_sPositionInHistory = m_sHistory.end();
            }
            m_bNavigate = false;
        }
    }

    if(p_cCurrent == cEndOfWord) {
        m_sCommandLine.AddParam();
        Write(p_cCurrent);
    } else if(p_cCurrent == cEndOfLine) {
        // optionally find method if not found
        std::vector<std::wstring> v_sCommandLineElements = m_sCommandLine.GetParams();
        if(m_psCommand == NULL)
            m_psCommand = FindCommand(v_sCommandLineElements.front());
        // print new line
        NewLine();
        // interpret command
        if(m_psCommand != NULL) {
            std::vector<mmCommands::mmParam> v_sExpectedParams = m_psCommand->GetInputParams();
            std::vector<std::wstring> v_sReceivedParams(v_sCommandLineElements.empty() ? v_sCommandLineElements.begin() : (v_sCommandLineElements.begin() + 1), v_sCommandLineElements.end());
            if(! ValidateParams(v_sReceivedParams, v_sExpectedParams)) {
                WriteLn(m_psCommand->GetInfo());
            } else if(! m_psCommand->Run(v_sCommandLineElements.front(), v_sExpectedParams)) {
                WriteLn(L"error: " + m_psCommand->GetErrorMessage());
            }
        } else {
            WriteLn(v_sCommandLineElements.front() + L": command not found");
        }
        // clear command
        m_psCommand = NULL;
        m_sHistory.push_back(m_sCommandLine);
        m_sCommandLine = mmCommandLine();
        // reset current position in history
        m_sPositionInHistory = m_sHistory.end();
        // display prompt
        DisplayPrompt();
    } else if(p_cCurrent == cAutoComplete) {
        // run autocomplete for current context
        if(! AutoComplete()) {
            // display prompt
            DisplayPrompt();
        }
        // echo all
        Write(m_sCommandLine.Print(cEndOfWord, cEscape));
    } else if(p_cCurrent == cBackSpace) {
        bool v_bSuccess = false;
        if(! m_sCommandLine.IsParamEmpty())
            v_bSuccess = m_sCommandLine.EraseFromParam();
        else
            v_bSuccess = m_sCommandLine.EraseParam();
        if(v_bSuccess) {
            Write(cBackSpace);
            Write(L' ');
            Write(cBackSpace);
        }
    } else if(IsAllowedCharacter(p_cCurrent)) {
        m_sCommandLine.AddToParam(p_cCurrent);
        Write(p_cCurrent);
    }

    return true;
}