如何为我的编译器创建 GUI?
我使用 flex 作为词法分析器,使用 bison 作为解析器生成器,但两者的结果都是 控制台窗口,我想要一个 GUI(比如 IDE) 那么该怎么做呢。 谢谢
i am using flex as lexical analyzer and bison as parser generator , but the result of both is
console window and i want to have a gui (like ide) for it
so how to do that .
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不。将编译器保留为命令行应用程序,而是教一些现有的 IDE 如何调用它并解析其输出。
Don't. Leave the compiler as a command line application and instead teach some existing IDE about how to call it and parse its output.
如果您将其保留为命令行,则可以使用开源 GUI 并将编译器插入其中 - 您可以免费获得适合您的编译器的出色 IDE ;)。
对于可以与自定义语言配合良好的 IDE:
您将在编写自己的代码时获得很多的乐趣无论如何,自定义插件,但它会比自己编写一个 IDE 少很多。
然而,另一个主题是为您的语言编写一个解释器,但我认为这不是您的目标。但是,如果是这样,您应该了解 readline。
如果您真的确定要为您的语言编写一个简单 IDE(编写复杂的 IDE 是一项长期任务),请尝试至少使用一种语言它适合快速 GUI 开发(C#、Java 等),并为基础提供类似记事本的应用程序。你可以从那里开始。
但请记住,几乎所有已知的编译器都是命令行的——IDE 只是执行并解析结果。这是有原因的,你知道的。
使用命令行的原因:
If you leave it as a command line, you can use Open Source GUI's and plug your compiler into it -- for free you get a brilliant IDE for YOUR compiler ;).
For IDE's that could go well with a custom language:
You'll have a lot of fun writing your custom plugins anyway, but it will be a lot less than writing an IDE yourself.
Another topic however, is writing an interpreter for your language, but I assume that's not what you are aiming for. If so however, you should learn about readline.
And if you're really sure you want to write a simple IDE for your language (writing a complex one is a task for ages), try to at least use a language that is suited for rapid GUI development (C#, Java, others), and get a working Notepad-like application for a base. You can start from there.
Remember however, that almost every known compiler is command-line -- the IDE's just execute and parse the results. There's a reason for that, y'know.
Reasons for command-line:
你使用什么操作系统?我假设linux bc我很难让bison在windows上运行,尽管我可以在windows中编译我的bison输出。
我没有 IDE。我在 VMWare 中安装了 linux,并启用了 Unity(因此我在 Windows7 Windows 上或下安装了 Linux Windows),并使用程序员记事本来编辑文件,作为我首选的简单 IDE。它有一些自动完成功能等。对于我的编译器的 Windows 版本,我可以将批处理文件设置为 pnotepad,在更改源代码时,我可以按 F5 运行 bat 文件并编译我的源代码并且它有输出。然而,在开发编译器时,我使用 alt-tab 切换到我的 Linux 终端并在那里运行构建。
当我在 Linux 上构建编译器时,它会运行自动脚本来查看是否有任何问题,并且我的 Linux 编译器会以不同的颜色构建输出错误。我不需要 IDE。我确实希望我能为视觉工作室提供某种我已经研究过的语言插件。看起来很困难,但这家伙在 Visual Studio 中使用 php 进行语法高亮 Visual Studio 2010 中是否支持本机 PHP?
What OS are you on? I'll assume linux bc i had difficulties getting bison running on windows although i can compile my bison output in windows.
I didnt have an IDE. I had linux in VMWare with unity on (so i had linux windows on or under windows7 windows) and used programmers notepad to edit the files as its my preferred simple IDE. It has some autocomplete and etc. For my windows build of my compiler i can set a batch file to pnotepad and while changing source i can press F5 which ran the bat file and compiled my source AND it had the output. However developing the compiler i used alt-tab to switch to my linux terminal and ran the build in there.
When i built the compiler on linux it would run automated scripts to see if anything broke and my linux compiler build output errors in a different color. I had no need for an IDE. I do hope i can have some kind of language plugin for visual studios which i already looked into. It looks difficult but this guy has syntax highlight with php in visual studios Native PHP support in Visual Studio 2010?
详细阐述 Kornel 答案中的 Eclipse 部分;这里有一个关于如何教学的指南
Eclipse 将成为您的语言的 IDE:
http://www.eclipse.org/articles/article .php?file=Article-BuildYourOwnDSL/index.html
Elaborating on the Eclipse part of Kornel's answer; here's a pointer to how you can teach
Eclipse to be the IDE for YOUR language:
http://www.eclipse.org/articles/article.php?file=Article-BuildYourOwnDSL/index.html