functionalscript 0.1.607 → 0.1.609

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 (62) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/Cargo.lock +4 -0
  3. package/Cargo.toml +4 -2
  4. package/README.md +1 -1
  5. package/com/rust/nanocom/src/cobject.rs +1 -1
  6. package/com/test/rust/src/lib.rs +4 -4
  7. package/dev/module.mjs +10 -33
  8. package/dev/test/module.f.mjs +1 -1
  9. package/djs/parser/module.f.d.mts +51 -31
  10. package/djs/parser/module.f.mjs +275 -122
  11. package/djs/parser/test.f.d.mts +4 -0
  12. package/djs/parser/test.f.mjs +179 -63
  13. package/djs/tokenizer/module.f.d.mts +1 -1
  14. package/djs/tokenizer/module.f.mjs +3 -1
  15. package/djs/tokenizer/test.f.mjs +1 -1
  16. package/doc/LANGUAGE.md +17 -16
  17. package/doc/README.md +14 -50
  18. package/fsc/README.md +0 -3
  19. package/fsm/README.md +1 -1
  20. package/html/README.md +24 -0
  21. package/issues/01-test-debug.md +3 -0
  22. package/issues/{publish.md → 05-publish.md} +8 -8
  23. package/issues/17-djs-extension.md +6 -0
  24. package/issues/README.md +20 -13
  25. package/issues/lang/1000-json.md +38 -0
  26. package/issues/lang/2110-default-export.md +2 -2
  27. package/issues/lang/2310-undefined.md +1 -1
  28. package/issues/lang/2330-property-accessor.md +225 -0
  29. package/issues/lang/2360-built-in.md +54 -47
  30. package/issues/lang/3240-export.md +44 -0
  31. package/issues/lang/README.md +64 -22
  32. package/issues/test.f.d.mts +16 -0
  33. package/issues/test.f.mjs +57 -0
  34. package/js/tokenizer/module.f.d.mts +8 -2
  35. package/js/tokenizer/module.f.mjs +29 -3
  36. package/js/tokenizer/test.f.mjs +9 -6
  37. package/json/tokenizer/module.f.mjs +2 -1
  38. package/jsr.json +1 -1
  39. package/nanvm-lib/Cargo.toml +6 -0
  40. package/nanvm-lib/src/extension.rs +119 -0
  41. package/nanvm-lib/src/interface.rs +136 -0
  42. package/nanvm-lib/src/lib.rs +7 -0
  43. package/nanvm-lib/src/naive.rs +229 -0
  44. package/nanvm-lib/src/nanenum.rs +230 -0
  45. package/nanvm-lib/src/nullish.rs +7 -0
  46. package/nanvm-lib/src/sign.rs +5 -0
  47. package/nanvm-lib/src/simple.rs +32 -0
  48. package/nanvm-lib/tests/test.f.d.mts +36 -0
  49. package/nanvm-lib/tests/test.f.mjs +79 -0
  50. package/nanvm-lib/tests/test.rs +108 -0
  51. package/package.json +1 -2
  52. package/text/README.md +2 -2
  53. package/index.f.d.mts +0 -83
  54. package/index.f.mjs +0 -83
  55. package/issues/lang/2351-property-accessor.md +0 -44
  56. package/issues/lang/2352-property-call.md +0 -43
  57. package/issues/lang/2353-property-at.md +0 -19
  58. package/issues/test-debug.md +0 -12
  59. /package/issues/{esm.md → 02-esm.md} +0 -0
  60. /package/issues/{djs.md → 03-djs.md} +0 -0
  61. /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
  62. /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## Unreleased
9
+
10
+ ## 0.1.608
package/Cargo.lock CHANGED
@@ -6,6 +6,10 @@ version = 3
6
6
  name = "nanocom"
7
7
  version = "0.2.1"
8
8
 
9
+ [[package]]
10
+ name = "nanvm-lib"
11
+ version = "0.1.0"
12
+
9
13
  [[package]]
10
14
  name = "testrust"
11
15
  version = "0.1.0"
package/Cargo.toml CHANGED
@@ -1,5 +1,7 @@
1
1
  [workspace]
