Lex 和 Yacc Xcode 4
如何使用 Xcode 4 设置 lex 和 Yacc?我应该在构建规则中编写什么自定义脚本来做到这一点?
我有一个 lex 文件 abc.l 和一个 yacc 文件 cba.y 都放置在与其他项目源文件相同的目录中。 parser.ymm
%{
#include<iostream>
#include<stdio.h>
#include "querystructure.h"
using namespace std;
static int col_id = 0;
extern void yyerror (char* message);
extern int yylex ();
%}
lexer.l/lexer.lm
%{
#include <stdio.h>
#include "y.tab.h"
%}
How to set up lex and Yacc with Xcode 4? What custom script should I write in the Build Rules to do that?
I have one lex file abc.l and one yacc file cba.y both placed in the same directory as that of other project source files.
parser.ymm
%{
#include<iostream>
#include<stdio.h>
#include "querystructure.h"
using namespace std;
static int col_id = 0;
extern void yyerror (char* message);
extern int yylex ();
%}
lexer.l/lexer.lm
%{
#include <stdio.h>
#include "y.tab.h"
%}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要做的就是将
*.y
文件重命名为*.ym
:我非常高兴我所要做的就是将 yacc 文件的后缀设为 .ym 而不是.y 让 Xcode 做所有正确的事情。
我还没有尝试过这个,但链接的帖子表明 XCode 内置了足够的智能,以便“自动”处理解析器生成器。
It sounds like all you need to do is to rename your
*.y
file to*.ym
:I am extremely pleased that all I had to do was make the suffix to the yacc file be .ym instead of .y to get Xcode to do all the right things.
I have not tried this, but the linked post suggests that XCode has enough smarts built into it in order to deal with parser generators "automagically".