在vscode 如何运行a.nut 程序(Squirrel语言)

在 VS Code 中运行 Squirrel 语言编写的 .nut 程序,需要先配置 Squirrel 运行环境并安装相关插件,具体步骤如下:

一、安装 Squirrel 解释器

Squirrel 程序需要通过其官方解释器 squirrelsq 执行,首先需要安装解释器:

  1. Windows 系统
    • 从 Squirrel 官方网站(squirrel-lang.org)下载源码
    • 用vs2010打开C:\Users\think\Downloads\squirrel_3_2_stable\squirrel3\squirrel.dsw
    • 编译生成sq.exe
    • sq.exe(解释器)的目录添加到系统环境变量 Path
  2. Linux/macOS 系统
    • 可通过源码编译(官网下载源码后执行 makemake install
    • 部分 Linux 发行版可通过包管理器安装(如 sudo apt-get install squirrel

二、在 VS Code 中配置运行环境

  1. 安装 Squirrel 语法高亮插件

    • 打开 VS Code,进入扩展面板(Ctrl+Shift+X)
    • 搜索并安装 Squirrel 插件(通常选择下载量较高的,如 Squirrel Language Supports件),用于代码高亮和语法提示,
  2. 配置任务运行器(tasks.json)

    • 打开 .nut 文件所在的项目文件夹
    • Ctrl+Shift+P 打开命令面板,输入 Tasks: Configure Task 并选择 Create tasks.json file from template
    • 选择 Others 模板,替换内容为:

    json

    cpp 复制代码
    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Run Squirrel Script",
                "type": "shell",
                "command": "sq.exe",  // 或 "squirrel",根据实际解释器命令调整
                "args": ["${file}"],  // 运行当前打开的 .nut 文件
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "problemMatcher": []
            }
        ]
    }

三、运行 .nut 程序

  1. 在 VS Code 中打开要运行的 a.nut 文件
  2. Ctrl+Shift+B 执行配置好的任务,即可在终端中看到程序运行结果
  3. 若需传递参数,可在 tasks.jsonargs 数组中添加,例如:["${file}", "param1", "param2"]
相关推荐
程序员Aries几秒前
从零开始实现一个高并发内存池_DayThree:内存池整体框架与ThreadCache、TLS无锁访问
c++·学习·单例模式
龙腾AI白云2 分钟前
大模型-扩散模型(Diffusion Model)原理讲解(4)
开发语言
charlie11451419125 分钟前
Windows 10 系统编程——线程专题1
c++·windows·学习·线程
夏鹏今天学习了吗33 分钟前
【LeetCode热题100(35/100)】LRU 缓存
算法·leetcode·缓存
爱吃小胖橘33 分钟前
Lua语法(2)
开发语言·unity·lua
_Power_Y35 分钟前
SSM面试题学习
java·开发语言·学习
拾光Ծ1 小时前
【C++】STL有序关联容器的双生花:set/multiset 和 map/multimap 使用指南
数据结构·c++·算法
SccTsAxR1 小时前
[初学C语言]关于scanf和printf函数
c语言·开发语言·经验分享·笔记·其他
害恶细君1 小时前
【超详细】使用conda配置python的开发环境
开发语言·python·jupyter·pycharm·conda·ipython
澄澈i2 小时前
设计模式学习[20]---桥接模式
c++·学习·设计模式·桥接模式