Skip to content

0.3.0

Compare
Choose a tag to compare
@alaviss alaviss released this 22 Oct 02:02
· 42 commits to main since this release
0.3.0
bbbbf39

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.