提交 d412a5d3 创建 作者: 赵鹏翀's avatar 赵鹏翀

add input file to project file

上级 4f69234a
<?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 &quot;$(InputPath)&quot;" 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)&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2xhtml.xsl y.output.xml &gt;y.output.html&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2dot.xsl y.output.xml &gt;y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;&quot;$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe&quot; y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;:good&#xA;exit /B 0&#xA;:bad&#xA;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)&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2xhtml.xsl y.output.xml &gt;y.output.html&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2dot.xsl y.output.xml &gt;y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;&quot;$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe&quot; y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;:good&#xA;exit /B 0&#xA;:bad&#xA;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 &quot;$(InputPath)&quot;" 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)&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2xhtml.xsl y.output.xml &gt;y.output.html&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2dot.xsl y.output.xml &gt;y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;&quot;$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe&quot; y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;:good&#xA;exit /B 0&#xA;:bad&#xA;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)&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2xhtml.xsl y.output.xml &gt;y.output.html&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;xsltproc.exe xml2dot.xsl y.output.xml &gt;y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;&quot;$(CPLInstallDir)Tools\Graphviz\bin\dotty.exe&quot; y.dot.txt&#xA;if %errorlevel% gtr 0 goto bad&#xA;&#xA;:good&#xA;exit /B 0&#xA;:bad&#xA;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>
没有这种文件类型的预览
%{
#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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论