inequality-grammar 1.3.6 → 1.3.7
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/LICENSE +200 -200
- package/README.md +38 -38
- package/dist/inequality-grammar.js +1 -1
- package/package.json +41 -41
- package/dist/src/index.d.ts +0 -9
- package/dist/src/parseBool.d.ts +0 -2
- package/dist/src/parseChem.d.ts +0 -2
- package/dist/src/parseInequalityChem.d.ts +0 -2
- package/dist/src/parseInequalityNuclear.d.ts +0 -2
- package/dist/src/parseMaths.d.ts +0 -2
- package/dist/src/parseNuclear.d.ts +0 -2
- package/dist/src/test/chemistry-lexer.test.d.ts +0 -1
- package/dist/src/test/chemistry-parser.test.d.ts +0 -1
- package/dist/src/test/nuclear-lexer.test.d.ts +0 -1
- package/dist/src/test/nuclear-parser.test.d.ts +0 -1
- package/dist/src/types.d.ts +0 -130
- package/dist/src/utils.d.ts +0 -28
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "inequality-grammar",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/inequality-grammar.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"dev": "webpack --watch --mode development",
|
|
11
|
-
"build": "webpack --mode production",
|
|
12
|
-
"test": "jest",
|
|
13
|
-
"prepublishOnly": "yarn && npm run build"
|
|
14
|
-
},
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/isaacphysics/inequality-grammar.git"
|
|
18
|
-
},
|
|
19
|
-
"author": "Andrea Franceschini <andrea.franceschini@gmail.com>",
|
|
20
|
-
"license": "Apache-2.0",
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "https://github.com/isaacphysics/inequality-grammar/issues"
|
|
23
|
-
},
|
|
24
|
-
"homepage": "https://github.com/isaacphysics/inequality-grammar#readme",
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@babel/core": "^7.23.9",
|
|
27
|
-
"@babel/preset-env": "^7.23.9",
|
|
28
|
-
"babel-jest": "^29.7.0",
|
|
29
|
-
"babel-loader": "^8.2.5",
|
|
30
|
-
"jest": "^29.7.0",
|
|
31
|
-
"nearley-loader": "^2.0.0",
|
|
32
|
-
"webpack": "^5.74.0",
|
|
33
|
-
"webpack-cli": "^4.10.0",
|
|
34
|
-
"jest-transform-nearley": "^2.0.0"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"lodash": "^4.17.21",
|
|
38
|
-
"moo": "^0.5.2",
|
|
39
|
-
"nearley": "^2.20.1"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "inequality-grammar",
|
|
3
|
+
"version": "1.3.7",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/inequality-grammar.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "webpack --watch --mode development",
|
|
11
|
+
"build": "webpack --mode production",
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"prepublishOnly": "yarn && npm run build"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/isaacphysics/inequality-grammar.git"
|
|
18
|
+
},
|
|
19
|
+
"author": "Andrea Franceschini <andrea.franceschini@gmail.com>",
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/isaacphysics/inequality-grammar/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/isaacphysics/inequality-grammar#readme",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/core": "^7.23.9",
|
|
27
|
+
"@babel/preset-env": "^7.23.9",
|
|
28
|
+
"babel-jest": "^29.7.0",
|
|
29
|
+
"babel-loader": "^8.2.5",
|
|
30
|
+
"jest": "^29.7.0",
|
|
31
|
+
"nearley-loader": "^2.0.0",
|
|
32
|
+
"webpack": "^5.74.0",
|
|
33
|
+
"webpack-cli": "^4.10.0",
|
|
34
|
+
"jest-transform-nearley": "^2.0.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"lodash": "^4.17.21",
|
|
38
|
+
"moo": "^0.5.2",
|
|
39
|
+
"nearley": "^2.20.1"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { parseMathsExpression } from './parseMaths';
|
|
2
|
-
export { parseBooleanExpression } from './parseBool';
|
|
3
|
-
export { parseChemistryExpression } from './parseChem';
|
|
4
|
-
export { parseNuclearExpression } from './parseNuclear';
|
|
5
|
-
export { parseInequalityChemistryExpression } from './parseInequalityChem';
|
|
6
|
-
export { parseInequalityNuclearExpression } from './parseInequalityNuclear';
|
|
7
|
-
export { ParsingError, InequalityWidget } from './types';
|
|
8
|
-
declare const parseExpression: typeof parseMathsExpression;
|
|
9
|
-
export { parseExpression, parseMathsExpression };
|
package/dist/src/parseBool.d.ts
DELETED
package/dist/src/parseChem.d.ts
DELETED
package/dist/src/parseMaths.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/src/types.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
declare const chemicalSymbol: string[];
|
|
2
|
-
type ChemicalSymbol = typeof chemicalSymbol[number];
|
|
3
|
-
export type ParticleString = 'alphaparticle' | 'betaparticle' | 'gammaray' | 'neutrino' | 'antineutrino' | 'electron' | 'positron' | 'neutron' | 'proton';
|
|
4
|
-
export type Type = 'error' | 'particle' | 'isotope' | 'term' | 'expr' | 'statement' | 'number' | 'ion' | 'compound' | 'bracket' | 'element';
|
|
5
|
-
export type Result = Statement | Expression | Term | ParseError | Ion | Compound | Bracket | Element | Isotope | Particle;
|
|
6
|
-
export type Fraction = {
|
|
7
|
-
numerator: number;
|
|
8
|
-
denominator: number;
|
|
9
|
-
};
|
|
10
|
-
export type InequalityWidget = {
|
|
11
|
-
type: string;
|
|
12
|
-
properties?: any;
|
|
13
|
-
children?: {
|
|
14
|
-
[key: string]: InequalityWidget;
|
|
15
|
-
};
|
|
16
|
-
position?: {
|
|
17
|
-
x: number;
|
|
18
|
-
y: number;
|
|
19
|
-
};
|
|
20
|
-
expression?: any;
|
|
21
|
-
};
|
|
22
|
-
export interface ASTNode extends InequalityWidget {
|
|
23
|
-
type: Type;
|
|
24
|
-
}
|
|
25
|
-
interface ParseError extends ASTNode {
|
|
26
|
-
type: 'error';
|
|
27
|
-
value: string;
|
|
28
|
-
loc: [number, number];
|
|
29
|
-
}
|
|
30
|
-
export declare function isParseError(node: InequalityWidget): node is ParseError;
|
|
31
|
-
export interface Particle extends ASTNode {
|
|
32
|
-
type: 'particle';
|
|
33
|
-
particle: ParticleString;
|
|
34
|
-
mass: number;
|
|
35
|
-
atomic: number;
|
|
36
|
-
}
|
|
37
|
-
export declare function isParticle(node: InequalityWidget): node is Particle;
|
|
38
|
-
export interface Isotope extends ASTNode {
|
|
39
|
-
type: 'isotope';
|
|
40
|
-
element: ChemicalSymbol;
|
|
41
|
-
mass: number;
|
|
42
|
-
atomic: number;
|
|
43
|
-
}
|
|
44
|
-
export declare function isIsotope(node: InequalityWidget): node is Isotope;
|
|
45
|
-
interface Term extends ASTNode {
|
|
46
|
-
type: 'term';
|
|
47
|
-
value: ASTNode;
|
|
48
|
-
coeff: number | Fraction;
|
|
49
|
-
}
|
|
50
|
-
export interface NuclearTerm extends Term {
|
|
51
|
-
value: Isotope | Particle;
|
|
52
|
-
coeff: number;
|
|
53
|
-
isParticle: boolean;
|
|
54
|
-
}
|
|
55
|
-
export declare function isNuclearTerm(node: InequalityWidget): node is NuclearTerm;
|
|
56
|
-
export interface Expression extends ASTNode {
|
|
57
|
-
type: 'expr';
|
|
58
|
-
term: Term;
|
|
59
|
-
rest: Expression | Term;
|
|
60
|
-
}
|
|
61
|
-
export declare function isExpression(node: InequalityWidget): node is Expression;
|
|
62
|
-
export interface Statement extends ASTNode {
|
|
63
|
-
type: 'statement';
|
|
64
|
-
left: Expression | Term;
|
|
65
|
-
right: Expression | Term;
|
|
66
|
-
arrow: 'SArr' | 'DArr';
|
|
67
|
-
}
|
|
68
|
-
export declare function isStatement(node: InequalityWidget): node is Statement;
|
|
69
|
-
export interface ChemistryTerm extends Term {
|
|
70
|
-
value: Ion | Compound | Element | Bracket;
|
|
71
|
-
coeff: Fraction;
|
|
72
|
-
isElectron: boolean;
|
|
73
|
-
isHydrate: boolean;
|
|
74
|
-
hydrate: number;
|
|
75
|
-
state: string;
|
|
76
|
-
}
|
|
77
|
-
export declare function isChemistryTerm(node: InequalityWidget): node is ChemistryTerm;
|
|
78
|
-
export interface Ion extends ASTNode {
|
|
79
|
-
type: 'ion';
|
|
80
|
-
molecule: Molecule;
|
|
81
|
-
charge: number;
|
|
82
|
-
chain?: Ion | Molecule;
|
|
83
|
-
}
|
|
84
|
-
export declare function isIon(node: InequalityWidget): node is Ion;
|
|
85
|
-
export interface Compound extends ASTNode {
|
|
86
|
-
type: 'compound';
|
|
87
|
-
head: Element | Bracket;
|
|
88
|
-
tail: Element | Bracket | Compound;
|
|
89
|
-
}
|
|
90
|
-
export declare function isCompound(node: InequalityWidget): node is Compound;
|
|
91
|
-
export interface Bracket extends ASTNode {
|
|
92
|
-
type: 'bracket';
|
|
93
|
-
bracket: 'round' | 'square';
|
|
94
|
-
compound: Compound;
|
|
95
|
-
coeff: number;
|
|
96
|
-
}
|
|
97
|
-
export declare function isBracket(node: InequalityWidget): node is Bracket;
|
|
98
|
-
export interface Element extends ASTNode {
|
|
99
|
-
type: 'element';
|
|
100
|
-
value: ChemicalSymbol;
|
|
101
|
-
coeff: number;
|
|
102
|
-
}
|
|
103
|
-
export declare function isElement(node: InequalityWidget): node is Element;
|
|
104
|
-
export type Molecule = Element | Compound;
|
|
105
|
-
export interface ChemistryAST {
|
|
106
|
-
result: Result;
|
|
107
|
-
}
|
|
108
|
-
export interface NuclearAST {
|
|
109
|
-
result: Result;
|
|
110
|
-
}
|
|
111
|
-
export type ParsingError = {
|
|
112
|
-
error: {
|
|
113
|
-
offset: number;
|
|
114
|
-
token: {
|
|
115
|
-
value: string;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
message: string;
|
|
119
|
-
stack: string;
|
|
120
|
-
};
|
|
121
|
-
export interface Token {
|
|
122
|
-
type: string;
|
|
123
|
-
value: string;
|
|
124
|
-
}
|
|
125
|
-
export interface ErrorToken extends Token {
|
|
126
|
-
type: string;
|
|
127
|
-
loc: [number, number];
|
|
128
|
-
}
|
|
129
|
-
export declare function isErrorToken(node: NuclearAST[] | ChemistryAST[] | ErrorToken): node is ErrorToken;
|
|
130
|
-
export {};
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { InequalityWidget } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Turns a chain of right-bound WidgetSpecs into an array.
|
|
4
|
-
*
|
|
5
|
-
* @param {InequalityWidget} node
|
|
6
|
-
* @returns {InequalityWidget[]}
|
|
7
|
-
*/
|
|
8
|
-
export declare const _rightChainToArray: (node: InequalityWidget) => InequalityWidget[];
|
|
9
|
-
/**
|
|
10
|
-
* Finds the last WidgetSpec going down the "right"-chain of children in an Inequality AST
|
|
11
|
-
* @param {InequalityWidget} node
|
|
12
|
-
* @returns {InequalityWidget}
|
|
13
|
-
*/
|
|
14
|
-
export declare const _findRightmost: (node: InequalityWidget) => InequalityWidget;
|
|
15
|
-
/**
|
|
16
|
-
* Checks if a node is just an empty set of brackets.
|
|
17
|
-
*
|
|
18
|
-
* @param {InequalityWidget} node
|
|
19
|
-
* @returns True if the node is an empty set of brackets.
|
|
20
|
-
*/
|
|
21
|
-
export declare const _safeToRemove: (node: InequalityWidget) => boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Attempts to simplify expressions where extra unnecessary brackets have been generated.
|
|
24
|
-
*
|
|
25
|
-
* @param {InequalityWidget} node - A subtree to simplify.
|
|
26
|
-
* @returns The simplified node.
|
|
27
|
-
*/
|
|
28
|
-
export declare const _simplify: (node: InequalityWidget) => InequalityWidget;
|