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.
Common errors
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.
Warnings
deprecated Package appears abandoned; last update was years ago. ↓
fix Consider alternatives like Babel, Recast, or SWC for active transpilation needs.
Install
npm install dawn.js yarn add dawn.js pnpm add dawn.js Imports
- LexParser wrong
const dawn = require('dawn.js'); new dawn.LexParser()correctimport { LexParser } from 'dawn.js' - SyntaxParser wrong
import SyntaxParser from 'dawn.js'correctimport { SyntaxParser } from 'dawn.js' - Flow wrong
const Flow = require('dawn.js').Flowcorrectimport { Flow } from 'dawn.js'
Quickstart
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(...);