MCPcopy Index your code
hub / github.com/KFlash/seafox

github.com/KFlash/seafox @v.1.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v.1.4.0 ↗ · + Follow
312 symbols 1,279 edges 115 files 0 documented · 0% updated 3y agov.1.4.0 · 2020-03-19★ 4913 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Seafox

A blazing fast 100% spec compliant, self-hosted javascript parser written in Typescript.

<a href="https://www.npmjs.com/package/seafox"><img src="https://img.shields.io/npm/v/seafox.svg?style=flat-square" alt="Seafox NPM"/></a>
<a href="https://lgtm.com/projects/g/KFlash/seafox/context:javascript"><img src="https://img.shields.io/lgtm/grade/javascript/g/KFlash/seafox.svg?logo=lgtm&logoWidth=18" alt="GitHub license" /></a>
<a href="https://lgtm.com/projects/g/KFlash/seafox/alerts"><img src="https://img.shields.io/lgtm/alerts/g/KFlash/seafox.svg?logo=lgtm&logoWidth=18" alt="Total alerts" /></a>
<a href="https://circleci.com/gh/KFlash/seafox"><img src="https://circleci.com/gh/KFlash/seafox.svg?style=svg" alt="Circle" /></a>
<a href="https://github.com/KFlash/seafox/blob/master/LICENSE.md"><img src="https://img.shields.io/github/license/KFlash/seafox.svg" alt="License" /></a>

Features

  • Conforms to the standard ECMAScript® 2020 (ECMA-262 10th Edition) language specification
  • Support for additional ECMAScript features for Web Browsers
  • Optionally track syntactic node locations
  • Emits an ESTree-compatible abstract syntax tree.
  • No backtracking
  • Low memory usage
  • Very well tested (~32 000 unit tests with full code coverage)
  • Lightweight - ~84 KB minified

Installation

npm install seafox --save-dev

API

Seafox generates AST according to ESTree AST format, and can be used to perform syntactic analysis (parsing) of a JavaScript program, and with ES2015 and later a JavaScript program can be either a script or a module.

The parse method exposed by Seafox takes an optional options object which allows you to specify whether to parse in script mode (the default) or in module mode.

This is the available options:

{
  // Allow parsing using Module as the goal symbol
  module?: boolean;

  // The flag to enable start and end offsets and line/column location information to each node
  loc: false;

  // Disable web compatibility
  disableWebCompat: false;

  // The flag to attach raw property to each literal and identifier node
  raw: false;

  // Enabled directives
  directives: false;

  // The flag to allow return in the global scope
  globalReturn: false;

  // The flag to enable implied strict mode
  impliedStrict: false;

// Enable non-standard parenthesized expression node
  preserveParens: false;
}

Example usage:


import { parseScript, parseModule, parse } from './seafox';

parseScript('({x: [y] = 0} = 1)');

parseModule('({x: [y] = 0} = 1)', { directives: true, raw: true });

parse('({x: [y] = 0} = 1)', { module: true });

parse('({x: [y] = 0} = 1)');

Extension points exported contracts — how you extend this code

Opts (Interface)
(no doc)
test/scanner/identifier.ts
Options (Interface)
(no doc)
src/seafox.ts
ParserState (Interface)
(no doc)
src/parser/common.ts
Opts (Interface)
(no doc)
test/scanner/punctuators.ts
Label (Interface)
(no doc)
src/parser/common.ts
ScopeState (Interface)
(no doc)
src/parser/scope.ts
ScopeError (Interface)
(no doc)
src/parser/scope.ts
_Node (Interface)
(no doc)
src/parser/types.ts

Core symbols most depended-on inside this repo

report
called by 261
src/errors.ts
parseRoot
called by 150
src/seafox.ts
nextToken
called by 125
src/scanner/scan.ts
setLoc
called by 103
src/parser/common.ts
fail
called by 94
test/scanner/numeric.ts
fail
called by 91
test/scanner/identifier.ts
pass
called by 59
test/parser/core.ts
consume
called by 59
src/parser/common.ts

Shape

Function 193
Interface 102
Enum 14
Class 2
Method 1

Languages

TypeScript100%

Modules by API surface

src/parser/types.ts95 symbols
src/parser/expressions.ts71 symbols
src/parser/statements.ts26 symbols
src/parser/common.ts23 symbols
src/parser/scope.ts12 symbols
src/parser/declaration.ts7 symbols
scripts/generate-unicode.js7 symbols
src/parser/module.ts6 symbols
src/errors.ts6 symbols
src/seafox.ts5 symbols
src/scanner/string.ts4 symbols
src/scanner/identifier.ts4 symbols

For agents

$ claude mcp add seafox \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact