mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Use generated parser instead of dynamically generating (#17049)
This commit is contained in:
parent
5eea130137
commit
0336858ed2
4 changed files with 2991 additions and 13 deletions
|
@ -2,6 +2,8 @@
|
|||
/src/fixtures/vislib/mock_data
|
||||
/src/ui/public/angular-bootstrap
|
||||
/src/ui/public/flot-charts
|
||||
/src/ui/public/kuery/ast/kuery.js
|
||||
/src/ui/public/kuery/ast/legacy_kuery.js
|
||||
/test/fixtures/scenarios
|
||||
/src/core_plugins/console/public/webpackShims
|
||||
/src/core_plugins/console/public/tests/webpackShims
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
import legacyKueryGrammar from 'raw-loader!./legacy_kuery.peg';
|
||||
import kueryGrammar from 'raw-loader!./kuery.peg';
|
||||
import PEG from 'pegjs';
|
||||
import _ from 'lodash';
|
||||
import { nodeTypes } from '../node_types/index';
|
||||
|
||||
const legacyKueryParser = PEG.buildParser(legacyKueryGrammar);
|
||||
const kueryParser = PEG.buildParser(kueryGrammar, {
|
||||
allowedStartRules: ['start', 'Literal'],
|
||||
});
|
||||
import { parse as parseKuery } from './kuery';
|
||||
import { parse as parseLegacyKuery } from './legacy_kuery';
|
||||
|
||||
export function fromLiteralExpression(expression, parseOptions) {
|
||||
parseOptions = {
|
||||
|
@ -15,18 +9,18 @@ export function fromLiteralExpression(expression, parseOptions) {
|
|||
startRule: 'Literal',
|
||||
};
|
||||
|
||||
return fromExpression(expression, parseOptions, kueryParser);
|
||||
return fromExpression(expression, parseOptions, parseKuery);
|
||||
}
|
||||
|
||||
export function fromLegacyKueryExpression(expression, parseOptions) {
|
||||
return fromExpression(expression, parseOptions, legacyKueryParser);
|
||||
return fromExpression(expression, parseOptions, parseLegacyKuery);
|
||||
}
|
||||
|
||||
export function fromKueryExpression(expression, parseOptions) {
|
||||
return fromExpression(expression, parseOptions, kueryParser);
|
||||
return fromExpression(expression, parseOptions, parseKuery);
|
||||
}
|
||||
|
||||
function fromExpression(expression, parseOptions = {}, parser = kueryParser) {
|
||||
function fromExpression(expression, parseOptions = {}, parse = parseKuery) {
|
||||
if (_.isUndefined(expression)) {
|
||||
throw new Error('expression must be a string, got undefined instead');
|
||||
}
|
||||
|
@ -36,7 +30,7 @@ function fromExpression(expression, parseOptions = {}, parser = kueryParser) {
|
|||
helpers: { nodeTypes }
|
||||
};
|
||||
|
||||
return parser.parse(expression, parseOptions);
|
||||
return parse(expression, parseOptions);
|
||||
}
|
||||
|
||||
export function toElasticsearchQuery(node, indexPattern) {
|
||||
|
|
1433
src/ui/public/kuery/ast/kuery.js
Normal file
1433
src/ui/public/kuery/ast/kuery.js
Normal file
File diff suppressed because it is too large
Load diff
1549
src/ui/public/kuery/ast/legacy_kuery.js
Normal file
1549
src/ui/public/kuery/ast/legacy_kuery.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue