UE4 - Hlsl parser; precedence operator expression parser

[CL 2347171 by Rolando Caloca in Main branch]
This commit is contained in:
Rolando Caloca
2014-11-03 11:36:09 -05:00
committed by UnrealBot
parent 5aed8938c2
commit 4ca487cbb0
8 changed files with 2308 additions and 154 deletions
@@ -6,6 +6,8 @@
#include "hlslcc.h"
#include "MetalBackend.h"
#include "GlslBackend.h"
#include "HlslLexer.h"
#include "HlslParser.h"
#include "RequiredProgramMainCPPInclude.h"
@@ -49,13 +51,22 @@ namespace CCT
FString HLSLShaderSource;
if (!FFileHelper::LoadFileToString(HLSLShaderSource, *RunInfo.InputFile))
{
UE_LOG(LogCrossCompilerTool, Error, TEXT("Couldn't load Input file!"));
UE_LOG(LogCrossCompilerTool, Error, TEXT("Couldn't load Input file '%s'!"), *RunInfo.InputFile);
return 1;
}
if (RunInfo.bUseNew)
{
// Assume it's preprocessed
////Parser.Parse(TEXT("+-1 * 2 + (3 + -4) + F(5) + G(6,7) + A++ - --B"));
//Parser.Parse(TEXT("void X() { a += (b ? 1 : 0); }"));
//Parser.Parse(TEXT("void X() { return 5 * 3 + 2; }"));
CrossCompiler::Parser::Parse(HLSLShaderSource);
//Scanner.Dump();
}
ANSICHAR* ShaderSource = 0;
ANSICHAR* ErrorLog = 0;
int Result = HlslCrossCompile(
TCHAR_TO_ANSI(*RunInfo.InputFile),
TCHAR_TO_ANSI(*HLSLShaderSource),
@@ -24,6 +24,7 @@ namespace CCT
FString OutputFile;
EBackend BackEnd;
bool bRunCPP;
bool bUseNew;
//bool bCPPOnly;
FRunInfo();
@@ -12,7 +12,8 @@ namespace CCT
InputFile(""),
OutputFile(""),
BackEnd(BE_Invalid),
bRunCPP(true)
bRunCPP(true),
bUseNew(false)
{
}
@@ -243,6 +244,10 @@ namespace CCT
{
bRunCPP = false;
}
else if (Switch.StartsWith(TEXT("new")))
{
bUseNew = true;
}
}
// Default to PS