diff --git a/nimterop/build/shell.nim b/nimterop/build/shell.nim index a5d49de..53c0b5f 100644 --- a/nimterop/build/shell.nim +++ b/nimterop/build/shell.nim @@ -323,6 +323,12 @@ proc gitCheckout*(file, outdir: string) = sleep(500) gecho "# Retrying ..." +proc gitAtCheckout*(outdir, checkout: string): bool = + ## Check if specified git repository is checked out to the specified + ## commit hash, tag or branch + result = checkout in execAction( + &"cd {outdir.sanitizePath} && git log --decorate --no-color -n 1 --format=oneline").output + proc gitPull*(url: string, outdir = "", plist = "", checkout = "", quiet = false) = ## Pull the specified git repository to the output directory ## @@ -334,13 +340,17 @@ proc gitPull*(url: string, outdir = "", plist = "", checkout = "", quiet = false ## `checkout` is the git tag, branch or commit hash to checkout once ## the repository is downloaded. This allows for pinning to a specific ## version of the code. - if dirExists(outdir/".git"): - gitReset(outdir) - return - let outdirQ = outdir.sanitizePath + if dirExists(outdir/".git"): + gitReset(outdir) + if checkout.nBl and not gitAtCheckout(outdir, checkout): + gecho &"# Updating repository to checkout {checkout}" + discard execAction( + &"cd {outdirQ} && git clean -fxd && git fetch && git checkout {checkout}", retry = 3) + return + mkDir(outdir) if not quiet: diff --git a/nimterop/globals.nim b/nimterop/globals.nim index a89bac4..c831589 100644 --- a/nimterop/globals.nim +++ b/nimterop/globals.nim @@ -111,7 +111,9 @@ when defined(TOAST): "bitwise_expression", "shift_expression", "math_expression", - "escape_sequence" + "escape_sequence", + "binary_expression", + "unary_expression" ].toHashSet() gEnumVals* {.used.} = @[ diff --git a/nimterop/setup.nim b/nimterop/setup.nim index 998d9e9..a0940d2 100644 --- a/nimterop/setup.nim +++ b/nimterop/setup.nim @@ -7,7 +7,7 @@ proc treesitterSetup*() = gitPull("https://github.com/tree-sitter/tree-sitter", cacheDir / "treesitter", """ lib/include/* lib/src/* -""", "0.15.5") +""", "0.15.14") gitPull("https://github.com/JuliaStrings/utf8proc", cacheDir / "utf8proc", """ *.c @@ -37,7 +37,7 @@ src/*.h src/*.c src/*.cc src/tree_sitter/parser.h -""", "v0.15.0") +""", "v0.15.3") writeFile(cacheDir / "treesitter_c" / "src" / "api.h", """ const TSLanguage *tree_sitter_c(); @@ -49,7 +49,7 @@ src/*.h src/*.c src/*.cc src/tree_sitter/parser.h -""", "v0.15.0") +""", "v0.15.1") writeFile(cacheDir / "treesitter_cpp" / "src" / "api.h", """ const TSLanguage *tree_sitter_cpp(); diff --git a/nimterop/toastlib/ast2.nim b/nimterop/toastlib/ast2.nim index 0016e29..783b6e4 100644 --- a/nimterop/toastlib/ast2.nim +++ b/nimterop/toastlib/ast2.nim @@ -1099,7 +1099,10 @@ proc getTypeProc(gState: State, name: string, node, rnode: TSNode): PNode = ncount = if not afdecl.isNil: # Pointer to function pointer - afdecl[0].getXCount("abstract_pointer_declarator") + if afdecl[0].getName() == "abstract_parenthesized_declarator": + afdecl[0][0].getXCount("abstract_pointer_declarator") + else: + afdecl[0].getXCount("abstract_pointer_declarator") else: node.getAtom().tsNodeParent().getPtrCount(reverse = true) diff --git a/nimterop/toastlib/exprparser.nim b/nimterop/toastlib/exprparser.nim index 28b49d3..13b1a98 100644 --- a/nimterop/toastlib/exprparser.nim +++ b/nimterop/toastlib/exprparser.nim @@ -535,7 +535,7 @@ proc processTSNode(gState: State, node: TSNode, typeofNode: var PNode): PNode = # once we upgrade of "math_expression", "logical_expression", "relational_expression", "bitwise_expression", "equality_expression", "binary_expression", - "shift_expression": + "shift_expression", "unary_expression": # Input -> a == b, a != b, !a, ~a, a < b, a > b, a <= b, a >= b, a >> b, a << b # Output -> # typeof(a)(a == typeof(a)(b))