Unvendor tree-sitter-cmake

pull/884/head
Antonin Delpeuch 2025-09-30 20:48:16 +07:00 committed by Wilfred Hughes
parent 0c2ba27886
commit 595eca2edb
55 changed files with 14 additions and 26211 deletions

11
Cargo.lock generated

@ -275,6 +275,7 @@ dependencies = [
"tree-sitter-bash",
"tree-sitter-c",
"tree-sitter-c-sharp",
"tree-sitter-cmake",
"tree-sitter-cpp",
"tree-sitter-css",
"tree-sitter-elixir",
@ -1029,6 +1030,16 @@ dependencies = [
"tree-sitter-language",
]
[[package]]
name = "tree-sitter-cmake"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c1b35d1dd7396d24b3e826bb0f975b915ec7e9125b989d5e9d24ebb6a08509a"
dependencies = [
"cc",
"tree-sitter-language",
]
[[package]]
name = "tree-sitter-cpp"
version = "0.23.4"

@ -79,6 +79,7 @@ tree-sitter-language = "0.1.3"
tree-sitter-bash = "0.23.3"
tree-sitter-c = "0.23.4"
tree-sitter-c-sharp = "0.23.1"
tree-sitter-cmake = "0.7.1"
tree-sitter-cpp = "0.23.4"
tree-sitter-css = "0.23.1"
tree-sitter-elixir = "0.3.4"

@ -77,11 +77,6 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-clojure-src",
extra_files: vec![],
},
TreeSitterParser {
name: "tree-sitter-cmake",
src_dir: "vendored_parsers/tree-sitter-cmake-src",
extra_files: vec!["scanner.c"],
},
TreeSitterParser {
name: "tree-sitter-commonlisp",
src_dir: "vendored_parsers/tree-sitter-commonlisp-src",

@ -72,7 +72,6 @@ extern "C" {
fn tree_sitter_ada() -> ts::Language;
fn tree_sitter_apex() -> ts::Language;
fn tree_sitter_clojure() -> ts::Language;
fn tree_sitter_cmake() -> ts::Language;
fn tree_sitter_commonlisp() -> ts::Language;
fn tree_sitter_dart() -> ts::Language;
fn tree_sitter_devicetree() -> ts::Language;
@ -212,7 +211,8 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
}
}
CMake => {
let language = unsafe { tree_sitter_cmake() };
let language_fn = tree_sitter_cmake::LANGUAGE;
let language = tree_sitter::Language::new(language_fn);
TreeSitterConfig {
language: language.clone(),
atom_nodes: ["argument"].into_iter().collect(),

@ -34,8 +34,6 @@
"$"
"{"
"}"
"<"
">"
] @punctuation.special
[

@ -1 +0,0 @@
tree-sitter-cmake/src

@ -1,39 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{json,toml,yml,gyp}]
indent_style = space
indent_size = 2
[*.js]
indent_style = space
indent_size = 2
[*.rs]
indent_style = space
indent_size = 4
[*.{c,cc,h}]
indent_style = space
indent_size = 4
[*.{py,pyi}]
indent_style = space
indent_size = 4
[*.swift]
indent_style = space
indent_size = 4
[*.go]
indent_style = tab
indent_size = 8
[Makefile]
indent_style = tab
indent_size = 8

@ -1,11 +0,0 @@
* text eol=lf
src/*.json linguist-generated
src/parser.c linguist-generated
src/tree_sitter/* linguist-generated
bindings/** linguist-generated
binding.gyp linguist-generated
setup.py linguist-generated
Makefile linguist-generated
Package.swift linguist-generated

@ -1,132 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# Ignore lock file
package-lock.json
# Tree sitter generated files
parser.exp
parser.lib
parser.obj
scanner.obj
# Rust files
target/**
Cargo.lock
#pnpm
pnpm-lock.yaml

@ -1,26 +0,0 @@
[package]
name = "tree-sitter-cmake"
description = "cmake grammar for the tree-sitter parsing library"
version = "0.4.3"
keywords = ["incremental", "parsing", "cmake"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/uyha/tree-sitter-cmake"
edition = "2018"
license = "MIT"
build = "bindings/rust/build.rs"
include = [
"bindings/rust/*",
"grammar.js",
"queries/*",
"src/*",
]
[lib]
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = ">=0.22"
[build-dependencies]
cc = "1.0"

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2021 Uy Ha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -1,109 +0,0 @@
VERSION := 0.0.1
LANGUAGE_NAME := tree-sitter-cmake
# repository
SRC_DIR := src
PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null)
ifeq ($(PARSER_URL),)
PARSER_URL := $(subst .git,,$(PARSER_REPO_URL))
ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),)
PARSER_URL := $(subst :,/,$(PARSER_URL))
PARSER_URL := $(subst git@,https://,$(PARSER_URL))
endif
endif
TS ?= tree-sitter
# ABI versioning
SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION)))
SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION)))
# install directory layout
PREFIX ?= /usr/local
INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
PCLIBDIR ?= $(LIBDIR)/pkgconfig
# object files
OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c))
# flags
ARFLAGS := rcs
override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC
# OS-specific bits
ifeq ($(OS),Windows_NT)
$(error "Windows is not supported")
else ifeq ($(shell uname),Darwin)
SOEXT = dylib
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl,
ifneq ($(ADDITIONAL_LIBS),)
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS),
endif
LINKSHARED := $(LINKSHARED)-install_name,$(LIBDIR)/lib$(LANGUAGE_NAME).$(SONAME_MAJOR).dylib,-rpath,@executable_path/../Frameworks
else
SOEXT = so
SOEXTVER_MAJOR = so.$(SONAME_MAJOR)
SOEXTVER = so.$(SONAME_MAJOR).$(SONAME_MINOR)
LINKSHARED := $(LINKSHARED)-shared -Wl,
ifneq ($(ADDITIONAL_LIBS),)
LINKSHARED := $(LINKSHARED)$(ADDITIONAL_LIBS)
endif
LINKSHARED := $(LINKSHARED)-soname,lib$(LANGUAGE_NAME).so.$(SONAME_MAJOR)
endif
ifneq ($(filter $(shell uname),FreeBSD NetBSD DragonFly),)
PCLIBDIR := $(PREFIX)/libdata/pkgconfig
endif
all: lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT) $(LANGUAGE_NAME).pc
lib$(LANGUAGE_NAME).a: $(OBJS)
$(AR) $(ARFLAGS) $@ $^
lib$(LANGUAGE_NAME).$(SOEXT): $(OBJS)
$(CC) $(LDFLAGS) $(LINKSHARED) $^ $(LDLIBS) -o $@
ifneq ($(STRIP),)
$(STRIP) $@
endif
$(LANGUAGE_NAME).pc: bindings/c/$(LANGUAGE_NAME).pc.in
sed -e 's|@URL@|$(PARSER_URL)|' \
-e 's|@VERSION@|$(VERSION)|' \
-e 's|@LIBDIR@|$(LIBDIR)|' \
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
-e 's|@REQUIRES@|$(REQUIRES)|' \
-e 's|@ADDITIONAL_LIBS@|$(ADDITIONAL_LIBS)|' \
-e 's|=$(PREFIX)|=$${prefix}|' \
-e 's|@PREFIX@|$(PREFIX)|' $< > $@
$(SRC_DIR)/parser.c: grammar.js
$(TS) generate --no-bindings
install: all
install -Dm644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
install -Dm644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
install -Dm755 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR)
ln -sf lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT)
uninstall:
$(RM) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER) \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER_MAJOR) \
'$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXT) \
'$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h \
'$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
clean:
$(RM) $(OBJS) $(LANGUAGE_NAME).pc lib$(LANGUAGE_NAME).a lib$(LANGUAGE_NAME).$(SOEXT)
test:
$(TS) test
.PHONY: all install uninstall clean test

@ -1,48 +0,0 @@
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "TreeSitterCmake",
platforms: [.macOS(.v10_13), .iOS(.v11)],
products: [
.library(name: "TreeSitterCmake", targets: ["TreeSitterCmake"]),
],
dependencies: [],
targets: [
.target(name: "TreeSitterCmake",
path: ".",
exclude: [
"Cargo.toml",
"Makefile",
"binding.gyp",
"bindings/c",
"bindings/go",
"bindings/node",
"bindings/python",
"bindings/rust",
"prebuilds",
"grammar.js",
"package.json",
"package-lock.json",
"pyproject.toml",
"setup.py",
"test",
"examples",
".editorconfig",
".github",
".gitignore",
".gitattributes",
".gitmodules",
],
sources: [
"src/parser.c",
// NOTE: if your language has an external scanner, add it here.
],
resources: [
.copy("queries")
],
publicHeadersPath: "bindings/swift",
cSettings: [.headerSearchPath("src")])
],
cLanguageStandard: .c11
)

@ -1,31 +0,0 @@
==============================
A Tree-sitter parser for CMake
==============================
This project provides a `cmake` parser. Its primary use case is to provide a `cmake` parser for `nvim-treesitter`.
Parsed syntax
=============
- Command
- General commands
- For and while loops
- If conditions
- Functions and macros
- Arguments
- Quoted arguments
- Bracket arguments
- Unquoted arguments
- Parentheses
- Variable refences
- Environment and cache variables
- Normal variables
- Generator expression

@ -1,21 +0,0 @@
{
"targets": [
{
"target_name": "tree_sitter_cmake_binding",
"dependencies": [
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api_except",
],
"include_dirs": [
"src",
],
"sources": [
"bindings/node/binding.cc",
"src/parser.c",
# NOTE: if your language has an external scanner, add it here.
],
"cflags_c": [
"-std=c11",
],
}
]
}

@ -1,16 +0,0 @@
#ifndef TREE_SITTER_CMAKE_H_
#define TREE_SITTER_CMAKE_H_
typedef struct TSLanguage TSLanguage;
#ifdef __cplusplus
extern "C" {
#endif
const TSLanguage *tree_sitter_cmake(void);
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_CMAKE_H_

@ -1,11 +0,0 @@
prefix=@PREFIX@
libdir=@LIBDIR@
includedir=@INCLUDEDIR@
Name: tree-sitter-cmake
Description: Cmake grammar for tree-sitter
URL: @URL@
Version: @VERSION@
Requires: @REQUIRES@
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-cmake
Cflags: -I${includedir}

@ -1,13 +0,0 @@
package tree_sitter_cmake
// #cgo CFLAGS: -std=c11 -fPIC
// #include "../../src/parser.c"
// // NOTE: if your language has an external scanner, add it here.
import "C"
import "unsafe"
// Get the tree-sitter Language for this grammar.
func Language() unsafe.Pointer {
return unsafe.Pointer(C.tree_sitter_cmake())
}

@ -1,15 +0,0 @@
package tree_sitter_cmake_test
import (
"testing"
tree_sitter "github.com/smacker/go-tree-sitter"
"github.com/tree-sitter/tree-sitter-cmake"
)
func TestCanLoadGrammar(t *testing.T) {
language := tree_sitter.NewLanguage(tree_sitter_cmake.Language())
if language == nil {
t.Errorf("Error loading Cmake grammar")
}
}

@ -1,5 +0,0 @@
module github.com/tree-sitter/tree-sitter-cmake
go 1.22
require github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8

@ -1,20 +0,0 @@
#include <napi.h>
typedef struct TSLanguage TSLanguage;
extern "C" TSLanguage *tree_sitter_cmake();
// "tree-sitter", "language" hashed with BLAKE2
const napi_type_tag LANGUAGE_TYPE_TAG = {
0x8AF2E5212AD58ABF, 0xD5006CAD83ABBA16
};
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports["name"] = Napi::String::New(env, "cmake");
auto language = Napi::External<TSLanguage>::New(env, tree_sitter_cmake());
language.TypeTag(&LANGUAGE_TYPE_TAG);
exports["language"] = language;
return exports;
}
NODE_API_MODULE(tree_sitter_cmake_binding, Init)

@ -1,28 +0,0 @@
type BaseNode = {
type: string;
named: boolean;
};
type ChildNode = {
multiple: boolean;
required: boolean;
types: BaseNode[];
};
type NodeInfo =
| (BaseNode & {
subtypes: BaseNode[];
})
| (BaseNode & {
fields: { [name: string]: ChildNode };
children: ChildNode[];
});
type Language = {
name: string;
language: unknown;
nodeTypeInfo: NodeInfo[];
};
declare const language: Language;
export = language;

@ -1,7 +0,0 @@
const root = require("path").join(__dirname, "..", "..");
module.exports = require("node-gyp-build")(root);
try {
module.exports.nodeTypeInfo = require("../../src/node-types.json");
} catch (_) {}

@ -1,5 +0,0 @@
"Cmake grammar for tree-sitter"
from ._binding import language
__all__ = ["language"]

@ -1,27 +0,0 @@
#include <Python.h>
typedef struct TSLanguage TSLanguage;
TSLanguage *tree_sitter_cmake(void);
static PyObject* _binding_language(PyObject *self, PyObject *args) {
return PyLong_FromVoidPtr(tree_sitter_cmake());
}
static PyMethodDef methods[] = {
{"language", _binding_language, METH_NOARGS,
"Get the tree-sitter language for this grammar."},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "_binding",
.m_doc = NULL,
.m_size = -1,
.m_methods = methods
};
PyMODINIT_FUNC PyInit__binding(void) {
return PyModule_Create(&module);
}

@ -1,19 +0,0 @@
fn main() {
let src_dir = std::path::Path::new("src");
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
c_config.file(&parser_path);
let scanner_path = src_dir.join("scanner.c");
c_config.file(&scanner_path);
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
c_config.compile("parser");
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
}

@ -1,52 +0,0 @@
//! This crate provides cmake language support for the [tree-sitter][] parsing library.
//!
//! Typically, you will use the [language][language func] function to add this language to a
//! tree-sitter [Parser][], and then use the parser to parse some code:
//!
//! ```
//! let code = "";
//! let mut parser = tree_sitter::Parser::new();
//! parser.set_language(tree_sitter_cmake::language()).expect("Error loading cmake grammar");
//! let tree = parser.parse(code, None).unwrap();
//! ```
//!
//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
//! [language func]: fn.language.html
//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
//! [tree-sitter]: https://tree-sitter.github.io/
use tree_sitter::Language;
extern "C" {
fn tree_sitter_cmake() -> Language;
}
/// Get the tree-sitter [Language][] for this grammar.
///
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
pub fn language() -> Language {
unsafe { tree_sitter_cmake() }
}
/// The content of the [`node-types.json`][] file for this grammar.
///
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
// Uncomment these to include any queries that this grammar contains
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
#[cfg(test)]
mod tests {
#[test]
fn test_can_load_grammar() {
let mut parser = tree_sitter::Parser::new();
parser
.set_language(super::language())
.expect("Error loading cmake language");
}
}

@ -1,16 +0,0 @@
#ifndef TREE_SITTER_CMAKE_H_
#define TREE_SITTER_CMAKE_H_
typedef struct TSLanguage TSLanguage;
#ifdef __cplusplus
extern "C" {
#endif
const TSLanguage *tree_sitter_cmake(void);
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_CMAKE_H_

@ -1,109 +0,0 @@
commands = [
"if",
"elseif",
"else",
"endif",
"foreach",
"endforeach",
"while",
"endwhile",
"function",
"endfunction",
"macro",
"endmacro",
"block",
"endblock",
];
module.exports = grammar({
name: "cmake",
externals: ($) => [$.bracket_argument, $.bracket_comment, $.line_comment],
extras: (_) => [],
rules: {
source_file: ($) => repeat($._untrimmed_command_invocation),
escape_sequence: ($) => choice($._escape_identity, $._escape_encoded, $._escape_semicolon),
_escape_identity: (_) => /\\[^A-Za-z0-9;]/,
_escape_encoded: (_) => choice("\\t", "\\r", "\\n"),
_escape_semicolon: (_) => choice(";", "\\;"),
variable: ($) => prec.left(repeat1(choice(/[a-zA-Z0-9/_.+-]/, $.escape_sequence, $.variable_ref))),
variable_ref: ($) => choice($.normal_var, $.env_var, $.cache_var),
normal_var: ($) => seq("$", "{", $.variable, "}"),
env_var: ($) => seq("$", "ENV", "{", $.variable, "}"),
cache_var: ($) => seq("$", "CACHE", "{", $.variable, "}"),
gen_exp: ($) => seq("$", "<", optional($._gen_exp_content), ">"),
_gen_exp_content: ($) => seq($.argument, optional($._gen_exp_arguments)),
_gen_exp_arguments: ($) => seq(":", repeat(seq($.argument, optional(/[,;]/)))),
argument: ($) => choice($.bracket_argument, $.quoted_argument, $.unquoted_argument),
_untrimmed_argument: ($) => choice(/\s/, $.bracket_comment, $.line_comment, $.argument, $._paren_argument),
_paren_argument: ($) => seq("(", repeat($._untrimmed_argument), ")"),
quoted_argument: ($) => seq('"', optional($.quoted_element), '"'),
quoted_element: ($) => repeat1(choice($.variable_ref, $.gen_exp, $._quoted_text, $.escape_sequence)),
_quoted_text: (_) => prec.left(repeat1(choice("$", /[^\\"]/))),
unquoted_argument: ($) =>
prec.right(repeat1(choice($.variable_ref, $.gen_exp, $._unquoted_text, $.escape_sequence))),
_unquoted_text: (_) => prec.left(repeat1(choice("$", /[^()#"\\]/))),
body: ($) => prec.right(repeat1($._untrimmed_command_invocation)),
argument_list: ($) => repeat1($._untrimmed_argument),
if_command: ($) => command($.if, $.argument_list),
elseif_command: ($) => command($.elseif, $.argument_list),
else_command: ($) => command($.else, optional($.argument_list)),
endif_command: ($) => command($.endif, optional($.argument_list)),
if_condition: ($) => seq($.if_command, repeat(choice($.body, $.elseif_command, $.else_command)), $.endif_command),
foreach_command: ($) => command($.foreach, $.argument_list),
endforeach_command: ($) => command($.endforeach, optional($.argument)),
foreach_loop: ($) => seq($.foreach_command, $.body, $.endforeach_command),
while_command: ($) => command($.while, $.argument_list),
endwhile_command: ($) => command($.endwhile, optional(seq(/\s*/, $.argument, /\s*/))),
while_loop: ($) => seq($.while_command, $.body, $.endwhile_command),
function_command: ($) => command($.function, $.argument_list),
endfunction_command: ($) => command($.endfunction, optional($.argument_list)),
function_def: ($) => seq($.function_command, $.body, $.endfunction_command),
macro_command: ($) => command($.macro, $.argument_list),
endmacro_command: ($) => command($.endmacro, optional($.argument_list)),
macro_def: ($) => seq($.macro_command, $.body, $.endmacro_command),
block_command: ($) => command($.block, $.argument_list),
endblock_command: ($) => command($.endblock, optional($.argument_list)),
block_def: ($) => seq($.block_command, $.body, $.endblock_command),
normal_command: ($) => command($.identifier, optional($.argument_list)),
_command_invocation: ($) =>
choice($.normal_command, $.if_condition, $.foreach_loop, $.while_loop, $.function_def, $.macro_def, $.block_def),
_untrimmed_command_invocation: ($) => choice(/\s/, $.bracket_comment, $.line_comment, $._command_invocation),
...commandNames(...commands),
identifier: (_) => /[A-Za-z_][A-Za-z0-9_]*/,
integer: (_) => /[+-]*\d+/,
},
});
function iregex(s) {
return new RegExp(Array.from(s).reduce((acc, value) => acc + `[${value.toLowerCase()}${value.toUpperCase()}]`, ""));
}
function commandName(name) {
return { [name]: (_) => iregex(name) };
}
function commandNames(...names) {
return Object.assign({}, ...names.map(commandName));
}
function command(name_rule, arg_rule) {
return seq(name_rule, repeat(/[\t ]/), "(", arg_rule, ")");
}

