VastNova 语言参考

版本 0 beta5 (2026.2.22)

输出 out

out "Hello"          # 输出字符串
out 123              # 输出数字
out a                # 输出变量值
out "value =" a      # 混合输出

变量 var

var a                # 声明变量(默认为空)
var b = 10           # 声明并赋值
var c = "text"
var d = input "提示"  # 声明并从输入赋值

常量 const

const PI = 3.14159   # 常量必须立即赋值且不可修改

输入 input / in

var x
x = input "请输入:"   # 显示提示并读取输入
in x                  # 简单输入(无提示),变量需已定义

赋值

a = 5                # 对已定义变量重新赋值
b = a + 10           # 支持表达式
c = input "新值:"    # 从输入赋值

数学运算

支持 + - * /,遵循先乘除后加减的优先级。

var result = 10 + 5 * 2   # 结果为 20

条件判断 if

if a > b {
    out "a 大于 b"
}
if a == "admin" && b != 0 {
    out "条件满足"
}

注释

// 单行注释
# 这也是单行注释
!# 多行注释开始
可以跨越多行
直到遇到结束标记 #!

嵌入 C++ 项目

vastnova.h 复制到项目目录,然后在代码中包含:

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

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

编译时需要 C++11 或更高版本。

交互式命令行

VastNova 提供了一个简单的交互式解释器示例(见 main.cpp),可逐行执行代码:

$ ./vastnova
Vastnova 0 beta4
Welcome!

>>> out "Hello"
Hello
>>> var a = 10
>>> a = a * 2
>>> out a
20
>>> exit
goodbye!

运行脚本文件

$ ./vastnova script.vn

许可证

MIT License

VastNova Language Reference

Version 0 beta5 (2026.2.22)

Output out

out "Hello"          # output string
out 123              # output number
out a                # output variable value
out "value =" a      # mixed output

Variable var

var a                # declare variable (initially empty)
var b = 10           # declare and assign
var c = "text"
var d = input "Prompt: "  # declare and assign from input

Constant const

const PI = 3.14159   # constant must be assigned immediately and cannot be changed

Input input / in

var x
x = input "Enter: "  # show prompt and read input
in x                  # simple input (no prompt), variable must already exist

Assignment

a = 5                # reassign existing variable
b = a + 10           # expressions allowed
c = input "New value: "  # assign from input

Arithmetic

Supports + - * / with standard precedence (multiplication/division before addition/subtraction).

var result = 10 + 5 * 2   # yields 20

Conditional if

if a > b {
    out "a is greater than b"
}
if a == "admin" && b != 0 {
    out "condition satisfied"
}

Comments

// single-line comment
# also single-line comment
!# multi-line comment start
can span multiple lines
until closing marker #!

Integration into C++

Copy vastnova.h into your project directory, then include it:

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

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

Compile with C++11 or later.

Interactive Command Line

VastNova provides a simple interactive interpreter example (see main.cpp) that executes code line by line:

$ ./vastnova
Vastnova 0 beta4
Welcome!

>>> out "Hello"
Hello
>>> var a = 10
>>> a = a * 2
>>> out a
20
>>> exit
goodbye!

Running Script Files

$ ./vastnova script.vn

License

MIT License