Skip to content

Ohm v16.0.0

Compare
Choose a tag to compare
@pdubroy pdubroy released this 02 Oct 05:09

NPM
Browser bundles: ohm.jsohm.min.js

Ohm v16 is primarily about improving the experience of using Ohm with TypeScript. In order to do that, we needed to make some minor breaking changes. With the major version change, we also took the opportunity to clean up and simplify some parts of the API.

All of the breaking changes are described below. For more information about how to modify your existing code to work with Ohm v16, see the upgrade guide.

Breaking changes:

API

  • [2519de5] grammarFromScriptElement and grammarsFromScriptElements have been removed.
  • [74ff254] The ohm-js package now requires an ES2017 environment. This means that very old browsers (e.g., Internet Explorer and Edge 14 and below) are no longer supported. See caniuse for an overview.
  • There is no longer a default semantic action for iteration nodes. Release notes: default semantic actions.
  • The _iter and _nonterminal actions now take a variable number of arguments, rather than a single Node[] argument. Release notes: args to _iter and _nonterminal actions.
  • (TypeScript only): On semantics objects, the methods addOperation, extendOperation, addAttribute, and extendAttribute now have a required type parameter, which is the return type of the operation (or the type of the attribute). The related types Action and ActionDict are similarly parameterized by the return type of the semantic actions. Release notes: type parameters for operations and actions.

Other notable changes:

  • [7d69cde] Node.primitiveValue is now deprecated — Node.sourceString is equivalent, and should be used instead.
  • Improvements and additions to the TypeScript declarations (index.d.ts) to make them more accurate and comprehensive.
  • [37a2091] The generateExample method has been removed from the PExpr class. (It was never part of Ohm's public API.)
  • [bcbb864] Removed the ohm-js executable, as it was only ever intended for internal use. The new @ohm-js/cli package can now be used to generate grammar bundles.