@ -1,46 +0,0 @@
{
"name": "tree-sitter-cmake",
"version": "0.4.3",
"description": "CMake grammar for tree-sitter",
"main": "bindings/node",
"types": "bindings/node",
"author": "Uy Ha",
"license": "MIT",
"dependencies": {
"node-addon-api": "^7.1.0",
"node-gyp-build": "^4.8.0"
},
"peerDependencies": {
"tree-sitter": "^0.21.0"
},
"peerDependenciesMeta": {
"tree_sitter": {
"optional": true
}
},
"tree-sitter": [
{
"scope": "source.cmake",
"file-types": [
"cmake",
"CMakeLists.txt"
]
}
],
"devDependencies": {
"tree-sitter-cli": "^0.21.0",
"prebuildify": "^6.0.0"
},
"scripts": {
"install": "node-gyp-build",
"prebuildify": "prebuildify --napi --strip"
},
"files": [
"grammar.js",
"binding.gyp",
"prebuilds/**",
"bindings/node/*",
"queries/*",
"src/**"
]
}

@ -1,29 +0,0 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "tree-sitter-cmake"
description = "Cmake grammar for tree-sitter"
version = "0.0.1"
keywords = ["incremental", "parsing", "tree-sitter", "cmake"]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Compilers",
"Topic :: Text Processing :: Linguistic",
"Typing :: Typed"
]
requires-python = ">=3.8"
license.text = "MIT"
readme = "README.md"
[project.urls]
Homepage = "https://github.com/tree-sitter/tree-sitter-cmake"
[project.optional-dependencies]
core = ["tree-sitter~=0.21"]
[tool.cibuildwheel]
build = "cp38-*"
build-frontend = "build"

@ -1,57 +0,0 @@
from os.path import isdir, join
from platform import system
from setuptools import Extension, find_packages, setup
from setuptools.command.build import build
from wheel.bdist_wheel import bdist_wheel
class Build(build):
def run(self):
if isdir("queries"):
dest = join(self.build_lib, "tree_sitter_cmake", "queries")
self.copy_tree("queries", dest)
super().run()
class BdistWheel(bdist_wheel):
def get_tag(self):
python, abi, platform = super().get_tag()
if python.startswith("cp"):
python, abi = "cp38", "abi3"
return python, abi, platform
setup(
packages=find_packages("bindings/python"),
package_dir={"": "bindings/python"},
package_data={
"tree_sitter_cmake": ["*.pyi", "py.typed"],
"tree_sitter_cmake.queries": ["*.scm"],
},
ext_package="tree_sitter_cmake",
ext_modules=[
Extension(
name="_binding",
sources=[
"bindings/python/tree_sitter_cmake/binding.c",
"src/parser.c",
# NOTE: if your language uses an external scanner, add it here.
],
extra_compile_args=(
["-std=c11"] if system() != 'Windows' else []
),
define_macros=[
("Py_LIMITED_API", "0x03080000"),
("PY_SSIZE_T_CLEAN", None)
],
include_dirs=["src"],
py_limited_api=True,
)
],
cmdclass={
"build": Build,
"bdist_wheel": BdistWheel
},
zip_safe=False
)

File diff suppressed because it is too large Load Diff

@ -1,877 +0,0 @@
[
{
"type": "argument",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "bracket_argument",
"named": true
},
{
"type": "quoted_argument",
"named": true
},
{
"type": "unquoted_argument",
"named": true
}
]
}
},
{
"type": "argument_list",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "argument",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "line_comment",
"named": true
}
]
}
},
{
"type": "block_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "block",
"named": true
}
]
}
},
{
"type": "block_def",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "block_command",
"named": true
},
{
"type": "body",
"named": true
},
{
"type": "endblock_command",
"named": true
}
]
}
},
{
"type": "body",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "block_def",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "foreach_loop",
"named": true
},
{
"type": "function_def",
"named": true
},
{
"type": "if_condition",
"named": true
},
{
"type": "line_comment",
"named": true
},
{
"type": "macro_def",
"named": true
},
{
"type": "normal_command",
"named": true
},
{
"type": "while_loop",
"named": true
}
]
}
},
{
"type": "cache_var",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "variable",
"named": true
}
]
}
},
{
"type": "else_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "else",
"named": true
}
]
}
},
{
"type": "elseif_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "elseif",
"named": true
}
]
}
},
{
"type": "endblock_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "endblock",
"named": true
}
]
}
},
{
"type": "endforeach_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument",
"named": true
},
{
"type": "endforeach",
"named": true
}
]
}
},
{
"type": "endfunction_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "endfunction",
"named": true
}
]
}
},
{
"type": "endif_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "endif",
"named": true
}
]
}
},
{
"type": "endmacro_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "endmacro",
"named": true
}
]
}
},
{
"type": "endwhile_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument",
"named": true
},
{
"type": "endwhile",
"named": true
}
]
}
},
{
"type": "env_var",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "variable",
"named": true
}
]
}
},
{
"type": "escape_sequence",
"named": true,
"fields": {}
},
{
"type": "foreach_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "foreach",
"named": true
}
]
}
},
{
"type": "foreach_loop",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "body",
"named": true
},
{
"type": "endforeach_command",
"named": true
},
{
"type": "foreach_command",
"named": true
}
]
}
},
{
"type": "function_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "function",
"named": true
}
]
}
},
{
"type": "function_def",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "body",
"named": true
},
{
"type": "endfunction_command",
"named": true
},
{
"type": "function_command",
"named": true
}
]
}
},
{
"type": "gen_exp",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "argument",
"named": true
}
]
}
},
{
"type": "if_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "if",
"named": true
}
]
}
},
{
"type": "if_condition",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "body",
"named": true
},
{
"type": "else_command",
"named": true
},
{
"type": "elseif_command",
"named": true
},
{
"type": "endif_command",
"named": true
},
{
"type": "if_command",
"named": true
}
]
}
},
{
"type": "macro_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "macro",
"named": true
}
]
}
},
{
"type": "macro_def",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "body",
"named": true
},
{
"type": "endmacro_command",
"named": true
},
{
"type": "macro_command",
"named": true
}
]
}
},
{
"type": "normal_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "identifier",
"named": true
}
]
}
},
{
"type": "normal_var",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "variable",
"named": true
}
]
}
},
{
"type": "quoted_argument",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "quoted_element",
"named": true
}
]
}
},
{
"type": "quoted_element",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "escape_sequence",
"named": true
},
{
"type": "gen_exp",
"named": true
},
{
"type": "variable_ref",
"named": true
}
]
}
},
{
"type": "source_file",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "block_def",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "foreach_loop",
"named": true
},
{
"type": "function_def",
"named": true
},
{
"type": "if_condition",
"named": true
},
{
"type": "line_comment",
"named": true
},
{
"type": "macro_def",
"named": true
},
{
"type": "normal_command",
"named": true
},
{
"type": "while_loop",
"named": true
}
]
}
},
{
"type": "unquoted_argument",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "escape_sequence",
"named": true
},
{
"type": "gen_exp",
"named": true
},
{
"type": "variable_ref",
"named": true
}
]
}
},
{
"type": "variable",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "escape_sequence",
"named": true
},
{
"type": "variable_ref",
"named": true
}
]
}
},
{
"type": "variable_ref",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "cache_var",
"named": true
},
{
"type": "env_var",
"named": true
},
{
"type": "normal_var",
"named": true
}
]
}
},
{
"type": "while_command",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "argument_list",
"named": true
},
{
"type": "while",
"named": true
}
]
}
},
{
"type": "while_loop",
"named": true,
"fields": {},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "body",
"named": true
},
{
"type": "endwhile_command",
"named": true
},
{
"type": "while_command",
"named": true
}
]
}
},
{
"type": "\"",
"named": false
},
{
"type": "$",
"named": false
},
{
"type": "(",
"named": false
},
{
"type": ")",
"named": false
},
{
"type": ":",
"named": false
},
{
"type": ";",
"named": false
},
{
"type": "<",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": "CACHE",
"named": false
},
{
"type": "ENV",
"named": false
},
{
"type": "\\;",
"named": false
},
{
"type": "\\n",
"named": false
},
{
"type": "\\r",
"named": false
},
{
"type": "\\t",
"named": false
},
{
"type": "block",
"named": true
},
{
"type": "bracket_argument",
"named": true
},
{
"type": "bracket_comment",
"named": true
},
{
"type": "else",
"named": true
},
{
"type": "elseif",
"named": true
},
{
"type": "endblock",
"named": true
},
{
"type": "endforeach",
"named": true
},
{
"type": "endfunction",
"named": true
},
{
"type": "endif",
"named": true
},
{
"type": "endmacro",
"named": true
},
{
"type": "endwhile",
"named": true
},
{
"type": "foreach",
"named": true
},
{
"type": "function",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "if",
"named": true
},
{
"type": "line_comment",
"named": true
},
{
"type": "macro",
"named": true
},
{
"type": "while",
"named": true
},
{
"type": "{",
"named": false
},
{
"type": "}",
"named": false
}
]

File diff suppressed because it is too large Load Diff

