@words-lang/parser 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +60 -0
  2. package/package.json +7 -2
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @words-lang/parser
2
+
3
+ ![WORDS](https://raw.githubusercontent.com/krud-soft/words-lang/main/packages/extension/icons/wds-background.png)
4
+
5
+ Standalone lexer, parser, and semantic analyser for the [WORDS specification language](https://krud-soft.github.io/words/).
6
+
7
+ Part of the [words-lang](https://github.com/krud-soft/words-lang) tooling monorepo.
8
+
9
+ ## Installation
10
+ ```bash
11
+ npm install @words-lang/parser
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Parse a single file
17
+ ```typescript
18
+ import { Lexer, Parser } from '@words-lang/parser'
19
+ import * as fs from 'fs'
20
+
21
+ const source = fs.readFileSync('MyModule/states/Unauthenticated.wds', 'utf-8')
22
+ const tokens = new Lexer(source).tokenize()
23
+ const { document, diagnostics } = new Parser(tokens).parse()
24
+ ```
25
+
26
+ ### Analyse a full project
27
+ ```typescript
28
+ import { Workspace, Analyser } from '@words-lang/parser'
29
+
30
+ const workspace = Workspace.load('./my-words-project')
31
+ const { diagnostics } = new Analyser(workspace).analyse()
32
+
33
+ for (const { filePath, diagnostic } of diagnostics) {
34
+ console.log(`${filePath} [${diagnostic.code}] ${diagnostic.message}`)
35
+ }
36
+ ```
37
+
38
+ ### Diagnostic codes
39
+
40
+ | Code | Layer | Description |
41
+ |---|---|---|
42
+ | `P001` | Parser | Unexpected token |
43
+ | `P002` | Parser | Unexpected end of file |
44
+ | `A001` | Analyser | Module listed in system has no definition |
45
+ | `A002` | Analyser | State referenced in process has no definition |
46
+ | `A003` | Analyser | Context referenced in process has no definition |
47
+ | `A004` | Analyser | Context in returns has no corresponding when rule |
48
+ | `A005` | Analyser | State is never entered |
49
+ | `A006` | Analyser | state.return() references an undeclared context |
50
+ | `A007` | Analyser | Ownership declaration does not match construct module |
51
+
52
+ ## What is WORDS?
53
+
54
+ WORDS is a behavioral specification language for describing software systems at an intermediate level between a human requirement and a working implementation — structured enough to be machine-actionable, close enough to natural language to be written and reviewed without tooling.
55
+
56
+ Full documentation at [krud-soft.github.io/words](https://krud-soft.github.io/words/).
57
+
58
+ ## License
59
+
60
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@words-lang/parser",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Standalone parser and semantic analyser for the WORDS specification language",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,5 +19,10 @@
19
19
  "@types/node": "^25.5.0",
20
20
  "typescript": "^5.3.0",
21
21
  "vitest": "^1.0.0"
22
- }
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/krud-soft/words-lang"
26
+ },
27
+ "homepage": "https://krud-soft.github.io/words/"
23
28
  }