fix the warning
This commit is contained in:
parent
77e3850c81
commit
11e4740918
@ -1,87 +0,0 @@
|
|||||||
var Generator = require('jison').Generator
|
|
||||||
var options = {
|
|
||||||
type: 'slr',
|
|
||||||
moduleType: 'commonjs',
|
|
||||||
moduleName: 'spdxparse' }
|
|
||||||
|
|
||||||
var words = [ 'AND', 'OR', 'WITH' ]
|
|
||||||
|
|
||||||
var quote = function(argument) {
|
|
||||||
return '\'' + argument + '\'' }
|
|
||||||
|
|
||||||
var regexEscape = function(s) {
|
|
||||||
return s.replace(/[\^\\$*+?.()|{}\[\]\/]/g, '\\$&') }
|
|
||||||
|
|
||||||
var handleLicensesAndExceptions = function() {
|
|
||||||
var ids = require('spdx-license-ids')
|
|
||||||
var exceptions = require('spdx-exceptions')
|
|
||||||
|
|
||||||
// Sort tokens longest-first (both license ids and exception strings)
|
|
||||||
var tokens = ids.concat(exceptions)
|
|
||||||
tokens.sort(function(a, b) { return ( b.length - a.length ) })
|
|
||||||
return tokens.map(function(t) {
|
|
||||||
var type = ( (ids.indexOf(t) >= 0) ? 'LICENSE' : 'EXCEPTION' )
|
|
||||||
return [ regexEscape(t), ( 'return ' + quote(type) ) ] }) }
|
|
||||||
|
|
||||||
var grammar = {
|
|
||||||
lex: {
|
|
||||||
macros: { },
|
|
||||||
rules: [
|
|
||||||
[ '$', 'return ' + quote('EOS') ],
|
|
||||||
[ '\\s+', '/* skip whitespace */' ],
|
|
||||||
[ '\\+', 'return ' + quote('PLUS') ],
|
|
||||||
[ '\\(', 'return ' + quote('OPEN') ],
|
|
||||||
[ '\\)', 'return ' + quote('CLOSE') ],
|
|
||||||
[ ':', 'return ' + quote('COLON') ],
|
|
||||||
[ 'DocumentRef-([0-9A-Za-z-+.]+)',
|
|
||||||
'return ' + quote('DOCUMENTREF') ],
|
|
||||||
[ 'LicenseRef-([0-9A-Za-z-+.]+)',
|
|
||||||
'return ' + quote('LICENSEREF') ] ]
|
|
||||||
.concat(words.map(function(word) {
|
|
||||||
return [ word, 'return ' + quote(word) ] }))
|
|
||||||
.concat(handleLicensesAndExceptions()) },
|
|
||||||
operators: [
|
|
||||||
[ 'left', 'OR' ],
|
|
||||||
[ 'left', 'AND' ],
|
|
||||||
[ 'right', 'PLUS', 'WITH' ] ],
|
|
||||||
tokens: [
|
|
||||||
'CLOSE',
|
|
||||||
'COLON',
|
|
||||||
'EXCEPTION',
|
|
||||||
'LICENSE',
|
|
||||||
'LICENSEREF',
|
|
||||||
'OPEN',
|
|
||||||
'PLUS' ]
|
|
||||||
.concat(words)
|
|
||||||
.join(' '),
|
|
||||||
start: 'start',
|
|
||||||
bnf: {
|
|
||||||
start: [
|
|
||||||
[ 'expression EOS', 'return $$ = $1' ] ],
|
|
||||||
simpleExpression: [
|
|
||||||
[ 'LICENSE',
|
|
||||||
'$$ = { license: yytext }' ],
|
|
||||||
[ 'LICENSE PLUS',
|
|
||||||
'$$ = { license: $1, plus: true }' ],
|
|
||||||
[ 'LICENSEREF',
|
|
||||||
'$$ = { license: yytext }' ],
|
|
||||||
[ 'DOCUMENTREF COLON LICENSEREF',
|
|
||||||
'$$ = { license: yytext }' ] ],
|
|
||||||
expression: [
|
|
||||||
[ 'simpleExpression',
|
|
||||||
'$$ = $1' ],
|
|
||||||
[ 'simpleExpression WITH EXCEPTION',
|
|
||||||
[ '$$ = { exception: $3 }',
|
|
||||||
'$$.license = $1.license',
|
|
||||||
'if ($1.hasOwnProperty(\'plus\')) {',
|
|
||||||
' $$.plus = $1.plus',
|
|
||||||
'}' ]
|
|
||||||
.join('\n') ],
|
|
||||||
[ 'expression AND expression',
|
|
||||||
'$$ = { conjunction: \'and\', left: $1, right: $3 }' ],
|
|
||||||
[ 'expression OR expression',
|
|
||||||
'$$ = { conjunction: \'or\', left: $1, right: $3 }' ],
|
|
||||||
[ 'OPEN expression CLOSE',
|
|
||||||
'$$ = $2' ] ] } }
|
|
||||||
|
|
||||||
console.log(new Generator(grammar, options).generate())
|
|
||||||
@ -8,25 +8,21 @@ Summary: Parse SPDX license expressions
|
|||||||
License: MIT and CC-BY
|
License: MIT and CC-BY
|
||||||
URL: https://github.com/kemitchell/spdx-expression-parse.js.git
|
URL: https://github.com/kemitchell/spdx-expression-parse.js.git
|
||||||
Source0: https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-%{version}.tgz
|
Source0: https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-%{version}.tgz
|
||||||
Source1: https://raw.githubusercontent.com/kemitchell/spdx-expression-parse.js/v%{version}/generate-parser.js
|
|
||||||
ExclusiveArch: %{nodejs_arches} noarch
|
ExclusiveArch: %{nodejs_arches} noarch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRequires: nodejs-packaging uglify-js npm(jison) npm(spdx-license-ids)
|
BuildRequires: nodejs-packaging uglify-js npm(jison) npm(spdx-license-ids)
|
||||||
BuildRequires: npm(spdx-exceptions)
|
BuildRequires: npm(spdx-exceptions)
|
||||||
%if 0%{?enable_tests}
|
%if 0%{?enable_tests}
|
||||||
%endif
|
%endif
|
||||||
Requires: nodejs
|
Requires: nodejs
|
||||||
%description
|
%description
|
||||||
Parse SPDX license expressions
|
Parse SPDX license expressions
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n package
|
%setup -q -n package
|
||||||
cp -p %{SOURCE1} .
|
|
||||||
rm parser.generated.js
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%nodejs_symlink_deps --check
|
%nodejs_symlink_deps --check
|
||||||
%__nodejs generate-parser.js | %{_bindir}/uglifyjs > parser.generated.js
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename}
|
mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
version-control: github
|
version_control: github
|
||||||
src_repo: kemitchell/spdx-expression-parse.js
|
src_repo: kemitchell/spdx-expression-parse.js
|
||||||
tag_prefix: ^v
|
tag_prefix: ^v
|
||||||
seperator: .
|
seperator: .
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user