设为首页 加入收藏

TOP

自己动手写C语言编译器(3)(五)
2014-11-23 22:37:13 来源: 作者: 【 】 浏览:4
Tags:自己 手写 语言 编译器
if ('0' <= c2 && c2 <= '7') {

c = (c << 3) + (c2 - '0');

c2 = read();

if ('0' <= c2 && c2 <= '7' && first <= '3') {

c = (c << 3) + (c2 - '0');

d = read();

} else

d = c2;

} else

d = c2;

} else {

switch (c) {

case 'a':

c = 0x7;

break;

case 'b':

c = '\b';

break;

case 'f':

c = 0xC;

break;

case 'n':

c = '\n';

break;

case 'r':

c = '\r';

break;

case 't':

c = '\t';

break;

case 'v':

c = 0xB;

break;

}

d = read();

}

} else {

c = d;

d = read();

}

if (i >= buf.size()) {

buf.resize(buf.size()*2);

}

buf[i++] = (char)c;

}

/* If we broke out of the loop because we found a matching quote

* character then arrange to read a new character next time

* around; otherwise, save the character.

*/

peekc = (d == ttype) NEED_CHAR : d;

buf.resize(i);

std::copy(buf.begin(), buf.end(), sval.begin());

return ttype;

}

if (c == '/' && (slashSlashCommentsP || slashStarCommentsP)) {

c = read();

if (c == '*' && slashStarCommentsP) {

int prevc = 0;

while ((c = read()) != '/' || prevc != '*') {

if (c == '\r') {

LINENO++;

c = read();

if (c == '\n') {

c = read();

}

} else {

if (c == '\n') {

LINENO++;

c = read();

}

}

if (c < 0)

return ttype = TT_EOF;

prevc = c;

}

return nextToken();

} else if (c == '/' && slashSlashCommentsP) {

while ((c = read()) != '\n' && c != '\r' && c >= 0)

首页 上一页 2 3 4 5 下一页 尾页 5/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇位运算及其应用实例(2) 下一篇自己动手写C语言编译器(5)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: