Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
LEX与YACC项目模板3
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
CP Lab Group
任务模板的模板
LEX与YACC项目模板3
提交
d412a5d3
提交
d412a5d3
3月 19, 2020
创建
作者:
赵鹏翀
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add input file to project file
上级
4f69234a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
128 行增加
和
124 行删除
+128
-124
lex_yacc.cplproj
lex_yacc.cplproj
+70
-66
lex_yacc.puo
lex_yacc.puo
+0
-0
yacc.txt
yacc.txt
+58
-58
没有找到文件。
lex_yacc.cplproj
浏览文件 @
d412a5d3
<?xml version="1.0" encoding="gb2312"?>
<OSLProject
Version=
"1.00"
Name=
"lex_yacc"
SubjectID=
"11c951f4-9b13-40e1-8b73-39ba7d73b89b"
ProjectTemplateID=
"419bab45-a766-4de8-829e-a60059af6849"
>
<Configurations>
<Configuration
Name=
"Debug"
CommandArgument=
"sample.txt"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"_DEBUG"
GenerateDebugInformation=
"-1"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
MapFileName=
""
AdditionalDependencies=
""
DisplayVerbose=
"0"
AdditionalOptions=
""
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"NDEBUG"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
</Configurations>
<Files>
<Filter
Name=
"Lex 输入文件"
>
<File
RelativePath=
".\lex.txt"
>
<FileConfiguration
Name=
"Debug"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"flex.exe -b -oyylex.c "$(InputPath)""
Description=
"正在使用 Lex 生成分析程序......"
Outputs=
"lex.backup"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"TINY 语言样例"
>
<File
RelativePath=
".\sample.txt"
>
</File>
</Filter>
<Filter
Name=
"Yacc 输入文件"
>
<File
RelativePath=
".\yacc.txt"
>
<FileConfiguration
Name=
"Debug"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"bison.exe -y --defines=ytab.h --report=all --report-file=y.output.txt --output=ytab.c --xml=y.output.xml $(InputFileName)
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2xhtml.xsl y.output.xml >y.output.html
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2dot.xsl y.output.xml >y.dot.txt
if %errorlevel% gtr 0 goto bad

"$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe" y.dot.txt
if %errorlevel% gtr 0 goto bad

:good
exit /B 0
:bad
exit /B 1"
Description=
"正在使用 Yacc 生成分析程序..."
Outputs=
"y.output.xml"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"bison.exe -y --defines=ytab.h --report=all --report-file=y.output.txt --output=ytab.c --xml=y.output.xml $(InputFileName)
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2xhtml.xsl y.output.xml >y.output.html
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2dot.xsl y.output.xml >y.dot.txt
if %errorlevel% gtr 0 goto bad

"$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe" y.dot.txt
if %errorlevel% gtr 0 goto bad

:good
exit /B 0
:bad
exit /B 1"
Description=
"正在使用 Yacc 生成分析程序..."
Outputs=
"y.output.xml"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"头文件"
>
<File
RelativePath=
".\main.h"
>
</File>
<File
RelativePath=
".\ytab.h"
>
</File>
</Filter>
<Filter
Name=
"报告"
>
<File
RelativePath=
".\y.dot.txt"
>
</File>
<File
RelativePath=
".\y.output.html"
>
</File>
<File
RelativePath=
".\y.output.txt"
>
</File>
</Filter>
<Filter
Name=
"源文件"
Filter=
"cpp;c;cc;cxx"
>
<File
RelativePath=
".\ytab.c"
>
</File>
<File
RelativePath=
".\yylex.c"
>
</File>
</Filter>
<File
RelativePath=
".\readme.md"
>
</File>
</Files>
</OSLProject>
<?xml version="1.0" encoding="gb2312"?>
<OSLProject
Version=
"1.00"
Name=
"lex_yacc"
SubjectID=
"11c951f4-9b13-40e1-8b73-39ba7d73b89b"
ProjectTemplateID=
"419bab45-a766-4de8-829e-a60059af6849"
>
<Configurations>
<Configuration
Name=
"Debug"
CommandArgument=
"sample.txt"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"_DEBUG"
GenerateDebugInformation=
"-1"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
MapFileName=
""
AdditionalDependencies=
""
DisplayVerbose=
"0"
AdditionalOptions=
""
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release"
CommandArgument=
"sample.txt"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"NDEBUG"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
</Configurations>
<Files>
<Filter
Name=
"Lex 输入文件"
>
<File
RelativePath=
".\lex.txt"
>
<FileConfiguration
Name=
"Debug"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"flex.exe -b -oyylex.c "$(InputPath)""
Description=
"正在使用 Lex 生成分析程序......"
Outputs=
"lex.backup"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"TINY 语言样例"
>
<File
RelativePath=
".\sample.txt"
>
</File>
</Filter>
<Filter
Name=
"Yacc 输入文件"
>
<File
RelativePath=
".\yacc.txt"
>
<FileConfiguration
Name=
"Debug"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"bison.exe -y --defines=ytab.h --report=all --report-file=y.output.txt --output=ytab.c --xml=y.output.xml $(InputFileName)
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2xhtml.xsl y.output.xml >y.output.html
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2dot.xsl y.output.xml >y.dot.txt
if %errorlevel% gtr 0 goto bad

"$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe" y.dot.txt
if %errorlevel% gtr 0 goto bad

:good
exit /B 0
:bad
exit /B 1"
Description=
"正在使用 Yacc 生成分析程序..."
Outputs=
"y.output.xml"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release"
>
<Tool
Name=
"CustomBuildTool"
CommandLine=
"bison.exe -y --defines=ytab.h --report=all --report-file=y.output.txt --output=ytab.c --xml=y.output.xml $(InputFileName)
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2xhtml.xsl y.output.xml >y.output.html
if %errorlevel% gtr 0 goto bad

xsltproc.exe xml2dot.xsl y.output.xml >y.dot.txt
if %errorlevel% gtr 0 goto bad

"$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe" y.dot.txt
if %errorlevel% gtr 0 goto bad

:good
exit /B 0
:bad
exit /B 1"
Description=
"正在使用 Yacc 生成分析程序..."
Outputs=
"y.output.xml"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name=
"头文件"
>
<File
RelativePath=
".\main.h"
>
</File>
<File
RelativePath=
".\ytab.h"
>
</File>
</Filter>
<Filter
Name=
"报告"
>
<File
RelativePath=
".\y.dot.txt"
>
</File>
<File
RelativePath=
".\y.output.html"
>
</File>
<File
RelativePath=
".\y.output.txt"
>
</File>
</Filter>
<Filter
Name=
"源文件"
Filter=
"cpp;c;cc;cxx"
>
<File
RelativePath=
".\ytab.c"
>
</File>
<File
RelativePath=
".\yylex.c"
>
</File>
</Filter>
<File
RelativePath=
".\input1.txt"
>
</File>
<File
RelativePath=
".\output1.txt"
>
</File>
<File
RelativePath=
".\readme.md"
>
</File>
</Files>
</OSLProject>
lex_yacc.puo
浏览文件 @
d412a5d3
没有这种文件类型的预览
yacc.txt
浏览文件 @
d412a5d3
%{
#include "main.h"
int yyerror(const char *s);
extern int yylex(void);
%}
%%
program:
;
%%
int main(int argc, char* argv[])
{
// 使用第一个参数输入待处理文件的名称,若没有没有输入此参数就报告错误
if(argc < 2)
{
printf("Usage:
scan.exe filename.\n");
return 1;
}
// 打开待处理的文件
FILE* file = fopen(argv[1], "rt");
if(NULL == file)
{
printf("Can not open file \"%s\".\n", argv[1]);
return 1;
}
//
// TODO:
//
yyparse(); //使yacc开始读取输入和解析,它会调用lex的yylex()读取记号
fclose(file);
return 0;
}
/* 打印错误信息 */
int yyerror(const char* s)
{
fprintf(stdout, "%s\n", s);
return 0;
}
%{
#include "main.h"
int yyerror(const char *s);
extern int yylex(void);
%}
%%
program:
;
%%
int main(int argc, char* argv[])
{
// 使用第一个参数输入待处理文件的名称,若没有没有输入此参数就报告错误
if(argc < 2)
{
printf("Usage:
app.exe filename.\n");
return 1;
}
// 打开待处理的文件
FILE* file = fopen(argv[1], "rt");
if(NULL == file)
{
printf("Can not open file \"%s\".\n", argv[1]);
return 1;
}
//
// TODO:
//
yyparse(); //使yacc开始读取输入和解析,它会调用lex的yylex()读取记号
fclose(file);
return 0;
}
/* 打印错误信息 */
int yyerror(const char* s)
{
fprintf(stdout, "%s\n", s);
return 0;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论