本文整理汇总了C++中NextCh函数的典型用法代码示例。如果您正苦于以下问题:C++ NextCh函数的具体用法?C++ NextCh怎么用?C++ NextCh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NextCh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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
}
示例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;
}
示例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
}
示例5: NextCh
void CRScanner::Reset()
{
CurrLine = 1; LineStart = 0; BuffPos = -1; CurrCol = 0;
ComEols = 0;
NextSym.Init();
NextCh();
}
示例6: while
void CParser::DigRep()
{
// changes the current character to the first character that
// isn't a decimal
while ((ch >= '0') && (ch <= '9'))
NextCh();
}
示例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();
}
}
示例8: ScanPastEOL
void ScanPastEOL()
{
int ch;
do {
ch = NextCh();
} while (ch != '\n' && ch != 0);
}
示例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;
}
示例10: SkipSpaces
// Skips spaces in input
void SkipSpaces()
{
int c;
do {
c = NextCh();
} while(c != '\n' && isspace(c) && c != 0);
unNextCh();
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
}
示例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();
}
}