- Added
extractExamples
to theextras
module, which can extract example inputs — written with a special comment syntax — from grammar definitions.
- [c2e552d]: Add
_buildGrammar
back to exports. (It's a private API used by the Ohm Editor.) - [4d9ee89]: Ensure
ohm.version
reports the correct value. Due to a change in the build scripts, it was stuck at '17.0.0'.
- [#424]:
any
now consumes an entire code point (i.e., a full Unicode character), not just a single, 16-bit code unit. - [55c787b]: The namespace helpers (
namespace
,extendNamespace
) have been removed. (These were always optional.) - [bea0be9]: When used as an ES module, the main 'ohm-js' module now has only named exports (i.e., no default export). The same is true for
ohm-js/extras
. - [#395]: In generated type definitions, action dictionary types now inherit from
BaseActionDict<T>
, a new supertype ofActionDict<T>
. - [9e32f8d]:
ohm.util
is removed from the public API.getLineAndColumn
andgetLineAndColumn
have been moved into theextras
module. - [#398]: Changed the default behavior
toAST
for the built-in list rules (ListOf
and friends). Both the syntactic (ListOf
, ...) and lexical versions (listOf
, ...) are now represented as arrays, with the separators discarded. Previously, the syntactic versions were represented by arrays, but with separators included, and the lexical versions were represented as strings (just like other lexical rules).
- [#416]: Fix crash when calling
toString
on a non-root node - [13c8991]: The deprecated
grammarFromScriptElement
andgrammarsFromScriptElements
functions have been entirely removed. - Improvements to the TypeScript types:
- [#407]: Added types for the built-in
asIteration
operation - [#410]: Added types for
Interval.getLineAndColumn
- [#407]: Added types for the built-in
- [#368]: The
primitiveValue
property of nodes, which was deprecated in Ohm v16, has now been completely removed.
- [#390] Added type information for ohm.pexprs
(Same as 16.3.3)
- [#374] Fixed incorrect type annotation for Node.isOptional()
- [#370] Fix ohmjs/ohm-editor#72 - grammars with super-splice (...) not working in the Ohm Editor
- [#368]: The (undocumented)
toJSON()
method of nodes has been removed. It was originally intended to support an experimental feature of the Ohm Editor.
- [#366]: Fix #363 by removing imports of ohm-js from extras (it’s not required)
- Added support for ES6-style Unicode code point escapes (
\u{...}
) inside terminal expressions. This can be used to specify code points above0xFFFF
. - Range expressions can now match a single code point, rather than being limited to a single, 16-bit code unit. E.g.,
"😇".."😈"
is now a valid range expression.
- [#357] The "wrong number of arguments for rule" error message now includes the line and column where the error occurred.
- [#350] Added full support for importing Ohm as an ES module.
- [#344] Removed circular dependencies between core modules, allowing Ohm to be built with Rollup.
- Added [
applySyntactic
][], a built-in rule to allow application of a syntactic rule from a lexical context (see #136 for details).
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.
API
- [2519de5]
grammarFromScriptElement
andgrammarsFromScriptElements
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 singleNode[]
argument. Release notes: args to _iter and _nonterminal actions. - (TypeScript only): On semantics objects, the methods
addOperation
,extendOperation
,addAttribute
, andextendAttribute
now have a required type parameter, which is the return type of the operation (or the type of the attribute). The related typesAction
andActionDict
are similarly parameterized by the return type of the semantic actions. Release notes: type parameters for operations and actions.
- [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.
- [0af8165] Fixed an off-by-one error in Node.hasChildren(), where it returned false for nodes with a single child.
(Same as 15.4.0)
- [15c63a9] Added a toString() method to the object returned from getLineAndColumn().
- [b39b4f6] Added
getLineAndColumn
method toInterval
. - [255693c] Fixed #282: Single-line comments can't appear after case name
- [b519a05] Added a new super-splice operator (
...
) to the Ohm language, which can be used to append and/or prepend cases to a supergrammar rule body.
(Same as 15.2.0)
- [1986ee2] Eliminated dependency on 'inherits' package
- [e5fa522] Moved TypeScript dependencies to devDependencies
- [7fe5b7c] Removed the dependency on the es6-symbol package
- [5b15169] Converted the Ohm codebase to more modern JS, and switched from Browserify to Webpack for bundling. (#264)
The first official stable release of Ohm! 🌭🎉
Going forward, Ohm will follow the semantic versioning convention.
This means that breaking changes to either the language or the API will only be introduced
in a new major version of the ohm-js
package.
(Same as 15.0.0.)
API
Features:
- [1c286f6] The
message
andshortMessage
properties of errors are now enumerable. - [dec2846] Added a TypeScript type definition file (d.ts) for the extras submodule (#214)
- [369a1de] Prevent infinite loops during parsing, by throwing an error if a repetition expression consumes no input. (#211)
Fixes:
- [7857b8f] Fixed
npm install
issue with the 15.0.0 release (#260) - [8202eff] Switched to Buffer.from, as
new Buffer
is deprecated in Node v10. - [59b28be] CaseInsensitiveTerminal.toFailure() now passes the grammar arg through.
- [b9499e2] Crash w/ ERR_INVALID_CALLBACK in Node v10.0.0.
- [db8573c] Undefined errors with nested expression toFailure(...) (#218)
API
- [753dc4d] Ohm's version number is now exposed as a top-level 'version' property
- [c5d7046] missingSemanticAction errors include an action call stack
- [f06ccbb] Range expressions now only work with single-character terminals. E.g.,
"a".."z"
is valid but"foo".."bar"
is not.
Big stuff
- Ohm now supports incremental parsing! See the new Matcher class, which
can be instantiated for a grammar
g
viag.matcher()
.
Language
- [75d1bc8] Update built-in
lower
,upper
, andunicodeLtmo
rules to be consistent with unicode-9.0.0 - [4f864a0] Add built-in rule
caseInsensitive
rule for case-insensitive string matching (fixes #162)
API
- [b63aa84] Remove MatchResult.prototype.getDiscardedSpaces()
- [7b455d2] Remove
children
andchildOffset
from TerminalNodes (fixes #176)
Misc
- [865c948] Add Typescript type declarations (#187)
- [798ea77] Show action call stack when a semantic action is missing (fixes #53)
- [482b693] Add VisitorFamily to extras (#156)
- [17d1e32]: Grammar.prototype.semantics renamed to
createSemantics
. - [e98ba04]: Combine ruleBodies, ruleFormals, ruleDescriptions properties of Grammar objects into a single 'rules' property.
- [555dc22, 6ef0bce, 17ee66f]: The 'interval' property of CST nodes & semantic wrappers is now called 'source'.
- [7b34725]: Add 'sourceString' property to Wrappers, as an alias for
source.contents
(formerlyinterval.contents
) - [7797eba]: Grammar recipe format is now pure JSON, rather than JavaScript source.
Language
- [5d972f6]: Inline rule declarations are now only allowed in top-level alternation nodes.
- Previously, the grammar allowed inline rule declarations in any alternation, but it only really makes sense at the top level.
- [fdf4381]: Matching on structured data (Objects, Arrays, etc.) is no longer supported.
- This was a feature that Ohm inherited from OMeta, but we found that we almost never used it in Ohm. Removing it allows significant simplification to the language, code, and documentation.
API
- [e497d47]: Like grammars, Semantics instances now have a
toRecipe
method
Language
- [3ce66ea]: Allow leading pipe in rule bodies (suggested by Jason Merrill).
- In rule definitions, the body may optionally begin with a
|
character, which will be ignored.
- In rule definitions, the body may optionally begin with a
- [761d6ef]:
ListOf_some
andListOf_none
renamed toNonemptyListOf
andEmptyListOf
. - [c548f01]: The built-in
spaces_
rule has been renamed tospaces
.
API
- [22ff905]: No more default semantic action for _terminal.
- To duplicate the old behavior, you can write a "_terminal" semantic action that just
returns
this.primitiveValue
, as in the math example.
- To duplicate the old behavior, you can write a "_terminal" semantic action that just
returns
- [8efa687]: Expose pexprs as part of the public API (
ohm.pexprs
). - #63: Semantics instances now include a built-in attribute named 'asIteration'.
- This simplifies working with the built-in
ListOf
rule. - Needs documentation (#93)
- This simplifies working with the built-in
- [7590d82]: Add "extras" module, with toAST() operation.
- See the documentation for more information.
- [e24a146]: New
isOptional
method on parse nodes.- See the documentation for more information.
- [64ee822]: New
getDiscardedSpaces
method on MatchResult, which makes Alex happy.- Needs documentation (#92)