@ -1,95 +0,0 @@
#include <tree_sitter/parser.h>
#include <wctype.h>
enum TokenType { BRACKET_ARGUMENT, BRACKET_COMMENT, LINE_COMMENT };
static void skip(TSLexer *lexer) { lexer->advance(lexer, true); }
static void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
static void skip_wspace(TSLexer *lexer) {
while (iswspace(lexer->lookahead)) {
skip(lexer);
}
}
static bool is_bracket_argument(TSLexer *lexer) {
if (lexer->lookahead != '[') {
return false;
}
advance(lexer);
int open_level = 0;
while (lexer->lookahead == '=') {
++open_level;
advance(lexer);
}
if (lexer->lookahead != '[') {
return false;
}
while (lexer->lookahead != '\0') {
advance(lexer);
if (lexer->lookahead == ']') {
advance(lexer);
int close_level = 0;
while (lexer->lookahead == '=') {
++close_level;
advance(lexer);
}
if (lexer->lookahead == ']' && close_level == open_level) {
advance(lexer);
return true;
}
}
}
return false;
}
static bool scan(void *payload, TSLexer *lexer, bool const *valid_symbols) {
skip_wspace(lexer);
if (lexer->lookahead != '#' && valid_symbols[BRACKET_ARGUMENT]) {
if (is_bracket_argument(lexer)) {
lexer->result_symbol = BRACKET_ARGUMENT;
return true;
}
}
if (lexer->lookahead == '#' &&
(valid_symbols[BRACKET_COMMENT] || valid_symbols[LINE_COMMENT])) {
advance(lexer);
if (is_bracket_argument(lexer)) {
lexer->result_symbol = BRACKET_COMMENT;
return true;
} else {
while (lexer->lookahead != '\n' && lexer->lookahead != '\0') {
advance(lexer);
}
lexer->result_symbol = LINE_COMMENT;
return true;
}
}
return false;
}
void *tree_sitter_cmake_external_scanner_create() { return NULL; }
void tree_sitter_cmake_external_scanner_destroy(void *payload) {}
unsigned tree_sitter_cmake_external_scanner_serialize(void *payload,
char *buffer) {
return 0;
}
void tree_sitter_cmake_external_scanner_deserialize(void *payload,
char const *buffer,
unsigned length) {}
bool tree_sitter_cmake_external_scanner_scan(void *payload, TSLexer *lexer,
bool const *valid_symbols) {
return scan(payload, lexer, valid_symbols);
}

@ -1,54 +0,0 @@
#ifndef TREE_SITTER_ALLOC_H_
#define TREE_SITTER_ALLOC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
// Allow clients to override allocation functions
#ifdef TREE_SITTER_REUSE_ALLOCATOR
extern void *(*ts_current_malloc)(size_t);
extern void *(*ts_current_calloc)(size_t, size_t);
extern void *(*ts_current_realloc)(void *, size_t);
extern void (*ts_current_free)(void *);
#ifndef ts_malloc
#define ts_malloc ts_current_malloc
#endif
#ifndef ts_calloc
#define ts_calloc ts_current_calloc
#endif
#ifndef ts_realloc
#define ts_realloc ts_current_realloc
#endif
#ifndef ts_free
#define ts_free ts_current_free
#endif
#else
#ifndef ts_malloc
#define ts_malloc malloc
#endif
#ifndef ts_calloc
#define ts_calloc calloc
#endif
#ifndef ts_realloc
#define ts_realloc realloc
#endif
#ifndef ts_free
#define ts_free free
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_ALLOC_H_

@ -1,290 +0,0 @@
#ifndef TREE_SITTER_ARRAY_H_
#define TREE_SITTER_ARRAY_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "./alloc.h"
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
#pragma warning(disable : 4101)
#elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#define Array(T) \
struct { \
T *contents; \
uint32_t size; \
uint32_t capacity; \
}
/// Initialize an array.
#define array_init(self) \
((self)->size = 0, (self)->capacity = 0, (self)->contents = NULL)
/// Create an empty array.
#define array_new() \
{ NULL, 0, 0 }
/// Get a pointer to the element at a given `index` in the array.
#define array_get(self, _index) \
(assert((uint32_t)(_index) < (self)->size), &(self)->contents[_index])
/// Get a pointer to the first element in the array.
#define array_front(self) array_get(self, 0)
/// Get a pointer to the last element in the array.
#define array_back(self) array_get(self, (self)->size - 1)
/// Clear the array, setting its size to zero. Note that this does not free any
/// memory allocated for the array's contents.
#define array_clear(self) ((self)->size = 0)
/// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
/// less than the array's current capacity, this function has no effect.
#define array_reserve(self, new_capacity) \
_array__reserve((Array *)(self), array_elem_size(self), new_capacity)
/// Free any memory allocated for this array. Note that this does not free any
/// memory allocated for the array's contents.
#define array_delete(self) _array__delete((Array *)(self))
/// Push a new `element` onto the end of the array.
#define array_push(self, element) \
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
(self)->contents[(self)->size++] = (element))
/// Increase the array's size by `count` elements.
/// New elements are zero-initialized.
#define array_grow_by(self, count) \
do { \
if ((count) == 0) break; \
_array__grow((Array *)(self), count, array_elem_size(self)); \
memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
(self)->size += (count); \
} while (0)
/// Append all elements from one array to the end of another.
#define array_push_all(self, other) \
array_extend((self), (other)->size, (other)->contents)
/// Append `count` elements to the end of the array, reading their values from the
/// `contents` pointer.
#define array_extend(self, count, contents) \
_array__splice( \
(Array *)(self), array_elem_size(self), (self)->size, \
0, count, contents \
)
/// Remove `old_count` elements from the array starting at the given `index`. At
/// the same index, insert `new_count` new elements, reading their values from the
/// `new_contents` pointer.
#define array_splice(self, _index, old_count, new_count, new_contents) \
_array__splice( \
(Array *)(self), array_elem_size(self), _index, \
old_count, new_count, new_contents \
)
/// Insert one `element` into the array at the given `index`.
#define array_insert(self, _index, element) \
_array__splice((Array *)(self), array_elem_size(self), _index, 0, 1, &(element))
/// Remove one element from the array at the given `index`.
#define array_erase(self, _index) \
_array__erase((Array *)(self), array_elem_size(self), _index)
/// Pop the last element off the array, returning the element by value.
#define array_pop(self) ((self)->contents[--(self)->size])
/// Assign the contents of one array to another, reallocating if necessary.
#define array_assign(self, other) \
_array__assign((Array *)(self), (const Array *)(other), array_elem_size(self))
/// Swap one array with another
#define array_swap(self, other) \
_array__swap((Array *)(self), (Array *)(other))
/// Get the size of the array contents
#define array_elem_size(self) (sizeof *(self)->contents)
/// Search a sorted array for a given `needle` value, using the given `compare`
/// callback to determine the order.
///
/// If an existing element is found to be equal to `needle`, then the `index`
/// out-parameter is set to the existing value's index, and the `exists`
/// out-parameter is set to true. Otherwise, `index` is set to an index where
/// `needle` should be inserted in order to preserve the sorting, and `exists`
/// is set to false.
#define array_search_sorted_with(self, compare, needle, _index, _exists) \
_array__search_sorted(self, 0, compare, , needle, _index, _exists)
/// Search a sorted array for a given `needle` value, using integer comparisons
/// of a given struct field (specified with a leading dot) to determine the order.
///
/// See also `array_search_sorted_with`.
#define array_search_sorted_by(self, field, needle, _index, _exists) \
_array__search_sorted(self, 0, _compare_int, field, needle, _index, _exists)
/// Insert a given `value` into a sorted array, using the given `compare`
/// callback to determine the order.
#define array_insert_sorted_with(self, compare, value) \
do { \
unsigned _index, _exists; \
array_search_sorted_with(self, compare, &(value), &_index, &_exists); \
if (!_exists) array_insert(self, _index, value); \
} while (0)
/// Insert a given `value` into a sorted array, using integer comparisons of
/// a given struct field (specified with a leading dot) to determine the order.
///
/// See also `array_search_sorted_by`.
#define array_insert_sorted_by(self, field, value) \
do { \
unsigned _index, _exists; \
array_search_sorted_by(self, field, (value) field, &_index, &_exists); \
if (!_exists) array_insert(self, _index, value); \
} while (0)
// Private
typedef Array(void) Array;
/// This is not what you're looking for, see `array_delete`.
static inline void _array__delete(Array *self) {
if (self->contents) {
ts_free(self->contents);
self->contents = NULL;
self->size = 0;
self->capacity = 0;
}
}
/// This is not what you're looking for, see `array_erase`.
static inline void _array__erase(Array *self, size_t element_size,
uint32_t index) {
assert(index < self->size);
char *contents = (char *)self->contents;
memmove(contents + index * element_size, contents + (index + 1) * element_size,
(self->size - index - 1) * element_size);
self->size--;
}
/// This is not what you're looking for, see `array_reserve`.
static inline void _array__reserve(Array *self, size_t element_size, uint32_t new_capacity) {
if (new_capacity > self->capacity) {
if (self->contents) {
self->contents = ts_realloc(self->contents, new_capacity * element_size);
} else {
self->contents = ts_malloc(new_capacity * element_size);
}
self->capacity = new_capacity;
}
}
/// This is not what you're looking for, see `array_assign`.
static inline void _array__assign(Array *self, const Array *other, size_t element_size) {
_array__reserve(self, element_size, other->size);
self->size = other->size;
memcpy(self->contents, other->contents, self->size * element_size);
}
/// This is not what you're looking for, see `array_swap`.
static inline void _array__swap(Array *self, Array *other) {
Array swap = *other;
*other = *self;
*self = swap;
}
/// This is not what you're looking for, see `array_push` or `array_grow_by`.
static inline void _array__grow(Array *self, uint32_t count, size_t element_size) {
uint32_t new_size = self->size + count;
if (new_size > self->capacity) {
uint32_t new_capacity = self->capacity * 2;
if (new_capacity < 8) new_capacity = 8;
if (new_capacity < new_size) new_capacity = new_size;
_array__reserve(self, element_size, new_capacity);
}
}
/// This is not what you're looking for, see `array_splice`.
static inline void _array__splice(Array *self, size_t element_size,
uint32_t index, uint32_t old_count,
uint32_t new_count, const void *elements) {
uint32_t new_size = self->size + new_count - old_count;
uint32_t old_end = index + old_count;
uint32_t new_end = index + new_count;
assert(old_end <= self->size);
_array__reserve(self, element_size, new_size);
char *contents = (char *)self->contents;
if (self->size > old_end) {
memmove(
contents + new_end * element_size,
contents + old_end * element_size,
(self->size - old_end) * element_size
);
}
if (new_count > 0) {
if (elements) {
memcpy(
(contents + index * element_size),
elements,
new_count * element_size
);
} else {
memset(
(contents + index * element_size),
0,
new_count * element_size
);
}
}
self->size += new_count - old_count;
}
/// A binary search routine, based on Rust's `std::slice::binary_search_by`.
/// This is not what you're looking for, see `array_search_sorted_with` or `array_search_sorted_by`.
#define _array__search_sorted(self, start, compare, suffix, needle, _index, _exists) \
do { \
*(_index) = start; \
*(_exists) = false; \
uint32_t size = (self)->size - *(_index); \
if (size == 0) break; \
int comparison; \
while (size > 1) { \
uint32_t half_size = size / 2; \
uint32_t mid_index = *(_index) + half_size; \
comparison = compare(&((self)->contents[mid_index] suffix), (needle)); \
if (comparison <= 0) *(_index) = mid_index; \
size -= half_size; \
} \
comparison = compare(&((self)->contents[*(_index)] suffix), (needle)); \
if (comparison == 0) *(_exists) = true; \
else if (comparison < 0) *(_index) += 1; \
} while (0)
/// Helper macro for the `_sorted_by` routines below. This takes the left (existing)
/// parameter by reference in order to work with the generic sorting function above.
#define _compare_int(a, b) ((int)*(a) - (int)(b))
#ifdef _MSC_VER
#pragma warning(default : 4101)
#elif defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_ARRAY_H_

@ -1,230 +0,0 @@
#ifndef TREE_SITTER_PARSER_H_
#define TREE_SITTER_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#define ts_builtin_sym_error ((TSSymbol)-1)
#define ts_builtin_sym_end 0
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
#ifndef TREE_SITTER_API_H_
typedef uint16_t TSStateId;
typedef uint16_t TSSymbol;
typedef uint16_t TSFieldId;
typedef struct TSLanguage TSLanguage;
#endif
typedef struct {
TSFieldId field_id;
uint8_t child_index;
bool inherited;
} TSFieldMapEntry;
typedef struct {
uint16_t index;
uint16_t length;
} TSFieldMapSlice;
typedef struct {
bool visible;
bool named;
bool supertype;
} TSSymbolMetadata;
typedef struct TSLexer TSLexer;
struct TSLexer {
int32_t lookahead;
TSSymbol result_symbol;
void (*advance)(TSLexer *, bool);
void (*mark_end)(TSLexer *);
uint32_t (*get_column)(TSLexer *);
bool (*is_at_included_range_start)(const TSLexer *);
bool (*eof)(const TSLexer *);
};
typedef enum {
TSParseActionTypeShift,
TSParseActionTypeReduce,
TSParseActionTypeAccept,
TSParseActionTypeRecover,
} TSParseActionType;
typedef union {
struct {
uint8_t type;
TSStateId state;
bool extra;
bool repetition;
} shift;
struct {
uint8_t type;
uint8_t child_count;
TSSymbol symbol;
int16_t dynamic_precedence;
uint16_t production_id;
} reduce;
uint8_t type;
} TSParseAction;
typedef struct {
uint16_t lex_state;
uint16_t external_lex_state;
} TSLexMode;
typedef union {
TSParseAction action;
struct {
uint8_t count;
bool reusable;
} entry;
} TSParseActionEntry;
struct TSLanguage {
uint32_t version;
uint32_t symbol_count;
uint32_t alias_count;
uint32_t token_count;
uint32_t external_token_count;
uint32_t state_count;
uint32_t large_state_count;
uint32_t production_id_count;
uint32_t field_count;
uint16_t max_alias_sequence_length;
const uint16_t *parse_table;
const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map;
const TSParseActionEntry *parse_actions;
const char * const *symbol_names;
const char * const *field_names;
const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata;
const TSSymbol *public_symbol_map;
const uint16_t *alias_map;
const TSSymbol *alias_sequences;
const TSLexMode *lex_modes;
bool (*lex_fn)(TSLexer *, TSStateId);
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
TSSymbol keyword_capture_token;
struct {
const bool *states;
const TSSymbol *symbol_map;
void *(*create)(void);
void (*destroy)(void *);
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
/*
* Lexer Macros
*/
#ifdef _MSC_VER
#define UNUSED __pragma(warning(suppress : 4101))
#else
#define UNUSED __attribute__((unused))
#endif
#define START_LEXER() \
bool result = false; \
bool skip = false; \
UNUSED \
bool eof = false; \
int32_t lookahead; \
goto start; \
next_state: \
lexer->advance(lexer, skip); \
start: \
skip = false; \
lookahead = lexer->lookahead;
#define ADVANCE(state_value) \
{ \
state = state_value; \
goto next_state; \
}
#define SKIP(state_value) \
{ \
skip = true; \
state = state_value; \
goto next_state; \
}
#define ACCEPT_TOKEN(symbol_value) \
result = true; \
lexer->result_symbol = symbol_value; \
lexer->mark_end(lexer);
#define END_STATE() return result;
/*
* Parse Table Macros
*/
#define SMALL_STATE(id) ((id) - LARGE_STATE_COUNT)
#define STATE(id) id
#define ACTIONS(id) id
#define SHIFT(state_value) \
{{ \
.shift = { \
.type = TSParseActionTypeShift, \
.state = (state_value) \
} \
}}
#define SHIFT_REPEAT(state_value) \
{{ \
.shift = { \
.type = TSParseActionTypeShift, \
.state = (state_value), \
.repetition = true \
} \
}}
#define SHIFT_EXTRA() \
{{ \
.shift = { \
.type = TSParseActionTypeShift, \
.extra = true \
} \
}}
#define REDUCE(symbol_val, child_count_val, ...) \
{{ \
.reduce = { \
.type = TSParseActionTypeReduce, \
.symbol = symbol_val, \
.child_count = child_count_val, \
__VA_ARGS__ \
}, \
}}
#define RECOVER() \
{{ \
.type = TSParseActionTypeRecover \
}}
#define ACCEPT_INPUT() \
{{ \
.type = TSParseActionTypeAccept \
}}
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_PARSER_H_

@ -1,195 +0,0 @@
======================================================
Function definition with no arguments [block_commands]
======================================================
function(fn)
endfunction()
---
(source_file
(function_def
(function_command
(function)
(argument_list
(argument
(unquoted_argument)
)
)
)
(body)
(endfunction_command
(endfunction)
)
)
)
========================================================
Function definition with many arguments [block_commands]
========================================================
function(fn arg1 arg2 arg3)
endfunction()
---
(source_file
(function_def
(function_command
(function)
(argument_list
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
)
)
(body)
(endfunction_command
(endfunction)
)
)
)
===================================================
Macro definition with no arguments [block_commands]
===================================================
macro(fn)
endmacro()
---
(source_file
(macro_def
(macro_command
(macro)
(argument_list
(argument
(unquoted_argument)
)
)
)
(body)
(endmacro_command
(endmacro)
)
)
)
========================================================
macro definition with many arguments [block_commands]
========================================================
macro(fn arg1 arg2 arg3)
endmacro()
---
(source_file
(macro_def
(macro_command
(macro)
(argument_list
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
)
)
(body)
(endmacro_command
(endmacro)
)
)
)
============================
Block scope [block_commands]
============================
block(SCOPE_FOR POLICIES VARIABLES PROPAGATE var)
endblock()
---
(source_file
(block_def
(block_command
(block)
(argument_list
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
(argument
(unquoted_argument)
)
)
)
(body)
(endblock_command
(endblock)
)
)
)
================================
Nested function [block_commands]
================================
function(a)
function(b)
endfunction()
endfunction()
---
(source_file
(function_def
(function_command
(function)
(argument_list
(argument
(unquoted_argument)
)
)
)
(body
(function_def
(function_command
(function)
(argument_list
(argument
(unquoted_argument)
)
)
)
(body)
(endfunction_command
(endfunction)
)
)
)
(endfunction_command
(endfunction)
)
)
)

@ -1,105 +0,0 @@
=========================================
Empty bracket argument [bracket_argument]
=========================================
message([[]])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
)
)
)
=======================================
One bracket argument [bracket_argument]
=======================================
message([[an argument]])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
)
)
)
========================================
Two bracket arguments [bracket_argument]
========================================
message([[first argument]] [[second argument]])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
(argument (bracket_argument))
)
)
)
========================================================
Two bracket with two equals arguments [bracket_argument]
========================================================
message(
[====[first argument]====]
[====[second argument]====]
)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
(argument (bracket_argument))
)
)
)
===================================================
Bracket argument with line break [bracket_argument]
===================================================
message([[an argument
with line break
]])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
)
)
)
=====================================================================================
Bracket argument with embedded brackets and equal signs line break [bracket_argument]
=====================================================================================
message([===[an argument
with line break ]==]
]===])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (bracket_argument))
)
)
)

@ -1,62 +0,0 @@
=========================
Bracket comment [comment]
=========================
#[[Some comment]]
---
(source_file
(bracket_comment)
)
==========================================================
Command invocation with embedded bracket comment [comment]
==========================================================
message(STATUS #[[Some comment]] "comment is next" #[[Some comment]])
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(bracket_comment)
(argument (quoted_argument (quoted_element)))
(bracket_comment)
)
)
)
======================
Line comment [comment]
======================
# [[Some comment]] "comment is next" #[[Some comment]]
---
(source_file
(line_comment)
)
===================================
Message with Line comment [comment]
===================================
message(STATUS #Some line comment
Second #Some other line comment
)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(line_comment)
(argument (unquoted_argument))
(line_comment)
)
)
)

@ -1,304 +0,0 @@
====================
Empty if [condition]
====================
if ( cond )
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endif_command (endif))
)
)
===========================
Empty if elseif [condition]
===========================
if(cond)
elseif(cond)
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(elseif_command
(elseif)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endif_command (endif))
)
)
================================
Empty if elseif else [condition]
================================
if(cond)
elseif(cond)
else()
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(elseif_command
(elseif)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(else_command (else))
(body)
(endif_command (endif))
)
)
============================================
If with many command invocations [condition]
============================================
if(cond)
message(STATUS)
message(STATUS)
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(endif_command (endif))
)
)
==============================================================
If, elseof, and else with many command invocations [condition]
==============================================================
if(cond)
message(STATUS)
message(STATUS)
elseif(cond)
message(STATUS)
message(STATUS)
else(cond)
message(STATUS)
message(STATUS)
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(elseif_command
(elseif)
(argument_list
(argument (unquoted_argument))
)
)
(body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(else_command
(else)
(argument_list
(argument (unquoted_argument))
)
)
(body
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
(endif_command (endif))
)
)
======================================
Condition with parentheses [condition]
======================================
if((A AND B) OR C)
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endif_command (endif))
)
)
==============================================
Condition with not and parentheses [condition]
==============================================
if(NOT (A AND B) OR C)
else(NOT (A AND B) OR C)
endif(NOT (A AND B) OR C)
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(else_command
(else)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endif_command
(endif)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)
)
============================
Nested condition [condition]
============================
if(A)
if(A)
endif()
endif()
---
(source_file
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body
(if_condition
(if_command
(if)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endif_command (endif))
)
)
(endif_command (endif))
)
)

