java转成c++Lexer

来源:百度知道 编辑:UC知道 时间:2024/09/28 12:48:13
完成的话100 分,
问题太长, 这里发不到。

Test.txt保存以下测试内容:

vo ads int b;
if b=3.6
{
case
if(c!= 0.98) v=4;
else break;
if(c>=0.98)v=5;
}

运行结果:

if
(
c
!=
0.98
)
v
==
4
;
else
break
;
if
(
c
<=
0.98
)
v
==
5
;
}

//Java转换过后的C++源代码如下:
#include <iostream>
#include <fstream>
#include <string>

const char eolnCh = '\n';
const char eofCh = '\004';

using namespace std;

string letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
string digits = "0123456789";

string divideTok = "/" ;
string eofTok = "\04" ;
string plusTok = "+" ;
string minusTok = "-" ;
string multiplyTok = "*";
string leftParenTok