{"id":26529,"library":"tscc-compiler","title":"tscc-compiler","description":"An LALR(1) compiler generator written in TypeScript that produces both tokenizer and parser from a single grammar specification. Stable version 1.1.3 generates parsers in JavaScript and TypeScript. It implements the Hanolee algorithm for LALR(1) table construction and includes a CLI tool, a module API, and browser support. Unlike many parser generators, it handles lexical analysis generation in addition to parsing, and provides detailed reporting of DFA and LALR parse tables. Maintenance is irregular.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/Hadron67/tscc-compiler","tags":["javascript","tscc","LALR(1)","compiler compiler","parser","compiler","Hanolee algorithm"],"install":[{"cmd":"npm install tscc-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add tscc-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add tscc-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package provides a default export as `main` function. Use named import in ES modules; the CJS require pattern works but misses the named import style.","wrong":"const tscc = require('tscc-compiler').main;","symbol":"main","correct":"import { main } from 'tscc-compiler';"},{"note":"CLI is available globally if installed with -g, or via npx. The module does not export a CLI as a function.","wrong":"tscc-compiler --help","symbol":"tscc-compiler CLI","correct":"npx tscc-compiler file.y"},{"note":"The default export is an object containing `main`. Avoid using `.main` on the default if you destructure. For browsers, use global `tscc` after including the script.","wrong":"const tscc = require('tscc-compiler'); tscc.main(...);","symbol":"tscc","correct":"import tscc from 'tscc-compiler';"}],"quickstart":{"code":"import fs from 'fs';\nimport { main } from 'tscc-compiler';\n\nconst input = fs.readFileSync('grammar.y', 'utf-8');\nconst result = main({\n  inputFile: 'grammar.y',\n  input: input,\n  outputFile: 'grammar.output',\n  stdout: {\n    write: (s) => process.stdout.write(s),\n    writeln: (s) => console.log(s || '')\n  },\n  writeFile: (path, content) => fs.writeFileSync(path, content),\n  printDetailedTime: true,\n  printDFA: true,\n  showlah: false,\n  showFullItemsets: false\n});\n\nif (result !== 0) {\n  console.error('Compilation failed');\n}\n","lang":"typescript","description":"Shows how to invoke the compiler programmatically with all required options and file I/O."},"warnings":[{"fix":"Update call sites to expect a numeric return value (0 success, -1 failure) instead of a callback.","message":"The main function signature changed between versions: older versions required a callback, now it returns 0/-1.","severity":"breaking","affected_versions":"<1.0"},{"fix":"Ensure the `stdout` option object has `write(s)` and `writeln(s)` methods, even if they are empty functions.","message":"The `stdout` object must implement both `write` and `writeln` methods. Missing either causes a runtime error.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use `outputFile` for the report; the parser is auto-named based on `inputFile`.","message":"The output file is NOT the generated parser; it's a report file containing DFA and parse tables. The parser itself is written to `inputFile` with `.ts` or `.js` extension.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"For testing, use the programmatic API with `testInput` option instead of CLI.","message":"The `-t` CLI option for test input uses a custom format (tokens in <>, raw strings). This is not validated and can produce confusing errors.","severity":"deprecated","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install tscc-compiler` for Node.js, or include `<script src='tscc.min.js'></script>` in HTML.","cause":"Package not installed or used in a browser context without including the script.","error":"Error: Cannot find module 'tscc-compiler'"},{"fix":"Use `import { main } from 'tscc-compiler'` then call `main(...)`, or use `const tscc = require('tscc-compiler'); tscc.main(...)`.","cause":"Attempting to call the default export directly instead of calling `main`.","error":"TypeError: tscc is not a function"},{"fix":"Provide an object with both functions, e.g., `{ write: (s) => process.stdout.write(s), writeln: (s) => console.log(s) }`.","cause":"Missing method in the `stdout` object passed to `main`.","error":"The 'stdout' option must have 'write' and 'writeln' methods."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}