VastNova

轻量级、易嵌入的脚本语言
Lightweight, embeddable scripting language

极简语法,动态类型,数学运算,条件判断,交互输入,单头文件嵌入,专为快速集成和交互式使用而设计。

Minimal syntax, dynamic typing, arithmetic, conditionals, interactive input, header-only — designed for quick integration and interactive use.

特性

Features

极简语法
Minimal Syntax

仅包含 out/print, var, const, in/read, if 等关键字,易于学习。

Only out/print, var, const, in/read, if keywords, easy to learn.

🔢
动态类型
Dynamic Typing

自动区分数字和字符串,无需类型声明。

Automatically distinguishes numbers and strings.

数学运算
Arithmetic

支持 + - * / 及运算符优先级。

Supports + - * / with operator precedence.

⚖️
条件判断
Conditionals

支持 > < == != && ||,字符串可比较。

Supports > < == != && ||, with string comparison.

⌨️
交互输入
Interactive Input

通过 input 或 in/read 获取用户输入。

Get user input via input or in/read commands.

📦
单头文件
Header-only

仅依赖 C++ 标准库,极易嵌入任何 C++ 项目。

Depends only on C++ standard library, easy to embed.

快速开始

Quick Start

// Hello World 示例 (使用 print 和 read)
print "Hello, VastNova!"
var name = input "What's your name? "
read name   // 也可以使用 in name
print "Nice to meet you, " name

将 vastnova.h 复制到项目,然后:

Copy vastnova.h into your project, then:

#include "vastnova.h"
#include <iostream>

int main() {
    vast(R"(
        print "Hello, VastNova!"
        var name = input "What's your name? "
        print "Nice to meet you, " name
    )");
    return 0;
}

编译:g++ -std=c++11 main.cpp -o vastnova

Compile: g++ -std=c++11 main.cpp -o vastnova

语法速览

Syntax Overview

输出 (out/print)

out "Hello"
print 123
out a
print "value =" a

变量 / 常量

var a
var b = 10
const PI = 3.14

输入 (in/read / input)

x = input "Enter: "
in x
read x

条件 if

if a > b {
    out "a > b"
}
if a == "admin" && b != 0 {
    // ...
}

更新日志

Version History

0 beta6 (2026.3.3) - 新增 read 和 print 关键字,与原有的 out/in 完全兼容。Added read and print keywords, fully compatible with existing out/in.

0 beta5 (2026.2.22) - 新增 if 语句及字符串比较支持Added if statements and string comparison support