occam-lexers 23.1.82 → 23.2.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 +27 -12
- package/lib/bnf/entries.js +2 -2
- package/lib/specialSymbols.js +6 -1
- package/package.json +1 -1
- package/src/bnf/entries.js +1 -1
- package/src/specialSymbols.js +2 -0
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ Three lexers are documented:
|
|
|
19
19
|
* A basic lexer, for illustrative purposes.
|
|
20
20
|
* A common lexer, which can be extended.
|
|
21
21
|
|
|
22
|
-
All lexers share common functionality.
|
|
22
|
+
All lexers share common functionality.
|
|
23
|
+
Each tokenises the ends of lines first and then on the whole tokenises the remaining content in the following order:
|
|
23
24
|
|
|
24
25
|
1. Whitespace
|
|
25
26
|
2. Comments
|
|
@@ -29,21 +30,32 @@ All lexers share common functionality. Each tokenises the ends of lines first an
|
|
|
29
30
|
|
|
30
31
|
If any part of the content cannot be tokenised, an error is thrown.
|
|
31
32
|
|
|
32
|
-
The other significant tokens are defined by the lexical entries, each of which maps a significant token type to a regular expression.
|
|
33
|
+
The other significant tokens are defined by the lexical entries, each of which maps a significant token type to a regular expression.
|
|
34
|
+
On the other hand, the regular expressions and related functionality to match the first four types of otokens are hard-coded.
|
|
33
35
|
|
|
34
|
-
Comment and whitespace tokens are considered to be non-significant whilst the others are considered to be significant.
|
|
36
|
+
Comment and whitespace tokens are considered to be non-significant whilst the others are considered to be significant.
|
|
37
|
+
The exception to this rule is end of line tokens, which can be either.
|
|
38
|
+
Non-significant tokens are ignored by parsers although they separate significant tokens.
|
|
35
39
|
|
|
36
40
|
The lexical entries for the BNF lexer are the following:
|
|
37
41
|
|
|
38
42
|
[
|
|
39
|
-
|
|
40
|
-
{ "special": "^(?:::=|\\||\\(|\\)|\\?|\\!|\\*|\\+|\\.|ε|;|<NO_WHITESPACE>|<END_OF_LINE>)" },
|
|
41
|
-
|
|
42
|
-
{ "type": "^\\[[^\\]]+\\]" },
|
|
43
|
-
|
|
44
|
-
{ "name": "^[\\w|~]+" },
|
|
45
43
|
|
|
46
|
-
|
|
44
|
+
{
|
|
45
|
+
"special": "^(?:\\||\\(|\\)|\\?|\\*|\\+|\\.\\.\\.|\\.\\.|\\.|::=|;|`|ε|<START_OF_CONTENT>|<NO_WHITESPACE>|<END_OF_LINE>)"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"number": "^(?:0|[1-9][0-9]*)"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "^[\\w~]+"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "^\\[[^\\]]+\\]"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"unassigned": "^[^\\s]+"
|
|
58
|
+
}
|
|
47
59
|
|
|
48
60
|
]
|
|
49
61
|
|
|
@@ -73,13 +85,16 @@ The examples will then be available at the following URL:
|
|
|
73
85
|
|
|
74
86
|
http://localhost:8888
|
|
75
87
|
|
|
76
|
-
The source for the examples can be found in the `src/example.js` file and corresponding `src/example` folder.
|
|
88
|
+
The source for the examples can be found in the `src/example.js` file and corresponding `src/example` folder.
|
|
89
|
+
You are encouraged to try the examples whilst reading what follows.
|
|
90
|
+
You can rebuild them on the fly with the following command:
|
|
77
91
|
|
|
78
92
|
npm run watch-debug
|
|
79
93
|
|
|
80
94
|
The development server will reload the page whenever you make changes.
|
|
81
95
|
|
|
82
|
-
One last thing to bear in mind is that this package is included by way of a relative rather than a package import.
|
|
96
|
+
One last thing to bear in mind is that this package is included by way of a relative rather than a package import.
|
|
97
|
+
If you are importing it into your own application, however, then you should use the standard package import.
|
|
83
98
|
|
|
84
99
|
## Usage
|
|
85
100
|
|
package/lib/bnf/entries.js
CHANGED
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
});
|
|
11
11
|
const entries = [
|
|
12
12
|
{
|
|
13
|
-
"special": "^(?:\\||\\(|\\)
|
|
13
|
+
"special": "^(?:\\||\\(|\\)|\\?|\\*|\\+|\\.\\.\\.|\\.\\.|\\.|::=|;|`|ε|<START_OF_CONTENT>|<NO_WHITESPACE>|<END_OF_LINE>)"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"number": "^(?:0|[1-9][0-9]*)"
|
|
@@ -27,4 +27,4 @@ const entries = [
|
|
|
27
27
|
];
|
|
28
28
|
const _default = entries;
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ibmYvZW50cmllcy5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcclxuXHJcbmNvbnN0IGVudHJpZXMgPSBbXHJcbiAge1xyXG4gICAgXCJzcGVjaWFsXCI6IFwiXig/OlxcXFx8fFxcXFwofFxcXFwpfFxcXFw/
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ibmYvZW50cmllcy5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcclxuXHJcbmNvbnN0IGVudHJpZXMgPSBbXHJcbiAge1xyXG4gICAgXCJzcGVjaWFsXCI6IFwiXig/OlxcXFx8fFxcXFwofFxcXFwpfFxcXFw/fFxcXFwqfFxcXFwrfFxcXFwuXFxcXC5cXFxcLnxcXFxcLlxcXFwufFxcXFwufDo6PXw7fGB8zrV8PFNUQVJUX09GX0NPTlRFTlQ+fDxOT19XSElURVNQQUNFPnw8RU5EX09GX0xJTkU+KVwiXHJcbiAgfSxcclxuICB7XHJcbiAgICBcIm51bWJlclwiOiBcIl4oPzowfFsxLTldWzAtOV0qKVwiXHJcbiAgfSxcclxuICB7XHJcbiAgICBcIm5hbWVcIjogXCJeW1xcXFx3fl0rXCJcclxuICB9LFxyXG4gIHtcclxuICAgIFwidHlwZVwiOiBcIl5cXFxcW1teXFxcXF1dK1xcXFxdXCJcclxuICB9LFxyXG4gIHtcclxuICAgIFwidW5hc3NpZ25lZFwiOiBcIl5bXlxcXFxzXStcIlxyXG4gIH1cclxuXTtcclxuXHJcbmV4cG9ydCBkZWZhdWx0IGVudHJpZXM7XHJcbiJdLCJuYW1lcyI6WyJlbnRyaWVzIl0sIm1hcHBpbmdzIjoiQUFBQTs7OzsrQkFvQkE7OztlQUFBOzs7QUFsQkEsTUFBTUEsVUFBVTtJQUNkO1FBQ0UsV0FBVztJQUNiO0lBQ0E7UUFDRSxVQUFVO0lBQ1o7SUFDQTtRQUNFLFFBQVE7SUFDVjtJQUNBO1FBQ0UsUUFBUTtJQUNWO0lBQ0E7UUFDRSxjQUFjO0lBQ2hCO0NBQ0Q7TUFFRCxXQUFlQSJ9
|
package/lib/specialSymbols.js
CHANGED
|
@@ -12,6 +12,9 @@ _export(exports, {
|
|
|
12
12
|
get asterisk () {
|
|
13
13
|
return asterisk;
|
|
14
14
|
},
|
|
15
|
+
get backtick () {
|
|
16
|
+
return backtick;
|
|
17
|
+
},
|
|
15
18
|
get closeBracket () {
|
|
16
19
|
return closeBracket;
|
|
17
20
|
},
|
|
@@ -61,6 +64,7 @@ _export(exports, {
|
|
|
61
64
|
const plus = "+";
|
|
62
65
|
const opaque = ".";
|
|
63
66
|
const epsilon = 'ε';
|
|
67
|
+
const backtick = "`";
|
|
64
68
|
const wildcard = ".";
|
|
65
69
|
const asterisk = "*";
|
|
66
70
|
const ellipsis = "...";
|
|
@@ -77,6 +81,7 @@ const _default = {
|
|
|
77
81
|
plus,
|
|
78
82
|
opaque,
|
|
79
83
|
epsilon,
|
|
84
|
+
backtick,
|
|
80
85
|
wildcard,
|
|
81
86
|
asterisk,
|
|
82
87
|
ellipsis,
|
|
@@ -91,4 +96,4 @@ const _default = {
|
|
|
91
96
|
noWhitespace
|
|
92
97
|
};
|
|
93
98
|
|
|
94
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
99
|
+
//#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QUNuQixNQUFNRSxhQUFhO0FBQ25CLE1BQU1DLGNBQWM7QUFDcEIsTUFBTU4sY0FBYztBQUNwQixNQUFNTixlQUFlO0FBQ3JCLE1BQU1RLGVBQWU7QUFDckIsTUFBTU4sWUFBWTtBQUNsQixNQUFNRSxlQUFlO01BRTVCLFdBQWU7SUFDYkc7SUFDQUY7SUFDQUY7SUFDQUo7SUFDQWM7SUFDQWY7SUFDQUc7SUFDQVM7SUFDQUQ7SUFDQUU7SUFDQUM7SUFDQU47SUFDQU47SUFDQVE7SUFDQU47SUFDQUU7QUFDRiJ9
|
package/package.json
CHANGED
package/src/bnf/entries.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const entries = [
|
|
4
4
|
{
|
|
5
|
-
"special": "^(?:\\||\\(|\\)
|
|
5
|
+
"special": "^(?:\\||\\(|\\)|\\?|\\*|\\+|\\.\\.\\.|\\.\\.|\\.|::=|;|`|ε|<START_OF_CONTENT>|<NO_WHITESPACE>|<END_OF_LINE>)"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
8
|
"number": "^(?:0|[1-9][0-9]*)"
|
package/src/specialSymbols.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const plus = "+";
|
|
4
4
|
export const opaque = ".";
|
|
5
5
|
export const epsilon = 'ε';
|
|
6
|
+
export const backtick = "`";
|
|
6
7
|
export const wildcard = ".";
|
|
7
8
|
export const asterisk = "*";
|
|
8
9
|
export const ellipsis = "...";
|
|
@@ -20,6 +21,7 @@ export default {
|
|
|
20
21
|
plus,
|
|
21
22
|
opaque,
|
|
22
23
|
epsilon,
|
|
24
|
+
backtick,
|
|
23
25
|
wildcard,
|
|
24
26
|
asterisk,
|
|
25
27
|
ellipsis,
|