MCPcopy Create free account
hub / github.com/beefytech/Beef / HandlePreprocessor

Method HandlePreprocessor

IDEHelper/Compiler/BfParser.cpp:1064–1476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062}
1063
1064bool BfParser::HandlePreprocessor()
1065{
1066 int triviaStart = mTriviaStart;
1067
1068 int checkIdx = 0;
1069 for (int checkIdx = mLineStart; checkIdx < mSrcIdx - 1; checkIdx++)
1070 {
1071 if (!isspace((uint8)mSrc[checkIdx]))
1072 {
1073 if (mPreprocessorIgnoreDepth == 0)
1074 {
1075 if (mSrc[mSrcIdx - 1] != '#')
1076 return false;
1077 mPassInstance->FailAt("Preprocessor directives must appear as the first non-whitespace character on a line", mSourceData, checkIdx);
1078 break;
1079 }
1080 else
1081 continue; // Keep searching for #endif
1082 }
1083 }
1084
1085 String pragma;
1086 String pragmaParam;
1087
1088 switch (mSrc[mSrcIdx - 1])
1089 {
1090 case '<':
1091 if (mPreprocessorIgnoreDepth > 0)
1092 return false;
1093 pragma = "<<<";
1094 break;
1095 case '=':
1096 if (mPreprocessorIgnoreDepth > 0)
1097 return false;
1098 pragma = "===";
1099 break;
1100 case '>':
1101 if (mPreprocessorIgnoreDepth > 1)
1102 return false;
1103 pragma = ">>>";
1104 break;
1105 }
1106
1107 bool atEnd = false;
1108
1109 int startIdx = mSrcIdx - 1;
1110 int spaceIdx = -1;
1111 int charIdx = -1;
1112 while (true)
1113 {
1114 char c = mSrc[mSrcIdx++];
1115
1116 if (c == '\n')
1117 {
1118 int checkIdx = mSrcIdx - 2;
1119 bool hadSlash = false;
1120 while (checkIdx >= startIdx)
1121 {

Callers

nothing calls this directly

Calls 15

StringClass · 0.85
FailAtMethod · 0.80
SetSrcEndMethod · 0.80
WarnAtMethod · 0.80
IsWhitespaceFunction · 0.70
IsEmptyMethod · 0.45
emptyMethod · 0.45
GetSrcStartMethod · 0.45
pop_backMethod · 0.45
ToStringMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected