📄 main.cpp
字号:
/*
* file: main.cpp
* func: The main source file.
*/
// First 与 Follow 集生成程序
/*
* CFF v1.5
*
* 这是我的一个防 Bison 1.24 扫描器自动生成器中的一部分,将它提取出来,以
* 方便大家在需要的时候使用。
* 本程序可以从输入文件中读取类似于 Bison1.24 中定义的上下文无关文法并对其
* 进行处理,输出其终结符集、非终结符集、产生式(文法)集、First与Follow集。
*
* CFF1.5 修改:
* 1) 可以对文法进行化简。
* 2) 增加 '.' 作为标识符的一部分,其作用相当于下划线('_'),即现在
* a.ff 也可以是一个合法的标识符名称。
* 3) 支持绝大部分的 Bison1.24 语法规则,如 %token,%left,%right,%prec...,
* 注释,文法动作,嵌入式文法动作等。
* 4) 程序结果输出到独立的文件中。
* 5) 取消命令行参数。
* 6) 为原始文法添加 “@start->开始符号” 的新产生式。
* 7) 修改了一些小错误。
*/
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <cstdlib>
#include <algorithm>
#include "types.h"
#include "cmd.h"
#include "lex.h"
//#include "parse.h"
#include "first.h"
using std::cout;
using std::cin;
using std::endl;
sint32 main(sint32 argc,char *argv[])
{
// 命令行分析 ...
Cmd cmd(argc,argv);
// ....
if(argc <= 1)
{// 命令行参数为空。
cout<<"\n请输入文法文件:";
std::string fname;
cin>>fname;
cmd.set_ifname(fname);
}
Lex lex(cmd.get_ifname());
First first(lex,cmd);
first.start_parse();
first.crt_First();
first.crt_Follow();
first.print_Version("--- Create by CFF 1.5 ---");
first.print_Terminals();
first.print_Nonterminals();
first.print_Rulers();
first.print_First();
first.print_Follow();
if (argc<=1)
system("pause");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -