Create grunt task to generate parsers from peg files (#17069)

* Create grunt task to generate parsers from peg files

* Leave comment

* Move grunt config to config/
This commit is contained in:
Lukas Olson 2018-03-21 16:42:23 -07:00
parent eb9de427eb
commit 12246483d6
8 changed files with 163 additions and 15 deletions

View file

@ -248,8 +248,10 @@
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-copy": "0.8.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-esvm": "3.2.12",
"grunt-karma": "2.0.0",
"grunt-peg": "^2.0.1",
"grunt-run": "0.7.0",
"grunt-simple-mocha": "0.4.0",
"gulp-sourcemaps": "1.7.3",

View file

@ -1430,4 +1430,4 @@ module.exports = (function() {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
})();
})();

View file

@ -1,3 +1,8 @@
/**
* To generate the parsing module (kuery.js), run `grunt peg`
* To watch changes and generate on file change, run `grunt watch:peg`
*/
// Initialization block
{
const { nodeTypes } = options.helpers;

View file

@ -1546,4 +1546,4 @@ module.exports = (function() {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
})();
})();

View file

@ -1,5 +1,8 @@
/*
* Kuery parser
*
* To generate the parsing module (legacy_kuery.js), run `grunt peg`
* To watch changes and generate on file change, run `grunt watch:peg`
*/
/*

13
tasks/config/peg.js Normal file
View file

@ -0,0 +1,13 @@
module.exports = {
legacyKuery: {
src: 'src/ui/public/kuery/ast/legacy_kuery.peg',
dest: 'src/ui/public/kuery/ast/legacy_kuery.js'
},
kuery: {
src: 'src/ui/public/kuery/ast/kuery.peg',
dest: 'src/ui/public/kuery/ast/kuery.js',
options: {
allowedStartRules: ['start', 'Literal']
}
}
};

6
tasks/config/watch.js Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
peg: {
files: ['src/ui/public/kuery/ast/*.peg'],
tasks: ['peg']
}
};

145
yarn.lock
View file

@ -585,7 +585,7 @@ async@0.9.x:
version "0.9.2"
resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
async@1.x, async@^1.4.0, async@^1.4.2, async@^1.5.2, async@~1.5.2:
async@1.x, async@^1.4.0, async@^1.4.2, async@^1.5.0, async@^1.5.2, async@~1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
@ -1509,6 +1509,21 @@ body-parser@^1.16.1:
raw-body "2.3.2"
type-is "~1.6.15"
body-parser@~1.14.0:
version "1.14.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.14.2.tgz#1015cb1fe2c443858259581db53332f8d0cf50f9"
dependencies:
bytes "2.2.0"
content-type "~1.0.1"
debug "~2.2.0"
depd "~1.1.0"
http-errors "~1.3.1"
iconv-lite "0.4.13"
on-finished "~2.3.0"
qs "5.2.0"
raw-body "~2.1.5"
type-is "~1.6.10"
boolbase@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
@ -1730,6 +1745,14 @@ bytes@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-1.0.0.tgz#3569ede8ba34315fab99c3e92cb04c7220de1fa8"
bytes@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.2.0.tgz#fd35464a403f6f9117c2de3609ecff9cae000588"
bytes@2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339"
bytes@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
@ -3094,7 +3117,7 @@ delegates@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
depd@1.1.1, depd@~1.1.1:
depd@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359"
@ -3102,7 +3125,7 @@ depd@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.0.1.tgz#80aec64c9d6d97e65cc2a9caa93c0aa6abf73aaa"
depd@~1.1.2:
depd@~1.1.0, depd@~1.1.1, depd@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
@ -4152,6 +4175,12 @@ fastparse@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8"
faye-websocket@~0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4"
dependencies:
websocket-driver ">=0.5.1"
fb-watchman@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
@ -4524,6 +4553,12 @@ gauge@~2.7.3:
strip-ansi "^3.0.1"
wide-align "^1.1.0"
gaze@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/gaze/-/gaze-1.1.2.tgz#847224677adb8870d679257ed3388fdb61e40105"
dependencies:
globule "^1.0.0"
generate-function@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74"
@ -4642,7 +4677,7 @@ glob@7.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
glob@7.1.2, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@~7.1.1:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
@ -4746,6 +4781,14 @@ globby@^6.1.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"
globule@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/globule/-/globule-1.2.0.tgz#1dc49c6822dd9e8a2fa00ba2a295006e8664bd09"
dependencies:
glob "~7.1.1"
lodash "~4.17.4"
minimatch "~3.0.2"
gm@~1.21.1:
version "1.21.1"
resolved "https://registry.yarnpkg.com/gm/-/gm-1.21.1.tgz#7ed5ed05db36d30c1943f39c3bc1c839b8f2361d"
@ -4859,6 +4902,15 @@ grunt-contrib-copy@0.8.1:
chalk "^1.1.1"
file-sync-cmp "^0.1.0"
grunt-contrib-watch@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/grunt-contrib-watch/-/grunt-contrib-watch-1.0.0.tgz#84a1a7a1d6abd26ed568413496c73133e990018f"
dependencies:
async "^1.5.0"
gaze "^1.0.0"
lodash "^3.10.1"
tiny-lr "^0.2.1"
grunt-esvm@3.2.12:
version "3.2.12"
resolved "https://registry.yarnpkg.com/grunt-esvm/-/grunt-esvm-3.2.12.tgz#6d1d2a2a946b2f9a790e9899d114c1258ef4f414"
@ -4910,6 +4962,12 @@ grunt-legacy-util@~1.0.0:
underscore.string "~3.2.3"
which "~1.2.1"
grunt-peg@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/grunt-peg/-/grunt-peg-2.0.1.tgz#831db299ffd8fb3627da64e2f04ae65cc4f56ae3"
dependencies:
pegjs "~0.9.0"
grunt-run@0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/grunt-run/-/grunt-run-0.7.0.tgz#1a6ec07e46d5de64eeb49ac60324055c29020b82"
@ -5254,6 +5312,17 @@ http-errors@1.6.2, http-errors@~1.6.2:
setprototypeof "1.0.3"
statuses ">= 1.3.1 < 2"
http-errors@~1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.3.1.tgz#197e22cdebd4198585e8694ef6786197b91ed942"
dependencies:
inherits "~2.0.1"
statuses "1"
http-parser-js@>=0.4.0:
version "0.4.9"
resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.4.9.tgz#ea1a04fb64adff0242e9974f297dd4c3cad271e1"
http-proxy-agent@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-1.0.0.tgz#cc1ce38e453bf984a0f7702d2dd59c73d081284a"
@ -5318,6 +5387,10 @@ iconv-lite@0.4, iconv-lite@0.4.19, iconv-lite@^0.4.13, iconv-lite@^0.4.17, iconv
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
iconv-lite@0.4.13:
version "0.4.13"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2"
iconv-lite@0.4.7:
version "0.4.7"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.7.tgz#89d32fec821bf8597f44609b4bc09bed5c209a23"
@ -6933,6 +7006,10 @@ linkify-it@^2.0.0:
dependencies:
uc.micro "^1.0.1"
livereload-js@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/livereload-js/-/livereload-js-2.3.0.tgz#c3ab22e8aaf5bf3505d80d098cbad67726548c9a"
load-bmfont@^1.2.3:
version "1.3.0"
resolved "https://registry.yarnpkg.com/load-bmfont/-/load-bmfont-1.3.0.tgz#bb7e7c710de6bcafcb13cb3b8c81e0c0131ecbc9"
@ -7207,10 +7284,14 @@ lodash@3.10.1, lodash@^3.0.1, lodash@^3.10.0, lodash@^3.10.1, lodash@^3.3.1, lod
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
lodash@4.17.4, lodash@^4.0.0, lodash@^4.0.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.6.1, lodash@^4.8.2:
lodash@4.17.4:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.6.1, lodash@^4.8.2, lodash@~4.17.4:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
lodash@~4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.3.0.tgz#efd9c4a6ec53f3b05412429915c3e4824e4d25a4"
@ -7553,7 +7634,7 @@ minimatch@0.3:
lru-cache "2"
sigmund "~1.0.0"
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.0:
"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.0, minimatch@~3.0.2:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
@ -8284,7 +8365,7 @@ parseuri@0.0.5:
dependencies:
better-assert "~1.0.0"
parseurl@~1.3.2:
parseurl@~1.3.0, parseurl@~1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
@ -8364,7 +8445,7 @@ peekaboo@2.x.x:
version "2.0.2"
resolved "https://registry.yarnpkg.com/peekaboo/-/peekaboo-2.0.2.tgz#fc42e139efd698c6ff2870a6b20c047cd9aa29ff"
pegjs@0.9.0:
pegjs@0.9.0, pegjs@~0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/pegjs/-/pegjs-0.9.0.tgz#f6aefa2e3ce56169208e52179dfe41f89141a369"
@ -8888,6 +8969,10 @@ qs@2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-2.3.3.tgz#e9e85adbe75da0bbe4c8e0476a086290f863b404"
qs@5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.0.tgz#a9f31142af468cb72b25b30136ba2456834916be"
qs@6.5.1, qs@^6.0.2, qs@^6.5.1, qs@~6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
@ -8896,6 +8981,10 @@ qs@~4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-4.0.0.tgz#c31d9b74ec27df75e543a86c78728ed8d4623607"
qs@~5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-5.1.0.tgz#4d932e5c7ea411cca76a312d39a606200fd50cd9"
qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
@ -8984,6 +9073,14 @@ raw-body@2.3.2:
iconv-lite "0.4.19"
unpipe "1.0.0"
raw-body@~2.1.5:
version "2.1.7"
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.1.7.tgz#adfeace2e4fb3098058014d08c072dcc59758774"
dependencies:
bytes "2.4.0"
iconv-lite "0.4.13"
unpipe "1.0.0"
raw-loader@0.5.1, raw-loader@~0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-0.5.1.tgz#0c3d0beaed8a01c966d9787bf778281252a979aa"
@ -10259,7 +10356,7 @@ statehood@4.x.x:
items "2.x.x"
joi "9.x.x"
"statuses@>= 1.3.1 < 2", statuses@~1.4.0:
statuses@1, "statuses@>= 1.3.1 < 2", statuses@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
@ -10694,6 +10791,17 @@ timers-ext@0.1:
es5-ext "~0.10.14"
next-tick "1"
tiny-lr@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/tiny-lr/-/tiny-lr-0.2.1.tgz#b3fdba802e5d56a33c2f6f10794b32e477ac729d"
dependencies:
body-parser "~1.14.0"
debug "~2.2.0"
faye-websocket "~0.10.0"
livereload-js "^2.2.0"
parseurl "~1.3.0"
qs "~5.1.0"
tinycolor2@^1.1.2, tinycolor2@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8"
@ -10891,12 +10999,12 @@ type-detect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-1.0.0.tgz#762217cc06db258ec48908a1298e8b95121e8ea2"
type-is@~1.6.0, type-is@~1.6.15:
version "1.6.15"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410"
type-is@~1.6.0, type-is@~1.6.10, type-is@~1.6.15:
version "1.6.16"
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194"
dependencies:
media-typer "0.3.0"
mime-types "~2.1.15"
mime-types "~2.1.18"
typechecker@^4.3.0:
version "4.4.1"
@ -11593,6 +11701,17 @@ webpack@3.6.0:
webpack-sources "^1.0.1"
yargs "^8.0.2"
websocket-driver@>=0.5.1:
version "0.7.0"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.0.tgz#0caf9d2d755d93aee049d4bdd0d3fe2cca2a24eb"
dependencies:
http-parser-js ">=0.4.0"
websocket-extensions ">=0.1.1"
websocket-extensions@>=0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29"
whatwg-encoding@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz#57c235bc8657e914d24e1a397d3c82daee0a6ba3"