Firescript Language Parser

raw JSON →
0.15.0 verified Thu Apr 23 auth: no javascript

The `firescript-parser` package provides a parser module for the Firescript language, designed to convert Firescript source code into an Abstract Syntax Tree (AST). As of its current version 0.15.0, both the language and its parser are actively under development and are not yet recommended for production use. Firescript itself is an indentation-based scripting language that compiles to clean, readable JavaScript, emphasizing strict syntax and dynamic typing. The parser's release cadence is irregular, closely tied to the evolving specifications of the Firescript language. Its primary differentiator is its specific utility for the Firescript ecosystem, rather than being a general-purpose parser for established languages.

error SyntaxError: Unexpected token
cause The input Firescript code contains a syntax error or uses features not yet supported by the parser.
fix
Review your Firescript code for syntax correctness according to the language specification. If the code is valid Firescript, the parser might be outdated or not yet support a specific language feature.
error TypeError: Parser is not a constructor
cause The `Parser` class was imported incorrectly, often due to attempting a named import instead of the default export, or incorrect CommonJS usage.
fix
For ESM, use import Parser from 'firescript-parser';. For CommonJS, use const Parser = require('firescript-parser').default;.
error Module not found: Can't resolve 'firescript-parser'
cause The `firescript-parser` package is not installed or not correctly linked in your project's dependencies.
fix
Run npm install firescript-parser or yarn add firescript-parser in your project directory.
breaking The Firescript language and its parser are actively under development (version 0.15.0) and are not recommended for production use. Significant breaking changes to the API and AST structure are highly likely in future pre-1.0 releases as the language specification evolves.
fix Monitor the project's GitHub repository for updates and changelogs. Pin exact versions of the package in your `package.json` to prevent unexpected breaks.
gotcha The official documentation for the Firescript language itself is 'not ready yet'. This indicates that detailed documentation for the parser's AST structure, specific syntax nuances, and advanced usage might be limited or informal, requiring direct source code inspection.
fix Refer to the Firescript language's GitHub repository and the parser's source code for the most up-to-date understanding of syntax and AST structure.
gotcha Firescript is a niche language. The parser is specific to Firescript and not compatible with standard JavaScript, TypeScript, or other common languages. Attempting to parse non-Firescript code will result in syntax errors.
fix Ensure that the input provided to `firescript-parser` adheres strictly to the Firescript language syntax. Use appropriate parsers for other language types.
npm install firescript-parser
yarn add firescript-parser
pnpm add firescript-parser

Demonstrates how to import the `Parser` class, instantiate it, and parse a basic Firescript code snippet into an AST.

import Parser from 'firescript-parser';

const parser = new Parser();
try {
  const firescriptCode = "const foo = 'bar'\nlet baz = 10";
  const ast = parser.parse(firescriptCode);
  console.log('Successfully parsed Firescript code.');
  console.log(JSON.stringify(ast, null, 2));
  // Example: Accessing part of the AST (structure may vary)
  // if (ast && ast.body && ast.body.length > 0) {
  //   console.log('First statement type:', ast.body[0].type);
  // }
} catch (error) {
  console.error('Parsing failed:', error.message);
}