@ -1,25 +0,0 @@
========================================
Escape sequence of "\;" [escape_sequence]
=========================================
set(var "It is \; and \"")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument))
(argument
(quoted_argument
(quoted_element
(escape_sequence)
(escape_sequence)
)
)
)
)
)
)

@ -1,136 +0,0 @@
==================================
Empty foreach loop [foreach]
==================================
foreach(var)
endforeach()
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
)
)
===============================================================
Empty foreach loop with one argument endforeach [foreach]
===============================================================
foreach(var)
endforeach(var)
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command
(endforeach)
(argument (unquoted_argument))
)
)
)
=================================
Uppercase foreach [foreach]
=================================
FOREACH(var)
ENDFOREACH()
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
)
)
==================================
Mixed case foreach [foreach]
==================================
forEach(var)
endForEach()
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
)
)
==================================
Empty IN [foreach]
==================================
foreach(var IN)
endforeach()
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
)
)
==================================
Empty RANGE [foreach]
==================================
foreach(var RANGE)
endforeach()
---
(source_file
(foreach_loop
(foreach_command
(foreach)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
(body)
(endforeach_command (endforeach))
)
)

@ -1,36 +0,0 @@
===================================================
add_custom_target without new line [function_calls]
===================================================
add_custom_target(OUTPUT somefile)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)
================================================
add_custom_target with new line [function_calls]
================================================
add_custom_target(
OUTPUT somefile)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)

@ -1,143 +0,0 @@
=======================================
Unquoted generator expression [gen_exp]
=======================================
message($<>)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(gen_exp)
)
)
)
)
)
=====================================
Quoted generator expression [gen_exp]
=====================================
message("$<>")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(gen_exp)
)
)
)
)
)
)
=====================
No argument [gen_exp]
=====================
message($<ANGLE-R>)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(gen_exp
(argument
(unquoted_argument)
)
)
)
)
)
)
)
============================================
No argument with superfluous colon [gen_exp]
============================================
message($<ANGLE-R:>)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(gen_exp
(argument
(unquoted_argument)
)
)
)
)
)
)
)
======================
One argument [gen_exp]
======================
message($<BOOL:-NOTFOUND>)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(gen_exp
(argument
(unquoted_argument))
(argument
(unquoted_argument)
)
)
)
)
)
)
)
=======================
Two arguments [gen_exp]
=======================
message($<AND:TRUE,FALSE>)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(gen_exp
(argument
(unquoted_argument))
(argument
(unquoted_argument))
(argument
(unquoted_argument)
)
)
)
)
)
)
)

@ -1,101 +0,0 @@
=====================
No argument [message]
=====================
message()
---
(source_file
(normal_command
(identifier)
)
)
=================================
No argument with spaces [message]
=================================
message( )
---
(source_file
(normal_command
(identifier)
(argument_list)
)
)
===============================================
Message without argument with newline [message]
===============================================
message(
)
---
(source_file
(normal_command
(identifier)
(argument_list)
)
)
==================================================
Message with STATUS and bracket argument [message]
==================================================
message(STATUS [=[Some argument ]==] ]=] )
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (bracket_argument))
)
)
)
==============================================================
Message with STATUS and bracket argument and newline [message]
==============================================================
message(STATUS
[=[Some argument
]==] ]=] )
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (bracket_argument))
)
)
)
======================================================
Message with STATUS and an unquoted argument [message]
======================================================
message(STATUS argument)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)

@ -1,62 +0,0 @@
===================================================
Parentheses inside command invocation [parentheses]
===================================================
message(STATUS (TEST))
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)
===========================================================
Missing parentheses inside command invocation [parentheses]
===========================================================
message(STATUS (TEST)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
(MISSING ")")
)
)
==================================================================
Nested missing parentheses inside command invocation [parentheses]
==================================================================
message(STATUS ((TEST))
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
(MISSING ")")
)
)
===============================================
Many arguments inside parentheses [parentheses]
===============================================
message(STATUS (TEST SECOND_TEST))
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)

@ -1,196 +0,0 @@
===========================================
One empty quoted argument [quoted_argument]
===========================================
message("")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (quoted_argument))
)
)
)
=====================================
One quoted argument [quoted_argument]
=====================================
message("An argument")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (quoted_argument (quoted_element)))
)
)
)
======================================
Two quoted arguments [quoted_argument]
======================================
message("First argument" "Second argument")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (quoted_argument (quoted_element)))
(argument (quoted_argument (quoted_element)))
)
)
)
===================================================
A quoted argument with line break [quoted_argument]
===================================================
message("An argument
with line break")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (quoted_argument (quoted_element)))
)
)
)
========================================
One variable reference [quoted_argument]
========================================
message("${var}")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(variable_ref (normal_var (variable)))
)
)
)
)
)
)
=========================================
Two Variable references [quoted_argument]
=========================================
message("${var} ${var}")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(variable_ref (normal_var (variable)))
(variable_ref (normal_var (variable)))
)
)
)
)
)
)
======================================================================
Variable reference inside another variable reference [quoted_argument]
======================================================================
message("${var_${var}}")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
)
)
)
======================================================================
Lookalike bracket comment inside quoted argument [quoted_argument]
======================================================================
message("${var_${var}} #[[comment]]")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
)
)
)
======================================================================
Lookalike line comment inside quoted argument [quoted_argument]
======================================================================
message("${var_${var}} #comment")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
)
)
)
===========================================================
Lookalike variable inside quoted argument [quoted_argument]
===========================================================
message("$var")
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(quoted_argument
(quoted_element)
)
)
)
)
)

@ -1,156 +0,0 @@
========================================================
Command invocation with one argument [unquoted_argument]
========================================================
message(STATUS)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
=========================================================
Command invocation with two arguments [unquoted_argument]
=========================================================
message(STATUS Hello)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
(argument (unquoted_argument))
)
)
)
===============================================================
Command invocations with leading seperation [unquoted_argument]
===============================================================
message( STATUS)
message(
STATUS)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
============================================================
Command invocations with escape sequence [unquoted_argument]
============================================================
message( STATUS)
message(
STATUS)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
(normal_command
(identifier)
(argument_list
(argument (unquoted_argument))
)
)
)
========================================
Variable referencing [unquoted_argument]
========================================
message(${var_ref})
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(variable_ref (normal_var (variable)))
)
)
)
)
)
====================================================================
Variable referencing inside variable referencing [unquoted_argument]
====================================================================
message(${var_${var_ref}})
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument
(variable_ref (normal_var (variable (variable_ref (normal_var (variable))))))
)
)
)
)
)
===============================================================
Lookalike variable inside unquoted argument [unquoted_argument]
===============================================================
message($var)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument)
)
)
)
)
=====================================================
Single quote in unquoted_argument [unquoted_argument]
=====================================================
message(hello'world)
---
(source_file
(normal_command
(identifier)
(argument_list
(argument
(unquoted_argument)
)
)
)
)

@ -1,47 +0,0 @@
===================
Empty while [while]
===================
while(cond)
endwhile()
---
(source_file
(while_loop
(while_command
(while)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endwhile_command (endwhile))
)
)
============================================
Empty while with argument in endwhile[while]
============================================
while(cond)
endwhile(cond)
---
(source_file
(while_loop
(while_command
(while)
(argument_list
(argument (unquoted_argument))
)
)
(body)
(endwhile_command
(endwhile)
(argument (unquoted_argument))
)
)
)