Skip to content

Commit 7baca89

Browse files
committed
Convert Jison configuration to JSON
1 parent 34a8b29 commit 7baca89

File tree

3 files changed

+79
-56
lines changed

3 files changed

+79
-56
lines changed

generate-parser.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"repository": "jslicense/spdx-expression-parse.js",
3434
"scripts": {
3535
"lint": "standard",
36-
"prepublish": "node generate-parser.js > parser.js",
36+
"prepublish": "jison -p slr -m commonjs -o parser.js parser.json",
3737
"pretest": "npm run prepublish",
3838
"test": "defence -i javascript README.md | replace-require-self | node"
3939
}

parser.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"operators": [
3+
[
4+
"left",
5+
"OR"
6+
],
7+
[
8+
"left",
9+
"AND"
10+
],
11+
[
12+
"right",
13+
"PLUS",
14+
"WITH"
15+
]
16+
],
17+
"tokens": [
18+
"CLOSE",
19+
"COLON",
20+
"EXCEPTION",
21+
"LICENSE",
22+
"LICENSEREF",
23+
"OPEN",
24+
"PLUS",
25+
"AND",
26+
"OR",
27+
"WITH"
28+
],
29+
"start": "start",
30+
"bnf": {
31+
"start": [
32+
[
33+
"expression EOS",
34+
"return $$ = $1"
35+
]
36+
],
37+
"simpleExpression": [
38+
[
39+
"LICENSE",
40+
"$$ = {license: yytext}"
41+
],
42+
[
43+
"LICENSE PLUS",
44+
"$$ = {license: $1, plus: true}"
45+
],
46+
[
47+
"LICENSEREF",
48+
"$$ = {license: yytext}"
49+
],
50+
[
51+
"DOCUMENTREF COLON LICENSEREF",
52+
"$$ = {license: yytext}"
53+
]
54+
],
55+
"expression": [
56+
[
57+
"simpleExpression",
58+
"$$ = $1"
59+
],
60+
[
61+
"simpleExpression WITH EXCEPTION",
62+
"$$ = {exception: $3}\n$$.license = $1.license\nif ($1.hasOwnProperty('plus')) {\n $$.plus = $1.plus\n}"
63+
],
64+
[
65+
"expression AND expression",
66+
"$$ = {conjunction: 'and', left: $1, right: $3}"
67+
],
68+
[
69+
"expression OR expression",
70+
"$$ = {conjunction: 'or', left: $1, right: $3}"
71+
],
72+
[
73+
"OPEN expression CLOSE",
74+
"$$ = $2"
75+
]
76+
]
77+
}
78+
}

0 commit comments

Comments
 (0)