MCPcopy Create free account
hub / github.com/dchester/jsonpath / parse

Function parse

jsonpath.js:3672–3743  ·  view source on GitHub ↗
(code, options)

Source from the content-addressed store, hash-verified

3670 }
3671
3672 function parse(code, options) {
3673 var program, toString;
3674
3675 toString = String;
3676 if (typeof code !== 'string' && !(code instanceof String)) {
3677 code = toString(code);
3678 }
3679
3680 delegate = SyntaxTreeDelegate;
3681 source = code;
3682 index = 0;
3683 lineNumber = (source.length > 0) ? 1 : 0;
3684 lineStart = 0;
3685 length = source.length;
3686 lookahead = null;
3687 state = {
3688 allowIn: true,
3689 labelSet: {},
3690 inFunctionBody: false,
3691 inIteration: false,
3692 inSwitch: false,
3693 lastCommentStart: -1
3694 };
3695
3696 extra = {};
3697 if (typeof options !== 'undefined') {
3698 extra.range = (typeof options.range === 'boolean') && options.range;
3699 extra.loc = (typeof options.loc === 'boolean') && options.loc;
3700 extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
3701
3702 if (extra.loc && options.source !== null && options.source !== undefined) {
3703 extra.source = toString(options.source);
3704 }
3705
3706 if (typeof options.tokens === 'boolean' && options.tokens) {
3707 extra.tokens = [];
3708 }
3709 if (typeof options.comment === 'boolean' && options.comment) {
3710 extra.comments = [];
3711 }
3712 if (typeof options.tolerant === 'boolean' && options.tolerant) {
3713 extra.errors = [];
3714 }
3715 if (extra.attachComment) {
3716 extra.range = true;
3717 extra.comments = [];
3718 extra.bottomRightStack = [];
3719 extra.trailingComments = [];
3720 extra.leadingComments = [];
3721 }
3722 }
3723
3724 try {
3725 program = parseProgram();
3726 if (typeof extra.comments !== 'undefined') {
3727 program.comments = extra.comments;
3728 }
3729 if (typeof extra.tokens !== 'undefined') {

Callers

nothing calls this directly

Calls 2

parseProgramFunction · 0.85
filterTokenLocationFunction · 0.85

Tested by

no test coverage detected