Files
hakorune/apps/ny-echo/main.nyash
Moe Charm 11506cee3b Phase 11-12: LLVM backend initial, semantics layer, plugin unification
Major changes:
- LLVM backend initial implementation (compiler.rs, llvm mode)
- Semantics layer integration in interpreter (operators.rs)
- Phase 12 plugin architecture revision (3-layer system)
- Builtin box removal preparation
- MIR instruction set documentation (26→Core-15 migration)
- Cross-backend testing infrastructure
- Await/nowait syntax support

New features:
- LLVM AOT compilation support (--backend llvm)
- Semantics layer for interpreter→VM flow
- Tri-backend smoke tests
- Plugin-only registry mode

Bug fixes:
- Interpreter plugin box arithmetic operations
- Branch test returns incorrect values

Documentation:
- Phase 12 README.md updated with new plugin architecture
- Removed obsolete NYIR proposals
- Added LLVM test programs documentation

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 23:44:34 +09:00

82 lines
2.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ny-echo - 最小CLI実装
// 目的: I/O・StringBoxの道通し確認
// 使用法: ny-echo [--upper|--lower]
static box Main {
init { console, options }
main(args) {
me.console = new ConsoleBox()
me.options = me.parseArgs(args)
// バージョン表示
if me.options.get("version") {
me.console.log("ny-echo v1.0.0 (Nyash " + NYASH_VERSION + ")")
return 0
}
// ヘルプ表示
if me.options.get("help") {
me.showHelp()
return 0
}
// メインループ
me.processInput()
return 0
}
parseArgs(args) {
local options = new MapBox()
// foreach は未対応のため、index で明示ループ
local i = 0
local n = args.length()
loop(i < n) {
local arg = args.get(i)
if arg == "--upper" {
options.set("upper", true)
} else if arg == "--lower" {
options.set("lower", true)
} else if arg == "--version" || arg == "-v" {
options.set("version", true)
} else if arg == "--help" || arg == "-h" {
options.set("help", true)
}
i = i + 1
}
return options
}
processInput() {
loop(true) {
local input = me.console.readLine()
if input == null { return 0 } // EOF → 関数終了に変更break未対応MIR対策
local output = me.transformText(input)
me.console.log(output)
}
}
transformText(text) {
if me.options.get("upper") {
return text.toUpperCase()
} else if me.options.get("lower") {
return text.toLowerCase()
} else {
return text // そのまま出力
}
}
showHelp() {
me.console.log("Usage: ny-echo [OPTIONS]")
me.console.log("")
me.console.log("Options:")
me.console.log(" --upper Convert input to uppercase")
me.console.log(" --lower Convert input to lowercase")
me.console.log(" -v, --version Show version information")
me.console.log(" -h, --help Show this help message")
me.console.log("")
me.console.log("Reads from stdin and echoes to stdout with optional transformation.")
}
}