dawn.js

raw JSON →
0.1.1 verified Fri May 01 auth: no javascript abandoned

dawn.js is a general-purpose source-to-source transpiler framework implemented in JavaScript (CoffeeScript). Version 0.1.1 provides built-in lexical parser, syntax parser (with AST generation), symbol table generator, and a customizable plugin system (Flow) for transforming code between languages. It targets developers needing autocompletion, refactoring, or cross-language compilation features. Released under MIT, but appears to be early-stage with limited documentation and infrequent updates compared to established alternatives like Babel or Recast.

error Error: Cannot find module 'dawn.js'
cause Package not installed or wrong import path.
fix
npm install dawn.js (note: npm package name is dawn.js with dot)
error TypeError: dawn.LexParser is not a constructor
cause Incorrect import style (CommonJS vs ESM).
fix
Use import { LexParser } from 'dawn.js' instead of require.
deprecated Package appears abandoned; last update was years ago.
fix Consider alternatives like Babel, Recast, or SWC for active transpilation needs.
npm install dawn.js
yarn add dawn.js
pnpm add dawn.js

Demonstrates basic lexical and syntax parsing, and symbol table generation using dawn.js.

import { LexParser, SyntaxParser, SymbolTable, Flow } from 'dawn.js';

const code = `const x = 1 + 2;`;

// Lexical analysis
const lexer = new LexParser();
const tokens = lexer.analyze(code);
console.log('Tokens:', tokens);

// Syntax analysis (requires BNF grammar definition)
// Minimal example using built-in grammar? Not explicitly provided.
// Assume BNF grammar string:
const bnf = `
<program> ::= <statement>
<statement> ::= <assignment>
<assignment> ::= "const" <identifier> "=" <expression> ";"
<expression> ::= <number> "+" <number>
`;
const syntaxParser = new SyntaxParser(bnf);
const ast = syntaxParser.parse(tokens);
console.log('AST:', ast);

// Symbol table
const symbolTable = new SymbolTable();
symbolTable.build(ast);
console.log('Symbols:', symbolTable);

// Plugin system placeholder
const flow = new Flow();
// flow.addPlugin(...);