How to use the pegjs.parser.parse function in pegjs

To help you get started, we’ve selected a few pegjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pegjs / pegjs / test / unit / parser.spec.js View on Github external
        expect( () => parser.parse( text ) )
            .to.throw( "Unbalanced brace." )
github pegjs / pegjs / test / unit / parser.spec.js View on Github external
Assertion.addMethod( "parseAs", function ( expected, options ) {

            options = typeof options === "undefined" ? {} : options;

            const result = parser.parse( utils.flag( this, "object" ), options );

            stripProperties( result );

            this.assert(
                utils.eql( result, expected ),
                "expected #{this} to parse as #{exp} but got #{act}",
                "expected #{this} to not parse as #{exp}",
                expected,
                result,
                ! utils.flag( this, "negate" ),
            );

        } );
github pegjs / pegjs / test / unit / parser.spec.js View on Github external
Assertion.addMethod( "failToParse", function ( props ) {

            let passed, result;

            try {

                result = parser.parse( utils.flag( this, "object" ) );
                passed = true;

            } catch ( e ) {

                result = e;
                passed = false;

            }

            if ( passed ) {

                stripProperties( result );

            }

            this.assert(