本文整理汇总了C++中NextCh函数的典型用法代码示例。如果您正苦于以下问题:C++ NextCh函数的具体用法?C++ NextCh怎么用?C++ NextCh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NextCh函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NextCh
void Scanner::SetScannerBehindT()
{
buffer->SetPos(t->pos);
NextCh();
line = t->line; col = t->col; charPos = t->charPos;
for (size_t i = 0; i < tlen; i++) NextCh();
}
开发者ID:OgreTransporter,项目名称:libosmscout,代码行数:7,代码来源:Scanner.cpp
示例2: malloc
void Scanner::Init() {
EOL = '\n';
eofSym = 0;
maxT = 16;
noSym = 16;
int i;
for (i = 65; i <= 90; ++i) start.set(i, 1);
for (i = 97; i <= 122; ++i) start.set(i, 1);
for (i = 48; i <= 57; ++i) start.set(i, 2);
start.set(58, 19);
start.set(59, 11);
start.set(43, 13);
start.set(45, 14);
start.set(42, 15);
start.set(94, 16);
start.set(40, 17);
start.set(41, 18);
start.set(Buffer::EoF, -1);
keywords.set(L"display", 3);
keywords.set(L"halt", 8);
keywords.set(L"mod", 12);
tvalLength = 128;
tval = new wchar_t[tvalLength]; // text of current token
// HEAP_BLOCK_SIZE byte heap + pointer to next heap block
heap = malloc(HEAP_BLOCK_SIZE + sizeof(void*));
firstHeap = heap;
heapEnd = (void**) (((char*) heap) + HEAP_BLOCK_SIZE);
*heapEnd = 0;
heapTop = heap;
if (sizeof(Token) > HEAP_BLOCK_SIZE) {
wprintf(L"--- Too small HEAP_BLOCK_SIZE\n");
exit(1);
}
pos = -1; line = 1; col = 0;
oldEols = 0;
NextCh();
if (ch == 0xEF) { // check optional byte order mark for UTF-8
NextCh(); int ch1 = ch;
NextCh(); int ch2 = ch;
if (ch1 != 0xBB || ch2 != 0xBF) {
wprintf(L"Illegal byte order mark at start of file");
exit(1);
}
Buffer *oldBuf = buffer;
buffer = new UTF8Buffer(buffer); col = 0;
delete oldBuf; oldBuf = NULL;
NextCh();
}
pt = tokens = CreateToken(); // first token is a dummy
}
开发者ID:Newky,项目名称:3rdYear,代码行数:56,代码来源:Scanner.cpp
示例3: NextCh
bool Scanner::Comment0() {
int level = 1, pos0 = pos, line0 = line, col0 = col, charPos0 = charPos;
NextCh();
if (ch == L'+') {
NextCh();
for(;;) {
if (ch == L'+') {
NextCh();
if (ch == L'/') {
level--;
if (level == 0) {
oldEols = line - line0;
NextCh();
return true;
}
NextCh();
}
} else if (ch == L'/') {
NextCh();
if (ch == L'+') {
level++;
NextCh();
}
} else if (ch == buffer->EoF) return false;
else NextCh();
}
} else {
buffer->SetPos(pos0);
NextCh();
line = line0;
col = col0;
charPos = charPos0;
}
return false;
}
开发者ID:S-V,项目名称:Lollipop,代码行数:35,代码来源:Scanner.cpp
示例4: malloc
void Scanner::Init() {
EOL = '\n';
eofSym = 0;
maxT = 9;
noSym = 9;
int i;
for (i = 48; i <= 57; ++i) start.set(i, 1);
start.set(99, 2);
start.set(40, 6);
start.set(41, 7);
start.set(43, 8);
start.set(45, 9);
start.set(42, 10);
start.set(47, 11);
start.set(Buffer::EoF, -1);
tvalLength = 128;
tval = new wchar_t[tvalLength]; // text of current token
// COCO_HEAP_BLOCK_SIZE byte heap + pointer to next heap block
heap = malloc(COCO_HEAP_BLOCK_SIZE + sizeof(void*));
firstHeap = heap;
heapEnd = (void**) (((char*) heap) + COCO_HEAP_BLOCK_SIZE);
*heapEnd = 0;
heapTop = heap;
if (sizeof(Token) > COCO_HEAP_BLOCK_SIZE) {
wprintf(L"--- Too small COCO_HEAP_BLOCK_SIZE\n");
exit(1);
}
pos = -1; line = 1; col = 0; charPos = -1;
oldEols = 0;
NextCh();
if (ch == 0xEF) { // check optional byte order mark for UTF-8
NextCh(); int ch1 = ch;
NextCh(); int ch2 = ch;
if (ch1 != 0xBB || ch2 != 0xBF) {
wprintf(L"Illegal byte order mark at start of file");
exit(1);
}
Buffer *oldBuf = buffer;
buffer = new UTF8Buffer(buffer); col = 0; charPos = -1;
delete oldBuf; oldBuf = NULL;
NextCh();
}
pt = tokens = CreateToken(); // first token is a dummy
}
开发者ID:m-hm,项目名称:shahab,代码行数:50,代码来源:Scanner.cpp
示例5: NextCh
void CRScanner::Reset()
{
CurrLine = 1; LineStart = 0; BuffPos = -1; CurrCol = 0;
ComEols = 0;
NextSym.Init();
NextCh();
}
开发者ID:armornick,项目名称:CocoR,代码行数:7,代码来源:cr_scan.cpp
示例6: while
void CParser::DigRep()
{
// changes the current character to the first character that
// isn't a decimal
while ((ch >= '0') && (ch <= '9'))
NextCh();
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:7,代码来源:InputParser.cpp
示例7: ResetText
void ResetText(){
/*if(Path == NULL){
fprintf(stderr, "Call format: O <source code path>\n");
exit(1);
}
else */if((fInput = fopen(/*Path*/"Input.txt", "rb")) == NULL){
ResetError = TRUE;
Message = "Source code file not found!";
}
else{
ResetError = FALSE;
fseek(fInput, 0, SEEK_END);
len = ftell(fInput);
if(len == -1L){
fprintf(stderr, "Input file fseek error.");
exit(1);
}
bytes = malloc(len);
fseek(fInput, 0, SEEK_SET);
fread(bytes, 1, len, fInput);
Message = "OK";
Pos = 0;
Line = 1;
fclose(fInput);
NextCh();
}
}
开发者ID:litvinenkonikita,项目名称:O2-translator,代码行数:29,代码来源:text.c
示例8: ScanPastEOL
void ScanPastEOL()
{
int ch;
do {
ch = NextCh();
} while (ch != '\n' && ch != 0);
}
开发者ID:BigEd,项目名称:Cores,代码行数:8,代码来源:INPUT.C
示例9: while
Token* Scanner::NextToken() {
while (ch == ' ' ||
ch == 10 || ch == 13
) NextCh();
int recKind = noSym;
int recEnd = pos;
t = CreateToken();
t->pos = pos; t->col = col; t->line = line; t->charPos = charPos;
int state = start.state(ch);
tlen = 0; AddCh();
switch (state) {
case -1: { t->kind = eofSym; break; } // NextCh already done
case 0: {
case_0:
if (recKind != noSym) {
tlen = recEnd - t->pos;
SetScannerBehindT();
}
t->kind = recKind; break;
} // NextCh already done
case 1:
case_1:
recEnd = pos; recKind = 1;
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_1;}
else {t->kind = 1; break;}
case 2:
if (ch == L'a') {AddCh(); goto case_3;}
else {goto case_0;}
case 3:
case_3:
if (ch == L'l') {AddCh(); goto case_4;}
else {goto case_0;}
case 4:
case_4:
if (ch == L'c') {AddCh(); goto case_5;}
else {goto case_0;}
case 5:
case_5:
{t->kind = 2; break;}
case 6:
{t->kind = 3; break;}
case 7:
{t->kind = 4; break;}
case 8:
{t->kind = 5; break;}
case 9:
{t->kind = 6; break;}
case 10:
{t->kind = 7; break;}
case 11:
{t->kind = 8; break;}
}
AppendVal(t);
return t;
}
开发者ID:m-hm,项目名称:shahab,代码行数:58,代码来源:Scanner.cpp
示例10: SkipSpaces
// Skips spaces in input
void SkipSpaces()
{
int c;
do {
c = NextCh();
} while(c != '\n' && isspace(c) && c != 0);
unNextCh();
}
开发者ID:BigEd,项目名称:Cores,代码行数:10,代码来源:INPUT.C
示例11: NextNonSpace
// Gets the next non space character
int NextNonSpace(int skipnl)
{
int ch;
do {
ch = NextCh();
} while((ch != '\n' || skipnl) && isspace(ch) && ch!=0);
return (ch);
}
开发者ID:BigEd,项目名称:Cores,代码行数:10,代码来源:INPUT.C
示例12: AddCh
static void AddCh(CJcScanner* scanner){
char *newBuf;
if (scanner->tlen >= scanner->tvalLength){
scanner->tvalLength *= 2;
newBuf = (char*)g_oInterface.Malloc(scanner->tvalLength);
MemoryCopy(newBuf, scanner->tval, scanner->tlen*sizeof(char));
g_oInterface.Free(scanner->tval);
scanner->tval = newBuf;
}
scanner->tval[scanner->tlen++] = scanner->ch;
NextCh(scanner);
}
开发者ID:nightstyles,项目名称:focp,代码行数:12,代码来源:jc_scanner.c
示例13: while
Token* Scanner::NextToken() {
while (ch == ' ' ||
ch == 10 || ch == 13
) NextCh();
int recKind = noSym;
int recEnd = pos;
t = CreateToken();
t->pos = pos; t->col = col; t->line = line;
int state = start.state(ch);
tlen = 0; AddCh();
switch (state) {
case -1: { t->kind = eofSym; break; } // NextCh already done
case 0: {
case_0:
if (recKind != noSym) {
tlen = recEnd - t->pos;
SetScannerBehindT();
}
t->kind = recKind; break;
} // NextCh already done
case 1:
case_1:
recEnd = pos; recKind = 1;
if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_1;}
else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;}
case 2:
case_2:
recEnd = pos; recKind = 2;
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_2;}
else {t->kind = 2; break;}
case 3:
if (ch == L'=') {AddCh(); goto case_4;}
else {goto case_0;}
case 4:
case_4:
{t->kind = 3; break;}
case 5:
{t->kind = 4; break;}
case 6:
{t->kind = 5; break;}
case 7:
{t->kind = 6; break;}
case 8:
{t->kind = 8; break;}
case 9:
{t->kind = 9; break;}
}
AppendVal(t);
return t;
}
开发者ID:Divo,项目名称:twominutestomidnightIMPORT,代码行数:53,代码来源:Scanner.cpp
示例14: memcpy
void Scanner::AddCh() {
if (tlen >= tvalLength) {
tvalLength *= 2;
wchar_t *newBuf = new wchar_t[tvalLength];
memcpy(newBuf, tval, tlen*sizeof(wchar_t));
delete [] tval;
tval = newBuf;
}
if (ch != Buffer::EoF) {
tval[tlen++] = valCh;
NextCh();
}
}
开发者ID:bharcode,项目名称:nammaDB,代码行数:13,代码来源:Scanner.cpp
示例15: UnassembleCommand
void UnassembleCommand(void) {
int count = 8; // Default instruction count to display
Sb(); if (IsDwDebugNumeric(NextCh())) {Uaddr = ReadInstructionAddress("U"); Wl();}
Sb(); if (IsDwDebugNumeric(NextCh())) {count = ReadNumber(0);}
Sb(); if (!DwEoln()) {Wsl("Unrecognised parameters on unassemble command.");}
int firstByte = Uaddr;
int limitByte = min(firstByte + count*4, FlashSize()); // Allow for up to 2 words per instruction
int length = limitByte - firstByte;
if (length <= 0) {Fail("Nothing to disassemble.");}
u8 buf[length+2];
DwReadFlash(firstByte, length, buf);
buf[length] = 0; buf[length+1] = 0;
while (1) {
Uaddr += DisassembleInstruction(Uaddr, &buf[Uaddr-firstByte]);
count--;
if (count <= 0 || Uaddr >= FlashSize()) {return;}
Wl();
}
}
开发者ID:dcwbrown,项目名称:dwire-debug,代码行数:23,代码来源:UnassembleCommand.c
示例16: NextCh
void CParser::TermChar(char c)
{
// generates an error if the next char isn't the specified char c,
// otherwise, skip the char
if (ch == c)
{
NextCh();
}
else
{
STR_String str;
str.Format("Warning: %c expected\ncontinuing without it", c);
trace(str);
}
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:15,代码来源:InputParser.cpp
示例17: NextCh
void NextCh(){
if( (Ch = bytes[++Index]) == EOF ){
Ch = chEOT;
}
else if(Ch == '\n'){
Line++;
Pos = 0;
Ch = chEOL;
}
else if(Ch == '\r'){
NextCh();
}
else if(Ch == '\t'){
while(++Pos % TABSIZE);
}
else{
Pos++;
}
}
开发者ID:litvinenkonikita,项目名称:O2-translator,代码行数:20,代码来源:text.c
示例18: SearchForDefined
void SearchForDefined()
{
char *ptr, *id, *sptr;
int c;
SDef tdef, *p;
ptr = inptr;
while(1)
{
if (PeekCh() == 0) // Stop at end of current input
break;
SkipSpaces();
sptr = inptr;
id = GetIdentifier();
if (id)
{
if (strcmp(id, "defined") == 0)
{
c = NextNonSpace(0);
if (c != '(') {
err(20);
break;
}
id = GetIdentifier();
if (id == NULL) {
err(21);
break;
}
c = NextNonSpace(0);
if (c != ')')
err(22);
tdef.name = id;
p = (SDef *)htFind(&HashInfo, &tdef);
SubMacro((char *)(p ? "1" : "0"), inptr-sptr);
}
}
else
NextCh();
}
inptr = ptr;
}
开发者ID:BigEd,项目名称:Cores,代码行数:41,代码来源:SUB.C
示例19: while
Token* Scanner::NextToken() {
while (ch == ' ' ||
(ch >= 9 && ch <= 10) || ch == 13
) NextCh();
int recKind = noSym;
int recEnd = pos;
t = CreateToken();
t->pos = pos; t->col = col; t->line = line; t->charPos = charPos;
int state = start.state(ch);
tlen = 0; AddCh();
switch (state) {
case -1: { t->kind = eofSym; break; } // NextCh already done
case 0: {
case_0:
if (recKind != noSym) {
tlen = recEnd - t->pos;
SetScannerBehindT();
}
t->kind = recKind; break;
} // NextCh already done
case 1:
case_1:
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_2;}
else {goto case_0;}
case 2:
case_2:
recEnd = pos; recKind = 2;
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_2;}
else {t->kind = 2; break;}
case 3:
if ((ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_4;}
else {goto case_0;}
case 4:
case_4:
if ((ch >= L'A' && ch <= L'Z') || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_4;}
else if (ch == L'"') {AddCh(); goto case_5;}
else {goto case_0;}
case 5:
case_5:
{t->kind = 3; break;}
case 6:
case_6:
recEnd = pos; recKind = 4;
if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'Z') || ch == L'_' || (ch >= L'a' && ch <= L'z')) {AddCh(); goto case_6;}
else {t->kind = 4; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;}
case 7:
case_7:
recEnd = pos; recKind = 1;
if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_7;}
else if (ch == L'.') {AddCh(); goto case_1;}
else {t->kind = 1; break;}
case 8:
{t->kind = 6; break;}
case 9:
{t->kind = 7; break;}
case 10:
{t->kind = 9; break;}
case 11:
{t->kind = 10; break;}
case 12:
{t->kind = 11; break;}
case 13:
if (ch == L'.') {AddCh(); goto case_14;}
else {goto case_0;}
case 14:
case_14:
{t->kind = 12; break;}
case 15:
{t->kind = 13; break;}
case 16:
{t->kind = 17; break;}
case 17:
{t->kind = 18; break;}
case 18:
{t->kind = 22; break;}
case 19:
{t->kind = 23; break;}
case 20:
{t->kind = 31; break;}
case 21:
{t->kind = 33; break;}
case 22:
case_22:
{t->kind = 53; break;}
case 23:
case_23:
{t->kind = 54; break;}
case 24:
case_24:
{t->kind = 55; break;}
case 25:
case_25:
{t->kind = 56; break;}
case 26:
{t->kind = 61; break;}
case 27:
{t->kind = 62; break;}
case 28:
//.........这里部分代码省略.........
开发者ID:cesarcastmore,项目名称:Logo,代码行数:101,代码来源:Scanner.cpp
示例20: while
TokenRef Scanner::NextToken() {
while (ch == ' ' ||
(ch >= 9 && ch <= 10) || ch == 13 || ch == ' '
) NextCh();
if ((ch == '/' && Comment0()) || (ch == '/' && Comment1())) return NextToken();
int recKind = noSym;
size_t recEnd = pos;
t = CreateToken();
t->pos = pos; t->col = col; t->line = line; t->charPos = charPos;
int state = start.state(ch);
tlen = 0; AddCh();
switch (state) {
case -1: { t->kind = eofSym; break; } // NextCh already done
case 0: {
case_0:
if (recKind != noSym) {
tlen = recEnd - t->pos;
SetScannerBehindT();
}
t->kind = recKind; break;
} // NextCh already done
case 1:
case_1:
recEnd = pos; recKind = 1;
if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_1;}
else {t->kind = 1; char *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;}
case 2:
case_2:
if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_3;}
else {goto case_0;}
case 3:
case_3:
recEnd = pos; recKind = 3;
if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_3;}
else {t->kind = 3; break;}
case 4:
case_4:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_5;}
else {goto case_0;}
case 5:
case_5:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_6;}
else {goto case_0;}
case 6:
case_6:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_7;}
else {goto case_0;}
case 7:
case_7:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_8;}
else {goto case_0;}
case 8:
case_8:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_9;}
else {goto case_0;}
case 9:
case_9:
recEnd = pos; recKind = 4;
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_10;}
else {t->kind = 4; break;}
case 10:
case_10:
if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f')) {AddCh(); goto case_11;}
else {goto case_0;}
case 11:
case_11:
{t->kind = 4; break;}
case 12:
if ((ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_13;}
else {goto case_0;}
case 13:
case_13:
recEnd = pos; recKind = 5;
if ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || ch == '_' || (ch >= 'a' && ch <= 'z')) {AddCh(); goto case_13;}
else {t->kind = 5; break;}
case 14:
case_14:
if (ch <= '!' || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_14;}
else if (ch == '"') {AddCh(); goto case_15;}
else if (ch == 92) {AddCh(); goto case_17;}
else {goto case_0;}
case 15:
case_15:
{t->kind = 6; break;}
case 16:
case_16:
recEnd = pos; recKind = 2;
if ((ch >= '0' && ch <= '9')) {AddCh(); goto case_16;}
else if (ch == '.') {AddCh(); goto case_2;}
else {t->kind = 2; break;}
case 17:
case_17:
if (ch <= '!' || (ch >= '#' && ch <= '[') || (ch >= ']' && ch <= 65535)) {AddCh(); goto case_14;}
else if (ch == 92) {AddCh(); goto case_17;}
else if (ch == '"') {AddCh(); goto case_18;}
else {goto case_0;}
case 18:
//.........这里部分代码省略.........
开发者ID:OgreTransporter,项目名称:libosmscout,代码行数:101,代码来源:Scanner.cpp
注:本文中的NextCh函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论