Skip to content

Latest commit

 

History

History
86 lines (64 loc) · 2.7 KB

README.md

File metadata and controls

86 lines (64 loc) · 2.7 KB

Ny examples

Ny is early-stage, and examples can become stale as the parser and backends converge. This page therefore starts with the same minimal program used by the CTest smoke path instead of presenting unverified standard-library APIs as working examples.

Hello from Ny

fn main() -> i32
    println("Hello from Ny")
    return 0
end fn

From the repository root, after running ./scripts/build-sdk.sh:

sdk/nilcompiler --no-stdlib --no-bundle \
  --output hello.nil tests/smoke/hello.ny
sdk/nilinterpreter hello.nil

Expected program output:

Hello from Ny

The checked-in source is tests/smoke/hello.ny.

Mixed-language project

projects/hello-mixed contains a Matrix entrypoint importing a Ny module. From the repository root with a built SDK:

sdk/nilbuild run --project examples/projects/hello-mixed/nil.project.nildata
sdk/nilbuild run --project examples/projects/hello-mixed/nil.project.nildata --target native

Both print Hello from Ny and Matrix. See the project guide for the manifest and analyzer policy.

Function keyword fixture

The parser accepts both short and long function keywords in the development fixture:

fn short_form()
    println("short form")
end fn

function long_form()
    println("long form")
end function

See tests/language/function-keywords.ny. Files in tests/language are regression inputs, not a language-conformance promise; some exercise parser/compiler behavior without being registered as runtime tests.

Application conformance suite

applications/ contains eight deterministic, production-shaped programs covering control flow, recursion, arrays, structs, traits, enums, generics, modules, manual memory, and @ai_context metadata. Each application has exact output and exit contracts and runs through the textual and binary interpreter paths, both bundle formats, LLVM JIT, and LLVM AOT. Known native-backend gaps are explicit XFAILs rather than silent success.

Larger experimental programs

nilaix/examples and the first-party trees under packages contain larger UI, IDE, engine, and integration experiments. They are useful design and compiler-development material, but they are not curated, supported examples and may require native dependencies or unfinished language features.

For syntax beyond the smoke fixtures, consult the language reference together with current tests and compiler diagnostics. The reference includes intended syntax that may not be implemented uniformly across all backends.