2
+ resolver = "2"
2
3
  members = [
3
4
  "com/rust/nanocom",
4
- "com/test/rust"
5
- ]
5
+ "com/test/rust",
6
+ "nanvm-lib"
7
+ ]
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![NPM Version](https://img.shields.io/npm/v/functionalscript)](https://www.npmjs.com/package/functionalscript)
4
4
  [![JSR Version](https://img.shields.io/jsr/v/%40functionalscript/functionalscript)](https://jsr.io/@functionalscript/functionalscript)
5
5
 
6
- FunctionalScript is a purely functional programming language and a strict subset of
6
+ FunctionalScript is a safe, purely functional programming language and a strict subset of
7
7
  [ECMAScript](https://en.wikipedia.org/wiki/ECMAScript)/[JavaScript](https://en.wikipedia.org/wiki/JavaScript). It's inspired by
8
8
 
9
9
  - [JSON](https://en.wikipedia.org/wiki/JSON) and [JSON5](https://json5.org/) as subsets of JavaScript.
@@ -54,7 +54,7 @@ impl<T: Class> CObject<T> {
54
54
  match t.counter.fetch_sub(1, Ordering::Relaxed) {
55
55
  1 => {
56
56
  let m = t as *const CObject<T> as *mut CObject<T>;
57
- unsafe { Box::from_raw(m) };
57
+ let _ = unsafe { Box::from_raw(m) };
58
58
  0
59
59
  }
60
60
  x => x - 1,
@@ -28,19 +28,19 @@ impl _result::IMy::Ex for nanocom::CObject<My> {
28
28
  todo!()
29
29
  }
30
30
 
31
- fn SetUnsafe(&self, p: *const _result::Slice, size: u32) {
31
+ fn SetUnsafe(&self, _p: *const _result::Slice, _size: u32) {
32
32
  todo!()
33
33
  }
34
34
 
35
- fn Some(&self, p: &_result::IMy::Object) -> bool {
35
+ fn Some(&self, _p: &_result::IMy::Object) -> bool {
36
36
  todo!()
37
37
  }
38
38
 
39
- fn GetIMy(&self, a: u16, b: i16) -> _result::IMy::Ref {
39
+ fn GetIMy(&self, _a: u16, _b: i16) -> _result::IMy::Ref {
40
40
  todo!()
41
41
  }
42
42
 
43
- fn SetManagedStruct(&self, a: _result::ManagedStruct) {
43
+ fn SetManagedStruct(&self, _a: _result::ManagedStruct) {
44
44
  todo!()
45
45
  }
46
46
  }
package/dev/module.mjs CHANGED
@@ -86,7 +86,7 @@ export const loadModuleMap = async () => {
86
86
  const file = `${p}/${name}`
87
87
  if (i.isDirectory()) {
88
88
  await f(file)
89
- } else if (name.endsWith('.f.cjs') || name.endsWith('.f.mjs') || name.endsWith('.f.js')) {
89
+ } else if (name.endsWith('.f.mjs') || name.endsWith('.f.js')) {
90
90
  const source = await import(`../${file}`)
91
91
  map.push([file, source.default])
92
92
  }
@@ -179,36 +179,13 @@ const codeAdd = i => p => m => {
179
179
  }
180
180
 
181
181
  export const index = async () => {
182
- {
183
- const jj = './jsr.json'
184
- const n = '/module.f.mjs'
185
- const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }))
186
- const exportsA = Object.keys(await loadModuleMap())
187
- .filter(v => v.endsWith(n))
188
- .map(v => [v.replace(n, ''), v])
189
- const exports = Object.fromEntries(exportsA)
190
- await writeFile(
191
- jj,
192
- JSON.stringify({ ...jsr_json, exports }, null, 2))
193
- }
194
-
195
- //
196
- /** @type {FolderMap} */
197
- let m = {}
198
- for (const k in await loadModuleMap()) {
199
- const [, ...s] = k.split('/')
200
- switch (s[s.length - 1]) {
201
- case 'module.f.cjs': case 'module.f.mjs': case 'module.f.js':
202
- m = folderMapAdd(m)(s)
203
- break
204
- }
205
- }
206
- const [e, i] = codeAdd(indent)('')(m)
207
- let s =
208
- '// Generated file.\n' +
209
- i +
210
- 'export default {\n' +
211
- e +
212
- '}\n'
213
- await writeFile('index.f.mjs', s)
182
+ const jj = './jsr.json'
183
+ const n = '/module.f.mjs'
184
+ const jsr_json = JSON.parse(await readFile(jj, { encoding: 'utf8' }))
185
+ const list = Object.keys(await loadModuleMap()).filter(v => v.endsWith(n))
186
+ const exportsA = list.map(v => [v.replace(n, ''), v])
187
+ const exports = Object.fromEntries(exportsA)
188
+ await writeFile(
189
+ jj,
190
+ JSON.stringify({ ...jsr_json, exports }, null, 2))
214
191
  }
@@ -47,7 +47,7 @@ import * as Result from '../../types/result/module.f.mjs'
47
47
  */
48
48
 
49
49
  /** @type {(s: string) => boolean} */
50
- const isTest = s => s.endsWith('test.f.cjs') || s.endsWith('test.f.mjs') || s.endsWith('test.f.js')
50
+ const isTest = s => s.endsWith('test.f.mjs') || s.endsWith('test.f.js')
51
51
 
52
52
  /**
53
53
  * @typedef {{
@@ -2,39 +2,59 @@ declare namespace _default {
2
2
  export { parse };
3
3
  }
4
4
  export default _default;
5
- export type JsonObject = {
6
- readonly kind: "object";
7
- readonly values: Map.Map<Djs.Unknown>;
8
- readonly key: string;
9
- };
10
- export type JsonArray = {
11
- readonly kind: "array";
12
- readonly values: List.List<Djs.Unknown>;
13
- };
14
- export type JsonStackElement = JsonObject | JsonArray;
15
- export type JsonStack = List.List<JsonStackElement>;
16
- export type StateModule = {
17
- readonly status: "module";
18
- readonly stage: "module" | "." | "exports" | "=";
19
- };
20
- export type StateParse = {
21
- readonly status: "" | "[" | "[v" | "[," | "{" | "{k" | "{:" | "{v" | "{,";
22
- readonly top: JsonStackElement | null;
23
- readonly stack: JsonStack;
24
- };
25
- export type StateResult = {
26
- readonly status: "result";
27
- readonly value: Djs.Unknown;
28
- };
29
- export type StateError = {
30
- readonly status: "error";
5
+ export type DjsModule = [readonly string[], readonly DjsConst[]];
6
+ export type DjsConst = boolean | string | number | null | bigint | DjsModuleRef | DjsArray | DjsObject;
7
+ export type DjsModuleRef = ["aref" | "cref", number];
8
+ export type DjsArray = ["array", readonly DjsConst[]];
9
+ export type DjsObject = { readonly [k in string]: DjsConst; };
10
+ export type DjsStackArray = ["array", List.List<DjsConst>];
11
+ export type DjsStackObject = ["object", Map.Map<DjsConst>, string];
12
+ export type DjsStackElement = DjsStackArray | DjsStackObject;
13
+ export type DjsStack = List.List<DjsStackElement>;
14
+ export type ParserState = InitialState | NewLineRequiredState | ImportState | ConstState | ExportState | ParseValueState | ResultState | ErrorState;
15
+ export type ModuleState = {
16
+ readonly refs: Map.Map<DjsModuleRef>;
17
+ readonly modules: List.List<string>;
18
+ readonly consts: List.List<DjsConst>;
19
+ };
20
+ export type InitialState = {
21
+ readonly state: "";
22
+ readonly module: ModuleState;
23
+ };
24
+ export type NewLineRequiredState = {
25
+ readonly state: "nl";
26
+ readonly module: ModuleState;
27
+ };
28
+ export type ImportState = {
29
+ readonly state: "import" | "import+name" | "import+from";
30
+ readonly module: ModuleState;
31
+ };
32
+ export type ConstState = {
33
+ readonly state: "const" | "const+name";
34
+ readonly module: ModuleState;
35
+ };
36
+ export type ExportState = {
37
+ readonly state: "export";
38
+ readonly module: ModuleState;
39
+ };
40
+ export type ParseValueState = {
41
+ readonly state: "constValue" | "exportValue";
42
+ readonly module: ModuleState;
43
+ readonly valueState: "" | "[" | "[v" | "[," | "{" | "{k" | "{:" | "{v" | "{,";
44
+ readonly top: DjsStackElement | null;
45
+ readonly stack: DjsStack;
46
+ };
47
+ export type ResultState = {
48
+ readonly state: "result";
49
+ readonly module: ModuleState;
50
+ };
51
+ export type ErrorState = {
52
+ readonly state: "error";
31
53
  readonly message: string;
32
54
  };
33
- export type DjsState = StateModule | StateParse | StateResult | StateError;
34
- /** @type {(tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<Djs.Unknown, string>} */
35
- declare const parse: (tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<Djs.Unknown, string>;
36
- import * as Map from '../../types/map/module.f.mjs';
37
- import * as Djs from '../module.f.mjs';
55
+ /** @type {(tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<DjsModule, string>} */
56
+ declare const parse: (tokenList: List.List<tokenizerT.DjsToken>) => Result.Result<DjsModule, string>;
38
57
  import * as List from '../../types/list/module.f.mjs';
58
+ import * as Map from '../../types/map/module.f.mjs';
39
59
  import * as tokenizerT from '../tokenizer/module.f.mjs';
40
60
  import * as Result from '../../types/result/module.f.mjs';