适用于Windows或Linux或Mac的ML IDE和编译器 [英] ML IDE and Compiler for Windows or Linux or Mac

查看:76
本文介绍了适用于Windows或Linux或Mac的ML IDE和编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须用ML编写一些代码,这是我第一次使用这种语言.是否有标准ML的开发环境?(最好在Windows下).我尝试使用谷歌搜索(和stackOverFlowing!),但是发现的只是用于Linux的普通编译器(最多使用交互式控制台),但是没有IDE或Eclipse/NetBeans插件.有什么建议吗?

I have to write some code in ML and it is my first time I`m going to use the language. Is there any Development Environment for Standard ML? (preferably under Windows). I tried googling (and stackOverFlowing ! ) but all I found was plain compilers for Linux (at most with an interactive console), but no IDE nor Eclipse/NetBeans plugin. Any suggestions ?

推荐答案

如何使用Sublime Text 2配置SML

对于那些更喜欢Sublime Text而不是Emacs作为SML编程选择的编辑者,以下指南介绍了如何配置Sublime Text与SML一起使用.

How to Configure SML with Sublime Text 2

For those who prefer Sublime Text instead of Emacs as the editor of choice to program SML, the following guide describes how to configure Sublime Text to work with SML.

为使该指南对您有用,您必须已经安装了 smlnj .

For this guide to work for you, you must already have installed smlnj.

下载Sublime Text 2 开始.确保下载版本2,因为SML语法支持尚不适用于版本3.

Start by Downloading Sublime Text 2. Make sure to download version 2, because the SML syntax support does not yet work with version 3.

Sublime Text支持一组令人惊叹的软件包(即插件),您可以单独安装它们.这些软件包之一称为软件包控制".您必须首先安装程序包控制,才能直接从编辑器安装其他程序包.提供的链接说明了安装此软件包所需的操作.

Sublime Text supports an amazing set of packages (i.e. plugins) that you can install separately. One of those packages is called Package Control. You must first Install Package Control to be able to install other packages directly from the editor. The provided link explains what you need to do to install this package.

现在您已经安装了Package Control,安装其他软件包将非常容易.我们现在必须安装两个软件包:SML以支持该编程语言的语法突出显示功能,以及SublimeREPL,您可能会猜到,这是一个在Sublime Text中添加了许多编程语言的REPL功能的软件包.

Now that you have Package Control installed it is going to be really easy to install other packages. There are two packages that we must install now: SML to support syntax highlighting features for the programming language and SublimeREPL which, as you might guess, is a package that adds REPL capabilities for many different programming languages to Sublime Text.

要安装这些软件包,必须转到菜单并找到工具"->命令面板",然后键入安装软件包".在搜索框中,输入要安装的软件包的名称,从找到的列表中选择软件包,然后按Enter进行安装.对上面提到的两个软件包执行此操作:"SML"和"SublimeREPL"

To install these packages you must go to the menu and look for Tools -> Command Palette and type "Install Package". In the search box, you write the name of the package you want to install, select your package from the found list, and hit enter to get it installed. Do this for the two packages mentioned above: "SML" and "SublimeREPL"

一旦安装了SML软件包,如果打开SML文件,则应在编辑器中获得语法突出显示功能.它甚至提供了一个称为黑曜石之子"的Sublime Text主题,您可以在首选项"->配色方案"->"SML"->黑曜石之子"中启用.但是,您不需要使主题能够与SML一起使用,这只是一个首选项.

Once you have installed the SML package, if you open an SML file you should get syntax highlight capabilities within the editor. It even provides a Sublime Text Theme called Son of Obsidian that you could enable in Preferences -> Color Scheme -> SML -> Son of Obsidian. But you are not required to enable the theme to work with SML, this is just a preference.

一旦安装了SublimeREPL软件包,就可以进入菜单工具-> SublimeREPL-> SML并打开一个SML REPL会话,该会话将支持使用SML软件包突出显示语法以及命令历史记录,行编辑和自动完成功能.如果打开两个并排的选项卡,则可以使生活变得非常轻松,在左侧的选项卡中,您可以拥有SML代码文件,在右侧的位置,您可以拥有SML REPL会话.您可以使用查看->布局选项来做到这一点.

Once you have installed the SublimeREPL package you will be able to go to the menu Tools -> SublimeREPL -> SML and open an SML REPL session that will support syntax highlight using the SML package, and command history, line editing and autocompletion. You can make your life really easy if you open two side by side tabs and in your left tab you can have your SML code file and in your right, you SML REPL session. You can do that by using the View -> Layout options.

现在,让我们添加一些键盘快捷键来使用REPL.SublimeREPL软件包提供的键盘配置很少,并且所提供的键盘配置可能无法与SML REPL配合使用.所以这就是我通常要做的.

Now let's add a few keyboard shortcuts to work with the REPL. The SublimeREPL package offers little keyboard configuration, and the ones provided are probably not going to work well with the SML REPL. So this is what I typically do.

  • 首先转到首选项->浏览软件包
  • 进入SublimeREPL/config/SML子文件夹.
  • 在Sublime Text本身中编辑文件 Default.sublime-commands .该文件包含工具"->"SublimeREPL"菜单中的当前SML菜单选项.因此,我们现在将其更改为创建第二个选项,该选项可以在新的SML REPL会话中运行现有文件.我编辑的文件如下图所示.注意"id"字段.我们可以根据需要定义任意数量的不同命令,并为其指定不同的ID.在下一步中,我们将定义每个命令的作用.

  • First go to Preferences -> Browse Packages
  • Go into the SublimeREPL/config/SML subfolder.
  • Edit the file Default.sublime-commands in Sublime Text itself. This file contains the current SML menu options within the Tools -> SublimeREPL menu. So, we'll now change it to create a second option that can run an existing file in a new SML REPL session. My edited file looks as shown below. Notice the "id" field. We can define as many different commands as we want, giving them a different ID. In the next step, we'll define what every command does.

[
    {
        "caption": "SublimeREPL: SML",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_sml",
            "file": "config/SML/Main.sublime-menu"
        }
    },
    {
        "caption": "SublimeREPL: SML - Run File",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_sml_run",
            "file": "config/SML/Main.sublime-menu"
        }
    }    
]

  • 现在,在与上一个文件相同的目录中,编辑 Main.sublime-menu 文件.该文件包含以上定义的每个命令应执行的操作的详细信息.我编辑的文件定义了上述两个命令,一个命令只是打开REPL,另一个命令是打开REPL中的当前文件.它看起来如下:

  • Now, in the same directory as the previous file, edit the Main.sublime-menu file. This file contains the details of what every command defined above should do. My edited file defines the two commands described above, one to simply open the REPL and one to open the current file in the REPL. It looks as follows:

    [
         {
            "id": "tools",        
            "children":
            [{
                "caption": "SublimeREPL",
                "mnemonic": "r",
                "id": "SublimeREPL",
                "children":
                [{
                    "caption": "SML",
                    "id": "SML",
                    "children": [
                        {"command": "repl_open",
                         "caption": "SML",
                         "id": "repl_sml",
                         "args": {
                            "type": "subprocess",
                            "encoding": "utf8",
                            "cmd": ["sml"],
                            "cwd": "$file_path",
                            "external_id": "sml",
                            "syntax": "Packages/SML (Standard ML)/sml.tmLanguage"
                            }
                        },
                        {"command": "repl_open",
                         "caption": "SML - Run Current File",
                         "id": "repl_sml_run",
                         "args": {
                            "type": "subprocess",
                            "encoding": "utf8",
                            "cmd": ["sml", "$file_basename"],
                            "cwd": "$file_path",
                            "external_id": "sml",
                            "syntax": "Packages/SML (Standard ML)/sml.tmLanguage"
                            }
                        }
                    ]                                
                }]
            }]
        }
    ]
    

  • 最后一步是为这两个命令添加键盘快捷键.转到首选项"->键绑定用户",并使用以下两个附加命令编辑文件.可以随意更改我的键并使用您认为合适的任何其他快捷键,前提是这些键不用于其他功能.

  • The final step is to add keyboard shortcuts for this two commands. Go to Preferences -> Key Bindings User and edit the file with the following two additional commands. Feel free to change my keys and use whatever other shortcut keys you find appropriate, provided they are not used for other features.

    [
        {  
          "keys":["ctrl+alt+j","k"],   
          "command": "repl_open",      
          "args": {  
               "type": "subprocess",  
               "encoding": "utf8",  
               "cmd": ["sml"],  
               "cwd": "$file_path",  
               "syntax": "Packages/SML (Standard ML)/sml.tmLanguage",
               "external_id": "sml"
          }  
        } ,
        {  
          "keys":["ctrl+alt+j","m"],   
          "command": "repl_open",      
          "args": {  
               "type": "subprocess",  
               "encoding": "utf8",  
               "cmd": ["sml", "$file_basename"],  
               "cwd": "$file_path",  
               "syntax": "Packages/SML (Standard ML)/sml.tmLanguage",
               "external_id": "sml"
          }  
        }  
    ]
    

  • 我们完成了.现在,您只需按 CTRL + J K (这是按Ctrl + Alt + J,然后释放键)即可打开SML REPL然后按K).并且,如果您当前正在使用SML文件,则可以按 CTRL + J M 将其发送到新的SML REPL会话.

    And we're done. Now, you can open the SML REPL by simply pressing CTRL+J,K (this is press Ctrl+Alt+J, then release keys and press K). And if you are currently working in an SML file, you can press CTRL+J,M to send it to a new SML REPL session.

    Sublime Text提供了一些配置,这些配置使您可以解析代码文件并确定是否有问题,并让您确切地知道问题出在哪里.为此,我们必须配置一个构建系统".该配置只是一个文件,该文件告诉sublime文本运行什么命令以及如何解释输出.如果sml解析器无法解析或执行程序,则输出将告诉您问题出在哪里.构建系统使我们可以定义正则表达式来解析此类输出,并帮助Sublime文本找到包含问题的行和列.

    Sublime Text provides configurations that allow you to parse your code file and determine if something is wrong and let you know exactly where the problem is. In order to do this, we must configure a "build system". The configuration is simply a file that tells sublime text what command to run and how to interpret the output. If sml parser gets to fail to parse or execute your program then the output tells you where the problem is. The build system lets us define a regular expression to parse such output and help Sublime text find the line and column that contains the problem.

    转到首选项"->浏览软件包",然后在用户"文件夹下创建一个名为 SML.sublime-build 的新文件,并按如下所示定义文件:

    Go to Preferences -> Browse Packages and under the User folder create a new file named SML.sublime-build and define the file as follows:

    {  
      "cmd": ["/usr/local/bin/sml","$file"],  
      "selector": "source.sml",  
      "working_dir": "$file_path",
      "file_regex": "^(.*\\.sml):(\\d+)\\.(\\d+)(\\-(\\d+)\\.(\\d+))?\\s(.*)$"
     } 
    

    请确保将命令路径替换为系统中的有效路径.保存文件后,可以转到菜单,然后选择工具->构建系统-> SML.然后,要检查文件,可以执行工具->构建以分析文件并查找任何错误.通过使用菜单选项工具"->构建结果"->下一个结果"和上一个结果",您可以在构建系统选项检测到的错误之间导航,并且Sublime Text会将光标定位在SML编译器报告的错误的确切位置上

    Make sure to replace the command path with a valid path in your system. Once you have saved the file, you can go to the menu and choose Tools -> Build System -> SML. Then, to check your file, you can do Tools -> Build to parse your file and find any errors. And by using the menu option Tools -> Build Result -> Next Result and Previous Result you can navigate between the errors detected by the build system option and Sublime Text will position the cursor in the exact position of the error as reported by the SML compiler.

    我上面的正则表达式可能不是最好的,所以请随意调整它.

    My regular expression above might not be the best, so feel free to improve it as you see fit.

    就是这样.您已经准备好开始使用SML和Sublime Text进行编码.

    And that's it. You're pretty much ready to start coding with SML and Sublime Text.

    这篇关于适用于Windows或Linux或Mac的ML IDE和编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