Lex 和 Yacc Xcode 4

发布于 2024-12-22 16:48:32 字数 478 浏览 7 评论 0原文

如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱我好吗 2024-12-29 16:48:32

听起来您需要做的就是将 *.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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文