Skip to content

Releases: alaviss/tree-sitter-nim

0.6.2: ready for WASM

11 Jul 23:56
0.6.2
897e5d3
Compare
Choose a tag to compare

This is a small release to fix compilation against WASM target. This allows the grammar to be used with the Zed text editor.

Implementation improvements

  • Disable error logging when compiled against WASM (#94). This allows the parser to be compiled to WASM and work with applications like Zed.

0.6.1: support new tree-sitter

06 Jul 23:32
0.6.1
bb2f809
Compare
Choose a tag to compare

This is a small release with a tiny grammar fix to keep it working with
future tree-sitter versions.

Grammar improvements

  • Use hint tokens instead of semi-externalizing export marker (#92).
    This change is done to keep the parser compatible with the next
    tree-sitter version and should not have any bearing on parser
    correctness or performance.

0.6.0: custom allocator support

17 Apr 18:34
0.6.0
961c279
Compare
Choose a tag to compare

This is a small release, only updating the tree-sitter base to support
custom allocators.

Implementation improvements

  • Custom allocators are now supported via
    -DTREE_SITTER_REUSE_ALLOCATOR. When set, the library will use
    tree-sitter's current allocator instead of libc's allocator.

  • Binding code is added for: C, Go, Python and Swift.

  • Node and Rust bindings has been updated to the latest version.

0.5.0: feature-complete

30 Dec 06:30
0.5.0
70ceee8
Compare
Choose a tag to compare

Once again, we start with parse statistics:

Total parses: 3987;
successful parses: 3950;
failed parses: 37;
success percentage: 99.07%

This is a big milestone, as right now, the only files that couldn't be
parsed are either invalid Nim (used to test the compiler) and/or Nim
using features that were part of one-off experiments that we decided
not to support.

This parser can now parses 100% of Nim.

Let's dive into the details

Parsing improvements

Grammar improvements

  • Concept declaration without body is now supported.

  • type(x) expressions are now supported. Note that while these
    generates (typeof) node, there are no plans to expand this special
    case beyond top-level in order to match how Nim handles this.

Layout improvements

  • Indentation state of the current parse is now removed from the
    scanner. Instead the scanner will reconstruct this state from the
    token stream. This allowed us to remove the get_column dependency,
    speeding up the parser overall.

0.4.0

11 Dec 23:59
0.4.0
77762e3
Compare
Choose a tag to compare

Per tradition, let's start with parse statistics:

Total parses: 3987;
successful parses: 3943;
failed parses: 44;
success percentage: 98.90%

Nothing too notable this cycle, but we managed to parse a bit more.
While the changes weren't breaking, modifying the layout engine is
rather risky and thus a minor is issued to warn users to test this
version before using in production.

Parsing improvements

Grammar improvements

  • except and finally branches within try expressions are now
    optional (#62). This enabled much better error recovery.

  • Field names for complex structures are made consistent and many was
    added (#69). This should make writing tools interacting with the
    syntax tree a lot easier.

  • Type declaration body is now optional (#72). This is a syntax quirk
    utilized by system.nim.

Layout engine improvements

  • Removed "one-shot termination" hack during error recovery (#72).

  • SYNCHRONIZE syntax node is no longer used to fix scanner state
    (#72). This in theory should cause less errors to happen during
    incremental parsing which would translate to better editing
    experience.

  • Scanner now properly end layout in error states (#72). This delivers
    better error recovery in error states where a layout could not be
    ended (ie. in parentheses).

0.3.0

22 Oct 02:02
0.3.0
bbbbf39
Compare
Choose a tag to compare

This is a huge release, with the parser at 67MiB in size. But we gained
a lot in return.

Starting with parse statistics:

Total parses: 3987;
successful parses: 3939;
failed parses: 48;
success percentage: 98.80%

We are now very close to parsing 99% of the Nim compiler, and that's
including the tests where parsing is supposed to fail.

Let's dive into the big changes:

Breaking changes

  • String and comment content has been spun off into their own nodes
    (#54). In addition to this, string_literal has been specialized into
    interpreted, raw and long variants. This should allow for a much
    easier time writing capture queries.

Parsing improvements

Layout engine improvements (#53)

  • Statements and blocks now terminate as close to their origin as
    possible. This means:

    foo()| <- terminates here
    
    bar()
    ^ instead of here
    
  • Layouts are now ended whenever indentation falls off, which improves
    tree-sitter ability to figure out what error happened.

  • The scanner now properly terminates statements in error recovery,
    which allows for less syntax tree unraveling when such events happens.

  • "Terrible" if/try statements are now handled properly. The
    statements in question usually look like this:

    if x:
      y else: z
    
    try:
      proc foo() =
        something except: bar()
    

    These can be found within the Nim compiler source code.

Grammar improvements (#60)

  • Relaxed rules for generic parameter list and tuple field list. The
    following are now valid:

    proc foo[]()
    
    tuple[]
    

    This is done to align with how the Nim compiler handle these cases.

  • Multi statements term rewriting patterns are now supported.

  • Full support for Unicode identifiers and operators. This support was
    previously removed in 0.0.2, but recent improvements have allowed them
    to return.

0.2.0: scanner translated to C

19 Oct 23:41
0.2.0
a43d806
Compare
Choose a tag to compare

With the tree-sitter project not looking to support C++ scanners in the
long run, the scanner has been translated to C.

This translation was done carefully to not introduce any regression and
is expected to be bug-for-bug compatible with the older version. However
as this could break horribly, I'm opting to issue a new minor version.

With that done, let's dive into parsing statistics:

Total parses: 3987;
successful parses: 3919;
failed parses: 68;
success percentage: 98.29%

We saw a small uptick in number of successful parses, but nothing
out of the ordinary.

Notable changes in this cycle:

Parsing improvements

  • Trailing semicolon in parenthesized expressions are now recognized
    (#47).

Query changes

  • Short raw string opening has been converted to a literal choice (#46).
    This allows query writer to easily distinguish between string
    variants via the opening token.

Implementation changes

  • Complete translation of the scanner to C (#50).

0.1.1: improved error recovery

23 Sep 00:33
0.1.1
4e357b8
Compare
Choose a tag to compare

This is a small bug fixing release.

Let's start with parsing statistics:

Total parses: 3987;
successful parses: 3914;
failed parses: 73;
success percentage: 98.17%

Notable changes of this cycle:

Parsing improvements

  • Added support trailing commas within a symbol declaration list (#39)

Implementation improvements

  • Avoid emitting _layout_empty during error recovery (#40).
    This should provide a large improvement to the syntax tree in light of deeply-nested invalid code.

0.1.0: ready for integration

22 Sep 18:09
0.1.0
35c0245
Compare
Choose a tag to compare

First, a shout out for @aMOPel efforts to write queries to bring this
grammar into https://github.com/nvim-treesitter/nvim-treesitter.

Their work on this allowed the grammar to mature greatly with regards to
grammar node design.

Per tradition, here are the parse statistics against the compiler for
this version:

Total parses: 3987;
successful parses: 3911;
failed parses: 76;
success percentage: 98.09%

This is done from a full clone of the compiler source including extra
code from nimble and atlas.

The parser size grew a little to 47MiB in this release.

Below are notable changes of this cycle:

Breaking changes

  • type_expression is no longer an anonymized node by @aMOPel (#29).
    This allows for an easier time matching against all the nitty gritty
    expressions that can happen within a type context.

Parsing improvements

  • using blocks are now supported by @aMOPel (#31).
  • Long string opening are now matchable tokens by @alaviss (#34).
  • The parsing behavior for *: now matches the compiler by @alaviss (#36).

Regressions

  • Unicode operators remains unsupported as adding them still inflates
    the parser size considerably.

0.0.3: smaller and better parser

28 May 02:59
0.0.3
ecbd15e
Compare
Choose a tag to compare

Per tradition, let's start with parse statistics:

Total parses: 3226;
successful parses: 3154;
failed parses: 72;
success percentage: 97.77%

The parser size is now 46MiB, only 39% the size of the previous release.
This means the parser can finally be placed within the repository, which
has been done in this release.

Below are notable changes of this cycle:

Breaking changes

  • infix and prefix operators are now unified under the operator
    node.
  • The _ identifier has been split from identifier into
    blank_identifier.
  • tuple_deconstruct_declaration no longer has a child
    symbol_declaration_list. The list contents will now be direct
    children of tuple_deconstruct_declaration.
  • modified_type has been removed in favor of var_type, ref_type,
    etc. directly.

Parsing improvements

  • defer blocks are now supported.
  • pragma expressions precedence has been fixed. Previously they are
    stronger than even an unary expression, now they're on the bottom
    of the chain, similar to the compiler.
  • do blocks can now have pragmas attached to them.

Implementation improvements

  • ), ], } and .} is no longer externalized. This reduced the
    parser size considerably with no loss of functionality.
  • routine expressions are now defined as an extension of their type
    counterpart. This allowed state merging from the parser and reduced
    parser size considerably.

Regressions

  • Unicode operators remains unsupported as adding them still inflates
    the parser size considerably.