acorn

  • Version 8.3.0
  • Published
  • 453 kB
  • No dependencies
  • MIT license

Install

npm i acorn
yarn add acorn
pnpm add acorn

Overview

ECMAScript parser

Index

Variables

variable defaultOptions

const defaultOptions: Options;

    variable lineBreak

    const lineBreak: RegExp;

      variable lineBreakG

      const lineBreakG: RegExp;

        variable tokContexts

        const tokContexts: {
        b_stat: TokContext;
        b_expr: TokContext;
        b_tmpl: TokContext;
        p_stat: TokContext;
        p_expr: TokContext;
        q_tmpl: TokContext;
        f_expr: TokContext;
        };

          variable tokTypes

          const tokTypes: {
          num: TokenType;
          regexp: TokenType;
          string: TokenType;
          name: TokenType;
          privateId: TokenType;
          eof: TokenType;
          bracketL: TokenType;
          bracketR: TokenType;
          braceL: TokenType;
          braceR: TokenType;
          parenL: TokenType;
          parenR: TokenType;
          comma: TokenType;
          semi: TokenType;
          colon: TokenType;
          dot: TokenType;
          question: TokenType;
          arrow: TokenType;
          template: TokenType;
          ellipsis: TokenType;
          backQuote: TokenType;
          dollarBraceL: TokenType;
          eq: TokenType;
          assign: TokenType;
          incDec: TokenType;
          prefix: TokenType;
          logicalOR: TokenType;
          logicalAND: TokenType;
          bitwiseOR: TokenType;
          bitwiseXOR: TokenType;
          bitwiseAND: TokenType;
          equality: TokenType;
          relational: TokenType;
          bitShift: TokenType;
          plusMin: TokenType;
          modulo: TokenType;
          star: TokenType;
          slash: TokenType;
          starstar: TokenType;
          _break: TokenType;
          _case: TokenType;
          _catch: TokenType;
          _continue: TokenType;
          _debugger: TokenType;
          _default: TokenType;
          _do: TokenType;
          _else: TokenType;
          _finally: TokenType;
          _for: TokenType;
          _function: TokenType;
          _if: TokenType;
          _return: TokenType;
          _switch: TokenType;
          _throw: TokenType;
          _try: TokenType;
          _var: TokenType;
          _const: TokenType;
          _while: TokenType;
          _with: TokenType;
          _new: TokenType;
          _this: TokenType;
          _super: TokenType;
          _class: TokenType;
          _extends: TokenType;
          _export: TokenType;
          _import: TokenType;
          _null: TokenType;
          _true: TokenType;
          _false: TokenType;
          _in: TokenType;
          _instanceof: TokenType;
          _typeof: TokenType;
          _void: TokenType;
          _delete: TokenType;
          };

            variable version

            const version: string;

              Functions

              function getLineInfo

              getLineInfo: (input: string, offset: number) => Position;

                function isIdentifierChar

                isIdentifierChar: (code: number, astral?: boolean) => boolean;

                  function isIdentifierStart

                  isIdentifierStart: (code: number, astral?: boolean) => boolean;

                    function isNewLine

                    isNewLine: (code: number) => boolean;

                      function parse

                      parse: (input: string, options: Options) => Node;

                        function parseExpressionAt

                        parseExpressionAt: (input: string, pos: number, options: Options) => Node;

                          function tokenizer

                          tokenizer: (
                          input: string,
                          options: Options
                          ) => { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, undefined> };

                            Classes

                            class Node

                            class Node {}

                              constructor

                              constructor(parser: Parser, pos: number, loc?: SourceLocation);

                                property end

                                end: number;

                                  property loc

                                  loc?: SourceLocation;

                                    property range

                                    range?: [number, number];

                                      property sourceFile

                                      sourceFile?: string;

                                        property start

                                        start: number;

                                          property type

                                          type: string;

                                            class Parser

                                            class Parser {}

                                              constructor

                                              constructor(options: Options, input: string, startPos?: number);

                                                method extend

                                                static extend: (
                                                this: typeof Parser,
                                                ...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]
                                                ) => typeof Parser;

                                                  method parse

                                                  static parse: (this: typeof Parser, input: string, options: Options) => Node;

                                                    method parseExpressionAt

                                                    static parseExpressionAt: (
                                                    this: typeof Parser,
                                                    input: string,
                                                    pos: number,
                                                    options: Options
                                                    ) => Node;

                                                      method tokenizer

                                                      static tokenizer: (
                                                      this: typeof Parser,
                                                      input: string,
                                                      options: Options
                                                      ) => { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, undefined> };

                                                        class SourceLocation

                                                        class SourceLocation {}

                                                          constructor

                                                          constructor(p: Parser, start: Position, end: Position);

                                                            property end

                                                            end: Position;

                                                              property source

                                                              source?: string;

                                                                property start

                                                                start: Position;

                                                                  class TokContext

                                                                  class TokContext {}

                                                                    constructor

                                                                    constructor(
                                                                    token: string,
                                                                    isExpr: boolean,
                                                                    preserveSpace: boolean,
                                                                    override?: (p: Parser) => void
                                                                    );

                                                                      class Token

                                                                      class Token {}

                                                                        constructor

                                                                        constructor(p: Parser);

                                                                          property end

                                                                          end: number;

                                                                            property loc

                                                                            loc?: SourceLocation;

                                                                              property range

                                                                              range?: [number, number];

                                                                                property start

                                                                                start: number;

                                                                                  property type

                                                                                  type: TokenType;

                                                                                    property value

                                                                                    value: any;

                                                                                      class TokenType

                                                                                      class TokenType {}

                                                                                        constructor

                                                                                        constructor(label: string, conf?: any);

                                                                                          property beforeExpr

                                                                                          beforeExpr: boolean;

                                                                                            property binop

                                                                                            binop: number;

                                                                                              property isAssign

                                                                                              isAssign: boolean;

                                                                                                property isLoop

                                                                                                isLoop: boolean;

                                                                                                  property keyword

                                                                                                  keyword: string;

                                                                                                    property label

                                                                                                    label: string;

                                                                                                      property postfix

                                                                                                      postfix: boolean;

                                                                                                        property prefix

                                                                                                        prefix: boolean;

                                                                                                          property startsExpr

                                                                                                          startsExpr: boolean;

                                                                                                            property updateContext

                                                                                                            updateContext?: (prevType: TokenType) => void;

                                                                                                              Interfaces

                                                                                                              interface AbstractToken

                                                                                                              interface AbstractToken {}

                                                                                                                interface Comment

                                                                                                                interface Comment extends AbstractToken {}

                                                                                                                  property end

                                                                                                                  end: number;

                                                                                                                    property loc

                                                                                                                    loc?: SourceLocation;

                                                                                                                      property range

                                                                                                                      range?: [number, number];

                                                                                                                        property start

                                                                                                                        start: number;

                                                                                                                          property type

                                                                                                                          type: string;

                                                                                                                            property value

                                                                                                                            value: string;

                                                                                                                              interface Options

                                                                                                                              interface Options {}

                                                                                                                                property allowAwaitOutsideFunction

                                                                                                                                allowAwaitOutsideFunction?: boolean;

                                                                                                                                  property allowHashBang

                                                                                                                                  allowHashBang?: boolean;

                                                                                                                                    property allowImportExportEverywhere

                                                                                                                                    allowImportExportEverywhere?: boolean;

                                                                                                                                      property allowReserved

                                                                                                                                      allowReserved?: boolean | 'never';

                                                                                                                                        property allowReturnOutsideFunction

                                                                                                                                        allowReturnOutsideFunction?: boolean;

                                                                                                                                          property directSourceFile

                                                                                                                                          directSourceFile?: string;

                                                                                                                                            property ecmaVersion

                                                                                                                                            ecmaVersion:
                                                                                                                                            | 3
                                                                                                                                            | 5
                                                                                                                                            | 6
                                                                                                                                            | 7
                                                                                                                                            | 8
                                                                                                                                            | 9
                                                                                                                                            | 10
                                                                                                                                            | 11
                                                                                                                                            | 12
                                                                                                                                            | 2015
                                                                                                                                            | 2016
                                                                                                                                            | 2017
                                                                                                                                            | 2018
                                                                                                                                            | 2019
                                                                                                                                            | 2020
                                                                                                                                            | 2021
                                                                                                                                            | 'latest';

                                                                                                                                              property locations

                                                                                                                                              locations?: boolean;

                                                                                                                                                property onComment

                                                                                                                                                onComment?:
                                                                                                                                                | ((
                                                                                                                                                isBlock: boolean,
                                                                                                                                                text: string,
                                                                                                                                                start: number,
                                                                                                                                                end: number,
                                                                                                                                                startLoc?: Position,
                                                                                                                                                endLoc?: Position
                                                                                                                                                ) => void)
                                                                                                                                                | Comment[];

                                                                                                                                                  property onInsertedSemicolon

                                                                                                                                                  onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void;

                                                                                                                                                    property onToken

                                                                                                                                                    onToken?: ((token: Token) => any) | Token[];

                                                                                                                                                      property onTrailingComma

                                                                                                                                                      onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void;

                                                                                                                                                        property preserveParens

                                                                                                                                                        preserveParens?: boolean;

                                                                                                                                                          property program

                                                                                                                                                          program?: Node;

                                                                                                                                                            property ranges

                                                                                                                                                            ranges?: boolean;

                                                                                                                                                              property sourceFile

                                                                                                                                                              sourceFile?: string;

                                                                                                                                                                property sourceType

                                                                                                                                                                sourceType?: 'script' | 'module';

                                                                                                                                                                  interface Position

                                                                                                                                                                  interface Position {}

                                                                                                                                                                    property column

                                                                                                                                                                    column: number;

                                                                                                                                                                      property line

                                                                                                                                                                      line: number;

                                                                                                                                                                        property offset

                                                                                                                                                                        offset: number;

                                                                                                                                                                          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/acorn.

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