@exercism/codemirror-lang-cobol 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +115 -2
- package/dist/index.cjs +748 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +738 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2024 by Erik Schierboom <erik_schierboom@hotmail.com> and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
-
#
|
|
1
|
+
# COBOL language support for CodeMirror
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
This repo contains a Lezer grammar for COBOL, with highlighting, indentation, folding and autocompletion for CodeMirror 6.
|
|
6
|
+
|
|
7
|
+
The grammar reads fixed-format source, which is what the COBOL track's solutions use and what GnuCOBOL expects by default:
|
|
8
|
+
|
|
9
|
+
- Columns 1 to 6 hold an optional sequence number.
|
|
10
|
+
- A `*` or `/` in column 7 makes the line a comment. A `-` there continues a literal from the line before.
|
|
11
|
+
- Code can run past column 72, and the grammar reads it as code, because many COBOL programs have code there.
|
|
12
|
+
|
|
13
|
+
Keywords are case-insensitive, and `*>` starts a comment anywhere on a line.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { cobol } from "@exercism/codemirror-lang-cobol";
|
|
19
|
+
|
|
20
|
+
new EditorView({ extensions: [basicSetup, cobol()] });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The completion offers:
|
|
24
|
+
|
|
25
|
+
- the verbs, the other reserved words, the figurative constants (such as `SPACES`) and the intrinsic functions, in upper or lower case, to match what the user is typing.
|
|
26
|
+
- snippets for the four divisions, data items, tables, `PERFORM VARYING`, `PERFORM UNTIL`, `PERFORM ... TIMES`, `IF`, `EVALUATE` and `STRING`.
|
|
27
|
+
- the names declared in the current program: data items, condition names, indexes, files, paragraphs and sections.
|
|
28
|
+
|
|
29
|
+
It offers nothing inside strings, pictures or comments.
|
|
30
|
+
|
|
31
|
+
To keep the package working on the Exercism website, don't change the versions of these packages:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
"@codemirror/language": "^6.10.1",
|
|
35
|
+
"@lezer/highlight": "^1.2.0",
|
|
36
|
+
"@lezer/lr": "^1.4.0"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
- NPM: `npm install @exercism/codemirror-lang-cobol`
|
|
42
|
+
- Yarn: `yarn add @exercism/codemirror-lang-cobol`
|
|
43
|
+
- Bun: `bun add @exercism/codemirror-lang-cobol`
|
|
44
|
+
|
|
45
|
+
## Prerequisites
|
|
46
|
+
|
|
47
|
+
- [Bun](https://bun.sh/)
|
|
48
|
+
|
|
49
|
+
## Resources
|
|
50
|
+
|
|
51
|
+
- [CodeMirror](https://codemirror.net/docs/)
|
|
52
|
+
- [Lezer](https://lezer.codemirror.net/docs/guide/)
|
|
53
|
+
- [Writing a Grammar](https://lezer.codemirror.net/docs/guide/#writing-a-grammar)
|
|
54
|
+
- [Examples](https://lezer.codemirror.net/examples/)
|
|
55
|
+
- [Existing grammar files](https://github.com/search?q=org%3Alezer-parser+path%3A%2F.grammar%24%2F&type=code)
|
|
56
|
+
|
|
57
|
+
## Structure
|
|
58
|
+
|
|
59
|
+
The source is written in [TypeScript](https://www.typescriptlang.org/).
|
|
60
|
+
|
|
61
|
+
The repo is structured as follows:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
.
|
|
65
|
+
├── src
|
|
66
|
+
│ ├── index.ts (the main plugin, with highlighting, indentation and folding)
|
|
67
|
+
│ ├── complete.ts (the completion sources)
|
|
68
|
+
│ ├── tokens.ts (the tokenizers for words, literals, pictures and fixed-format columns)
|
|
69
|
+
│ ├── syntax.grammar (the Lezer grammar)
|
|
70
|
+
│ ├── syntax.grammar.d.ts (the grammar typings)
|
|
71
|
+
│ └── syntax.grammar.terms.d.ts (the term typings, written by scripts/terms-dts.mjs)
|
|
72
|
+
├── scripts
|
|
73
|
+
│ └── terms-dts.mjs (writes the term typings before each build)
|
|
74
|
+
├── test
|
|
75
|
+
│ ├── cases (grammar test cases)
|
|
76
|
+
│ │ └ *.txt (test case)
|
|
77
|
+
│ ├── grammar.test.ts (runs the grammar test cases)
|
|
78
|
+
│ ├── complete.test.ts (tests the completion)
|
|
79
|
+
│ └── language.test.ts (tests folding and indentation)
|
|
80
|
+
├── index.html (dev server file)
|
|
81
|
+
├── rollup.config.js (bundling config)
|
|
82
|
+
├── tsconfig.json (typescript confif)
|
|
83
|
+
└── vite.config.js (vite dev server config)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Setup
|
|
87
|
+
|
|
88
|
+
Run `bun install` to install all dependencies.
|
|
89
|
+
|
|
90
|
+
## Developing
|
|
91
|
+
|
|
92
|
+
To help with development, run `bun run dev`.
|
|
93
|
+
This will start a [Vite](https://vite.dev/) dev server (usually at http://localhost:5173/) that renders the `index.html` file.
|
|
94
|
+
The `#editor` element shows some sample code, highlighted by the grammar in `src/syntax.grammar`.
|
|
95
|
+
When you change the grammar, the page refreshes.
|
|
96
|
+
|
|
97
|
+
## Testing
|
|
98
|
+
|
|
99
|
+
The `test/cases` directory contains the grammar test cases, in Lezer's test format.
|
|
100
|
+
Run `bun run test` to build the package and run all the tests.
|
|
101
|
+
|
|
102
|
+
The test runner reads the cases itself. Lezer's `fileTests` trims the leading spaces from each case, and in fixed format the first seven columns have a meaning.
|
|
103
|
+
|
|
104
|
+
Keep each test case file small and focused on one aspect of the grammar.
|
|
105
|
+
|
|
106
|
+
## Building
|
|
107
|
+
|
|
108
|
+
Run `bun run prepare` to build the package into `dist/`.
|
|
109
|
+
`bun install` runs the same command, so a fresh install also builds the package.
|
|
110
|
+
|
|
111
|
+
## Publishing
|
|
112
|
+
|
|
113
|
+
To publish a new version, set `version` in `package.json` and commit it.
|
|
114
|
+
Then push a tag made of `v` followed by that version, for example `v1.0.0`.
|
|
115
|
+
The tag starts the Publish workflow, which builds and tests the package and publishes it to npm.
|
|
116
|
+
If the tag differs from `version`, the workflow stops before it publishes.
|