highmark-occam 1.0.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.
- package/README.md +139 -0
- package/lib/blockListing.js +40 -0
- package/lib/constants.js +13 -0
- package/lib/div/container.js +44 -0
- package/lib/div/line.js +48 -0
- package/lib/div/lines.js +61 -0
- package/lib/div/syntax.js +50 -0
- package/lib/document/bnf.js +32 -0
- package/lib/document/furtle.js +37 -0
- package/lib/document/json.js +33 -0
- package/lib/document/markdown.js +45 -0
- package/lib/document/markdownStyle.js +39 -0
- package/lib/document/nominal.js +50 -0
- package/lib/document/plainText.js +28 -0
- package/lib/document.js +55 -0
- package/lib/documentTypes.js +54 -0
- package/lib/example/customGrammarsJSON/firstOrderLogic.js +28 -0
- package/lib/example/preamble.js +18 -0
- package/lib/example/view/div/column.js +24 -0
- package/lib/example/view/div/markdown.js +84 -0
- package/lib/example/view/div/sizeable.js +25 -0
- package/lib/example/view/heading.js +27 -0
- package/lib/example/view/input.js +28 -0
- package/lib/example/view/listing.js +26 -0
- package/lib/example/view/subHeading.js +29 -0
- package/lib/example/view/textarea/content.js +46 -0
- package/lib/example/view/textarea.js +30 -0
- package/lib/example/view.js +73 -0
- package/lib/example.js +23 -0
- package/lib/index.js +31 -0
- package/lib/line.js +42 -0
- package/lib/map/node/html.js +24 -0
- package/lib/node/html/listing/block.js +56 -0
- package/lib/overlay.js +65 -0
- package/lib/overlayTokenTypes.js +89 -0
- package/lib/prettyPrinter.js +55 -0
- package/lib/styles.js +22 -0
- package/lib/token/overlay/common/content.js +25 -0
- package/lib/token/overlay/common/error.js +25 -0
- package/lib/token/overlay/common/labelName.js +25 -0
- package/lib/token/overlay/common/nonsense.js +25 -0
- package/lib/token/overlay/common/procedureReferenceName.js +25 -0
- package/lib/token/overlay/common/referenceName.js +25 -0
- package/lib/token/overlay/common/stuff.js +25 -0
- package/lib/token/overlay/markdown/heading.js +25 -0
- package/lib/token/overlay/markdown/link.js +25 -0
- package/lib/token/overlay/markdown/listing.js +25 -0
- package/lib/token/overlay/markdown/path.js +25 -0
- package/lib/token/overlay/markdown/reference.js +25 -0
- package/lib/token/overlay/markdown/table.js +25 -0
- package/lib/token/overlay/markdownStyle/name.js +25 -0
- package/lib/token/overlay/markdownStyle/value.js +25 -0
- package/lib/token/overlay/nonTerminalNode.js +25 -0
- package/lib/token/overlay/terminalNode.js +25 -0
- package/lib/utilities/character.js +18 -0
- package/lib/utilities/customGrammars.js +48 -0
- package/lib/utilities/document.js +57 -0
- package/lib/utilities/grammar.js +51 -0
- package/lib/utilities/lines.js +32 -0
- package/lib/utilities/query.js +20 -0
- package/lib/utilities/tokens.js +19 -0
- package/license.txt +48 -0
- package/package.json +52 -0
- package/src/blockListing.js +39 -0
- package/src/constants.js +3 -0
- package/src/div/container.js +37 -0
- package/src/div/line.js +43 -0
- package/src/div/lines.js +68 -0
- package/src/div/syntax.js +45 -0
- package/src/document/bnf.js +27 -0
- package/src/document/furtle.js +32 -0
- package/src/document/json.js +28 -0
- package/src/document/markdown.js +40 -0
- package/src/document/markdownStyle.js +34 -0
- package/src/document/nominal.js +56 -0
- package/src/document/plainText.js +23 -0
- package/src/document.js +54 -0
- package/src/documentTypes.js +19 -0
- package/src/example/customGrammarsJSON/firstOrderLogic.js +18 -0
- package/src/example/preamble.js +13 -0
- package/src/example/view/div/column.js +11 -0
- package/src/example/view/div/markdown.js +99 -0
- package/src/example/view/div/sizeable.js +12 -0
- package/src/example/view/heading.js +14 -0
- package/src/example/view/input.js +15 -0
- package/src/example/view/listing.js +14 -0
- package/src/example/view/subHeading.js +16 -0
- package/src/example/view/textarea/content.js +43 -0
- package/src/example/view/textarea.js +17 -0
- package/src/example/view.js +93 -0
- package/src/example.js +28 -0
- package/src/index.js +5 -0
- package/src/line.js +47 -0
- package/src/map/node/html.js +13 -0
- package/src/node/html/listing/block.js +68 -0
- package/src/overlay.js +87 -0
- package/src/overlayTokenTypes.js +33 -0
- package/src/prettyPrinter.js +54 -0
- package/src/styles.js +4 -0
- package/src/token/overlay/common/content.js +11 -0
- package/src/token/overlay/common/error.js +11 -0
- package/src/token/overlay/common/labelName.js +11 -0
- package/src/token/overlay/common/nonsense.js +11 -0
- package/src/token/overlay/common/procedureReferenceName.js +11 -0
- package/src/token/overlay/common/referenceName.js +11 -0
- package/src/token/overlay/common/stuff.js +11 -0
- package/src/token/overlay/markdown/heading.js +11 -0
- package/src/token/overlay/markdown/link.js +11 -0
- package/src/token/overlay/markdown/listing.js +11 -0
- package/src/token/overlay/markdown/path.js +11 -0
- package/src/token/overlay/markdown/reference.js +11 -0
- package/src/token/overlay/markdown/table.js +11 -0
- package/src/token/overlay/markdownStyle/name.js +11 -0
- package/src/token/overlay/markdownStyle/value.js +11 -0
- package/src/token/overlay/nonTerminalNode.js +17 -0
- package/src/token/overlay/terminalNode.js +17 -0
- package/src/utilities/character.js +11 -0
- package/src/utilities/customGrammars.js +34 -0
- package/src/utilities/document.js +44 -0
- package/src/utilities/grammar.js +38 -0
- package/src/utilities/lines.js +31 -0
- package/src/utilities/query.js +13 -0
- package/src/utilities/tokens.js +12 -0
package/license.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
MIT And Anti-996 Licenses
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 James Smith
|
|
4
|
+
|
|
5
|
+
These licenses shall be included in all copies or substantial portions of
|
|
6
|
+
this software and associated documentation files (the "Software").
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this Software, to deal in the Software without restriction, including
|
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
12
|
+
persons to whom the Software is furnished to do so, subject to the following
|
|
13
|
+
conditions:
|
|
14
|
+
|
|
15
|
+
1. The individual or the legal entity must conspicuously display,
|
|
16
|
+
without modification, this License and the notice on each redistributed
|
|
17
|
+
or derivative copy of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
2. The individual or the legal entity must strictly comply with all
|
|
20
|
+
applicable laws, regulations, rules and standards of the jurisdiction
|
|
21
|
+
relating to labor and employment where the individual is physically
|
|
22
|
+
located or where the individual was born or naturalized; or where the
|
|
23
|
+
legal entity is registered or is operating (whichever is stricter). In
|
|
24
|
+
case that the jurisdiction has no such laws, regulations, rules and
|
|
25
|
+
standards or its laws, regulations, rules and standards are
|
|
26
|
+
unenforceable, the individual or the legal entity are required to
|
|
27
|
+
comply with Core International Labor Standards.
|
|
28
|
+
|
|
29
|
+
3. The individual or the legal entity shall not induce, suggest or force
|
|
30
|
+
its employee(s), whether full-time or part-time, or its independent
|
|
31
|
+
contractor(s), in any methods, to agree in oral or written form, to
|
|
32
|
+
directly or indirectly restrict, weaken or relinquish his or her
|
|
33
|
+
rights or remedies under such laws, regulations, rules and standards
|
|
34
|
+
relating to labor and employment as mentioned above, no matter whether
|
|
35
|
+
such written or oral agreements are enforceable under the laws of the
|
|
36
|
+
said jurisdiction, nor shall such individual or the legal entity
|
|
37
|
+
limit, in any methods, the rights of its employee(s) or independent
|
|
38
|
+
contractor(s) from reporting or complaining to the copyright holder or
|
|
39
|
+
relevant authorities monitoring the compliance of the license about
|
|
40
|
+
its violation(s) of the said license.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
43
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
44
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
45
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
46
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
47
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
48
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "highmark-occam",
|
|
3
|
+
"author": "James Smith",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"license": "MIT, Anti-996",
|
|
6
|
+
"homepage": "https://github.com/djalbat/highmark-occam",
|
|
7
|
+
"description": "Highmark support for Occam.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/djalbat/highmark-occam"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"easy": "^24.1.8",
|
|
14
|
+
"highmark-markdown": "^1.2.93",
|
|
15
|
+
"occam-custom-grammars": "^6.0.36",
|
|
16
|
+
"occam-grammars": "^1.3.529",
|
|
17
|
+
"occam-lexers": "^23.1.48",
|
|
18
|
+
"occam-nominal": "^1.0.115",
|
|
19
|
+
"occam-parsers": "^23.1.54",
|
|
20
|
+
"occam-query": "^4.1.159",
|
|
21
|
+
"occam-styles": "^5.0.453",
|
|
22
|
+
"yapp": "^5.1.305"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@swc/core": "1.13.20",
|
|
26
|
+
"easy-layout": "^6.0.301",
|
|
27
|
+
"easy-with-style": "^3.0.549",
|
|
28
|
+
"esbuild": "0.11.14",
|
|
29
|
+
"express": "^4.17.1",
|
|
30
|
+
"juxtapose": "^4.0.136",
|
|
31
|
+
"lively-cli": "^2.0.98",
|
|
32
|
+
"watchful-cli": "^1.7.89"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"start": "node ./bin/main.js",
|
|
36
|
+
"clean": "rm -rf ./lib",
|
|
37
|
+
"watchful": "watchful -m --transpiler=swc --bundler=esbuild --source-directory=./src --lib-directory=./lib --entry-file=example.js --bundle-file=./example.js --wait=100",
|
|
38
|
+
"batch": "npm run watchful batch --",
|
|
39
|
+
"batch-debug": "npm run watchful batch -- --debug",
|
|
40
|
+
"incremental": "npm run watchful incremental --",
|
|
41
|
+
"incremental-debug": "npm run watchful incremental -- --debug",
|
|
42
|
+
"build": "npm run clean && npm run batch",
|
|
43
|
+
"build-debug": "npm run clean && npm run batch-debug",
|
|
44
|
+
"watch": "npm run clean && npm run batch && npm run incremental",
|
|
45
|
+
"watch-debug": "npm run clean && npm run batch-debug && npm run incremental-debug"
|
|
46
|
+
},
|
|
47
|
+
"files": [
|
|
48
|
+
"src",
|
|
49
|
+
"lib"
|
|
50
|
+
],
|
|
51
|
+
"main": "./lib/index.js"
|
|
52
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import PrettyPrinter from "./prettyPrinter";
|
|
4
|
+
|
|
5
|
+
import { domUtilities } from "highmark-markdown";
|
|
6
|
+
import { elementUtilities } from "easy";
|
|
7
|
+
|
|
8
|
+
const { mountElement, unmountElement } = elementUtilities,
|
|
9
|
+
{ remove, insertAfter, insertBeforehand } = domUtilities;
|
|
10
|
+
|
|
11
|
+
export default class BlockListing extends PrettyPrinter {
|
|
12
|
+
mount(parentDOMElement, siblingDOMElement, context) {
|
|
13
|
+
const domElement = this.getDOMElement();
|
|
14
|
+
|
|
15
|
+
(siblingDOMElement !== null) ?
|
|
16
|
+
insertAfter(domElement, parentDOMElement, siblingDOMElement) :
|
|
17
|
+
insertBeforehand(domElement, parentDOMElement);
|
|
18
|
+
|
|
19
|
+
const element = this; ///
|
|
20
|
+
|
|
21
|
+
mountElement(element);
|
|
22
|
+
|
|
23
|
+
siblingDOMElement = domElement; ///
|
|
24
|
+
|
|
25
|
+
return siblingDOMElement;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
unmount(parentDOMElement, context) {
|
|
29
|
+
const element = this; ///
|
|
30
|
+
|
|
31
|
+
unmountElement(element);
|
|
32
|
+
|
|
33
|
+
const domElement = this.getDOMElement();
|
|
34
|
+
|
|
35
|
+
remove(domElement, parentDOMElement);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static fromClass(properties, ...remainingArgumments) { return PrettyPrinter.fromClass(BlockListing, properties, ...remainingArgumments) ; }
|
|
39
|
+
}
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style";
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
import { editorScheme } from "occam-styles";
|
|
7
|
+
|
|
8
|
+
import PrettyPrinter from "../prettyPrinter";
|
|
9
|
+
|
|
10
|
+
const { borderColour } = editorScheme;
|
|
11
|
+
|
|
12
|
+
class ContainerDiv extends Element {
|
|
13
|
+
childElements() {
|
|
14
|
+
const { changeCustomHandler } = this.properties;
|
|
15
|
+
|
|
16
|
+
return ([
|
|
17
|
+
|
|
18
|
+
<PrettyPrinter changeCustomHandler={changeCustomHandler} />
|
|
19
|
+
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static tagName = "div";
|
|
24
|
+
|
|
25
|
+
static defaultProperties = {
|
|
26
|
+
className: "container"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default withStyle(ContainerDiv)`
|
|
31
|
+
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
border: 1px solid ${borderColour};
|
|
35
|
+
position: relative;
|
|
36
|
+
|
|
37
|
+
`;
|
package/src/div/line.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
|
|
7
|
+
import SyntaxDiv from "../div/syntax";
|
|
8
|
+
|
|
9
|
+
class LineDiv extends Element {
|
|
10
|
+
getHTML() {
|
|
11
|
+
const { html } = this.properties;
|
|
12
|
+
|
|
13
|
+
return html
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
childElements() {
|
|
17
|
+
const html = this.getHTML();
|
|
18
|
+
|
|
19
|
+
return ([
|
|
20
|
+
|
|
21
|
+
<SyntaxDiv html={html} />
|
|
22
|
+
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static tagName = "div";
|
|
27
|
+
|
|
28
|
+
static ignoredProperties = [
|
|
29
|
+
"html"
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
static defaultProperties = {
|
|
33
|
+
className: "line"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default withStyle(LineDiv)`
|
|
38
|
+
|
|
39
|
+
font-size: inherit;
|
|
40
|
+
line-height: inherit;
|
|
41
|
+
font-family: inherit;
|
|
42
|
+
|
|
43
|
+
`;
|
package/src/div/lines.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
|
|
7
|
+
import LineDiv from "../div/line";
|
|
8
|
+
|
|
9
|
+
class LinesDiv extends Element {
|
|
10
|
+
getDocument() {
|
|
11
|
+
const { document } = this.properties;
|
|
12
|
+
|
|
13
|
+
return document;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
didMount() {
|
|
17
|
+
const document = this.getDocument(),
|
|
18
|
+
documentType = document.getType(),
|
|
19
|
+
documentTypeClass = documentType; ///
|
|
20
|
+
|
|
21
|
+
this.addClass(documentTypeClass);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
willUnmount() {
|
|
25
|
+
///
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
childElements() {
|
|
29
|
+
const document = this.getDocument(),
|
|
30
|
+
lines = document.getLines(),
|
|
31
|
+
lineDivs = lines.map((line) => {
|
|
32
|
+
const html = document.lineAsHTML(line),
|
|
33
|
+
lineDiv =
|
|
34
|
+
|
|
35
|
+
<LineDiv html={html} />
|
|
36
|
+
|
|
37
|
+
;
|
|
38
|
+
|
|
39
|
+
return lineDiv;
|
|
40
|
+
}),
|
|
41
|
+
childElements = lineDivs; ///
|
|
42
|
+
|
|
43
|
+
return childElements;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static tagName = "div";
|
|
47
|
+
|
|
48
|
+
static ignoredProperties = [
|
|
49
|
+
"document"
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
static defaultProperties = {
|
|
53
|
+
className: "lines",
|
|
54
|
+
spellCheck: "false"
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default withStyle(LinesDiv)`
|
|
59
|
+
|
|
60
|
+
outline: none;
|
|
61
|
+
display: grid;
|
|
62
|
+
min-width: 100%;
|
|
63
|
+
|
|
64
|
+
font-size: inherit;
|
|
65
|
+
line-height: inherit;
|
|
66
|
+
font-family: inherit;
|
|
67
|
+
|
|
68
|
+
`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
|
|
7
|
+
class SyntaxDiv extends Element {
|
|
8
|
+
getHTML() {
|
|
9
|
+
const { html } = this.properties;
|
|
10
|
+
|
|
11
|
+
return html
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
didMount() {
|
|
15
|
+
const html = this.getHTML();
|
|
16
|
+
|
|
17
|
+
this.html(html);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
willUnmount() {
|
|
21
|
+
///
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static tagName = "div";
|
|
25
|
+
|
|
26
|
+
static ignoredProperties = [
|
|
27
|
+
"html"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
static defaultProperties = {
|
|
31
|
+
className: "syntax"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default withStyle(SyntaxDiv)`
|
|
36
|
+
|
|
37
|
+
display: inline;
|
|
38
|
+
white-space: pre;
|
|
39
|
+
|
|
40
|
+
font-size: inherit;
|
|
41
|
+
line-height: inherit;
|
|
42
|
+
font-family: inherit;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { BNFLexer } from "occam-lexers";
|
|
4
|
+
import { BNFParser } from "occam-parsers";
|
|
5
|
+
|
|
6
|
+
import Document from "../document";
|
|
7
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
8
|
+
|
|
9
|
+
import { BNF_DOCUMENT_TYPE } from "../documentTypes";
|
|
10
|
+
|
|
11
|
+
const bnfLexer = BNFLexer.fromNothing(),
|
|
12
|
+
bnfParser = BNFParser.fromNothing();
|
|
13
|
+
|
|
14
|
+
export default class BNFDocument extends Document {
|
|
15
|
+
static overlayTokenMap = {
|
|
16
|
+
"//error": ErrorOverlayToken
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static fromContent(content) {
|
|
20
|
+
const type = BNF_DOCUMENT_TYPE,
|
|
21
|
+
lexer = bnfLexer, ///
|
|
22
|
+
parser = bnfParser, ///
|
|
23
|
+
bnfDocument = Document.fromContentTypeLexerAndParser(BNFDocument, content, type, lexer, parser);
|
|
24
|
+
|
|
25
|
+
return bnfDocument;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { FurtleLexer, FurtleParser } from "occam-grammars";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
7
|
+
import NonsenseOverlayToken from "../token/overlay/common/nonsense";
|
|
8
|
+
import LabelNameOverlayToken from "../token/overlay/common/labelName";
|
|
9
|
+
import ReferenceNameOverlayToken from "../token/overlay/common/referenceName";
|
|
10
|
+
|
|
11
|
+
import { FURTLE_DOCUMENT_TYPE } from "../documentTypes";
|
|
12
|
+
|
|
13
|
+
const furtleLexer = FurtleLexer.fromNothing(),
|
|
14
|
+
furtleParser = FurtleParser.fromNothing();
|
|
15
|
+
|
|
16
|
+
export default class FurtleDocument extends Document {
|
|
17
|
+
static overlayTokenMap = {
|
|
18
|
+
"//error": ErrorOverlayToken,
|
|
19
|
+
"//nonsense": NonsenseOverlayToken,
|
|
20
|
+
"//label/@name": LabelNameOverlayToken,
|
|
21
|
+
"//reference/@name": ReferenceNameOverlayToken
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
static fromContent(content) {
|
|
25
|
+
const type = FURTLE_DOCUMENT_TYPE,
|
|
26
|
+
lexer = furtleLexer, ///
|
|
27
|
+
parser = furtleParser, ///
|
|
28
|
+
furtleDocument = Document.fromContentTypeLexerAndParser(FurtleDocument, content, type, lexer, parser);
|
|
29
|
+
|
|
30
|
+
return furtleDocument;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { JSONLexer, JSONParser } from "occam-grammars";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
7
|
+
import NonsenseOverlayToken from "../token/overlay/common/nonsense";
|
|
8
|
+
|
|
9
|
+
import { JSON_DOCUMENT_TYPE } from "../documentTypes";
|
|
10
|
+
|
|
11
|
+
const jsonLexer = JSONLexer.fromNothing(),
|
|
12
|
+
jsonParser = JSONParser.fromNothing();
|
|
13
|
+
|
|
14
|
+
export default class JSONDocument extends Document {
|
|
15
|
+
static overlayTokenMap = {
|
|
16
|
+
"//error": ErrorOverlayToken,
|
|
17
|
+
"//nonsense": NonsenseOverlayToken
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
static fromContent(content) {
|
|
21
|
+
const type = JSON_DOCUMENT_TYPE,
|
|
22
|
+
lexer = jsonLexer, ///
|
|
23
|
+
parser = jsonParser, ///
|
|
24
|
+
jsonDocument = Document.fromContentTypeLexerAndParser(JSONDocument, content, type, lexer, parser);
|
|
25
|
+
|
|
26
|
+
return jsonDocument;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MarkdownLexer, MarkdownParser } from "highmark-markdown";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
import PathOverlayToken from "../token/overlay/markdown/path";
|
|
7
|
+
import LinkOverlayToken from "../token/overlay/markdown/link";
|
|
8
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
9
|
+
import TableOverlayToken from "../token/overlay/markdown/table";
|
|
10
|
+
import ListingOverlayToken from "../token/overlay/markdown/listing";
|
|
11
|
+
import HeadingOverlayToken from "../token/overlay/markdown/heading";
|
|
12
|
+
import NonsenseOverlayToken from "../token/overlay/common/nonsense";
|
|
13
|
+
import ReferenceOverlayToken from "../token/overlay/markdown/reference";
|
|
14
|
+
|
|
15
|
+
import { MARKDOWN_DOCUMENT_TYPE } from "../documentTypes";
|
|
16
|
+
|
|
17
|
+
const markdownLexer = MarkdownLexer.fromNothing(),
|
|
18
|
+
markdownParser = MarkdownParser.fromNothing();
|
|
19
|
+
|
|
20
|
+
export default class MarkdownDocument extends Document {
|
|
21
|
+
static overlayTokenMap = {
|
|
22
|
+
"//error": ErrorOverlayToken,
|
|
23
|
+
"//nonsense": NonsenseOverlayToken,
|
|
24
|
+
"//reference": ReferenceOverlayToken,
|
|
25
|
+
"//tableDivider|tableCellDivider": TableOverlayToken,
|
|
26
|
+
"//footnoteLink|emailLink|hyperlink": LinkOverlayToken,
|
|
27
|
+
"//embedDirective|includeDirective/path": PathOverlayToken,
|
|
28
|
+
"//blockStart|blockEnd|blockLine|inlineListing": ListingOverlayToken,
|
|
29
|
+
"//primaryHeading|secondaryHeading|tertiaryHeading|quaternaryHeading": HeadingOverlayToken
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static fromContent(content) {
|
|
33
|
+
const type = MARKDOWN_DOCUMENT_TYPE,
|
|
34
|
+
lexer = markdownLexer, ///
|
|
35
|
+
parser = markdownParser, ///
|
|
36
|
+
markdownDocument = Document.fromContentTypeLexerAndParser(MarkdownDocument, content, type, lexer, parser);
|
|
37
|
+
|
|
38
|
+
return markdownDocument;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MarkdownStyleLexer, MarkdownStyleParser } from "highmark-markdown";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
import NameOverlayToken from "../token/overlay/markdownStyle/name";
|
|
7
|
+
import ValueOverlayToken from "../token/overlay/markdownStyle/value";
|
|
8
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
9
|
+
import ContentOverlayToken from "../token/overlay/common/content";
|
|
10
|
+
import NonsenseOverlayToken from "../token/overlay/common/nonsense";
|
|
11
|
+
|
|
12
|
+
import { MARKDOWN_STYLE_DOCUMENT_TYPE } from "../documentTypes";
|
|
13
|
+
|
|
14
|
+
const markdownStyleLexer = MarkdownStyleLexer.fromNothing(),
|
|
15
|
+
markdownStyleParser = MarkdownStyleParser.fromNothing();
|
|
16
|
+
|
|
17
|
+
export default class MarkdownStyleDocument extends Document {
|
|
18
|
+
static overlayTokenMap = {
|
|
19
|
+
"//error": ErrorOverlayToken,
|
|
20
|
+
"//name": NameOverlayToken,
|
|
21
|
+
"//value": ValueOverlayToken,
|
|
22
|
+
"//nonsense": NonsenseOverlayToken,
|
|
23
|
+
"//content//*": ContentOverlayToken
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
static fromContent(content) {
|
|
27
|
+
const type = MARKDOWN_STYLE_DOCUMENT_TYPE,
|
|
28
|
+
lexer = markdownStyleLexer, ///
|
|
29
|
+
parser = markdownStyleParser, ///
|
|
30
|
+
markdownStyleDocument = Document.fromContentTypeLexerAndParser(MarkdownStyleDocument, content, type, lexer, parser);
|
|
31
|
+
|
|
32
|
+
return markdownStyleDocument;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { lexersUtilities, parsersUtilities } from "occam-nominal";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
import ErrorOverlayToken from "../token/overlay/common/error";
|
|
7
|
+
import StuffOverlayToken from "../token/overlay/common/stuff";
|
|
8
|
+
import NonsenseOverlayToken from "../token/overlay/common/nonsense";
|
|
9
|
+
import LabelNameOverlayToken from "../token/overlay/common/labelName";
|
|
10
|
+
import ReferenceNameOverlayToken from "../token/overlay/common/referenceName";
|
|
11
|
+
import ProcedureReferenceNameOverlayToken from "../token/overlay/common/procedureReferenceName";
|
|
12
|
+
|
|
13
|
+
import { NOMINAL_DOCUMENT_TYPE } from "../documentTypes";
|
|
14
|
+
import { combinedCustomGrammarFromReleaseName } from "../utilities/customGrammars";
|
|
15
|
+
|
|
16
|
+
const { nominalLexerFromNothing, nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
17
|
+
{ nominalParserFromNothing, nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
18
|
+
|
|
19
|
+
export default class NominalDocument extends Document {
|
|
20
|
+
static overlayTokenMap = {
|
|
21
|
+
"//error": ErrorOverlayToken,
|
|
22
|
+
"//stuff": StuffOverlayToken,
|
|
23
|
+
"//nonsense": NonsenseOverlayToken,
|
|
24
|
+
"//label/metavariable/@name": LabelNameOverlayToken,
|
|
25
|
+
"//procedureReference/@name": ProcedureReferenceNameOverlayToken,
|
|
26
|
+
"//reference/metavariable/@name": ReferenceNameOverlayToken
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
static fromContentAndReleaseName(content, releaseName) {
|
|
30
|
+
const type = NOMINAL_DOCUMENT_TYPE,
|
|
31
|
+
combinedCustomGrammar = combinedCustomGrammarFromReleaseName(releaseName),
|
|
32
|
+
nominalLexer = nominalLexerrFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
33
|
+
nominalParser = nominalParserrFromCombinedCustomGrammar(combinedCustomGrammar),
|
|
34
|
+
lexer = nominalLexer, ///
|
|
35
|
+
parser = nominalParser, ///
|
|
36
|
+
nominalDocument = Document.fromContentTypeLexerAndParser(NominalDocument, content, type, lexer, parser, releaseName);
|
|
37
|
+
|
|
38
|
+
return nominalDocument;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function nominalLexerrFromCombinedCustomGrammar(combinedCustomGrammar) {
|
|
43
|
+
const nominalLexer = (combinedCustomGrammar !== null) ?
|
|
44
|
+
nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar) :
|
|
45
|
+
nominalLexerFromNothing();
|
|
46
|
+
|
|
47
|
+
return nominalLexer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function nominalParserrFromCombinedCustomGrammar(combinedCustomGrammar) {
|
|
51
|
+
const nominalParser = (combinedCustomGrammar !== null) ?
|
|
52
|
+
nominalParserFromCombinedCustomGrammar(combinedCustomGrammar) :
|
|
53
|
+
nominalParserFromNothing();
|
|
54
|
+
|
|
55
|
+
return nominalParser;
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { PlainTextLexer, PlainTextParser } from "occam-grammars";
|
|
4
|
+
|
|
5
|
+
import Document from "../document";
|
|
6
|
+
|
|
7
|
+
import { PLAIN_TEXT_DOCUMENT_TYPE } from "../documentTypes";
|
|
8
|
+
|
|
9
|
+
const plainTextLexer = PlainTextLexer.fromNothing(),
|
|
10
|
+
plainTextParser = PlainTextParser.fromNothing();
|
|
11
|
+
|
|
12
|
+
export default class PlainTextDocument extends Document {
|
|
13
|
+
static overlayTokenMap = {};
|
|
14
|
+
|
|
15
|
+
static fromContent(content) {
|
|
16
|
+
const type = PLAIN_TEXT_DOCUMENT_TYPE,
|
|
17
|
+
lexer = plainTextLexer, ///
|
|
18
|
+
parser = plainTextParser, ///
|
|
19
|
+
plainTextDocument = Document.fromContentTypeLexerAndParser(PlainTextDocument, content, type, lexer, parser);
|
|
20
|
+
|
|
21
|
+
return plainTextDocument;
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/document.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Overlay from "./overlay";
|
|
4
|
+
|
|
5
|
+
import { tokensFromLines } from "./utilities/tokens";
|
|
6
|
+
import { linesFromContent } from "./utilities/lines";
|
|
7
|
+
|
|
8
|
+
export default class Document {
|
|
9
|
+
constructor(type, content, tokens, lines, node, overlay) {
|
|
10
|
+
this.type = type;
|
|
11
|
+
this.content = content;
|
|
12
|
+
this.tokens = tokens;
|
|
13
|
+
this.lines = lines;
|
|
14
|
+
this.node = node;
|
|
15
|
+
this.overlay = overlay;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getType() {
|
|
19
|
+
return this.type;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getContent() {
|
|
23
|
+
return this.content;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getTokens() {
|
|
27
|
+
return this.tokens;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getLines() {
|
|
31
|
+
return this.lines;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getNode() {
|
|
35
|
+
return this.node;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getOverlay() {
|
|
39
|
+
return this.overlay;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
lineAsHTML(line) { return this.overlay.lineAsHTML(line); }
|
|
43
|
+
|
|
44
|
+
static fromContentTypeLexerAndParser(Class, content, type, lexer, parser) {
|
|
45
|
+
const { overlayTokenMap } = Class,
|
|
46
|
+
lines = linesFromContent(content, lexer),
|
|
47
|
+
tokens = tokensFromLines(lines),
|
|
48
|
+
node = parser.parse(tokens),
|
|
49
|
+
overlay = Overlay.fromNodeAndOverlayTokenMap(node, overlayTokenMap),
|
|
50
|
+
document = new Class(type, content, tokens, lines, node, overlay);
|
|
51
|
+
|
|
52
|
+
return document;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const BNF_DOCUMENT_TYPE = "bnf";
|
|
4
|
+
export const JSON_DOCUMENT_TYPE = "json";
|
|
5
|
+
export const FURTLE_DOCUMENT_TYPE = "furtle";
|
|
6
|
+
export const NOMINAL_DOCUMENT_TYPE = "nominal";
|
|
7
|
+
export const MARKDOWN_DOCUMENT_TYPE = "markdown";
|
|
8
|
+
export const PLAIN_TEXT_DOCUMENT_TYPE = "plain-text";
|
|
9
|
+
export const MARKDOWN_STYLE_DOCUMENT_TYPE = "markdown-style";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
BNF_DOCUMENT_TYPE,
|
|
13
|
+
JSON_DOCUMENT_TYPE,
|
|
14
|
+
FURTLE_DOCUMENT_TYPE,
|
|
15
|
+
NOMINAL_DOCUMENT_TYPE,
|
|
16
|
+
MARKDOWN_DOCUMENT_TYPE,
|
|
17
|
+
PLAIN_TEXT_DOCUMENT_TYPE,
|
|
18
|
+
MARKDOWN_STYLE_DOCUMENT_TYPE
|
|
19
|
+
};
|