GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - engine262/engine262: An implementation of ECMA-262 in JavaScript

BranchesTags
Open more actions menu

Latest commit

 

History

1,391 Commits
1,391 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
api-baseline
api-baseline
 
 
bin
bin
 
 
config/api-extractor
config/api-extractor
 
 
lib-src
lib-src
 
 
scripts
scripts
 
 
spec
spec
 
 
src
src
 
 
test
test
 
 
website @ 5eb213d
website @ 5eb213d
 
 
.git-blame-ignore-revs
.git-blame-ignore-revs
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.npmignore
.npmignore
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
babel.config.json
babel.config.json
 
 
eslint.config.mjs
eslint.config.mjs
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
spec.json
spec.json
 
 
tsconfig.base.json
tsconfig.base.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.mts
vitest.config.mts
 
 

Repository files navigation

engine262

An implementation of ECMA-262 in JavaScript

Goals

  • 100% Spec Compliance
  • Introspection
  • Ease of modification

Non-Goals

  • Speed at the expense of any of the goals

This project is bound by a Code of Conduct.

Join us in #engine262:matrix.org.

Why this exists

While helping develop new features for JavaScript, I've found that one of the most useful methods of finding what works and what doesn't is being able to actually run code using the new feature. Babel is fantastic for this, but sometimes features just can't be nicely represented with it. Similarly, implementing a feature in one of the engines is a large undertaking, involving long compile times and annoying bugs with the optimizing compilers.

engine262 is a tool to allow JavaScript developers to have a playground where new features can be quickly prototyped and explored. As an example, adding do expressions to this engine is as simple as the following diff:

--- a/src/evaluator.mts
+++ b/src/evaluator.mts
@@ -232,6 +232,8 @@ export function* Evaluate(node) {
     case 'GeneratorBody':
     case 'AsyncGeneratorBody':
       return yield* Evaluate_AnyFunctionBody(node);
+    case 'DoExpression':
+      return yield* Evaluate_Block(node.Block);
     default:
       throw new OutOfRange('Evaluate', node);
   }
--- a/src/parser/ExpressionParser.mts
+++ b/src/parser/ExpressionParser.mts
@@ -579,6 +579,12 @@ export class ExpressionParser extends FunctionParser {
         return this.parseRegularExpressionLiteral();
       case Token.LPAREN:
         return this.parseParenthesizedExpression();
+      case Token.DO: {
+        const node = this.startNode<ParseNode.DoExpression>();
+        this.next();
+        node.Block = this.parseBlock();
+        return this.finishNode(node, 'DoExpression');
+      }
       default:
         return this.unexpected();
     }

This simplicity applies to many other proposals, such as optional chaining, pattern matching, the pipeline operator, and more. This engine has also been used to find bugs in ECMA-262 and test262, the test suite for conforming JavaScript implementations.

Requirements

To run engine262 itself, a engine with support for recent ECMAScript features is needed. Additionally, the CLI (bin/engine262.js) and test262 runner (test/test262/test262.mts) require a recent version of Node.js.

Using engine262

You can install it from npm.

npm install @engine262/engine262
yarn install @engine262/engine262
pnpm install @engine262/engine262

If you install it globally, you can use the CLI like so:

$ engine262

engine262 playground

Classic playground and Chrome Devtools style playground

engine262 CLI

--module/-m

Evaluate the file as a module.

--eval <string> / -e <string>

Evaluate the given string and exit.

--features=<featureA,featureB> / --features=all

Run engine262 --list-features to see all ECMAScript features can be switched.

--no-test262

Do not expose $ and $262 global variable for test262 test suite.

--no-inspector

Do not start an inspector.

By default engine262 will start an inspector on ws://localhost:9229/ (like Node.js with --inspector). See the Node.js guide for connecting.

--no-preview

Do not enable the preview feature in the inspector.

engine262 API

See the example.

Developing engine262

npm run build and npm run watch will build and watch the build.

npm run test:test262 will run the test262 test suite. Run npm run test:test262 -- --help to see the test runner options.

npm start start the engine262 CLI.

npm run inspector start the website (debugging engine262 mainly happens here).

Related Projects

Many people and organizations have attempted to write a JavaScript interpreter in JavaScript much like engine262, with different goals. Some of them are included here for reference, though engine262 is not based on any of them.

  • https://github.com/NeilFraser/JS-Interpreter
  • https://github.com/metaes/metaes
  • https://github.com/Siubaak/sval

About

An implementation of ECMA-262 in JavaScript

engine262.js.org

Topics

ecma262engine262interpreterjavascriptreference-implementation

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity
Custom properties

Stars

950 stars

Watchers

21 watching

Forks

77 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.