nomen-lang 0.0.19 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/NOMEN_AGENTS.md +56 -11
  2. package/core/System/Array.nm +11 -11
  3. package/core/System/Channel.nm +146 -12
  4. package/core/System/Console.nm +28 -17
  5. package/core/System/Controls/Button.nm +96 -8
  6. package/core/System/Controls/CheckBox.nm +117 -12
  7. package/core/System/Controls/Container.nm +114 -8
  8. package/core/System/Controls/Text.nm +98 -8
  9. package/core/System/Controls/TextBox.nm +120 -10
  10. package/core/System/Controls/Window.nm +231 -23
  11. package/core/System/Init.nm +4 -8
  12. package/core/System/Math.nm +10 -32
  13. package/core/System/Result.nm +1 -1
  14. package/core/System/Stream/Directory.nm +189 -63
  15. package/core/System/Stream/DirectoryError.nm +21 -0
  16. package/core/System/Stream/File.nm +339 -141
  17. package/core/System/Stream/FileError.nm +21 -0
  18. package/core/System/Stream/Http.nm +109 -44
  19. package/core/System/Stream/HttpError.nm +20 -0
  20. package/core/System/String.nm +83 -69
  21. package/core/System/StringBuilder.nm +11 -13
  22. package/core/System/Task.nm +46 -12
  23. package/core/System/Test.nm +1 -1
  24. package/core/System/Text/Json.nm +5 -3
  25. package/core/System/Text/JsonTree.nm +23 -14
  26. package/core/System/Text/Regex.nm +124 -64
  27. package/core/System/bool.nm +4 -9
  28. package/core/System/char.nm +3 -9
  29. package/core/System/float.nm +2 -1
  30. package/core/System/float32.nm +44 -0
  31. package/core/System/float64.nm +44 -0
  32. package/core/System/int.nm +3 -9
  33. package/core/System/int16.nm +47 -0
  34. package/core/System/int32.nm +47 -0
  35. package/core/System/int64.nm +3 -9
  36. package/core/System/int8.nm +3 -9
  37. package/core/System/ufloat.nm +44 -0
  38. package/core/System/ufloat32.nm +44 -0
  39. package/core/System/ufloat64.nm +44 -0
  40. package/core/System/uint.nm +3 -9
  41. package/core/System/uint16.nm +47 -0
  42. package/core/System/uint32.nm +47 -0
  43. package/core/System/uint64.nm +3 -9
  44. package/core/System/uint8.nm +3 -9
  45. package/core/docs/System/Channel.md +2 -0
  46. package/core/docs/System/Result.md +5 -1
  47. package/core/docs/System/Task.md +1 -1
  48. package/dist/index.mjs +32686 -15301
  49. package/package.json +38 -34
  50. package/src/args.ts +11 -0
  51. package/src/index.ts +15 -2
  52. package/src/init.ts +1 -1
  53. package/src/test.ts +1 -1
  54. package/src/types/Config.ts +2 -0
package/package.json CHANGED
@@ -1,35 +1,39 @@
1
1
  {
2
- "name": "nomen-lang",
3
- "version": "0.0.19",
4
- "description": "The CLI for the Nomen programming language.",
5
- "keywords": [],
6
- "license": "ISC",
7
- "author": "",
8
- "bin": {
9
- "nomen": "dist/index.mjs"
10
- },
11
- "files": [
12
- "dist",
13
- "src",
14
- "core",
15
- "NOMEN_AGENTS.md"
16
- ],
17
- "type": "module",
18
- "scripts": {
19
- "build": "node scripts/bundle-assets.mjs && vp pack",
20
- "dev": "node scripts/bundle-assets.mjs && vp pack --watch",
21
- "test": "vp test",
22
- "check": "vp check",
23
- "format": "vp check --fix",
24
- "prepare": "vp config",
25
- "go": "tsx src/index.ts",
26
- "register": "pnpm build && pnpm add -g ."
27
- },
28
- "devDependencies": {
29
- "@types/node": "^26.2.0",
30
- "chokidar": "^5.0.0",
31
- "tsx": "^4.23.12",
32
- "typescript": "^7.0.2",
33
- "vite-plus": "catalog:"
34
- }
35
- }
2
+ "name": "nomen-lang",
3
+ "version": "0.1.0",
4
+ "description": "The CLI for the Nomen programming language.",
5
+ "keywords": [],
6
+ "license": "ISC",
7
+ "author": "",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/andrewjk/nomen",
11
+ "directory": "cli"
12
+ },
13
+ "bin": {
14
+ "nomen": "dist/index.mjs"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src",
19
+ "core",
20
+ "NOMEN_AGENTS.md"
21
+ ],
22
+ "type": "module",
23
+ "devDependencies": {
24
+ "@types/node": "^26.2.0",
25
+ "chokidar": "^5.0.0",
26
+ "tsx": "^4.23.12",
27
+ "typescript": "^7.0.2",
28
+ "vite-plus": "0.2.9"
29
+ },
30
+ "scripts": {
31
+ "build": "node scripts/bundle-assets.mjs && vp pack",
32
+ "dev": "node scripts/bundle-assets.mjs && vp pack --watch",
33
+ "test": "vp test",
34
+ "check": "vp check",
35
+ "format": "vp check --fix",
36
+ "go": "tsx src/index.ts",
37
+ "register": "pnpm build && pnpm add -g ."
38
+ }
39
+ }
package/src/args.ts CHANGED
@@ -12,6 +12,10 @@ export interface Args {
12
12
  audit: boolean;
13
13
  audit_runtime?: string;
14
14
  check: boolean;
15
+ release: boolean;
16
+ /** Opt in to FP reassociation: float reductions vectorize under NEON
17
+ * (results may differ in the last ulp vs the scalar loop). */
18
+ fast_math: boolean;
15
19
  // Everything after a bare `--` on the command line — forwarded verbatim to
16
20
  // the compiled program by `nomen run`. Lets a program receive its own argv
17
21
  // (`nomen run --in app/main.nm -- arg1 arg2`).
@@ -42,6 +46,9 @@ const BOOLEAN_OPTIONS: Map<string, string> = new Map([
42
46
  ["w", "watch"],
43
47
  ["audit", "audit"],
44
48
  ["check", "check"],
49
+ ["release", "release"],
50
+ ["r", "release"],
51
+ ["fast-math", "fast_math"],
45
52
  ]);
46
53
 
47
54
  const DEFAULTS: Partial<Args> = {
@@ -49,6 +56,8 @@ const DEFAULTS: Partial<Args> = {
49
56
  watch: false,
50
57
  audit: false,
51
58
  check: false,
59
+ release: false,
60
+ fast_math: false,
52
61
  };
53
62
 
54
63
  function set(args: Args, key: string, value: string | boolean): void {
@@ -166,6 +175,8 @@ export function print_help(): void {
166
175
  " --lib, -l <path> Path to System library directory (containing package.jsonc)",
167
176
  " --audit Audit the generated program for memory issues",
168
177
  " --audit-runtime <path> Path to audit_runtime.c, linked in when --audit is set",
178
+ " --release, -r Build with optimizations (clang -O2; asm passes on aarch64)",
179
+ " --fast-math Allow FP reassociation (float loop reductions vectorize on aarch64)",
169
180
  " --check For `nomen format`: report files that would change",
170
181
  " -h, --help Show this help",
171
182
  ].join("\n"),
package/src/index.ts CHANGED
@@ -163,6 +163,8 @@ try {
163
163
  if (args.lib) config.lib = args.lib;
164
164
  if (args.audit) config.audit = args.audit;
165
165
  if (args.audit_runtime) config.audit_runtime = args.audit_runtime;
166
+ if (args.release) config.release = args.release;
167
+ if (args.fast_math) config.fast_math = args.fast_math;
166
168
 
167
169
  // Is the --in path a folder
168
170
  if (fs.lstatSync(args.in).isDirectory()) {
@@ -349,7 +351,13 @@ function processFile(filename: string, config: Config, mode: Mode, program_args:
349
351
  return;
350
352
  }
351
353
 
352
- const result = build(parsed.root, { arch, platform, audit: config.audit });
354
+ const result = build(parsed.root, {
355
+ arch,
356
+ platform,
357
+ audit: config.audit,
358
+ optimize: config.release,
359
+ fast_math: config.fast_math,
360
+ });
353
361
 
354
362
  if (result.errors && result.errors.length > 0) {
355
363
  console.log(render_errors(input, result.errors));
@@ -391,7 +399,12 @@ function processFile(filename: string, config: Config, mode: Mode, program_args:
391
399
  platform === "macos" || platform === "ios"
392
400
  ? " -framework CoreGraphics -framework Foundation -framework AppKit -lobjc"
393
401
  : "";
394
- execSync(`clang -o ${outfile} ${link_inputs}${framework_flags}`);
402
+ // Release mode compiles the C (and aarch64 companion C) with -O2,
403
+ // matching the optimized builds other toolchains produce by default.
404
+ // The aarch64 .s itself is assembled verbatim — its optimizations are
405
+ // the codegen passes enabled via `optimize` above.
406
+ const opt_flags = config.release ? " -O2" : "";
407
+ execSync(`clang${opt_flags} -o ${outfile} ${link_inputs}${framework_flags}`);
395
408
 
396
409
  if (mode === "build") {
397
410
  const buildTime = performance.now();
package/src/init.ts CHANGED
@@ -31,7 +31,7 @@ pub func main = (Init init) {
31
31
  `;
32
32
 
33
33
  const TEST_NM = `import System
34
- import System/Test
34
+ import System::Test
35
35
 
36
36
  pub func test_add = (ref Tester t) {
37
37
  t.expect(add(2, 2) == 4, "2 + 2 should equal 4")
package/src/test.ts CHANGED
@@ -183,7 +183,7 @@ export function generate_harness(tests: TestFunction[], benches: BenchFunction[]
183
183
  })
184
184
  .join("\n");
185
185
 
186
- let main = "\nimport System\nimport System/Test\n\npub func main = () {\n";
186
+ let main = "\nimport System\nimport System::Test\n\npub func main = () {\n";
187
187
  main += "\tvar Tester t = Tester()\n";
188
188
  for (const test of tests) {
189
189
  main += `\tt.begin_test("${escape_nm_string(test.name)}")\n`;
@@ -4,4 +4,6 @@ export default interface Config {
4
4
  lib?: string;
5
5
  audit?: boolean;
6
6
  audit_runtime?: string;
7
+ release?: boolean;
8
+ fast_math?: boolean;
7
9
  }