yapp 2.2.49 → 2.2.51
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 +2 -2
- package/example.js +857 -588
- package/lib/example/view/javascript.js +5 -6
- package/lib/example/view/json.js +5 -6
- package/lib/example/view/xml.js +5 -6
- package/lib/example/view.js +6 -5
- package/lib/example/yapp.js +1 -2
- package/lib/index.js +20 -6
- package/lib/lexer/javascript.js +13 -8
- package/lib/lexer/json.js +13 -8
- package/lib/lexer/plainText.js +13 -8
- package/lib/lexer/xml.js +13 -8
- package/lib/lexer/yapp.js +88 -0
- package/lib/parser/javascript.js +18 -16
- package/lib/parser/json.js +18 -16
- package/lib/parser/plainText.js +18 -16
- package/lib/parser/xml.js +18 -16
- package/lib/parser/yapp.js +140 -0
- package/package.json +2 -2
- package/src/example/view/javascript.js +4 -2
- package/src/example/view/json.js +4 -2
- package/src/example/view/xml.js +4 -2
- package/src/example/view.js +6 -4
- package/src/example/yapp.js +0 -1
- package/src/index.js +3 -1
- package/src/lexer/javascript.js +5 -5
- package/src/lexer/json.js +5 -5
- package/src/lexer/plainText.js +5 -5
- package/src/lexer/xml.js +5 -5
- package/src/lexer/yapp.js +5 -0
- package/src/parser/javascript.js +5 -26
- package/src/parser/json.js +5 -26
- package/src/parser/plainText.js +5 -26
- package/src/parser/xml.js +5 -26
- package/src/parser/yapp.js +52 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _occamLexers = require("occam-lexers");
|
|
7
|
+
var _occamGrammarUtilities = require("occam-grammar-utilities");
|
|
8
|
+
var _occamParsers = require("occam-parsers");
|
|
9
|
+
var _rules = require("../utilities/rules");
|
|
10
|
+
function _assertThisInitialized(self) {
|
|
11
|
+
if (self === void 0) {
|
|
12
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
}
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
function _classCallCheck(instance, Constructor) {
|
|
17
|
+
if (!(instance instanceof Constructor)) {
|
|
18
|
+
throw new TypeError("Cannot call a class as a function");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _defineProperties(target, props) {
|
|
22
|
+
for(var i = 0; i < props.length; i++){
|
|
23
|
+
var descriptor = props[i];
|
|
24
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
25
|
+
descriptor.configurable = true;
|
|
26
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
27
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
31
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
32
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
33
|
+
return Constructor;
|
|
34
|
+
}
|
|
35
|
+
function _getPrototypeOf(o) {
|
|
36
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
37
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
38
|
+
};
|
|
39
|
+
return _getPrototypeOf(o);
|
|
40
|
+
}
|
|
41
|
+
function _inherits(subClass, superClass) {
|
|
42
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
43
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
44
|
+
}
|
|
45
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
46
|
+
constructor: {
|
|
47
|
+
value: subClass,
|
|
48
|
+
writable: true,
|
|
49
|
+
configurable: true
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
53
|
+
}
|
|
54
|
+
function _possibleConstructorReturn(self, call) {
|
|
55
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
56
|
+
return call;
|
|
57
|
+
}
|
|
58
|
+
return _assertThisInitialized(self);
|
|
59
|
+
}
|
|
60
|
+
function _setPrototypeOf(o, p) {
|
|
61
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
62
|
+
o.__proto__ = p;
|
|
63
|
+
return o;
|
|
64
|
+
};
|
|
65
|
+
return _setPrototypeOf(o, p);
|
|
66
|
+
}
|
|
67
|
+
var _typeof = function(obj) {
|
|
68
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
69
|
+
};
|
|
70
|
+
function _isNativeReflectConstruct() {
|
|
71
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
72
|
+
if (Reflect.construct.sham) return false;
|
|
73
|
+
if (typeof Proxy === "function") return true;
|
|
74
|
+
try {
|
|
75
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
76
|
+
return true;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function _createSuper(Derived) {
|
|
82
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
83
|
+
return function _createSuperInternal() {
|
|
84
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
85
|
+
if (hasNativeReflectConstruct) {
|
|
86
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
87
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
88
|
+
} else {
|
|
89
|
+
result = Super.apply(this, arguments);
|
|
90
|
+
}
|
|
91
|
+
return _possibleConstructorReturn(this, result);
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
var bnfLexer = _occamLexers.BNFLexer.fromNothing(), bnfParser = _occamParsers.BNFParser.fromNothing();
|
|
95
|
+
var YappParser = /*#__PURE__*/ function(CommonParser) {
|
|
96
|
+
_inherits(YappParser, CommonParser);
|
|
97
|
+
var _super = _createSuper(YappParser);
|
|
98
|
+
function YappParser() {
|
|
99
|
+
_classCallCheck(this, YappParser);
|
|
100
|
+
return _super.apply(this, arguments);
|
|
101
|
+
}
|
|
102
|
+
_createClass(YappParser, null, [
|
|
103
|
+
{
|
|
104
|
+
key: "fromNothing",
|
|
105
|
+
value: function fromNothing(Class) {
|
|
106
|
+
var bnf = Class.bnf, rules = rulesFromBNF(bnf), parser = parserFromRules(Class, rules);
|
|
107
|
+
return parser;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
key: "fromBNF",
|
|
112
|
+
value: function fromBNF(Class, bnf) {
|
|
113
|
+
var rules = rulesFromBNF(bnf), parser = parserFromRules(Class, rules);
|
|
114
|
+
return parser;
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: "fromRules",
|
|
119
|
+
value: function fromRules(Class, rules) {
|
|
120
|
+
var parser = parserFromRules(Class, rules);
|
|
121
|
+
return parser;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]);
|
|
125
|
+
return YappParser;
|
|
126
|
+
}(_occamParsers.CommonParser);
|
|
127
|
+
exports.default = YappParser;
|
|
128
|
+
function rulesFromBNF(bnf) {
|
|
129
|
+
var tokens = bnfLexer.tokensFromBNF(bnf), rules = bnfParser.rulesFromTokens(tokens);
|
|
130
|
+
return rules;
|
|
131
|
+
}
|
|
132
|
+
function parserFromRules(Class, rules) {
|
|
133
|
+
var ruleMap = (0, _rules).ruleMapFromRules(rules);
|
|
134
|
+
var startRule = (0, _rules).startRuleFromRules(rules);
|
|
135
|
+
startRule = (0, _occamGrammarUtilities).eliminateLeftRecursion(startRule, ruleMap);
|
|
136
|
+
var parser = new Class(startRule, ruleMap);
|
|
137
|
+
return parser;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy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sUUFBUSxDQUFEQSxTQUFTLENBQUNQLEtBQUssRUFBRUUsS0FBSyxFQUFFLENBQUM7Z0JBQzlCLEdBQUssQ0FBQ0UsTUFBTSxHQUFHQyxlQUFlLENBQUNMLEtBQUssRUFBRUUsS0FBSztnQkFFM0MsTUFBTSxDQUFDRSxNQUFNO1lBQ2YsQ0FBQzs7O1dBcEJrQkwsVUFBVTtFQVBTLGFBQWU7a0JBT2xDQSxVQUFVO1NBdUJ0QkksWUFBWSxDQUFDRixHQUFHLEVBQUUsQ0FBQztJQUMxQixHQUFLLENBQUNPLE1BQU0sR0FBR1osUUFBUSxDQUFDYSxhQUFhLENBQUNSLEdBQUcsR0FDbkNDLEtBQUssR0FBR0osU0FBUyxDQUFDWSxlQUFlLENBQUNGLE1BQU07SUFFOUMsTUFBTSxDQUFDTixLQUFLO0FBQ2QsQ0FBQztTQUVRRyxlQUFlLENBQUNMLEtBQUssRUFBRUUsS0FBSyxFQUFFLENBQUM7SUFDdEMsR0FBSyxDQUFDUyxPQUFPLE9BcENzQyxNQUFvQixtQkFvQ3RDVCxLQUFLO0lBRXRDLEdBQUcsQ0FBQ1UsU0FBUyxPQXRDc0MsTUFBb0IscUJBc0NwQ1YsS0FBSztJQUV4Q1UsU0FBUyxPQTNDNEIsc0JBQXlCLHlCQTJDM0JBLFNBQVMsRUFBRUQsT0FBTztJQUVyRCxHQUFLLENBQUNQLE1BQU0sR0FBRyxHQUFHLENBQUNKLEtBQUssQ0FBQ1ksU0FBUyxFQUFFRCxPQUFPO0lBRTNDLE1BQU0sQ0FBQ1AsTUFBTTtBQUNmLENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yapp",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.51",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/yapp",
|
|
7
7
|
"description": "Yet Another Pretty Printer.",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"occam-dom": "^3.0.74",
|
|
18
18
|
"occam-grammar-utilities": "^5.0.80",
|
|
19
19
|
"occam-lexers": "^15.0.1",
|
|
20
|
-
"occam-parsers": "^14.0
|
|
20
|
+
"occam-parsers": "^14.1.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@swc/core": "^1.2.106",
|
|
@@ -5,9 +5,11 @@ import View from "../view";
|
|
|
5
5
|
import JavaScriptPlugin from "../../plugin/javascript";
|
|
6
6
|
|
|
7
7
|
export default class JavaScriptView extends View {
|
|
8
|
-
Plugin = JavaScriptPlugin;
|
|
8
|
+
static Plugin = JavaScriptPlugin;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
static firaCode = true;
|
|
11
|
+
|
|
12
|
+
static initialContent = `"use strict";
|
|
11
13
|
|
|
12
14
|
import "juxtapose";
|
|
13
15
|
|
package/src/example/view/json.js
CHANGED
|
@@ -5,9 +5,11 @@ import View from "../view";
|
|
|
5
5
|
import JSONPlugin from "../../plugin/json";
|
|
6
6
|
|
|
7
7
|
export default class JSONView extends View {
|
|
8
|
-
Plugin = JSONPlugin;
|
|
8
|
+
static Plugin = JSONPlugin;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
static firaCode = true;
|
|
11
|
+
|
|
12
|
+
static initialContent = `{
|
|
11
13
|
"type": "book",
|
|
12
14
|
"title": "Look to Windward",
|
|
13
15
|
"author": "Look to Windward",
|
package/src/example/view/xml.js
CHANGED
|
@@ -5,9 +5,11 @@ import View from "../view";
|
|
|
5
5
|
import XMLPlugin from "../../plugin/xml";
|
|
6
6
|
|
|
7
7
|
export default class XMLView extends View {
|
|
8
|
-
Plugin = XMLPlugin;
|
|
8
|
+
static Plugin = XMLPlugin;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
static firaCode = false;
|
|
11
|
+
|
|
12
|
+
static initialContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
11
13
|
<!-- Look to Windward by Iain M. Banks -->
|
|
12
14
|
<book>
|
|
13
15
|
<name>
|
package/src/example/view.js
CHANGED
|
@@ -111,7 +111,8 @@ class View extends Element {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
childElements() {
|
|
114
|
-
const
|
|
114
|
+
const { Plugin, firaCode, initialContent } = this.constructor,
|
|
115
|
+
dragHandler = this.dragHandler.bind(this),
|
|
115
116
|
keyUpHandler = this.keyUpHandler.bind(this),
|
|
116
117
|
contentChangeHandler = this.contentChangeHandler.bind(this);
|
|
117
118
|
|
|
@@ -121,8 +122,8 @@ class View extends Element {
|
|
|
121
122
|
<LeftSizeableDiv>
|
|
122
123
|
<RowsDiv>
|
|
123
124
|
<TopSizeableDiv>
|
|
124
|
-
<Yapp Plugin={
|
|
125
|
-
{
|
|
125
|
+
<Yapp Plugin={Plugin} firaCode={firaCode} onContentChange={contentChangeHandler} >
|
|
126
|
+
{initialContent}
|
|
126
127
|
</Yapp>
|
|
127
128
|
</TopSizeableDiv>
|
|
128
129
|
<HorizontalSplitterDiv onDrag={dragHandler}/>
|
|
@@ -177,7 +178,8 @@ class View extends Element {
|
|
|
177
178
|
initialise() {
|
|
178
179
|
this.assignContext();
|
|
179
180
|
|
|
180
|
-
const {
|
|
181
|
+
const { Plugin } = this.constructor,
|
|
182
|
+
{ Lexer, Parser } = Plugin,
|
|
181
183
|
{ bnf } = Parser,
|
|
182
184
|
{ entries } = Lexer,
|
|
183
185
|
lexicalEntries = entries; ///
|
package/src/example/yapp.js
CHANGED
package/src/index.js
CHANGED
|
@@ -4,8 +4,10 @@ import Yapp from "./yapp";
|
|
|
4
4
|
|
|
5
5
|
export default Yapp;
|
|
6
6
|
|
|
7
|
+
export { default as YappLexer } from "./lexer/yapp";
|
|
8
|
+
export { default as YappParser } from "./parser/yapp";
|
|
7
9
|
export { default as syntaxStyle } from "./style/syntax";
|
|
8
|
-
export { default as firaCodeStyle } from "./style/firaCode";
|
|
9
10
|
export { default as colourScheme } from "./scheme/colour";
|
|
11
|
+
export { default as firaCodeStyle } from "./style/firaCode";
|
|
10
12
|
|
|
11
13
|
export { renderYappStyles } from "./renderYappStyles";
|
package/src/lexer/javascript.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import YappLexer from "../lexer/yapp";
|
|
4
4
|
|
|
5
5
|
const entries = [
|
|
6
6
|
{
|
|
@@ -26,14 +26,14 @@ const entries = [
|
|
|
26
26
|
}
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
export default class JavaScriptLexer extends
|
|
29
|
+
export default class JavaScriptLexer extends YappLexer {
|
|
30
30
|
static entries = entries;
|
|
31
31
|
|
|
32
32
|
static RegularExpressionToken = null;
|
|
33
33
|
|
|
34
|
-
static fromNothing() { return
|
|
34
|
+
static fromNothing() { return YappLexer.fromEntries(JavaScriptLexer, entries); }
|
|
35
35
|
|
|
36
|
-
static fromRules(rules) { return
|
|
36
|
+
static fromRules(rules) { return YappLexer.fromRules(JavaScriptLexer, rules); }
|
|
37
37
|
|
|
38
|
-
static fromEntries(entries) { return
|
|
38
|
+
static fromEntries(entries) { return YappLexer.fromEntries(JavaScriptLexer, entries); }
|
|
39
39
|
}
|
package/src/lexer/json.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import YappLexer from "../lexer/yapp";
|
|
4
4
|
|
|
5
5
|
const entries = [
|
|
6
6
|
{
|
|
@@ -17,7 +17,7 @@ const entries = [
|
|
|
17
17
|
}
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
-
export default class JSONLexer extends
|
|
20
|
+
export default class JSONLexer extends YappLexer {
|
|
21
21
|
static entries = entries;
|
|
22
22
|
|
|
23
23
|
static SingleLineCommentToken = null;
|
|
@@ -32,9 +32,9 @@ export default class JSONLexer extends CommonLexer {
|
|
|
32
32
|
|
|
33
33
|
static SinglyQuotedStringLiteralToken = null;
|
|
34
34
|
|
|
35
|
-
static fromNothing() { return
|
|
35
|
+
static fromNothing() { return YappLexer.fromEntries(JSONLexer, entries); }
|
|
36
36
|
|
|
37
|
-
static fromRules(rules) { return
|
|
37
|
+
static fromRules(rules) { return YappLexer.fromRules(JSONLexer, rules); }
|
|
38
38
|
|
|
39
|
-
static fromEntries(entries) { return
|
|
39
|
+
static fromEntries(entries) { return YappLexer.fromEntries(JSONLexer, entries); }
|
|
40
40
|
}
|
package/src/lexer/plainText.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import YappLexer from "../lexer/yapp";
|
|
4
4
|
|
|
5
5
|
const entries = [
|
|
6
6
|
{
|
|
@@ -8,7 +8,7 @@ const entries = [
|
|
|
8
8
|
}
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
-
export default class PlainTextLexer extends
|
|
11
|
+
export default class PlainTextLexer extends YappLexer {
|
|
12
12
|
matchMultiLineCommentInComment(content, inComment) { return null; }
|
|
13
13
|
|
|
14
14
|
matchMultiLineCommentNotInComment(content, inComment) { return null; }
|
|
@@ -33,9 +33,9 @@ export default class PlainTextLexer extends CommonLexer {
|
|
|
33
33
|
|
|
34
34
|
static DoublyQuotedStringLiteralToken = null;
|
|
35
35
|
|
|
36
|
-
static fromNothing() { return
|
|
36
|
+
static fromNothing() { return YappLexer.fromEntries(PlainTextLexer, entries); }
|
|
37
37
|
|
|
38
|
-
static fromRules(rules) { return
|
|
38
|
+
static fromRules(rules) { return YappLexer.fromRules(PlainTextLexer, rules); }
|
|
39
39
|
|
|
40
|
-
static fromEntries(entries) { return
|
|
40
|
+
static fromEntries(entries) { return YappLexer.fromEntries(PlainTextLexer, entries); }
|
|
41
41
|
}
|
package/src/lexer/xml.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import YappLexer from "../lexer/yapp";
|
|
4
4
|
|
|
5
5
|
const entries = [
|
|
6
6
|
{
|
|
@@ -14,7 +14,7 @@ const entries = [
|
|
|
14
14
|
}
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
export default class XMLLexer extends
|
|
17
|
+
export default class XMLLexer extends YappLexer {
|
|
18
18
|
static entries = entries;
|
|
19
19
|
|
|
20
20
|
static SingleLineCommentToken = null;
|
|
@@ -29,9 +29,9 @@ export default class XMLLexer extends CommonLexer {
|
|
|
29
29
|
|
|
30
30
|
static SinglyQuotedStringLiteralToken = null;
|
|
31
31
|
|
|
32
|
-
static fromNothing() { return
|
|
32
|
+
static fromNothing() { return YappLexer.fromEntries(XMLLexer, entries); }
|
|
33
33
|
|
|
34
|
-
static fromRules(rules) { return
|
|
34
|
+
static fromRules(rules) { return YappLexer.fromRules(XMLLexer, rules); }
|
|
35
35
|
|
|
36
|
-
static fromEntries(entries) { return
|
|
36
|
+
static fromEntries(entries) { return YappLexer.fromEntries(XMLLexer, entries); }
|
|
37
37
|
}
|
package/src/parser/javascript.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
5
|
-
import { BNFParser, CommonParser } from "occam-parsers";
|
|
6
|
-
|
|
7
|
-
import { startRuleFromRules, ruleMapFromRules } from "../utilities/rules";
|
|
8
|
-
|
|
9
|
-
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
-
bnfParser = BNFParser.fromNothing();
|
|
3
|
+
import YappParser from "../parser/yapp";
|
|
11
4
|
|
|
12
5
|
const bnf = `
|
|
13
6
|
|
|
@@ -283,26 +276,12 @@ const bnf = `
|
|
|
283
276
|
|
|
284
277
|
`;
|
|
285
278
|
|
|
286
|
-
export default class JavaScriptParser extends
|
|
279
|
+
export default class JavaScriptParser extends YappParser {
|
|
287
280
|
static bnf = bnf;
|
|
288
281
|
|
|
289
|
-
static fromNothing() {
|
|
290
|
-
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
291
|
-
rules = bnfParser.rulesFromTokens(tokens),
|
|
292
|
-
javascriptParser = JavaScriptParser.fromRules(rules);
|
|
293
|
-
|
|
294
|
-
return javascriptParser;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
static fromRules(rules) {
|
|
298
|
-
const ruleMap = ruleMapFromRules(rules);
|
|
299
|
-
|
|
300
|
-
let startRule = startRuleFromRules(rules);
|
|
301
|
-
|
|
302
|
-
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
282
|
+
static fromNothing() { return YappParser.fromNothing(JavaScriptParser); }
|
|
303
283
|
|
|
304
|
-
|
|
284
|
+
static fromBNF(bnf) { return YappParser.fromBNF(JavaScriptParser, bnf); }
|
|
305
285
|
|
|
306
|
-
|
|
307
|
-
}
|
|
286
|
+
static fromRules(rules) { return YappParser.fromRules(JavaScriptParser, rules); }
|
|
308
287
|
}
|
package/src/parser/json.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
5
|
-
import { BNFParser, CommonParser } from "occam-parsers";
|
|
6
|
-
|
|
7
|
-
import { ruleMapFromRules, startRuleFromRules } from "../utilities/rules";
|
|
8
|
-
|
|
9
|
-
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
-
bnfParser = BNFParser.fromNothing();
|
|
3
|
+
import YappParser from "../parser/yapp";
|
|
11
4
|
|
|
12
5
|
const bnf = `
|
|
13
6
|
|
|
@@ -30,26 +23,12 @@ const bnf = `
|
|
|
30
23
|
|
|
31
24
|
`;
|
|
32
25
|
|
|
33
|
-
export default class JSONParser extends
|
|
26
|
+
export default class JSONParser extends YappParser {
|
|
34
27
|
static bnf = bnf;
|
|
35
28
|
|
|
36
|
-
static fromNothing() {
|
|
37
|
-
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
38
|
-
rules = bnfParser.rulesFromTokens(tokens),
|
|
39
|
-
jsonParser = JSONParser.fromRules(rules);
|
|
40
|
-
|
|
41
|
-
return jsonParser;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static fromRules(rules) {
|
|
45
|
-
const ruleMap = ruleMapFromRules(rules);
|
|
46
|
-
|
|
47
|
-
let startRule = startRuleFromRules(rules);
|
|
48
|
-
|
|
49
|
-
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
29
|
+
static fromNothing() { return YappParser.fromNothing(JSONParser); }
|
|
50
30
|
|
|
51
|
-
|
|
31
|
+
static fromBNF(bnf) { return YappParser.fromBNF(JSONParser, bnf); }
|
|
52
32
|
|
|
53
|
-
|
|
54
|
-
}
|
|
33
|
+
static fromRules(rules) { return YappParser.fromRules(JSONParser, rules); }
|
|
55
34
|
}
|
package/src/parser/plainText.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
5
|
-
import { BNFParser, CommonParser } from "occam-parsers";
|
|
6
|
-
|
|
7
|
-
import { ruleMapFromRules, startRuleFromRules } from "../utilities/rules";
|
|
8
|
-
|
|
9
|
-
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
-
bnfParser = BNFParser.fromNothing();
|
|
3
|
+
import YappParser from "./yapp";
|
|
11
4
|
|
|
12
5
|
const bnf = `
|
|
13
6
|
|
|
@@ -15,26 +8,12 @@ const bnf = `
|
|
|
15
8
|
|
|
16
9
|
`;
|
|
17
10
|
|
|
18
|
-
export default class PlainTextParser extends
|
|
11
|
+
export default class PlainTextParser extends YappParser {
|
|
19
12
|
static bnf = bnf;
|
|
20
13
|
|
|
21
|
-
static fromNothing() {
|
|
22
|
-
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
23
|
-
rules = bnfParser.rulesFromTokens(tokens),
|
|
24
|
-
plainTextParser = PlainTextParser.fromRules(rules);
|
|
25
|
-
|
|
26
|
-
return plainTextParser;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static fromRules(rules) {
|
|
30
|
-
const ruleMap = ruleMapFromRules(rules);
|
|
31
|
-
|
|
32
|
-
let startRule = startRuleFromRules(rules);
|
|
33
|
-
|
|
34
|
-
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
14
|
+
static fromNothing() { return YappParser.fromNothing(PlainTextParser); }
|
|
35
15
|
|
|
36
|
-
|
|
16
|
+
static fromBNF(bnf) { return YappParser.fromBNF(PlainTextParser, bnf); }
|
|
37
17
|
|
|
38
|
-
|
|
39
|
-
}
|
|
18
|
+
static fromRules(rules) { return YappParser.fromRules(PlainTextParser, rules); }
|
|
40
19
|
}
|
package/src/parser/xml.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
5
|
-
import { BNFParser, CommonParser } from "occam-parsers";
|
|
6
|
-
|
|
7
|
-
import { ruleMapFromRules, startRuleFromRules } from "../utilities/rules";
|
|
8
|
-
|
|
9
|
-
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
-
bnfParser = BNFParser.fromNothing();
|
|
3
|
+
import YappParser from "./yapp";
|
|
11
4
|
|
|
12
5
|
const bnf = `
|
|
13
6
|
|
|
@@ -48,26 +41,12 @@ const bnf = `
|
|
|
48
41
|
|
|
49
42
|
`;
|
|
50
43
|
|
|
51
|
-
export default class XMLParser extends
|
|
44
|
+
export default class XMLParser extends YappParser {
|
|
52
45
|
static bnf = bnf;
|
|
53
46
|
|
|
54
|
-
static fromNothing() {
|
|
55
|
-
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
56
|
-
rules = bnfParser.rulesFromTokens(tokens),
|
|
57
|
-
xmlParser = XMLParser.fromRules(rules);
|
|
58
|
-
|
|
59
|
-
return xmlParser;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static fromRules(rules) {
|
|
63
|
-
const ruleMap = ruleMapFromRules(rules);
|
|
64
|
-
|
|
65
|
-
let startRule = startRuleFromRules(rules);
|
|
66
|
-
|
|
67
|
-
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
47
|
+
static fromNothing() { return YappParser.fromNothing(XMLParser); }
|
|
68
48
|
|
|
69
|
-
|
|
49
|
+
static fromBNF(bnf) { return YappParser.fromBNF(XMLParser, bnf); }
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
}
|
|
51
|
+
static fromRules(rules) { return YappParser.fromRules(XMLParser, rules); }
|
|
73
52
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { BNFLexer } from "occam-lexers";
|
|
4
|
+
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
5
|
+
import { BNFParser, CommonParser } from "occam-parsers";
|
|
6
|
+
|
|
7
|
+
import { startRuleFromRules, ruleMapFromRules } from "../utilities/rules";
|
|
8
|
+
|
|
9
|
+
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
+
bnfParser = BNFParser.fromNothing();
|
|
11
|
+
|
|
12
|
+
export default class YappParser extends CommonParser {
|
|
13
|
+
static fromNothing(Class) {
|
|
14
|
+
const { bnf } = Class,
|
|
15
|
+
rules = rulesFromBNF(bnf),
|
|
16
|
+
parser = parserFromRules(Class, rules);
|
|
17
|
+
|
|
18
|
+
return parser;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static fromBNF(Class, bnf) {
|
|
22
|
+
const rules = rulesFromBNF(bnf),
|
|
23
|
+
parser = parserFromRules(Class, rules);
|
|
24
|
+
|
|
25
|
+
return parser;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static fromRules(Class, rules) {
|
|
29
|
+
const parser = parserFromRules(Class, rules);
|
|
30
|
+
|
|
31
|
+
return parser;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function rulesFromBNF(bnf) {
|
|
36
|
+
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
37
|
+
rules = bnfParser.rulesFromTokens(tokens);
|
|
38
|
+
|
|
39
|
+
return rules;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function parserFromRules(Class, rules) {
|
|
43
|
+
const ruleMap = ruleMapFromRules(rules);
|
|
44
|
+
|
|
45
|
+
let startRule = startRuleFromRules(rules);
|
|
46
|
+
|
|
47
|
+
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
48
|
+
|
|
49
|
+
const parser = new Class(startRule, ruleMap);
|
|
50
|
+
|
|
51
|
+
return parser;
|
|
52
|
+
}
|