yapp 2.2.47 → 2.2.52
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.html +1 -2
- package/example.js +858 -650
- package/index.html +1 -2
- 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 +11 -13
- package/lib/example/yapp.js +1 -2
- package/lib/index.js +20 -6
- package/lib/lexer/javascript.js +22 -11
- package/lib/lexer/json.js +22 -11
- package/lib/lexer/plainText.js +22 -11
- package/lib/lexer/xml.js +22 -11
- 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 +126 -0
- package/lib/utilities/parser.js +24 -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 +8 -8
- package/src/example/yapp.js +0 -1
- package/src/index.js +3 -1
- package/src/lexer/javascript.js +6 -4
- package/src/lexer/json.js +6 -4
- package/src/lexer/plainText.js +6 -4
- package/src/lexer/xml.js +6 -4
- 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 +28 -0
- package/src/utilities/parser.js +29 -0
- package/lib/example/div/columns.js +0 -35
- package/lib/example/div/splitter/horizontal.js +0 -35
- package/lib/example/div/splitter/vertical.js +0 -35
- package/src/example/div/columns.js +0 -11
- package/src/example/div/splitter/horizontal.js +0 -12
- package/src/example/div/splitter/vertical.js +0 -12
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _occamParsers = require("occam-parsers");
|
|
7
|
+
var _parser = require("../utilities/parser");
|
|
8
|
+
function _assertThisInitialized(self) {
|
|
9
|
+
if (self === void 0) {
|
|
10
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
11
|
+
}
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
function _classCallCheck(instance, Constructor) {
|
|
15
|
+
if (!(instance instanceof Constructor)) {
|
|
16
|
+
throw new TypeError("Cannot call a class as a function");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function _defineProperties(target, props) {
|
|
20
|
+
for(var i = 0; i < props.length; i++){
|
|
21
|
+
var descriptor = props[i];
|
|
22
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
23
|
+
descriptor.configurable = true;
|
|
24
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
29
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
30
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
31
|
+
return Constructor;
|
|
32
|
+
}
|
|
33
|
+
function _getPrototypeOf(o) {
|
|
34
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
35
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
36
|
+
};
|
|
37
|
+
return _getPrototypeOf(o);
|
|
38
|
+
}
|
|
39
|
+
function _inherits(subClass, superClass) {
|
|
40
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
41
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
42
|
+
}
|
|
43
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
44
|
+
constructor: {
|
|
45
|
+
value: subClass,
|
|
46
|
+
writable: true,
|
|
47
|
+
configurable: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
51
|
+
}
|
|
52
|
+
function _possibleConstructorReturn(self, call) {
|
|
53
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
54
|
+
return call;
|
|
55
|
+
}
|
|
56
|
+
return _assertThisInitialized(self);
|
|
57
|
+
}
|
|
58
|
+
function _setPrototypeOf(o, p) {
|
|
59
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
60
|
+
o.__proto__ = p;
|
|
61
|
+
return o;
|
|
62
|
+
};
|
|
63
|
+
return _setPrototypeOf(o, p);
|
|
64
|
+
}
|
|
65
|
+
var _typeof = function(obj) {
|
|
66
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
67
|
+
};
|
|
68
|
+
function _isNativeReflectConstruct() {
|
|
69
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
70
|
+
if (Reflect.construct.sham) return false;
|
|
71
|
+
if (typeof Proxy === "function") return true;
|
|
72
|
+
try {
|
|
73
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
74
|
+
return true;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function _createSuper(Derived) {
|
|
80
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
81
|
+
return function _createSuperInternal() {
|
|
82
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
83
|
+
if (hasNativeReflectConstruct) {
|
|
84
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
85
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
86
|
+
} else {
|
|
87
|
+
result = Super.apply(this, arguments);
|
|
88
|
+
}
|
|
89
|
+
return _possibleConstructorReturn(this, result);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var YappParser = /*#__PURE__*/ function(CommonParser) {
|
|
93
|
+
_inherits(YappParser, CommonParser);
|
|
94
|
+
var _super = _createSuper(YappParser);
|
|
95
|
+
function YappParser() {
|
|
96
|
+
_classCallCheck(this, YappParser);
|
|
97
|
+
return _super.apply(this, arguments);
|
|
98
|
+
}
|
|
99
|
+
_createClass(YappParser, null, [
|
|
100
|
+
{
|
|
101
|
+
key: "fromNothing",
|
|
102
|
+
value: function fromNothing(Class) {
|
|
103
|
+
var bnf = Class.bnf, rules = (0, _parser).rulesFromBNF(bnf), parser = (0, _parser).parserFromRules(Class, rules);
|
|
104
|
+
return parser;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: "fromBNF",
|
|
109
|
+
value: function fromBNF(Class, bnf) {
|
|
110
|
+
var rules = (0, _parser).rulesFromBNF(bnf), parser = (0, _parser).parserFromRules(Class, rules);
|
|
111
|
+
return parser;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
key: "fromRules",
|
|
116
|
+
value: function fromRules(Class, rules) {
|
|
117
|
+
var parser = (0, _parser).parserFromRules(Class, rules);
|
|
118
|
+
return parser;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
]);
|
|
122
|
+
return YappParser;
|
|
123
|
+
}(_occamParsers.CommonParser);
|
|
124
|
+
exports.default = YappParser;
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXJzZXIveWFwcC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcblxuaW1wb3J0IHsgQ29tbW9uUGFyc2VyIH0gZnJvbSBcIm9jY2FtLXBhcnNlcnNcIjtcblxuaW1wb3J0IHsgcnVsZXNGcm9tQk5GLCBwYXJzZXJGcm9tUnVsZXMgfSBmcm9tIFwiLi4vdXRpbGl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
+
});
|
|
5
|
+
exports.rulesFromBNF = rulesFromBNF;
|
|
6
|
+
exports.parserFromRules = parserFromRules;
|
|
7
|
+
var _occamLexers = require("occam-lexers");
|
|
8
|
+
var _occamParsers = require("occam-parsers");
|
|
9
|
+
var _occamGrammarUtilities = require("occam-grammar-utilities");
|
|
10
|
+
var _rules = require("../utilities/rules");
|
|
11
|
+
var bnfLexer = _occamLexers.BNFLexer.fromNothing(), bnfParser = _occamParsers.BNFParser.fromNothing();
|
|
12
|
+
function rulesFromBNF(bnf) {
|
|
13
|
+
var tokens = bnfLexer.tokensFromBNF(bnf), rules = bnfParser.rulesFromTokens(tokens);
|
|
14
|
+
return rules;
|
|
15
|
+
}
|
|
16
|
+
function parserFromRules(Class, rules) {
|
|
17
|
+
var ruleMap = (0, _rules).ruleMapFromRules(rules);
|
|
18
|
+
var startRule = (0, _rules).startRuleFromRules(rules);
|
|
19
|
+
startRule = (0, _occamGrammarUtilities).eliminateLeftRecursion(startRule, ruleMap);
|
|
20
|
+
var parser = new Class(startRule, ruleMap);
|
|
21
|
+
return parser;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGFyc2VyLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIlwidXNlIHN0cmljdFwiO1xuXG5pbXBvcnQgeyBCTkZMZXhlciB9IGZyb20gXCJvY2NhbS1sZXhlcnNcIjtcbmltcG9ydCB7IEJORlBhcnNlciB9IGZyb20gXCJvY2NhbS1wYXJzZXJzXCI7XG5pbXBvcnQgeyBlbGltaW5hdGVMZWZ0UmVjdXJzaW9uIH0gZnJvbSBcIm9jY2FtLWdyYW1tYXItdXRpbGl0aWVzXCI7XG5cbmltcG9ydCB7IHJ1bGVNYXBGcm9tUnVsZXMsIHN0YXJ0UnVsZUZyb21SdWxlcyB9IGZyb20gXCIuLi91dGl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BZCxZQUFjO0FBQ2IsR0FBZSxDQUFmLGFBQWU7QUFDRixHQUF5QixDQUF6QixzQkFBeUI7QUFFWCxHQUFvQixDQUFwQixNQUFvQjtBQUV6RSxHQUFLLENBQUNDLFFBQVEsR0FOVyxZQUFjLFVBTWJDLFdBQVcsSUFDL0JDLFNBQVMsR0FOVyxhQUFlLFdBTWJELFdBQVc7U0FFdkJILFlBQVksQ0FBQ0ssR0FBRyxFQUFFLENBQUM7SUFDakMsR0FBSyxDQUFDQyxNQUFNLEdBQUdKLFFBQVEsQ0FBQ0ssYUFBYSxDQUFDRixHQUFHLEdBQ25DRyxLQUFLLEdBQUdKLFNBQVMsQ0FBQ0ssZUFBZSxDQUFDSCxNQUFNO0lBRTlDLE1BQU0sQ0FBQ0UsS0FBSztBQUNkLENBQUM7U0FFZVAsZUFBZSxDQUFDUyxLQUFLLEVBQUVGLEtBQUssRUFBRSxDQUFDO0lBQzdDLEdBQUssQ0FBQ0csT0FBTyxPQWJzQyxNQUFvQixtQkFhdENILEtBQUs7SUFFdEMsR0FBRyxDQUFDSSxTQUFTLE9BZnNDLE1BQW9CLHFCQWVwQ0osS0FBSztJQUV4Q0ksU0FBUyxPQW5CNEIsc0JBQXlCLHlCQW1CM0JBLFNBQVMsRUFBRUQsT0FBTztJQUVyRCxHQUFLLENBQUNFLE1BQU0sR0FBRyxHQUFHLENBQUNILEtBQUssQ0FBQ0UsU0FBUyxFQUFFRCxPQUFPO0lBRTNDLE1BQU0sQ0FBQ0UsTUFBTTtBQUNmLENBQUMifQ==
|
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.52",
|
|
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.
|
|
20
|
+
"occam-parsers": "^14.1.1"
|
|
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
|
@@ -5,12 +5,11 @@ import withStyle from "easy-with-style"; ///
|
|
|
5
5
|
import { Element } from "easy";
|
|
6
6
|
import { BNFLexer } from "occam-lexers";
|
|
7
7
|
import { BNFParser } from "occam-parsers";
|
|
8
|
-
import { RowDiv, RowsDiv, ColumnDiv } from "easy-layout";
|
|
9
8
|
import { eliminateLeftRecursion, removeOrRenameIntermediateNodes } from "occam-grammar-utilities";
|
|
9
|
+
import { RowDiv, RowsDiv, ColumnDiv, ColumnsDiv, VerticalSplitterDiv, HorizontalSplitterDiv } from "easy-layout";
|
|
10
10
|
|
|
11
11
|
import Yapp from "./yapp";
|
|
12
12
|
import SubHeading from "./subHeading";
|
|
13
|
-
import ColumnsDiv from "./div/columns";
|
|
14
13
|
import BNFTextarea from "./textarea/bnf";
|
|
15
14
|
import TokensTextarea from "./textarea/tokens";
|
|
16
15
|
import TopSizeableDiv from "./div/sizeable/top";
|
|
@@ -18,8 +17,6 @@ import LeftSizeableDiv from "./div/sizeable/left";
|
|
|
18
17
|
import RightSizeableDiv from "./div/sizeable/right";
|
|
19
18
|
import MiddleSizeableDiv from "./div/sizeable/middle";
|
|
20
19
|
import ParseTreeTextarea from "./textarea/parseTree";
|
|
21
|
-
import VerticalSplitterDiv from "./div/splitter/vertical";
|
|
22
|
-
import HorizontalSplitterDiv from "./div/splitter/horizontal";
|
|
23
20
|
import LexicalEntriesTextarea from "./textarea/lexicalEntries";
|
|
24
21
|
|
|
25
22
|
import { ruleMapFromRules, startRuleFromRules } from "../utilities/rules";
|
|
@@ -114,7 +111,8 @@ class View extends Element {
|
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
childElements() {
|
|
117
|
-
const
|
|
114
|
+
const { Plugin, firaCode, initialContent } = this.constructor,
|
|
115
|
+
dragHandler = this.dragHandler.bind(this),
|
|
118
116
|
keyUpHandler = this.keyUpHandler.bind(this),
|
|
119
117
|
contentChangeHandler = this.contentChangeHandler.bind(this);
|
|
120
118
|
|
|
@@ -124,8 +122,8 @@ class View extends Element {
|
|
|
124
122
|
<LeftSizeableDiv>
|
|
125
123
|
<RowsDiv>
|
|
126
124
|
<TopSizeableDiv>
|
|
127
|
-
<Yapp Plugin={
|
|
128
|
-
{
|
|
125
|
+
<Yapp Plugin={Plugin} firaCode={firaCode} onContentChange={contentChangeHandler} >
|
|
126
|
+
{initialContent}
|
|
129
127
|
</Yapp>
|
|
130
128
|
</TopSizeableDiv>
|
|
131
129
|
<HorizontalSplitterDiv onDrag={dragHandler}/>
|
|
@@ -180,7 +178,8 @@ class View extends Element {
|
|
|
180
178
|
initialise() {
|
|
181
179
|
this.assignContext();
|
|
182
180
|
|
|
183
|
-
const {
|
|
181
|
+
const { Plugin } = this.constructor,
|
|
182
|
+
{ Lexer, Parser } = Plugin,
|
|
184
183
|
{ bnf } = Parser,
|
|
185
184
|
{ entries } = Lexer,
|
|
186
185
|
lexicalEntries = entries; ///
|
|
@@ -202,5 +201,6 @@ export default withStyle(View)`
|
|
|
202
201
|
width: 100%;
|
|
203
202
|
height: 100vh;
|
|
204
203
|
display: flex;
|
|
204
|
+
padding: 1rem;
|
|
205
205
|
|
|
206
206
|
`;
|
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,12 +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
|
|
34
|
+
static fromNothing() { return YappLexer.fromEntries(JavaScriptLexer, entries); }
|
|
35
35
|
|
|
36
|
-
static
|
|
36
|
+
static fromRules(rules) { return YappLexer.fromRules(JavaScriptLexer, rules); }
|
|
37
|
+
|
|
38
|
+
static fromEntries(entries) { return YappLexer.fromEntries(JavaScriptLexer, entries); }
|
|
37
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,7 +32,9 @@ export default class JSONLexer extends CommonLexer {
|
|
|
32
32
|
|
|
33
33
|
static SinglyQuotedStringLiteralToken = null;
|
|
34
34
|
|
|
35
|
-
static
|
|
35
|
+
static fromNothing() { return YappLexer.fromEntries(JSONLexer, entries); }
|
|
36
36
|
|
|
37
|
-
static
|
|
37
|
+
static fromRules(rules) { return YappLexer.fromRules(JSONLexer, rules); }
|
|
38
|
+
|
|
39
|
+
static fromEntries(entries) { return YappLexer.fromEntries(JSONLexer, entries); }
|
|
38
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,7 +33,9 @@ export default class PlainTextLexer extends CommonLexer {
|
|
|
33
33
|
|
|
34
34
|
static DoublyQuotedStringLiteralToken = null;
|
|
35
35
|
|
|
36
|
-
static
|
|
36
|
+
static fromNothing() { return YappLexer.fromEntries(PlainTextLexer, entries); }
|
|
37
37
|
|
|
38
|
-
static
|
|
38
|
+
static fromRules(rules) { return YappLexer.fromRules(PlainTextLexer, rules); }
|
|
39
|
+
|
|
40
|
+
static fromEntries(entries) { return YappLexer.fromEntries(PlainTextLexer, entries); }
|
|
39
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,7 +29,9 @@ export default class XMLLexer extends CommonLexer {
|
|
|
29
29
|
|
|
30
30
|
static SinglyQuotedStringLiteralToken = null;
|
|
31
31
|
|
|
32
|
-
static
|
|
32
|
+
static fromNothing() { return YappLexer.fromEntries(XMLLexer, entries); }
|
|
33
33
|
|
|
34
|
-
static
|
|
34
|
+
static fromRules(rules) { return YappLexer.fromRules(XMLLexer, rules); }
|
|
35
|
+
|
|
36
|
+
static fromEntries(entries) { return YappLexer.fromEntries(XMLLexer, entries); }
|
|
35
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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CommonParser } from "occam-parsers";
|
|
4
|
+
|
|
5
|
+
import { rulesFromBNF, parserFromRules } from "../utilities/parser";
|
|
6
|
+
|
|
7
|
+
export default class YappParser extends CommonParser {
|
|
8
|
+
static fromNothing(Class) {
|
|
9
|
+
const { bnf } = Class,
|
|
10
|
+
rules = rulesFromBNF(bnf),
|
|
11
|
+
parser = parserFromRules(Class, rules);
|
|
12
|
+
|
|
13
|
+
return parser;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static fromBNF(Class, bnf) {
|
|
17
|
+
const rules = rulesFromBNF(bnf),
|
|
18
|
+
parser = parserFromRules(Class, rules);
|
|
19
|
+
|
|
20
|
+
return parser;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static fromRules(Class, rules) {
|
|
24
|
+
const parser = parserFromRules(Class, rules);
|
|
25
|
+
|
|
26
|
+
return parser;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { BNFLexer } from "occam-lexers";
|
|
4
|
+
import { BNFParser } from "occam-parsers";
|
|
5
|
+
import { eliminateLeftRecursion } from "occam-grammar-utilities";
|
|
6
|
+
|
|
7
|
+
import { ruleMapFromRules, startRuleFromRules } from "../utilities/rules";
|
|
8
|
+
|
|
9
|
+
const bnfLexer = BNFLexer.fromNothing(),
|
|
10
|
+
bnfParser = BNFParser.fromNothing();
|
|
11
|
+
|
|
12
|
+
export function rulesFromBNF(bnf) {
|
|
13
|
+
const tokens = bnfLexer.tokensFromBNF(bnf),
|
|
14
|
+
rules = bnfParser.rulesFromTokens(tokens);
|
|
15
|
+
|
|
16
|
+
return rules;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function parserFromRules(Class, rules) {
|
|
20
|
+
const ruleMap = ruleMapFromRules(rules);
|
|
21
|
+
|
|
22
|
+
let startRule = startRuleFromRules(rules);
|
|
23
|
+
|
|
24
|
+
startRule = eliminateLeftRecursion(startRule, ruleMap);
|
|
25
|
+
|
|
26
|
+
const parser = new Class(startRule, ruleMap);
|
|
27
|
+
|
|
28
|
+
return parser;
|
|
29
|
+
}
|