本文整理汇总了C++中Grammar::GetLanguageName方法的典型用法代码示例。如果您正苦于以下问题:C++ Grammar::GetLanguageName方法的具体用法?C++ Grammar::GetLanguageName怎么用?C++ Grammar::GetLanguageName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grammar
的用法示例。
在下文中一共展示了Grammar::GetLanguageName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintOutputInterface
static void PrintOutputInterface(std::wostream& os, Grammar& g)
{
std::wstring ws(STR_HEADER);
std::wstring upperfile = MakeUpper(g.GetModuleName() + L".h");
FindReplace(upperfile, L".", L"_");
PrintGeneratedFileHeader(os);
os << L"#ifndef " << upperfile << "" << std::endl;
os << L"#define " << upperfile << "" << std::endl;
os << std::endl;
os << std::endl;
find_replace(ws, L"{DATE}", __WDATE__);
find_replace(ws, L"{GRAMMAR}", g.GetLanguageName());
os << L"#include \"Result.h\"\n";
os << L"#include " << "\"" << g.GetLanguageName() << ".h\"\n";
std::wostringstream ss;
PrintActions(ss, g, false);
find_replace(ws, L"{ACTIONS}", ss.str());
os << ws;
os << std::endl;
os << L"#endif" << std::endl;
}
示例2: PrintActions
static void PrintActions(std::wostream& os, Grammar& g, bool virt)
{
#if 0
os << L"/*Forward declarations for actions*/\n";
os << L"struct Eval_Context;\n";
os << L"\n";
os << L" " << g.GetLanguageName() << L"_Actions{\n";
const wchar_t * psz0 =
L" int (*{ACTION})( {LANG}_Context* ctx);\n";
std::wstring ws0(psz0);
find_replace(ws0, L"{LANG}", g.GetLanguageName());
for (int i = 0; i < g.GetNumberOfActions(); i++)
{
std::wstring ws(ws0);
find_replace(ws, L"{ACTION}", g.GetActionName(i));
os << ws;
}
os << L"};\n";
#else
os << L"typedef enum \n";
os << L"{\n";
for (int i = 0; i < g.GetNumberOfActions(); i++)
{
os << L" " << g.GetActionName(i) << L",\n";
}
os << g.GetLanguageName() << L"_OnError\n";
os << L"}" << g.GetLanguageName() << L"_Actions;\n";
#endif
}
示例3: PrintActionsNames
static void PrintActionsNames(std::wostream& os, Grammar& g, bool virt)
{
os << L"//\n";
os << L"const char* " << g.GetLanguageName() << L"_Actions_Text(";
os << L"" << g.GetLanguageName() << L"_Actions e)\n";
os << L"{\n";
os << L" switch(e)\n";
os << L" {\n";
for (int i = 0; i < g.GetNumberOfActions(); i++)
{
os << L" case " << g.GetActionName(i) << L": return \"" << g.GetActionName(i) << L"\";\n";
}
os << L" }\n";
os << L" return \"\";\n";
os << L"};\n";
}
示例4: GetFunctionName
static std::wstring GetFunctionName(Grammar& g,
const std::wstring& name)
{
std::wstring r;
if (name == L"Main")
{
r = g.GetLanguageName();
r += L"_Main";
}
else
{
r = L"Parse_";
r += name;
}
return r;
}
示例5: PrintGeneratedFileHeader
static void GenerateDescRec3(std::wostream& os,
Grammar& g,
MMap& map,
const std::wstring& tokenPrefix)
{
if (map.empty())
{
return;
}
PrintGeneratedFileHeader(os);
PrintGeneratedFileLicense(os);
os << L"#pragma once\n";
os << L"\n";
os << L"#include <string.h>\n";
os << L"#include \"" << g.GetModuleName() << L"Lex.h\"\n";
os << L"\n";
os << L"\n";
//PrintOutputClass(os, g);
PrintFowardDeclarations(os, g, map);
int i = 0;
int sub = 0;
int currentRuleIndex = -1;
auto it = map.begin();
for (; it != map.end();)
{
int currentRuleIndex = it->m_pNotTerminal->GetIndex();
//Faz todos desta regra (até ela mudar)
os << TAB_1 << L"int " << GetFunctionName(g, it->m_pNotTerminal->GetName()) << L"( " << g.GetLanguageName() << L"_Context* ctx)\n";
os << TAB_1 << L"{\n";
int sub = 0;
bool allsame = false;
bool firstPrinted = false;
if (PreAnalise(map, it, allsame) == 1)
{
//se so tem um nao precisa testar pelo token pois sempre haver um teste
//a seguir de qualquer forma
const Production& production = g.GetProduction(it->m_RuleIndex);
os << TAB__2 << L"//";
Print(os, production);
os << L"\n";
PrintProduction(os, production, g, tokenPrefix, TAB__2);
it++;
}
else
{
while (it->m_pNotTerminal->GetIndex() == currentRuleIndex)
{
//se todos forem iguais nao testa pelo token
//e so imprimi o primeiro que eh igual aos outros
if (!allsame)
{
if (sub == 0)
{
os << TAB__2 << L"if (IsToken(ctx, " << tokenPrefix << it->m_pTerminal->GetName() << L"))\n";
}
else
{
os << TAB__2 << L"else if (IsToken(ctx, " << tokenPrefix << it->m_pTerminal->GetName() << L"))\n";
}
}
const Production& production = g.GetProduction(it->m_RuleIndex);
if (!allsame)
{
os << TAB__2 << L"{\n";
}
if (!allsame || (allsame && !firstPrinted))
{
os << (!allsame ? TAB___3 : TAB__2);
os << L"/*";
Print(os, production);
os << L"*/\n";
PrintProduction(os, production, g, tokenPrefix, !allsame ? TAB___3 : TAB__2);
if (!allsame)
{
os << TAB__2 << L"}\n";
}
}
sub++;
it++;
if (it == map.end())
{
break;
}
firstPrinted = true;
}
}
//.........这里部分代码省略.........
示例6: GenerateDescRecC
void GenerateDescRecC(std::wostream& os,
Grammar& g,
MMap& map,
const std::wstring& tokenPrefix,
const std::wstring& parserFileSuffix)
{
if (map.empty())
{
return;
}
PrintGeneratedFileHeader(os);
PrintGeneratedFileLicense(os);
os << L"\n";
os << L"#include \"stdafx.h\"\n";
os << L"#include <assert.h>\n";
os << L"\n";
os << L"#include \"" << g.GetModuleName() << L"Lex.h\"\n";
os << L"#include \"" << g.GetModuleName() << parserFileSuffix << L".h\"\n";
os << L"\n";
os << L"\n";
//os << L"#include \"sstream.h\"\n";
//os << L"#include \"errors.h\"\n";
os << L"\n";
os << L"\n";
PrintActionsNames(os, g, false);
//PrintActions(os, g, false);
os << L"\n";
PrintFowardDeclarations(os, g, map);
std::wstring ws(SourceCode);
find_replace(ws, L"{GRAMMAR}", g.GetLanguageName());
find_replace(ws, L"{MODULE}", g.GetLanguageName());
os << ws;
int i = 0;
int currentRuleIndex = -1;
auto it = map.begin();
int rulecount = 0;
for (; it != map.end();)
{
int currentRuleIndex = it->m_pNotTerminal->GetIndex();
//Faz todos desta regra (até ela mudar)
os << L"Result " << GetFunctionName(g, it->m_pNotTerminal->GetName()) << L"( " << g.GetLanguageName() + L"_Context* ctx)\n";
os << L"{\n";
os << TAB_1 << L"Result result = RESULT_OK;\n";
os << TAB_1 << L"" << g.GetLanguageName() << L"_Tokens token = ctx->token; \n";
os << L"\n";
int sub = 0;
rulecount = 0;
while (it->m_pNotTerminal->GetIndex() == currentRuleIndex)
{
int currentResultIndex = it->m_RuleIndex;
//faz todos que resultam na mesma producao
int count = 0;
while (currentResultIndex == it->m_RuleIndex)
{
if (count == 0)
{
os << TAB_1;
if (rulecount > 0)
{
os << L"else ";
}
os << L"if (token == " << tokenPrefix << it->m_pTerminal->GetName();
}
else
{
os << L" ||\n";
os << TAB_1 << L" token == " << tokenPrefix << it->m_pTerminal->GetName();
}
auto itcopy = it;
it++;
count++;
if (it == map.end() ||
currentResultIndex != it->m_RuleIndex)
{
os << L")\n"; //fecha if
const Production& production = g.GetProduction(itcopy->m_RuleIndex);
os << TAB_1 << L"{\n";
os << TAB__2;
os << L"/*";
Print(os, production);
os << L"*/\n";
PrintProduction(os, production, g, tokenPrefix, TAB__2);
//.........这里部分代码省略.........