Skip to content

Commit

Permalink
stdlib: temporarily add AST pattern matching (#882)
Browse files Browse the repository at this point in the history
## Summary

Add the `ast_pattern_matching` module to the experimental standard
library. It implements pattern matching for `NimNode` AST and is copied
from https://github.com/krux02/ast-pattern-matching.

The first iteration of the language-server protocol (LSP) implementation
is going to use the pattern matching, but it's likely that the module
will be removed from the standard library again.

## Details

A copy of the `ast-pattern-matching` implementation already existed
within the `tests` directory, where it is used by the `tastpec.nim`
test. The module is moved to the `lib/experimental` directory and the
import is adjusted.
  • Loading branch information
bung87 authored Sep 11, 2023
1 parent 0584b0f commit 704308b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# this is a copy paste implementation of github.com/krux02/ast_pattern_matching
# Please provide bugfixes upstream first before adding them here.
## Implements pattern matching for ``NimNode`` AST. This module is copied
## from https://github.com/krux02/ast-pattern-matching.

import macros, strutils, tables

Expand Down
2 changes: 1 addition & 1 deletion tests/lang_syntax/astspec/tastspec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ joinable: false

# this test should ensure that the AST doesn't change slightly without it getting noticed.

import ../ast_pattern_matching
import experimental/ast_pattern_matching

template expectNimNode(arg: untyped): NimNode = arg
## This template here is just to be injected by `myquote`, so that
Expand Down

0 comments on commit 704308b

Please sign in to comment.