@exercism/codemirror-lang-awk 0.0.0-stage → 2.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/CHANGELOG.md +71 -0
- package/CODE_OF_CONDUCT.md +93 -0
- package/LICENSE +21 -0
- package/README.md +153 -2
- package/dist/completion.d.ts +5 -0
- package/dist/grammar.d.ts +11 -0
- package/dist/highlight.d.ts +7 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +852 -0
- package/dist/linter.d.ts +5 -0
- package/dist/theme.d.ts +9 -0
- package/dist/tokens.d.ts +27 -0
- package/package.json +54 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-21
|
|
9
|
+
|
|
10
|
+
This project was renamed from "gawk" to "awk". The public API now uses `awk` naming
|
|
11
|
+
throughout. This is a **breaking change**: the old `gawk*` names are no longer exported.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **BREAKING:** Renamed exports:
|
|
16
|
+
- `gawk()` → `awk()`
|
|
17
|
+
- `gawkLanguage` → `awkLanguage`
|
|
18
|
+
- `gawkHighlighting` → `awkHighlighting`
|
|
19
|
+
- `gawkStreamParser` → `awkStreamParser`
|
|
20
|
+
- `gawkHighlightStyle` → `awkHighlightStyle`
|
|
21
|
+
- `gawkCompletionSource` → `awkCompletionSource`
|
|
22
|
+
- `gawkLinter` → `awkLinter`
|
|
23
|
+
- `gawkDarkTheme` → `awkDarkTheme`
|
|
24
|
+
- `gawkLightTheme` → `awkLightTheme`
|
|
25
|
+
- `GawkState` → `AwkState`
|
|
26
|
+
- `GawkLanguageOptions` → `AwkLanguageOptions`
|
|
27
|
+
- **BREAKING:** Renamed the highlighting CSS classes from `cm-gawk-*` to `cm-awk-*`
|
|
28
|
+
(`directive`, `pattern`, `keyword`, `builtin-var`, `field`, `builtin-func`,
|
|
29
|
+
`func-def`, `func-call`, `string`, `regex`, `number`, `comment`, `operator`,
|
|
30
|
+
`punctuation`). Custom stylesheets targeting the old classes must be updated.
|
|
31
|
+
- The stream parser's language name is now `'awk'` (was `'gawk'`).
|
|
32
|
+
- Updated the README, demo and tests to use the new names.
|
|
33
|
+
|
|
34
|
+
### Unchanged
|
|
35
|
+
|
|
36
|
+
- The `GAWK_*` token constants (`GAWK_PATTERNS`, `GAWK_KEYWORDS`, `GAWK_DIRECTIVES`,
|
|
37
|
+
`GAWK_BUILTIN_VARS`, `GAWK_BUILTIN_FUNCTIONS`) keep their names.
|
|
38
|
+
|
|
39
|
+
### Migration
|
|
40
|
+
|
|
41
|
+
```diff
|
|
42
|
+
- import { gawk, gawkDarkTheme } from '@exercism/codemirror-lang-awk';
|
|
43
|
+
+ import { awk, awkDarkTheme } from '@exercism/codemirror-lang-awk';
|
|
44
|
+
|
|
45
|
+
- extensions: [basicSetup, gawk(), gawkDarkTheme]
|
|
46
|
+
+ extensions: [basicSetup, awk(), awkDarkTheme]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## [1.0.0] - 2026-11-20
|
|
50
|
+
|
|
51
|
+
Initial release of the CodeMirror 6 language package for AWK and GNU AWK (gawk).
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- Stream parser (`gawkStreamParser` / `gawkLanguage`) supporting POSIX AWK and GNU AWK:
|
|
56
|
+
directives (`@include`, `@load`, `@namespace`), pattern blocks (`BEGIN`, `END`,
|
|
57
|
+
`BEGINFILE`, `ENDFILE`), control keywords, regex literals, field references
|
|
58
|
+
(`$0`, `$NF`), and hex/octal numbers.
|
|
59
|
+
- Syntax highlighting (`gawkHighlighting`) with bundled dark and light themes
|
|
60
|
+
(`gawkDarkTheme`, `gawkLightTheme`).
|
|
61
|
+
- Context-aware autocompletion (`gawkCompletionSource`): directives, built-in functions
|
|
62
|
+
with signatures and documentation, built-in variables, snippets, and a scanner for
|
|
63
|
+
user-defined functions and variables in the document.
|
|
64
|
+
- Diagnostic linter (`gawkLinter`): unterminated strings and regexes, unmatched braces
|
|
65
|
+
and parentheses, unknown directives, and malformed function definitions.
|
|
66
|
+
- `gawk()` extension bundling highlighting, autocompletion and linting, with `lint` and
|
|
67
|
+
`autocomplete` options.
|
|
68
|
+
- Interactive demo (`npm run dev`).
|
|
69
|
+
|
|
70
|
+
[2.0.0]: https://github.com/exercism/codemirror-lang-awk/compare/v1.0.0...v2.0.0
|
|
71
|
+
[1.0.0]: https://github.com/exercism/codemirror-lang-awk/releases/tag/v1.0.0
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
Exercism is a platform centered around empathetic conversation.
|
|
6
|
+
We have a low tolerance for communication that makes anyone feel unwelcome, unsupported, insulted or discriminated against.
|
|
7
|
+
|
|
8
|
+
## Seen or experienced something uncomfortable?
|
|
9
|
+
|
|
10
|
+
If you see or experience abuse, harassment, discrimination, or feel unsafe or upset, please email [abuse@exercism.org](mailto:abuse@exercism.org?subject=%5BCoC%5D) and include \[CoC\] in the subject line.
|
|
11
|
+
We will follow up with you as a priority.
|
|
12
|
+
|
|
13
|
+
## Enforcement
|
|
14
|
+
|
|
15
|
+
We actively monitor for Code of Conduct (CoC) violations and take any reports of violations extremely seriously.
|
|
16
|
+
We have banned contributors, mentors and users due to violations.
|
|
17
|
+
|
|
18
|
+
After we receive a report of a CoC violation, we view that person's conversation history on Exercism and related communication channels and attempt to understand whether someone has deliberately broken the CoC, or accidentally crossed a line.
|
|
19
|
+
We generally reach out to the person who has been reported to discuss any concerns we have and warn them that repeated violations will result in a ban.
|
|
20
|
+
Sometimes we decide that no violation has occurred and that no action is required and sometimes we will also ban people on a first offense.
|
|
21
|
+
We strive to be fair, but will err on the side of protecting the culture of our community.
|
|
22
|
+
|
|
23
|
+
Exercism's leadership reserve the right to take whatever action they feel appropriate with regards to CoC violations.
|
|
24
|
+
|
|
25
|
+
## The simple version
|
|
26
|
+
|
|
27
|
+
- Be empathetic
|
|
28
|
+
- Be welcoming
|
|
29
|
+
- Be kind
|
|
30
|
+
- Be honest
|
|
31
|
+
- Be supportive
|
|
32
|
+
- Be polite
|
|
33
|
+
|
|
34
|
+
## The details
|
|
35
|
+
|
|
36
|
+
Exercism should be a safe place for everybody regardless of
|
|
37
|
+
|
|
38
|
+
- Gender, gender identity or gender expression
|
|
39
|
+
- Sexual orientation
|
|
40
|
+
- Disability
|
|
41
|
+
- Physical appearance (including but not limited to body size)
|
|
42
|
+
- Race
|
|
43
|
+
- Age
|
|
44
|
+
- Religion
|
|
45
|
+
- Anything else you can think of
|
|
46
|
+
|
|
47
|
+
As someone who is part of this community, you agree that:
|
|
48
|
+
|
|
49
|
+
- We are collectively and individually committed to safety and inclusivity
|
|
50
|
+
- We have zero tolerance for abuse, harassment, or discrimination
|
|
51
|
+
- We respect people’s boundaries and identities
|
|
52
|
+
- We refrain from using language that can be considered offensive or oppressive (systemically or otherwise), eg. sexist, racist, homophobic, transphobic, ableist, classist, etc.
|
|
53
|
+
- this includes (but is not limited to) various slurs.
|
|
54
|
+
- We avoid using offensive topics as a form of humor
|
|
55
|
+
|
|
56
|
+
We actively work towards:
|
|
57
|
+
|
|
58
|
+
- Being a safe community
|
|
59
|
+
- Cultivating a network of support & encouragement for each other
|
|
60
|
+
- Encouraging responsible and varied forms of expression
|
|
61
|
+
|
|
62
|
+
We condemn:
|
|
63
|
+
|
|
64
|
+
- Stalking, doxxing, or publishing private information
|
|
65
|
+
- Violence, threats of violence or violent language
|
|
66
|
+
- Anything that compromises people’s safety
|
|
67
|
+
- Conduct or speech which might be considered sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory or offensive in nature
|
|
68
|
+
- The use of unwelcome, suggestive, derogatory or inappropriate nicknames or terms
|
|
69
|
+
- Disrespect towards others (jokes, innuendo, dismissive attitudes) and towards differences of opinion
|
|
70
|
+
- Intimidation or harassment (online or in-person).
|
|
71
|
+
Please read the [Citizen Code of Conduct](https://github.com/stumpsyn/policies/blob/master/citizen_code_of_conduct.md) for how we interpret harassment
|
|
72
|
+
- Inappropriate attention or contact
|
|
73
|
+
- Not understanding the differences between constructive criticism and disparagement
|
|
74
|
+
|
|
75
|
+
These things are NOT OK.
|
|
76
|
+
|
|
77
|
+
Be aware of how your actions affect others.
|
|
78
|
+
If it makes someone uncomfortable, stop.
|
|
79
|
+
|
|
80
|
+
If you say something that is found offensive, and you are called out on it, try to:
|
|
81
|
+
|
|
82
|
+
- Listen without interruption
|
|
83
|
+
- Believe what the person is saying & do not attempt to disqualify what they have to say
|
|
84
|
+
- Ask for tips / help with avoiding making the offense in the future
|
|
85
|
+
- Apologize and ask forgiveness
|
|
86
|
+
|
|
87
|
+
## History
|
|
88
|
+
|
|
89
|
+
This policy was initially adopted from the Front-end London Slack community and has been modified since.
|
|
90
|
+
A version history can be seen on [GitHub](https://github.com/exercism/website-copy/edit/main/pages/code_of_conduct.md).
|
|
91
|
+
|
|
92
|
+
_This policy is a "living" document, and subject to refinement and expansion in the future.
|
|
93
|
+
This policy applies to the Exercism website, the Exercism GitHub organization, any other Exercism-related communication channels (e.g. Discord, Forum, Twitter, email) and any other Exercism entity or event._
|
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,154 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CodeMirror 6 GNU AWK (gawk) Support
|
|
2
|
+
|
|
3
|
+
`@exercism/codemirror-lang-awk` is a CodeMirror 6 language plugin providing full syntax highlighting, autocompletion, diagnostic linting, and custom themes for both standard **POSIX AWK** and **GNU AWK (gawk)**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
> **Note for Exercism Integration:** To ensure compatibility with the Exercism website platform, the following dependency version constraints are maintained:
|
|
8
|
+
> ```json
|
|
9
|
+
> "@codemirror/language": "^6.10.1",
|
|
10
|
+
> "@lezer/highlight": "^1.2.0",
|
|
11
|
+
> "@lezer/lr": "^1.4.0"
|
|
12
|
+
> ```
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 🚀 How to Run the Demo
|
|
16
|
+
|
|
17
|
+
### Prerequisites
|
|
18
|
+
* [Node.js](https://nodejs.org/) (v16+ recommended)
|
|
19
|
+
* `npm`
|
|
20
|
+
|
|
21
|
+
### Running the Demo Locally
|
|
22
|
+
1. **Install Dependencies**:
|
|
23
|
+
```bash
|
|
24
|
+
npm install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
2. **Start Development Server**:
|
|
28
|
+
```bash
|
|
29
|
+
npm run dev
|
|
30
|
+
```
|
|
31
|
+
Open your browser to `http://localhost:3000/` (or the URL printed in the terminal) to launch the interactive live editor demo.
|
|
32
|
+
|
|
33
|
+
3. **Build Library for Production**:
|
|
34
|
+
```bash
|
|
35
|
+
npm run build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
4. **Preview Production Build**:
|
|
39
|
+
```bash
|
|
40
|
+
npm run preview
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## ✨ CodeMirror 6 Features Implemented
|
|
46
|
+
|
|
47
|
+
* **Stream Parser Engine (`awkLanguage` / `awkStreamParser`)**:
|
|
48
|
+
Custom tokenizer built for CodeMirror 6 supporting standard AWK and GNU AWK extensions (including directives, special pattern blocks, regex literals, field references, and hex/octal numbers).
|
|
49
|
+
|
|
50
|
+
* **Syntax Highlighting & Bundled Themes (`awkHighlighting`, `awkDarkTheme`, `awkLightTheme`)**:
|
|
51
|
+
Token tags mapped to `@lezer/highlight` with custom dark and light editor themes tailored for AWK development.
|
|
52
|
+
|
|
53
|
+
* **Context-Aware Autocompletion (`awkCompletionSource`)**:
|
|
54
|
+
* **GNU Directives**: `@include`, `@load`, `@namespace`.
|
|
55
|
+
* **Built-in Functions**: Comprehensive completion list with function signatures, types, and detailed documentation tooltips (e.g., `gensub`, `patsplit`, `strftime`, `typeof`, `asort`).
|
|
56
|
+
* **Built-in Variables**: Standard and GNU-specific special variables (`FS`, `OFS`, `NR`, `NF`, `ARGIND`, `FPAT`, `ERRNO`, `SYMTAB`, etc.).
|
|
57
|
+
* **Snippets**: Quick insertions for `BEGIN`, `END`, `function`, `for (in)`, `for (i=1..n)`, `@include`, `@namespace`, and `@load`.
|
|
58
|
+
* **Document Symbol Scanner**: Dynamically collects user-defined function names and variable identifiers from the active document.
|
|
59
|
+
|
|
60
|
+
* **Live Diagnostic Linter (`awkLinter`)**:
|
|
61
|
+
Real-time syntax checking highlighting code issues directly in the editor:
|
|
62
|
+
* Unterminated string literals (`"text...`)
|
|
63
|
+
* Unclosed regular expression literals (`/pattern...`)
|
|
64
|
+
* Unmatched braces (`{}`) and parentheses (`()`)
|
|
65
|
+
* Unknown `@` directives or missing directive file/namespace strings
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 🛠️ AWK and GNU AWK (gawk) Features Implemented
|
|
70
|
+
|
|
71
|
+
### 1. Standard POSIX AWK Core
|
|
72
|
+
* **Pattern Blocks**: `BEGIN`, `END`
|
|
73
|
+
* **Control Keywords**: `if`, `else`, `while`, `do`, `for`, `in`, `break`, `continue`, `next`, `exit`, `return`, `delete`, `function`, `func`
|
|
74
|
+
* **Built-in Variables**: `ARGC`, `ARGV`, `CONVFMT`, `ENVIRON`, `FILENAME`, `FNR`, `FS`, `NF`, `NR`, `OFMT`, `OFS`, `ORS`, `RLENGTH`, `RS`, `RSTART`, `SUBSEP`
|
|
75
|
+
* **Built-in Functions**:
|
|
76
|
+
* *Math*: `atan2`, `cos`, `exp`, `int`, `log`, `rand`, `sin`, `sqrt`, `srand`
|
|
77
|
+
* *String*: `sub`, `gsub`, `index`, `length`, `match`, `split`, `sprintf`, `substr`, `tolower`, `toupper`
|
|
78
|
+
* *I/O*: `print`, `printf`, `getline`, `close`, `fflush`, `system`
|
|
79
|
+
* **Field References**: `$0`, `$1`, `$2`, ..., `$NF`
|
|
80
|
+
* **Regular Expressions**: `/pattern/` literals and binary regex match operators (`~`, `!~`)
|
|
81
|
+
|
|
82
|
+
### 2. GNU AWK (gawk) Specific Extensions
|
|
83
|
+
* **Directives**:
|
|
84
|
+
* `@include "filename.awk"` — modular code inclusion
|
|
85
|
+
* `@load "extension"` — dynamic C extension module loading
|
|
86
|
+
* `@namespace "name"` — symbol scoping and namespace isolation
|
|
87
|
+
* **Pattern Blocks**:
|
|
88
|
+
* `BEGINFILE` — executed before reading each new input file
|
|
89
|
+
* `ENDFILE` — executed after completing each input file
|
|
90
|
+
* **Built-in Variables**:
|
|
91
|
+
* `ARGIND` — index of current file in `ARGV`
|
|
92
|
+
* `ERRNO` — detailed system error string for failed I/O operations
|
|
93
|
+
* `FPAT` — regular expression defining field matching patterns (useful for CSV parsing)
|
|
94
|
+
* `FIELDWIDTHS` — space-separated column widths for fixed-width data
|
|
95
|
+
* `RT` — actual input text matching the record separator `RS`
|
|
96
|
+
* `SYMTAB` — global symbol table array mapping variable names to values
|
|
97
|
+
* `FUNCTAB` — array of all defined functions
|
|
98
|
+
* `PROCINFO` — process information and platform metadata array
|
|
99
|
+
* `BINMODE`, `LINT`, `PREC`, `ROUNDMODE`, `STRTAB`, `TEXTDOMAIN`
|
|
100
|
+
* **Built-in Functions**:
|
|
101
|
+
* *String & Array Extensions*: `gensub`, `patsplit`, `asort`, `asorti`, `strtonum`
|
|
102
|
+
* *Bitwise Operations*: `and`, `or`, `xor`, `compl`, `lshift`, `rshift`
|
|
103
|
+
* *Time Functions*: `systime`, `strftime`, `mktime`
|
|
104
|
+
* *Type Checking*: `typeof`, `isarray`
|
|
105
|
+
* *Internationalization (i18n)*: `bindtextdomain`, `dcgettext`, `dcngettext`
|
|
106
|
+
* **Numeric Formats**: Hexadecimal (`0x1F`) and octal (`0755`) numeric constants.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 📦 Usage & Code Example
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { EditorView } from '@codemirror/view';
|
|
114
|
+
import { basicSetup } from 'codemirror';
|
|
115
|
+
import { awk, awkDarkTheme } from '@exercism/codemirror-lang-awk';
|
|
116
|
+
|
|
117
|
+
const editor = new EditorView({
|
|
118
|
+
doc: `@include "helpers.awk"
|
|
119
|
+
@namespace "analytics"
|
|
120
|
+
|
|
121
|
+
BEGIN {
|
|
122
|
+
FS = ","
|
|
123
|
+
print "Processing environment:", ENVIRON["USER"]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
BEGINFILE {
|
|
127
|
+
print "Starting file #" ARGIND ":", FILENAME
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
$1 ~ /"GET|"POST/ {
|
|
131
|
+
# Extract match with GNU AWK gensub
|
|
132
|
+
clean_url = gensub(/"(GET|POST)\s+([^ ]+).*/, "\\2", "g", $0)
|
|
133
|
+
patsplit(clean_url, tokens, /[a-zA-Z0-9_]+/)
|
|
134
|
+
requests[$1]++
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
END {
|
|
138
|
+
print "Analysis complete."
|
|
139
|
+
}`,
|
|
140
|
+
extensions: [
|
|
141
|
+
basicSetup,
|
|
142
|
+
awk({ lint: true, autocomplete: true }),
|
|
143
|
+
awkDarkTheme
|
|
144
|
+
],
|
|
145
|
+
parent: document.getElementById('editor')!
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## 📜 License
|
|
152
|
+
|
|
153
|
+
[MIT](LICENSE)
|
|
2
154
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StreamParser } from '@codemirror/language';
|
|
2
|
+
export interface AwkState {
|
|
3
|
+
inString: boolean;
|
|
4
|
+
stringQuote: string;
|
|
5
|
+
inRegex: boolean;
|
|
6
|
+
expectRegex: boolean;
|
|
7
|
+
inComment: boolean;
|
|
8
|
+
inDirective: boolean;
|
|
9
|
+
lastToken: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const awkStreamParser: StreamParser<AwkState>;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("@codemirror/language"),g=require("@codemirror/autocomplete"),n=require("@lezer/highlight"),U=require("@codemirror/lint"),D=require("@codemirror/view"),S=new Set(["BEGIN","END","BEGINFILE","ENDFILE"]),v=new Set(["if","else","while","do","for","in","break","continue","next","nextfile","exit","return","delete","function","func"]),N=new Set(["@include","@load","@namespace"]),T=new Set(["ARGC","ARGV","CONVFMT","ENVIRON","FILENAME","FNR","FS","NF","NR","OFMT","OFS","ORS","RLENGTH","RS","RSTART","SUBSEP","ARGIND","BINMODE","ERRNO","FIELDWIDTHS","FPAT","FUNCTAB","LINT","PREC","ROUNDMODE","RT","STRTAB","SYMTAB","TEXTDOMAIN"]),x={atan2:{name:"atan2",signature:"atan2(y, x)",detail:"Math function",doc:"Returns the arctangent of y/x in radians.",type:"math"},cos:{name:"cos",signature:"cos(x)",detail:"Math function",doc:"Returns the cosine of x (x in radians).",type:"math"},exp:{name:"exp",signature:"exp(x)",detail:"Math function",doc:"Returns the exponential function of x (e^x).",type:"math"},int:{name:"int",signature:"int(x)",detail:"Math function",doc:"Truncates x to an integer value towards zero.",type:"math"},log:{name:"log",signature:"log(x)",detail:"Math function",doc:"Returns the natural logarithm of x.",type:"math"},rand:{name:"rand",signature:"rand()",detail:"Math function",doc:"Returns a random floating point number r such that 0 <= r < 1.",type:"math"},sin:{name:"sin",signature:"sin(x)",detail:"Math function",doc:"Returns the sine of x (x in radians).",type:"math"},sqrt:{name:"sqrt",signature:"sqrt(x)",detail:"Math function",doc:"Returns the square root of x.",type:"math"},srand:{name:"srand",signature:"srand([x])",detail:"Math function",doc:"Sets the seed for rand() to x and returns the previous seed. If x omitted, uses current time.",type:"math"},asort:{name:"asort",signature:"asort(source [, dest [, how]])",detail:"gawk String / Array function",doc:"Sorts array source by values. If dest given, source is duplicated into dest before sorting.",type:"string"},asorti:{name:"asorti",signature:"asorti(source [, dest [, how]])",detail:"gawk String / Array function",doc:"Sorts array source by indices instead of values into dest array.",type:"string"},gensub:{name:"gensub",signature:"gensub(regex, replacement, how [, target])",detail:"gawk String function",doc:'Substitutes replacement for regex in target (or $0). how can be "g", "G", or a number N for Nth match.',type:"string"},gsub:{name:"gsub",signature:"gsub(regex, replacement [, target])",detail:"String function",doc:"Globally substitutes replacement for regex in target (or $0). Returns number of substitutions made.",type:"string"},index:{name:"index",signature:"index(str, target)",detail:"String function",doc:"Returns the 1-based position of target substring in str, or 0 if not found.",type:"string"},length:{name:"length",signature:"length([str_or_arr])",detail:"String / Array function",doc:"Returns the length of string str or number of elements in array. Defaults to length($0).",type:"string"},match:{name:"match",signature:"match(str, regex [, array])",detail:"String function",doc:"Searches str for regex match. Sets RSTART, RLENGTH, and populates submatch array in gawk.",type:"string"},patsplit:{name:"patsplit",signature:"patsplit(str, arr [, regex [, seps]])",detail:"gawk String function",doc:"Splits str into arr matching regex pattern instead of field separators.",type:"string"},split:{name:"split",signature:"split(str, arr [, regex [, seps]])",detail:"String function",doc:"Splits str into arr elements indexed from 1 using field separator regex (or FS).",type:"string"},sprintf:{name:"sprintf",signature:"sprintf(fmt, expr1, ...)",detail:"String function",doc:"Formats expressions according to printf format specifier fmt and returns string.",type:"string"},strtonum:{name:"strtonum",signature:"strtonum(str)",detail:"gawk String function",doc:"Examines str and returns numeric value. Supports decimal, octal (leading 0), and hex (leading 0x/0X).",type:"string"},sub:{name:"sub",signature:"sub(regex, replacement [, target])",detail:"String function",doc:"Substitutes first match of regex with replacement in target (or $0). Returns 1 if matched, else 0.",type:"string"},substr:{name:"substr",signature:"substr(str, start [, length])",detail:"String function",doc:"Returns substring of str starting at 1-based start index up to length characters.",type:"string"},tolower:{name:"tolower",signature:"tolower(str)",detail:"String function",doc:"Returns copy of str converted to lowercase.",type:"string"},toupper:{name:"toupper",signature:"toupper(str)",detail:"String function",doc:"Returns copy of str converted to uppercase.",type:"string"},mktime:{name:"mktime",signature:"mktime(datespec [, utc])",detail:"gawk Time function",doc:'Converts "YYYY MM DD HH MM SS [DST]" datespec into epoch timestamp in seconds.',type:"time"},strftime:{name:"strftime",signature:"strftime([fmt [, timestamp [, utc]]])",detail:"gawk Time function",doc:"Formats timestamp (or current time) using strftime format specifier fmt.",type:"time"},systime:{name:"systime",signature:"systime()",detail:"gawk Time function",doc:"Returns current time as number of seconds since POSIX epoch.",type:"time"},and:{name:"and",signature:"and(v1, v2, ...)",detail:"gawk Bitwise function",doc:"Returns bitwise AND of arguments.",type:"bitwise"},compl:{name:"compl",signature:"compl(val)",detail:"gawk Bitwise function",doc:"Returns bitwise complement (NOT) of val.",type:"bitwise"},lshift:{name:"lshift",signature:"lshift(val, count)",detail:"gawk Bitwise function",doc:"Returns val shifted left by count bits.",type:"bitwise"},rshift:{name:"rshift",signature:"rshift(val, count)",detail:"gawk Bitwise function",doc:"Returns val shifted right by count bits.",type:"bitwise"},or:{name:"or",signature:"or(v1, v2, ...)",detail:"gawk Bitwise function",doc:"Returns bitwise OR of arguments.",type:"bitwise"},xor:{name:"xor",signature:"xor(v1, v2, ...)",detail:"gawk Bitwise function",doc:"Returns bitwise exclusive OR (XOR) of arguments.",type:"bitwise"},isarray:{name:"isarray",signature:"isarray(x)",detail:"gawk Type function",doc:"Returns 1 if x is an array, else 0.",type:"gawk"},typeof:{name:"typeof",signature:"typeof(x)",detail:"gawk Type function",doc:'Returns string indicating type of x ("array", "number", "string", "regexp", "unassigned", "untyped").',type:"gawk"},close:{name:"close",signature:"close(filename_or_cmd [, how])",detail:"I/O function",doc:"Closes an open file or pipe connection.",type:"io"},fflush:{name:"fflush",signature:"fflush([filename_or_cmd])",detail:"I/O function",doc:"Flushes pending output buffers for file/pipe or stdout if omitted.",type:"io"},system:{name:"system",signature:"system(command)",detail:"I/O function",doc:"Executes operating system shell command and returns its exit status.",type:"io"},bindtextdomain:{name:"bindtextdomain",signature:"bindtextdomain(dir [, domain])",detail:"gawk i18n function",doc:"Specifies directory for searching text domain MO files.",type:"gawk"},dcgettext:{name:"dcgettext",signature:"dcgettext(string [, domain [, category]])",detail:"gawk i18n function",doc:"Returns localized translation of string for domain and category.",type:"gawk"},dcngettext:{name:"dcngettext",signature:"dcngettext(string1, string2, number [, domain [, category]])",detail:"gawk i18n function",doc:"Returns plural-aware localized translation of string for number.",type:"gawk"}},F={name:"awk",tokenTable:{"special(keyword)":n.tags.special(n.tags.keyword),"special(variableName)":n.tags.special(n.tags.variableName),"standard(variableName)":n.tags.standard(n.tags.variableName),"standard(name)":n.tags.standard(n.tags.name),"function(definition)":n.tags.definition(n.tags.function(n.tags.variableName)),"function(call)":n.tags.function(n.tags.variableName)},startState(){return{inString:!1,stringQuote:'"',inRegex:!1,expectRegex:!0,inComment:!1,inDirective:!1,lastToken:""}},token(t,e){if(t.eatSpace())return null;if(t.peek()==="#")return t.skipToEnd(),e.expectRegex=!0,"comment";if(e.inString){let i=!1;for(;!t.eol();){const c=t.next();if(i)i=!1;else if(c==="\\")i=!0;else if(c===e.stringQuote)return e.inString=!1,e.expectRegex=!1,"string"}return i||(e.inString=!1),"string"}if(e.inRegex){let i=!1;for(;!t.eol();){const c=t.next();if(i)i=!1;else if(c==="\\")i=!0;else if(c==="/")return e.inRegex=!1,e.expectRegex=!1,"regexp"}return i||(e.inRegex=!1),"regexp"}if(t.peek()==="@"){t.eat("@"),t.eatWhile(/[\w_]/);const i=t.current();return e.expectRegex=!0,N.has(i)?(e.lastToken=i,"processingInstruction"):"keyword"}if(t.peek()==='"')return t.next(),e.inString=!0,e.stringQuote='"',"string";if(t.peek()==="/")return e.expectRegex?(t.next(),e.inRegex=!0,"regexp"):(t.next(),t.peek()==="="?(t.next(),e.lastToken="/="):e.lastToken="/",e.expectRegex=!0,"operator");if(t.peek()==="$")return t.next(),t.match(/^\d+/)||t.match(/^[A-Za-z_][A-Za-z0-9_]*/)?(e.expectRegex=!1,"special(variableName)"):(e.expectRegex=!0,"operator");if(t.match(/^0[xX][0-9a-fA-F]+/)||t.match(/^\d+(\.\d+)?([eE][+-]?\d+)?/))return e.expectRegex=!1,"number";if(t.match(/^(~|!~|\+\+|--|&&|\|\||\|&|==|!=|<=|>=|\+=|-=|\*=|\/=|%=|\^=|\*\*=|<<|>>|\*\*)/))return e.expectRegex=!0,"operator";const f=t.next();if("+-*%^=<>!~|&".includes(f))return e.expectRegex=!0,"operator";if("{}()[];,".includes(f))return f===")"||f==="}"?e.expectRegex=!1:e.expectRegex=!0,"punctuation";if(/[A-Za-z_]/.test(f)){t.eatWhile(/[\w_]/);const i=t.current();return S.has(i)?(e.expectRegex=!0,e.lastToken=i,"special(keyword)"):v.has(i)?(e.expectRegex=!0,e.lastToken=i,"keyword"):T.has(i)?(e.expectRegex=!1,e.lastToken=i,"standard(variableName)"):x[i]?(e.expectRegex=!0,e.lastToken=i,"standard(name)"):e.lastToken==="function"||e.lastToken==="func"?(e.expectRegex=!1,"function(definition)"):t.peek()==="("?(e.expectRegex=!0,"function(call)"):(e.expectRegex=!1,e.lastToken=i,"variableName")}return null},indent(t,e){return e.startsWith("}")?0:2}},M=[{tag:n.tags.keyword,class:"cm-awk-keyword"},{tag:n.tags.special(n.tags.keyword),class:"cm-awk-pattern"},{tag:n.tags.processingInstruction,class:"cm-awk-directive"},{tag:n.tags.meta,class:"cm-awk-directive"},{tag:n.tags.standard(n.tags.variableName),class:"cm-awk-builtin-var"},{tag:n.tags.special(n.tags.variableName),class:"cm-awk-field"},{tag:n.tags.standard(n.tags.name),class:"cm-awk-builtin-func"},{tag:n.tags.definition(n.tags.function(n.tags.variableName)),class:"cm-awk-func-def"},{tag:n.tags.function(n.tags.variableName),class:"cm-awk-func-call"},{tag:n.tags.string,class:"cm-awk-string"},{tag:n.tags.regexp,class:"cm-awk-regex"},{tag:n.tags.number,class:"cm-awk-number"},{tag:n.tags.comment,class:"cm-awk-comment"},{tag:n.tags.operator,class:"cm-awk-operator"},{tag:n.tags.punctuation,class:"cm-awk-punctuation"}],E=Array.from(N).map(t=>({label:t,type:"keyword",detail:"GNU AWK Directive",boost:10})),z=Array.from(S).map(t=>({label:t,type:"type",detail:"Pattern Block",boost:8})),K=Array.from(v).map(t=>({label:t,type:"keyword",detail:"Control Keyword"})),P=Array.from(T).map(t=>({label:t,type:"variable",detail:"GNU AWK Built-in Variable",boost:2})),Z=Object.values(x).map(t=>({label:t.name,type:"function",detail:t.signature,info:`${t.detail}
|
|
2
|
+
|
|
3
|
+
${t.doc}`,boost:3})),$=[{label:"BEGIN",type:"snippet",detail:"BEGIN pattern block",apply:g.snippet(`BEGIN {
|
|
4
|
+
\${1}
|
|
5
|
+
}`),boost:9},{label:"END",type:"snippet",detail:"END pattern block",apply:g.snippet(`END {
|
|
6
|
+
\${1}
|
|
7
|
+
}`),boost:9},{label:"function",type:"snippet",detail:"User-defined function definition",apply:g.snippet("function ${1:name}(${2:args}) {\n ${3}\n}"),boost:9},{label:"for (in)",type:"snippet",detail:"Array iteration loop",apply:g.snippet("for (${1:key} in ${2:array}) {\n ${3}\n}"),boost:8},{label:"for (i=1..n)",type:"snippet",detail:"Numeric count loop",apply:g.snippet("for (${1:i} = 1; ${1:i} <= ${2:n}; ${1:i}++) {\n ${3}\n}"),boost:8},{label:"if",type:"snippet",detail:"Conditional statement",apply:g.snippet("if (${1:condition}) {\n ${2}\n}"),boost:8},{label:"if-else",type:"snippet",detail:"If-else statement",apply:g.snippet(`if (\${1:condition}) {
|
|
8
|
+
\${2}
|
|
9
|
+
} else {
|
|
10
|
+
\${3}
|
|
11
|
+
}`),boost:8},{label:"@include",type:"snippet",detail:"Include AWK source file",apply:g.snippet('@include "${1:filename.awk}"'),boost:10},{label:"@namespace",type:"snippet",detail:"GNU AWK Namespace definition",apply:g.snippet('@namespace "${1:name}"'),boost:10},{label:"@load",type:"snippet",detail:"Load shared extension library",apply:g.snippet('@load "${1:extension}"'),boost:10}];function V(t){const e=new Map,f=/\b(?:function|func)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let i;for(;(i=f.exec(t))!==null;){const o=i[1];x[o]||e.set(o,{label:o,type:"function",detail:"User Function",boost:5})}const c=/\b([A-Za-z_][A-Za-z0-9_]*)\b/g;for(;(i=c.exec(t))!==null;){const o=i[1];!v.has(o)&&!S.has(o)&&!T.has(o)&&!x[o]&&!e.has(o)&&e.set(o,{label:o,type:"variable",detail:"Document Variable"})}return Array.from(e.values())}function O(t){const e=t.matchBefore(/@[\w_]*|[A-Za-z_][A-Za-z0-9_]*/);if(!e||e.from===e.to&&!t.explicit)return null;if(e.text.startsWith("@"))return{from:e.from,options:[...E,...$.filter(o=>o.label.startsWith("@"))],validFor:/^@[\w_]*$/};const i=t.state.doc.toString(),c=V(i);return{from:e.from,options:[...$,...z,...E,...K,...Z,...P,...c],validFor:/^[A-Za-z_][A-Za-z0-9_]*$/}}function B(){return U.linter(t=>{const e=[],f=t.state.doc,i=f.lines;let c=[],o=[];for(let u=1;u<=i;u++){const s=f.line(u),b=s.text,A=b.indexOf("#"),l=A!==-1?b.slice(0,A):b,C=b.match(/@([a-zA-Z0-9_]+)/g);if(C){for(const a of C)if(!N.has(a)){const r=s.from+b.indexOf(a);e.push({from:r,to:r+a.length,severity:"error",message:`Unknown GNU AWK directive '${a}'. Valid directives: @include, @load, @namespace.`})}}if(/@include\s*(?!["<])/.test(l)){const a=s.from+l.indexOf("@include");e.push({from:a,to:a+8,severity:"warning",message:'@include directive expects a quoted filename e.g. @include "filename.awk"'})}if(/@namespace\s*(?!["<])/.test(l)){const a=s.from+l.indexOf("@namespace");e.push({from:a,to:a+10,severity:"warning",message:'@namespace directive expects a quoted string e.g. @namespace "my_module"'})}const h=l.match(/\b(?:function|func)\b/);if(h){const a=l.slice(h.index+h[0].length).trim();if(a===""||a.startsWith("{")||a.startsWith("(")){const r=s.from+h.index;e.push({from:r,to:r+h[0].length,severity:"error",message:"Function definition missing function name."})}else{const r=l.match(/\b(?:function|func)\s+([A-Za-z_][A-Za-z0-9_]*)/);if(r){const p=r[1];if(!l.slice(r.index+r[0].length).trim().startsWith("(")){const d=s.from+r.index;e.push({from:d,to:d+r[0].length,severity:"error",message:`Function definition '${p}' missing parameter parentheses '()'.`})}}}}let y=!1,I="",W=0,w=!1,_=0,k=!1;for(let a=0;a<l.length;a++){const r=l[a],p=a>0?l[a-1]:"";if(y)r===I&&p!=="\\"&&(y=!1);else if(w)r==="["&&p!=="\\"?k=!0:r==="]"&&p!=="\\"?k=!1:r==="/"&&p!=="\\"&&!k&&(w=!1);else if(r==='"')y=!0,I='"',W=s.from+a;else if(r==="/"){const m=l.slice(0,a).trim();(m===""||/[=~,\(\!\?\:\{\;\+\-\*\%\&\|]$/.test(m)||/\b(print|printf|return|match|sub|gsub|gensub|patsplit|split|if|while)\s*$/i.test(m))&&(w=!0,k=!1,_=s.from+a)}else if(r==="{"){const m=o.filter(d=>d.line===u);for(const d of m)e.push({from:d.pos,to:d.pos+1,severity:"error",message:'Unclosed parenthesis "(" in condition before brace.'});o=o.filter(d=>d.line!==u),c.push({pos:s.from+a,line:u})}else r==="}"?c.length>0?c.pop():e.push({from:s.from+a,to:s.from+a+1,severity:"error",message:'Unmatched closing brace "}".'}):r==="("?o.push({pos:s.from+a,line:u}):r===")"&&(o.length>0?o.pop():e.push({from:s.from+a,to:s.from+a+1,severity:"error",message:'Unmatched closing parenthesis ")".'}))}y&&!l.endsWith("\\")&&e.push({from:W,to:s.to,severity:"error",message:"Unterminated string literal."}),w&&!l.endsWith("\\")&&e.push({from:_,to:s.to,severity:"error",message:"Unterminated regular expression."})}for(const u of c)e.push({from:u.pos,to:u.pos+1,severity:"error",message:'Unclosed brace "{"'});for(const u of o)e.push({from:u.pos,to:u.pos+1,severity:"error",message:'Unclosed parenthesis "("'});return e})}const q=D.EditorView.theme({"&":{backgroundColor:"#0f172a",color:"#f8fafc",fontFamily:"'Fira Code', 'JetBrains Mono', 'Source Code Pro', monospace",fontSize:"14px",borderRadius:"8px"},".cm-content":{caretColor:"#38bdf8"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"#38bdf8"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#1e293b"},".cm-activeLine":{backgroundColor:"rgba(51, 65, 85, 0.4)"},".cm-gutters":{backgroundColor:"#0b1329",color:"#64748b",borderRight:"1px solid #1e293b"},".cm-activeLineGutter":{backgroundColor:"#1e293b",color:"#38bdf8"},".cm-foldPlaceholder":{backgroundColor:"#1e293b",color:"#94a3b8",border:"none",borderRadius:"4px",padding:"0 4px"},".cm-awk-directive":{color:"#c084fc",fontWeight:"bold"},".cm-awk-pattern":{color:"#f59e0b",fontWeight:"bold"},".cm-awk-keyword":{color:"#f43f5e",fontWeight:"bold"},".cm-awk-builtin-var":{color:"#38bdf8",fontWeight:"600"},".cm-awk-field":{color:"#4ade80",fontWeight:"bold"},".cm-awk-builtin-func":{color:"#60a5fa"},".cm-awk-func-def":{color:"#a78bfa",fontWeight:"bold"},".cm-awk-func-call":{color:"#38bdf8"},".cm-awk-string":{color:"#a3e635"},".cm-awk-regex":{color:"#fb923c"},".cm-awk-number":{color:"#facc15"},".cm-awk-comment":{color:"#64748b",fontStyle:"italic"},".cm-awk-operator":{color:"#cbd5e1"},".cm-awk-punctuation":{color:"#94a3b8"}},{dark:!0}),H=D.EditorView.theme({"&":{backgroundColor:"#ffffff",color:"#0f172a",fontFamily:"'Fira Code', 'JetBrains Mono', 'Source Code Pro', monospace",fontSize:"14px",borderRadius:"8px"},".cm-content":{caretColor:"#0284c7"},".cm-gutters":{backgroundColor:"#f8fafc",color:"#94a3b8",borderRight:"1px solid #e2e8f0"},".cm-activeLine":{backgroundColor:"#f1f5f9"},".cm-activeLineGutter":{backgroundColor:"#e2e8f0",color:"#0284c7"},".cm-awk-directive":{color:"#7e22ce",fontWeight:"bold"},".cm-awk-pattern":{color:"#d97706",fontWeight:"bold"},".cm-awk-keyword":{color:"#be123c",fontWeight:"bold"},".cm-awk-builtin-var":{color:"#0369a1",fontWeight:"600"},".cm-awk-field":{color:"#15803d",fontWeight:"bold"},".cm-awk-builtin-func":{color:"#1d4ed8"},".cm-awk-func-def":{color:"#6d28d9",fontWeight:"bold"},".cm-awk-func-call":{color:"#0284c7"},".cm-awk-string":{color:"#4d7c0f"},".cm-awk-regex":{color:"#c2410c"},".cm-awk-number":{color:"#b45309"},".cm-awk-comment":{color:"#64748b",fontStyle:"italic"},".cm-awk-operator":{color:"#334155"},".cm-awk-punctuation":{color:"#475569"}},{dark:!1}),G=R.syntaxHighlighting(R.HighlightStyle.define(M)),L=R.StreamLanguage.define(F);function Y(t={}){const e=[G];return t.autocomplete!==!1&&e.push(g.autocompletion({override:[O]})),t.lint!==!1&&e.push(B()),new R.LanguageSupport(L,e)}exports.GAWK_BUILTIN_FUNCTIONS=x;exports.GAWK_BUILTIN_VARS=T;exports.GAWK_DIRECTIVES=N;exports.GAWK_KEYWORDS=v;exports.GAWK_PATTERNS=S;exports.awk=Y;exports.awkCompletionSource=O;exports.awkDarkTheme=q;exports.awkHighlightStyle=M;exports.awkHighlighting=G;exports.awkLanguage=L;exports.awkLightTheme=H;exports.awkLinter=B;exports.awkStreamParser=F;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StreamLanguage, LanguageSupport } from '@codemirror/language';
|
|
2
|
+
import { Extension } from '@codemirror/state';
|
|
3
|
+
export * from './tokens';
|
|
4
|
+
export * from './grammar';
|
|
5
|
+
export * from './highlight';
|
|
6
|
+
export * from './completion';
|
|
7
|
+
export * from './linter';
|
|
8
|
+
export * from './theme';
|
|
9
|
+
/**
|
|
10
|
+
* Highlighting Style extension for GNU AWK
|
|
11
|
+
*/
|
|
12
|
+
export declare const awkHighlighting: Extension;
|
|
13
|
+
/**
|
|
14
|
+
* CodeMirror 6 StreamLanguage definition for GNU AWK
|
|
15
|
+
*/
|
|
16
|
+
export declare const awkLanguage: StreamLanguage<import("./grammar").AwkState>;
|
|
17
|
+
export interface AwkLanguageOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Enable diagnostic linting for syntax errors. Default: true.
|
|
20
|
+
*/
|
|
21
|
+
lint?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Enable autocompletion source. Default: true.
|
|
24
|
+
*/
|
|
25
|
+
autocomplete?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Main CodeMirror 6 plugin extension function for GNU AWK (awk).
|
|
29
|
+
*
|
|
30
|
+
* @param options Configuration options for linting and autocompletion
|
|
31
|
+
* @returns LanguageSupport instance for CodeMirror 6
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { EditorView } from '@codemirror/view';
|
|
36
|
+
* import { basicSetup } from 'codemirror';
|
|
37
|
+
* import { awk } from '@exercism/codemirror-lang-awk';
|
|
38
|
+
*
|
|
39
|
+
* new EditorView({
|
|
40
|
+
* doc: 'BEGIN { print "Hello, GNU AWK!" }',
|
|
41
|
+
* extensions: [basicSetup, awk()]
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function awk(options?: AwkLanguageOptions): LanguageSupport;
|