?? main.cpp
字號:
#ifndef MAIN_CPP_INCLUDED
#define MAIN_CPP_INCLUDED
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
#include "mylist.h"
#include "scanner.h"
extern FILE* f;
extern char buffer[256];
extern string LexName[42];
extern CMyList<CToken> TokenList;
extern CMyList<string> identiferList;
extern CMyList<string> unsignedIntList;
int main()
{
f = fopen("test1.txt","r");
if (f == NULL)
{
printf("File load fail\n");
}
else
{
printf("File load succeed\n");
cout<<endl;
TokenList = getTokenList(f,buffer);
cout<<"There are " << TokenList.Size() << " tokens in the Tokenlist"<<endl;
if(TokenList.Size()!=0)
{
cout<<" lineShow lex sem " << endl;
cout<<" -------- ------------- -------------"<<endl;
for(int i=0;i < (TokenList.Size()+100);i++)
{
Node<CToken>* ptr = TokenList.GetNode(i);
if(ptr)
{
printf(" %8d %14s %12s \n",
(ptr->data).lineShow,
LexName[(ptr->data).lex].c_str(),
(ptr->data).sem.c_str());
}
}
}
cout<<endl;
cout<<"There are " << identiferList.Size() << " identifers in the Tokenlist"<<endl;
if(identiferList.Size()!=0)
{
cout<<" They are " <<endl;
for(int j=0;j < identiferList.Size();j++)
{
Node<string>* ptr = identiferList.GetNode(j);
if(ptr)
{
printf(" %12s \n",
(ptr->data).c_str());
}
}
}
cout<<endl;
cout<<"There are " << unsignedIntList.Size() << " unsignedInts in the Tokenlist"<<endl;
if(unsignedIntList.Size()!=0)
{
cout<<" They are " <<endl;
for(int k=0;k< unsignedIntList.Size();k++)
{
Node<string>* ptr = unsignedIntList.GetNode(k);
if(ptr)
{
printf(" %12s \n",
(ptr->data).c_str());
}
}
}
}
return 0;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -