本文整理汇总了C++中NextChar函数的典型用法代码示例。如果您正苦于以下问题:C++ NextChar函数的具体用法?C++ NextChar怎么用?C++ NextChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NextChar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void TFunctionScanner::SkipString(const TChar*& text)
{
TChar terminator = *text;
ASSERT(terminator == '\'' || terminator == '\"');
NextChar(text);
TChar previous = 0;
TChar previous2 = 0;
while (1)
{
TChar ch = *text;
if (ch == terminator && (previous != '\\' || previous2 == '\\'))
{
NextChar(text);
break;
}
previous2 = previous;
previous = ch;
NextChar(text);
}
}
示例2: NextChar
bool wxTextInputStream::EatEOL(const wxChar &c)
{
if (c == wxT('\n')) return true; // eat on UNIX
if (c == wxT('\r')) // eat on both Mac and DOS
{
wxChar c2 = NextChar();
if(c2 == wxEOT) return true; // end of stream reached, had enough :-)
if (c2 != wxT('\n')) UngetLast(); // Don't eat on Mac
return true;
}
return false;
}
示例3: NextChar
// Read string up to terminating quote, ignoring embedded double quotes
void Lexer::ScanString(int stringStart)
{
char ch;
do
{
ch = NextChar();
if (!ch)
{
CompileError(TEXTRANGE(stringStart, CharPosition()), LErrStringNotClosed);
}
else
{
if (ch == STRINGDELIM)
{
// Possible termination or double quotes
if (PeekAtChar() == STRINGDELIM)
ch = NextChar();
else
break;
}
*tp++ = ch;
}
} while (ch);
}
示例4: NextName
bool FarXMLScanner::ParseAttribute (FarXMLNode *node)
{
FarString attrName = NextName();
if (attrName.IsEmpty())
return false;
SkipWhitespace();
if (!NextExpectedChar ('='))
return false;
SkipWhitespace();
char valueDelimiter = NextChar();
if (valueDelimiter != '\'' && valueDelimiter != '\"')
{
ReportError ("\" or \'");
return false;
}
FarString attrValue;
while (1)
{
char c = NextChar();
if (c == valueDelimiter)
break;
else if (c == '&')
{
int entityValue = ParseEntity();
if (entityValue == -1)
return false;
attrValue += (char) entityValue;
}
else
attrValue += c;
}
node->AddAttr (attrName, attrValue);
return true;
}
示例5: malloc
// creates a new pathame string that is a dup of the input pathname, with the
// extension (if any) replaced by the given extension.
CHAR * NEAR CloneNameAddExt
(
CHAR * szInputFile,
CHAR * szExt
)
{
CHAR * szFile;
CHAR * pExt;
CHAR * pch;
// CONSIDER:
// assumes the extension is no more than 3 bytes incl '.' (ie non-DBCS)
// (This is true for the moment - can it ever change???)
// alloc string with enough space for ".", extension, and null
szFile = malloc(strlen(szInputFile)+1+3+1);
strcpy(szFile, szInputFile); // start with input file name
// find "." (if present) that occurs after last \ or /.
pExt = NULL;
for (pch = szFile; *pch; NextChar(pch))
{
switch (*pch)
{
#ifdef MAC
case ':':
case ' ': // start search over at a space
#else //MAC
case '\\':
case '/':
#endif //MAC
pExt = NULL;
break;
case '.':
pExt = pch;
break;
default:
;
}
}
if (pExt == NULL) // if no extension after last '\', then
pExt = pch; // append an extension to the name.
strcpy (pExt, szExt); // replace extension (if present) with
// desired extension
return szFile;
}
示例6: NextExpectedChar
bool NextExpectedChar (char expected)
{
char c = NextChar();
if (c != expected)
{
if (fErrorSink != NULL)
{
char buf [2];
buf [0] = expected;
buf [1] = '\0';
fErrorSink->ReportError (fCurLine, GetCurColumn(), buf);
}
return false;
}
return true;
}
示例7: NextChar
bool Parser::ParseKeyword(Statement* statement)
{
// ["?"]
if (GetCurrentChar() == '?') {
NextChar();
statement->SetType(Statement::kQuery);
}
// Keyword
BString* keyword = fScanner.ScanIdent();
if (keyword == NULL) {
Error("Identifier expected");
return false;
}
statement->SetKeyword(keyword);
return true;
}
示例8: SymName
void SymName (char* S)
/* Read a symbol from the input stream. The first character must have been
** checked before calling this function. The buffer is expected to be at
** least of size MAX_IDENTLEN+1.
*/
{
unsigned Len = 0;
do {
if (Len < MAX_IDENTLEN) {
++Len;
*S++ = CurC;
}
NextChar ();
} while (IsIdent (CurC) || IsDigit (CurC));
*S = '\0';
}
示例9: NextChar
Json* Json::Parser::ParsePrimary(){
NextChar();
Kind kind = KindPreview(ch);
Json* json = NULL;
switch(kind){
case kString: { json = ParseString(); break;}
case kNumber: { json = ParseNumber(); break;}
case kFalse: { json = ParseFalse(); break; }
case kTrue: { json = ParseTrue(); break; }
case kArray: { json = ParseArray(); break; }
case kObject: { json = ParseObject(); break; }
case kNull: break;
default: break;
};
return json;
}
示例10: main
/***********************************************************************
Function : main
Returns : zero for successful execution
3 if an error is encountered
The main routine allocates buffers for the input and output buffer.
Characters are then read from the input buffer building the line buffer
that will be sent to the filter processor. Lines are read and filtered
until the end of input is reached.
***********************************************************************/
int main( void )
{
char c;
unsigned long core;
setmode(1,O_BINARY); /* set output stream to binary mode */
core = farcoreleft();
if (core > 64000U)
BufSize = 64000U;
else BufSize = (unsigned)core; /* get available memory */
/* stay under 64K */
if ((CurInPtr = malloc(BufSize)) == NULL) /* allocate buffer space */
exit(3);
#if 0
processor = NULL; /* set current processor to none */
#endif
InBuffer = CurInPtr; /* input buffer is first half of space */
BufSize = BufSize/2; /* output buffer is 2nd half */
OutBuffer = InBuffer + BufSize;
CurOutPtr = OutBuffer; /* set buffer pointers */
LinePtr = Line;
CurBufLen = 0;
Put(PipeId,PipeIdLen); /* send ID string to message window */
while ((c = NextChar()) != 0) /* read characters */
{
if ((c == 13) || (c == 10)) /* build until line end */
{
*LinePtr = 0;
ProcessLine(Line); /* filter the line */
LinePtr = Line;
}
/* characters are added to buffer up to 132 characters max */
else if ((FP_OFF(LinePtr) - FP_OFF(&Line)) < 132)
{
*LinePtr = c; /* add to line buffer */
LinePtr++;
}
}
*LinePtr = 0;
ProcessLine(Line); /* filter last line */
EndMark = MsgEoFile;
Put(&EndMark,1); /* indicate end of input to
the message window */
flushOut((unsigned)(CurOutPtr-OutBuffer)); /* flush the buffer */
return 0; /* return OK */
}
示例11: NextChar
/*************************************************************************
Function : NextChar
Parameters: none
Returns : next character in input buffer or 0 on end of file
Input from the standard input stream is buffered in a global buffer InBuffer
which is allocated in function main. The function will return
the next character in the buffer, reading from the input stream when the
buffer becomes empty.
**************************************************************************/
char NextChar(void)
{
if (CurInPtr < InBuffer+CurBufLen) /* if buffer is not empty */
{
return *(CurInPtr++); /* return next character */
}
else
{
CurInPtr = InBuffer; /* reset pointer to front of buffer */
lseek(0,InOff,0); /* seek to the next section for read */
InOff += BufSize; /* increment pointer to next block */
if ((CurBufLen = read(0,InBuffer,BufSize)) !=0)
return NextChar(); /* recursive call merely returns
first character in buffer after read */
return 0; /* return 0 on end of file */
}
}
示例12: while
// expect we are not in a C-string.
bool Tokenizer::SkipToOneOfChars(const wxChar* chars, bool supportNesting, bool skipPreprocessor, bool skipAngleBrace)
{
while (NotEOF() && !CharInString(CurrentChar(), chars))
{
MoveToNextChar();
while (SkipString() || SkipComment())
;
// use 'while' here to cater for consecutive blocks to skip (e.g. sometemplate<foo>(bar)
// must skip <foo> and immediately after (bar))
// because if we don't, the next block won't be skipped ((bar) in the example) leading to weird
// parsing results
bool done = false;
while (supportNesting && !done)
{
switch (CurrentChar())
{
case '#':
if (skipPreprocessor)
SkipToEOL(true);
else
done = true;
break;
case '{': SkipBlock('{'); break;
case '(': SkipBlock('('); break;
case '[': SkipBlock('['); break;
case '<': // don't skip if << operator
if (skipAngleBrace)
{
if (NextChar() == '<')
MoveToNextChar(2); // skip it and also the next '<' or the next '<' leads to a SkipBlock('<');
else
SkipBlock('<');
break;
}
default: done = true; break;
}
}
}
return NotEOF();
}
示例13: while
wxString wxTextInputStream::ReadLine()
{
wxString line;
while ( !m_input.Eof() )
{
wxChar c = NextChar();
if(c == wxEOT)
break;
if (EatEOL(c))
break;
line += c;
}
return line;
}
示例14: CError
static void CError( void )
{
size_t len;
bool save;
len = 0;
while( CurrChar != '\n' && CurrChar != '\r' && CurrChar != EOF_CHAR ) {
if( len != 0 || CurrChar != ' ' ) {
Buffer[len++] = CurrChar;
}
NextChar();
}
Buffer[len] = '\0';
/* Force #error output to be reported, even with preprocessor */
save = CompFlags.cpp_output;
CompFlags.cpp_output = FALSE;
CErr2p( ERR_USER_ERROR_MSG, Buffer );
CompFlags.cpp_output = save;
}
示例15: ReadIdent
static void ReadIdent (void)
/* Read an identifier from the current input position into Ident. Filling SVal
** starts at the current position with the next character in C. It is assumed
** that any characters already filled in are ok, and the character in C is
** checked.
*/
{
/* Read the identifier */
do {
SB_AppendChar (&CurTok.SVal, C);
NextChar ();
} while (IsIdChar (C));
SB_Terminate (&CurTok.SVal);
/* If we should ignore case, convert the identifier to upper case */
if (IgnoreCase) {
UpcaseSVal ();
}
}