@types/pegjs

  • Version 0.10.6
  • Published
  • 9.11 kB
  • No dependencies
  • MIT license

Install

npm i @types/pegjs
yarn add @types/pegjs
pnpm add @types/pegjs

Overview

TypeScript definitions for pegjs

Index

Variables

variable GrammarError

var GrammarError: any;

    Functions

    function generate

    generate: {
    (grammar: string, options?: ParserBuildOptions): Parser;
    (grammar: string, options: OutputFormatAmdCommonjs): string;
    (grammar: string, options: OutputFormatUmd): string;
    (grammar: string, options: OutputFormatGlobals): string;
    (grammar: string, options: OutputFormatBare): string;
    };
    • Returns a generated parser object. It will throw an exception if the grammar is invalid. The exception will contain message property with more details about the error.

    • Returns the generated source code as a string. It will throw an exception if the grammar is invalid. The exception will contain message property with more details about the error.

    Interfaces

    interface BuildOptionsBase

    interface BuildOptionsBase {}

      property allowedStartRules

      allowedStartRules?: string[] | undefined;
      • rules the parser will be allowed to start parsing from (default: the first rule in the grammar)

      property cache

      cache?: boolean | undefined;
      • if true, makes the parser cache results, avoiding exponential parsing time in pathological cases but making the parser slower (default: false)

      property optimize

      optimize?: 'speed' | 'size' | undefined;
      • selects between optimizing the generated parser for parsing speed ("speed") or code size ("size") (default: "speed")

      property plugins

      plugins?: any[] | undefined;
      • plugins to use

      property trace

      trace?: boolean | undefined;
      • makes the parser trace its progress (default: false)

      interface ExpectedItem

      interface ExpectedItem {}

        property description

        description: string;

          property type

          type: string;

            property value

            value?: string | undefined;

              interface OutputFormatAmdCommonjs

              interface OutputFormatAmdCommonjs extends BuildOptionsBase {}

                property dependencies

                dependencies?: any;
                • parser dependencies, the value is an object which maps variables used to access the dependencies in the parser to module IDs used to load them; valid only when format is set to "amd", "commonjs", or "umd" (default: {})

                property format

                format: 'amd' | 'commonjs';
                • format of the genreated parser ("amd", "bare", "commonjs", "globals", or "umd"); valid only when output is set to "source" (default: "bare")

                property output

                output: 'source';
                • if set to "parser", the method will return generated parser object; if set to "source", it will return parser source code as a string (default: "parser")

                interface OutputFormatBare

                interface OutputFormatBare extends BuildOptionsBase {}

                  property format

                  format?: 'bare' | undefined;
                  • format of the genreated parser ("amd", "bare", "commonjs", "globals", or "umd"); valid only when output is set to "source" (default: "bare")

                  property output

                  output: 'source';
                  • if set to "parser", the method will return generated parser object; if set to "source", it will return parser source code as a string (default: "parser")

                  interface OutputFormatGlobals

                  interface OutputFormatGlobals extends BuildOptionsBase {}

                    property exportVar

                    exportVar?: any;
                    • name of a global variable into which the parser object is assigned to when no module loader is detected; valid only when format is set to "globals" or "umd" (default: null)

                    property format

                    format: 'globals';
                    • format of the genreated parser ("amd", "bare", "commonjs", "globals", or "umd"); valid only when output is set to "source" (default: "bare")

                    property output

                    output: 'source';
                    • if set to "parser", the method will return generated parser object; if set to "source", it will return parser source code as a string (default: "parser")

                    interface OutputFormatUmd

                    interface OutputFormatUmd extends BuildOptionsBase {}

                      property dependencies

                      dependencies?: any;
                      • parser dependencies, the value is an object which maps variables used to access the dependencies in the parser to module IDs used to load them; valid only when format is set to "amd", "commonjs", or "umd" (default: {})

                      property exportVar

                      exportVar?: any;
                      • name of a global variable into which the parser object is assigned to when no module loader is detected; valid only when format is set to "globals" or "umd" (default: null)

                      property format

                      format: 'umd';
                      • format of the genreated parser ("amd", "bare", "commonjs", "globals", or "umd"); valid only when output is set to "source" (default: "bare")

                      property output

                      output: 'source';
                      • if set to "parser", the method will return generated parser object; if set to "source", it will return parser source code as a string (default: "parser")

                      interface Parser

                      interface Parser {}

                        property SyntaxError

                        SyntaxError: any;

                          method parse

                          parse: (input: string, options?: ParserOptions) => any;

                            interface ParserBuildOptions

                            interface ParserBuildOptions extends BuildOptionsBase {}

                              property output

                              output?: 'parser' | undefined;
                              • if set to "parser", the method will return generated parser object; if set to "source", it will return parser source code as a string (default: "parser")

                              interface ParserOptions

                              interface ParserOptions {}

                                property startRule

                                startRule?: string | undefined;

                                  property tracer

                                  tracer?: any;

                                    index signature

                                    [key: string]: any;

                                      interface PegjsError

                                      interface PegjsError extends Error {}

                                        property expected

                                        expected?: ExpectedItem[] | undefined;

                                          property found

                                          found?: any;

                                            property location

                                            location: LocationRange;

                                              property message

                                              message: string;

                                                property name

                                                name: string;

                                                  property stack

                                                  stack?: any;

                                                    Type Aliases

                                                    type GrammarError

                                                    type GrammarError = PegjsError;

                                                      type Location

                                                      type Location = PEG.Location;

                                                        type LocationRange

                                                        type LocationRange = PEG.LocationRange;

                                                          Namespaces

                                                          namespace parser

                                                          namespace parser {}

                                                            variable SyntaxError

                                                            var SyntaxError: any;

                                                              type SyntaxError

                                                              type SyntaxError = PegjsError;

                                                                namespace PEG

                                                                namespace PEG {}

                                                                  function parse

                                                                  parse: (input: string) => any;

                                                                    class SyntaxError

                                                                    class SyntaxError {}

                                                                      property column

                                                                      column: number;

                                                                        property expected

                                                                        expected: any[];

                                                                          property found

                                                                          found: any;

                                                                            property line

                                                                            line: number;

                                                                              property location

                                                                              location: LocationRange;

                                                                                property message

                                                                                message: string;

                                                                                  property name

                                                                                  name: string;

                                                                                    property offset

                                                                                    offset: number;

                                                                                      interface Location

                                                                                      interface Location {}

                                                                                        property column

                                                                                        column: number;

                                                                                          property line

                                                                                          line: number;

                                                                                            property offset

                                                                                            offset: number;

                                                                                              interface LocationRange

                                                                                              interface LocationRange {}

                                                                                                property end

                                                                                                end: Location;

                                                                                                  property start

                                                                                                  start: Location;

                                                                                                    Package Files (1)

                                                                                                    Dependencies (0)

                                                                                                    No dependencies.

                                                                                                    Dev Dependencies (0)

                                                                                                    No dev dependencies.

                                                                                                    Peer Dependencies (0)

                                                                                                    No peer dependencies.

                                                                                                    Badge

                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/pegjs.

                                                                                                    • Markdown
                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/pegjs)
                                                                                                    • HTML
                                                                                                      <a href="https://www.jsdocs.io/package/@types/pegjs"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>