Alia 编译解释器(JS版本)
  • JavaScript 99.8%
  • C 0.2%
Find a file
2026-10-25 14:09:40 +08:00
Analyzer engine: 一元否定委托别名匹配 + 无类型形参 + each 裸数组迭代 2026-10-21 01:08:06 +08:00
ASTifier parser: tryParseAliasObjectCall 实参止于顶层二元运算符(pre-dot 形态)+ 候选切分异常安全 + 分派异常安全 2026-10-24 16:33:45 +08:00
Checker engine: 循环导入宿主支持 + 递归 type 记录检查 2026-10-18 12:20:01 +08:00
Compiler engine: 作用域原生下标判定对齐后端降低 + 格式化串转义往返 2026-10-21 01:08:10 +08:00
Debug 支持调试功能&格式化不删除注释 2026-10-03 10:53:32 +08:00
ErrorHandler engine: fs list/listRecursive + skipCheck 选项 + 检查源目录贯通 2026-10-21 01:08:10 +08:00
Formatter engine: 作用域原生下标判定对齐后端降低 + 格式化串转义往返 2026-10-21 01:08:10 +08:00
Interpreter dispatch: 实参提取堆叠体段拒绝求值(编译期不执行用户代码) 2026-10-25 14:09:40 +08:00
Language 移除计时器⏱ 2026-09-19 16:40:09 +08:00
Shell 错误诊断系统3+Shell换行 2026-07-11 12:37:21 +08:00
Tests engine: fs list/listRecursive + skipCheck 选项 + 检查源目录贯通 2026-10-21 01:08:10 +08:00
.gitignore 统一FFI CWD 2026-09-04 18:46:09 +08:00
index.js engine: fs list/listRecursive + skipCheck 选项 + 检查源目录贯通 2026-10-21 01:08:10 +08:00
package.json 去除Deasync依赖 2026-08-06 15:16:27 +08:00
README.md 更新名称及引用 2026-07-10 20:41:43 +08:00
TEST_MODE_GUIDE.md 更新测试系统 2026-06-06 20:21:44 +08:00

Alia Language System

This is a refactored implementation of the Alia programming language, organized into clear modules for AST parsing, interpretation, compilation, and formatting.

Architecture

The system is divided into four main components:

ASTifier

  • Tokenize: Lexical analysis, converting source code to tokens.
  • ExpressionParser: Parsing expressions into AST nodes.
  • Types: AST node definitions (Program, Statement, Expression, etc.).
  • Aliases: Utilities for handling alias definitions and pattern matching.

Interpreter

  • Runtime: Execution engine that interprets the AST.
  • CoreExts: Built-in methods and extensions for core types.

Compiler

  • Translates Alia AST to target languages.

Formatter

  • Pretty-prints Alia code from AST.

Key Design Decisions

  1. Clear AST Structure: The parser builds a comprehensive AST that includes all language constructs. Alias definitions are registered during parsing but stored in the AST for the interpreter to execute.

  2. Separation of Concerns:

    • Parser (ASTifier): Only parses and builds AST, registers aliases in a parsing-time registry.
    • Interpreter: Executes AST nodes directly, no pattern matching for aliases.
    • Compiler: Generates code from AST.
    • Formatter: Formats AST back to code.
  3. Stack-Based Execution: The core execution model is based on executing Stack objects, which contain sequences of statements.

Usage

const Alia = require('./index.js');
const alia = new Alia();

// Parse code to AST
const ast = alia.parse('let x = 5; x = x + 1;');

// Interpret AST
alia.interpret('let x = 5; x = x + 1;');

// Compile to JavaScript
const jsCode = alia.compile('let x = 5;', 'js');

// Format AST
const formatted = alia.format('let x=5;');

Directory Structure

bootstrap/Uildod(JS)/
├── Astify/
│   ├── Tokenize/index.js
│   ├── ExpressionParser/index.js
│   ├── Types/index.js
│   └── Aliases/index.js
├── Interpreter/
│   ├── Runtime/index.js
│   └── CoreExts/index.js
├── Compiler/index.js
├── Formatter/index.js
└── index.js