mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
QL: Add grammar for parsing blame files
This commit is contained in:
26
ql/buramu/tree-sitter-blame/Cargo.toml
Normal file
26
ql/buramu/tree-sitter-blame/Cargo.toml
Normal file
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "tree-sitter-blame"
|
||||
description = "blame grammar for the tree-sitter parsing library"
|
||||
version = "0.0.1"
|
||||
keywords = ["incremental", "parsing", "blame"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/tree-sitter/tree-sitter-blame"
|
||||
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.20.3"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
19
ql/buramu/tree-sitter-blame/binding.gyp
Normal file
19
ql/buramu/tree-sitter-blame/binding.gyp
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "tree_sitter_blame_binding",
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('nan')\")",
|
||||
"src"
|
||||
],
|
||||
"sources": [
|
||||
"bindings/node/binding.cc",
|
||||
"src/parser.c",
|
||||
# If your language uses an external scanner, add it here.
|
||||
],
|
||||
"cflags_c": [
|
||||
"-std=c99",
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
28
ql/buramu/tree-sitter-blame/bindings/node/binding.cc
Normal file
28
ql/buramu/tree-sitter-blame/bindings/node/binding.cc
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "tree_sitter/parser.h"
|
||||
#include <node.h>
|
||||
#include "nan.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
extern "C" TSLanguage * tree_sitter_blame();
|
||||
|
||||
namespace {
|
||||
|
||||
NAN_METHOD(New) {}
|
||||
|
||||
void Init(Local<Object> exports, Local<Object> module) {
|
||||
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
||||
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
||||
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
|
||||
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
||||
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
||||
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_blame());
|
||||
|
||||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("blame").ToLocalChecked());
|
||||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
||||
}
|
||||
|
||||
NODE_MODULE(tree_sitter_blame_binding, Init)
|
||||
|
||||
} // namespace
|
||||
19
ql/buramu/tree-sitter-blame/bindings/node/index.js
Normal file
19
ql/buramu/tree-sitter-blame/bindings/node/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
try {
|
||||
module.exports = require("../../build/Release/tree_sitter_blame_binding");
|
||||
} catch (error1) {
|
||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error1;
|
||||
}
|
||||
try {
|
||||
module.exports = require("../../build/Debug/tree_sitter_blame_binding");
|
||||
} catch (error2) {
|
||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error2;
|
||||
}
|
||||
throw error1
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||
} catch (_) {}
|
||||
40
ql/buramu/tree-sitter-blame/bindings/rust/build.rs
Normal file
40
ql/buramu/tree-sitter-blame/bindings/rust/build.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
|
||||
// If your language uses an external scanner written in C,
|
||||
// then include this block of code:
|
||||
|
||||
/*
|
||||
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());
|
||||
|
||||
// If your language uses an external scanner written in C++,
|
||||
// then include this block of code:
|
||||
|
||||
/*
|
||||
let mut cpp_config = cc::Build::new();
|
||||
cpp_config.cpp(true);
|
||||
cpp_config.include(&src_dir);
|
||||
cpp_config
|
||||
.flag_if_supported("-Wno-unused-parameter")
|
||||
.flag_if_supported("-Wno-unused-but-set-variable");
|
||||
let scanner_path = src_dir.join("scanner.cc");
|
||||
cpp_config.file(&scanner_path);
|
||||
cpp_config.compile("scanner");
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
*/
|
||||
}
|
||||
52
ql/buramu/tree-sitter-blame/bindings/rust/lib.rs
Normal file
52
ql/buramu/tree-sitter-blame/bindings/rust/lib.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
//! This crate provides blame 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_blame::language()).expect("Error loading blame 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_blame() -> 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_blame() }
|
||||
}
|
||||
|
||||
/// 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 blame language");
|
||||
}
|
||||
}
|
||||
20160
ql/buramu/tree-sitter-blame/dep.out
Normal file
20160
ql/buramu/tree-sitter-blame/dep.out
Normal file
File diff suppressed because it is too large
Load Diff
30
ql/buramu/tree-sitter-blame/grammar.js
Normal file
30
ql/buramu/tree-sitter-blame/grammar.js
Normal file
@@ -0,0 +1,30 @@
|
||||
module.exports = grammar({
|
||||
name: "blame",
|
||||
|
||||
extras: $ => [/\s/],
|
||||
|
||||
rules: {
|
||||
blame_info: $ => seq($._today, repeat(field('file_entry', $.file_entry))),
|
||||
|
||||
_today: $ => seq("today:", field('today', $.date)),
|
||||
|
||||
file_entry: $ => seq(
|
||||
"file: ",
|
||||
field('file_name', $.filename),
|
||||
"\n",
|
||||
repeat(field('blame_entry', $.blame_entry))
|
||||
),
|
||||
|
||||
blame_entry: $ => seq(
|
||||
"last_modified:",
|
||||
field('date', $.date),
|
||||
repeat(field('line', $.number)),
|
||||
),
|
||||
|
||||
date: $ => /\d{4}-\d{2}-\d{2}/,
|
||||
|
||||
filename: $ => /[a-zA-Z0-9_\-\.\/ ]+/,
|
||||
|
||||
number: $ => /\d+/,
|
||||
}
|
||||
});
|
||||
19
ql/buramu/tree-sitter-blame/package.json
Normal file
19
ql/buramu/tree-sitter-blame/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "tree-sitter-blame",
|
||||
"version": "0.0.1",
|
||||
"description": "blame grammar for tree-sitter",
|
||||
"main": "bindings/node",
|
||||
"keywords": [
|
||||
"parsing",
|
||||
"incremental"
|
||||
],
|
||||
"dependencies": {
|
||||
"nan": "^2.12.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tree-sitter-cli": "^0.20.7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tree-sitter test"
|
||||
}
|
||||
}
|
||||
126
ql/buramu/tree-sitter-blame/src/grammar.json
Normal file
126
ql/buramu/tree-sitter-blame/src/grammar.json
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"name": "blame",
|
||||
"rules": {
|
||||
"blame_info": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_today"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "FIELD",
|
||||
"name": "file_entry",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "file_entry"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"_today": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "today:"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "today",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "date"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"file_entry": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "file: "
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "file_name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "filename"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "\n"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "FIELD",
|
||||
"name": "blame_entry",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "blame_entry"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"blame_entry": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "last_modified:"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "date",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "date"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "FIELD",
|
||||
"name": "line",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"date": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\d{4}-\\d{2}-\\d{2}"
|
||||
},
|
||||
"filename": {
|
||||
"type": "PATTERN",
|
||||
"value": "[a-zA-Z0-9_\\-\\.\\/ ]+"
|
||||
},
|
||||
"number": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\d+"
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\s"
|
||||
}
|
||||
],
|
||||
"conflicts": [],
|
||||
"precedences": [],
|
||||
"externals": [],
|
||||
"inline": [],
|
||||
"supertypes": []
|
||||
}
|
||||
|
||||
108
ql/buramu/tree-sitter-blame/src/node-types.json
Normal file
108
ql/buramu/tree-sitter-blame/src/node-types.json
Normal file
@@ -0,0 +1,108 @@
|
||||
[
|
||||
{
|
||||
"type": "blame_entry",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"date": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "date",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"line": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "number",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "blame_info",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"file_entry": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "file_entry",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"today": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "date",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "file_entry",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"blame_entry": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "blame_entry",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"file_name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "filename",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "\n",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "file: ",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "filename",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "last_modified:",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "today:",
|
||||
"named": false
|
||||
}
|
||||
]
|
||||
691
ql/buramu/tree-sitter-blame/src/parser.c
Normal file
691
ql/buramu/tree-sitter-blame/src/parser.c
Normal file
@@ -0,0 +1,691 @@
|
||||
#include <tree_sitter/parser.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
|
||||
#define LANGUAGE_VERSION 14
|
||||
#define STATE_COUNT 20
|
||||
#define LARGE_STATE_COUNT 2
|
||||
#define SYMBOL_COUNT 15
|
||||
#define ALIAS_COUNT 0
|
||||
#define TOKEN_COUNT 8
|
||||
#define EXTERNAL_TOKEN_COUNT 0
|
||||
#define FIELD_COUNT 6
|
||||
#define MAX_ALIAS_SEQUENCE_LENGTH 4
|
||||
#define PRODUCTION_ID_COUNT 14
|
||||
|
||||
enum {
|
||||
anon_sym_today_COLON = 1,
|
||||
anon_sym_file_COLON = 2,
|
||||
anon_sym_LF = 3,
|
||||
anon_sym_last_modified_COLON = 4,
|
||||
sym_date = 5,
|
||||
sym_filename = 6,
|
||||
sym_number = 7,
|
||||
sym_blame_info = 8,
|
||||
sym__today = 9,
|
||||
sym_file_entry = 10,
|
||||
sym_blame_entry = 11,
|
||||
aux_sym_blame_info_repeat1 = 12,
|
||||
aux_sym_file_entry_repeat1 = 13,
|
||||
aux_sym_blame_entry_repeat1 = 14,
|
||||
};
|
||||
|
||||
static const char * const ts_symbol_names[] = {
|
||||
[ts_builtin_sym_end] = "end",
|
||||
[anon_sym_today_COLON] = "today:",
|
||||
[anon_sym_file_COLON] = "file: ",
|
||||
[anon_sym_LF] = "\n",
|
||||
[anon_sym_last_modified_COLON] = "last_modified:",
|
||||
[sym_date] = "date",
|
||||
[sym_filename] = "filename",
|
||||
[sym_number] = "number",
|
||||
[sym_blame_info] = "blame_info",
|
||||
[sym__today] = "_today",
|
||||
[sym_file_entry] = "file_entry",
|
||||
[sym_blame_entry] = "blame_entry",
|
||||
[aux_sym_blame_info_repeat1] = "blame_info_repeat1",
|
||||
[aux_sym_file_entry_repeat1] = "file_entry_repeat1",
|
||||
[aux_sym_blame_entry_repeat1] = "blame_entry_repeat1",
|
||||
};
|
||||
|
||||
static const TSSymbol ts_symbol_map[] = {
|
||||
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
||||
[anon_sym_today_COLON] = anon_sym_today_COLON,
|
||||
[anon_sym_file_COLON] = anon_sym_file_COLON,
|
||||
[anon_sym_LF] = anon_sym_LF,
|
||||
[anon_sym_last_modified_COLON] = anon_sym_last_modified_COLON,
|
||||
[sym_date] = sym_date,
|
||||
[sym_filename] = sym_filename,
|
||||
[sym_number] = sym_number,
|
||||
[sym_blame_info] = sym_blame_info,
|
||||
[sym__today] = sym__today,
|
||||
[sym_file_entry] = sym_file_entry,
|
||||
[sym_blame_entry] = sym_blame_entry,
|
||||
[aux_sym_blame_info_repeat1] = aux_sym_blame_info_repeat1,
|
||||
[aux_sym_file_entry_repeat1] = aux_sym_file_entry_repeat1,
|
||||
[aux_sym_blame_entry_repeat1] = aux_sym_blame_entry_repeat1,
|
||||
};
|
||||
|
||||
static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
[ts_builtin_sym_end] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[anon_sym_today_COLON] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_file_COLON] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_LF] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_last_modified_COLON] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[sym_date] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_filename] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_number] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_blame_info] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym__today] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym_file_entry] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym_blame_entry] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[aux_sym_blame_info_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
[aux_sym_file_entry_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
[aux_sym_blame_entry_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
};
|
||||
|
||||
enum {
|
||||
field_blame_entry = 1,
|
||||
field_date = 2,
|
||||
field_file_entry = 3,
|
||||
field_file_name = 4,
|
||||
field_line = 5,
|
||||
field_today = 6,
|
||||
};
|
||||
|
||||
static const char * const ts_field_names[] = {
|
||||
[0] = NULL,
|
||||
[field_blame_entry] = "blame_entry",
|
||||
[field_date] = "date",
|
||||
[field_file_entry] = "file_entry",
|
||||
[field_file_name] = "file_name",
|
||||
[field_line] = "line",
|
||||
[field_today] = "today",
|
||||
};
|
||||
|
||||
static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = {
|
||||
[1] = {.index = 0, .length = 1},
|
||||
[2] = {.index = 1, .length = 1},
|
||||
[3] = {.index = 2, .length = 1},
|
||||
[4] = {.index = 3, .length = 2},
|
||||
[5] = {.index = 5, .length = 2},
|
||||
[6] = {.index = 7, .length = 1},
|
||||
[7] = {.index = 8, .length = 1},
|
||||
[8] = {.index = 9, .length = 2},
|
||||
[9] = {.index = 11, .length = 1},
|
||||
[10] = {.index = 12, .length = 2},
|
||||
[11] = {.index = 14, .length = 1},
|
||||
[12] = {.index = 15, .length = 2},
|
||||
[13] = {.index = 17, .length = 2},
|
||||
};
|
||||
|
||||
static const TSFieldMapEntry ts_field_map_entries[] = {
|
||||
[0] =
|
||||
{field_today, 0, .inherited = true},
|
||||
[1] =
|
||||
{field_today, 1},
|
||||
[2] =
|
||||
{field_file_entry, 0},
|
||||
[3] =
|
||||
{field_file_entry, 1, .inherited = true},
|
||||
{field_today, 0, .inherited = true},
|
||||
[5] =
|
||||
{field_file_entry, 0, .inherited = true},
|
||||
{field_file_entry, 1, .inherited = true},
|
||||
[7] =
|
||||
{field_file_name, 1},
|
||||
[8] =
|
||||
{field_blame_entry, 0},
|
||||
[9] =
|
||||
{field_blame_entry, 3, .inherited = true},
|
||||
{field_file_name, 1},
|
||||
[11] =
|
||||
{field_date, 1},
|
||||
[12] =
|
||||
{field_blame_entry, 0, .inherited = true},
|
||||
{field_blame_entry, 1, .inherited = true},
|
||||
[14] =
|
||||
{field_line, 0},
|
||||
[15] =
|
||||
{field_date, 1},
|
||||
{field_line, 2, .inherited = true},
|
||||
[17] =
|
||||
{field_line, 0, .inherited = true},
|
||||
{field_line, 1, .inherited = true},
|
||||
};
|
||||
|
||||
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
||||
[0] = {0},
|
||||
};
|
||||
|
||||
static const uint16_t ts_non_terminal_alias_map[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
static const TSStateId ts_primary_state_ids[STATE_COUNT] = {
|
||||
[0] = 0,
|
||||
[1] = 1,
|
||||
[2] = 2,
|
||||
[3] = 3,
|
||||
[4] = 4,
|
||||
[5] = 5,
|
||||
[6] = 6,
|
||||
[7] = 7,
|
||||
[8] = 8,
|
||||
[9] = 9,
|
||||
[10] = 10,
|
||||
[11] = 11,
|
||||
[12] = 12,
|
||||
[13] = 13,
|
||||
[14] = 14,
|
||||
[15] = 15,
|
||||
[16] = 16,
|
||||
[17] = 17,
|
||||
[18] = 18,
|
||||
[19] = 19,
|
||||
};
|
||||
|
||||
static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
START_LEXER();
|
||||
eof = lexer->eof(lexer);
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (eof) ADVANCE(37);
|
||||
if (lookahead == 'f') ADVANCE(18);
|
||||
if (lookahead == 'l') ADVANCE(10);
|
||||
if (lookahead == 't') ADVANCE(23);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(0)
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(48);
|
||||
END_STATE();
|
||||
case 1:
|
||||
if (lookahead == '\n') ADVANCE(40);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(1)
|
||||
END_STATE();
|
||||
case 2:
|
||||
if (lookahead == ' ') ADVANCE(39);
|
||||
END_STATE();
|
||||
case 3:
|
||||
if (lookahead == ' ') ADVANCE(43);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r') SKIP(3)
|
||||
if (('-' <= lookahead && lookahead <= '9') ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
lookahead == '_' ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(44);
|
||||
END_STATE();
|
||||
case 4:
|
||||
if (lookahead == '-') ADVANCE(31);
|
||||
END_STATE();
|
||||
case 5:
|
||||
if (lookahead == '-') ADVANCE(32);
|
||||
END_STATE();
|
||||
case 6:
|
||||
if (lookahead == ':') ADVANCE(2);
|
||||
END_STATE();
|
||||
case 7:
|
||||
if (lookahead == ':') ADVANCE(38);
|
||||
END_STATE();
|
||||
case 8:
|
||||
if (lookahead == ':') ADVANCE(41);
|
||||
END_STATE();
|
||||
case 9:
|
||||
if (lookahead == '_') ADVANCE(22);
|
||||
END_STATE();
|
||||
case 10:
|
||||
if (lookahead == 'a') ADVANCE(25);
|
||||
END_STATE();
|
||||
case 11:
|
||||
if (lookahead == 'a') ADVANCE(27);
|
||||
END_STATE();
|
||||
case 12:
|
||||
if (lookahead == 'd') ADVANCE(19);
|
||||
END_STATE();
|
||||
case 13:
|
||||
if (lookahead == 'd') ADVANCE(11);
|
||||
END_STATE();
|
||||
case 14:
|
||||
if (lookahead == 'd') ADVANCE(8);
|
||||
END_STATE();
|
||||
case 15:
|
||||
if (lookahead == 'e') ADVANCE(6);
|
||||
END_STATE();
|
||||
case 16:
|
||||
if (lookahead == 'e') ADVANCE(14);
|
||||
END_STATE();
|
||||
case 17:
|
||||
if (lookahead == 'f') ADVANCE(20);
|
||||
END_STATE();
|
||||
case 18:
|
||||
if (lookahead == 'i') ADVANCE(21);
|
||||
END_STATE();
|
||||
case 19:
|
||||
if (lookahead == 'i') ADVANCE(17);
|
||||
END_STATE();
|
||||
case 20:
|
||||
if (lookahead == 'i') ADVANCE(16);
|
||||
END_STATE();
|
||||
case 21:
|
||||
if (lookahead == 'l') ADVANCE(15);
|
||||
END_STATE();
|
||||
case 22:
|
||||
if (lookahead == 'm') ADVANCE(24);
|
||||
END_STATE();
|
||||
case 23:
|
||||
if (lookahead == 'o') ADVANCE(13);
|
||||
END_STATE();
|
||||
case 24:
|
||||
if (lookahead == 'o') ADVANCE(12);
|
||||
END_STATE();
|
||||
case 25:
|
||||
if (lookahead == 's') ADVANCE(26);
|
||||
END_STATE();
|
||||
case 26:
|
||||
if (lookahead == 't') ADVANCE(9);
|
||||
END_STATE();
|
||||
case 27:
|
||||
if (lookahead == 'y') ADVANCE(7);
|
||||
END_STATE();
|
||||
case 28:
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(28)
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(35);
|
||||
END_STATE();
|
||||
case 29:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(5);
|
||||
END_STATE();
|
||||
case 30:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(42);
|
||||
END_STATE();
|
||||
case 31:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(29);
|
||||
END_STATE();
|
||||
case 32:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(30);
|
||||
END_STATE();
|
||||
case 33:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(4);
|
||||
END_STATE();
|
||||
case 34:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(33);
|
||||
END_STATE();
|
||||
case 35:
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(34);
|
||||
END_STATE();
|
||||
case 36:
|
||||
if (eof) ADVANCE(37);
|
||||
if (lookahead == 'f') ADVANCE(18);
|
||||
if (lookahead == 'l') ADVANCE(10);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(36)
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(49);
|
||||
END_STATE();
|
||||
case 37:
|
||||
ACCEPT_TOKEN(ts_builtin_sym_end);
|
||||
END_STATE();
|
||||
case 38:
|
||||
ACCEPT_TOKEN(anon_sym_today_COLON);
|
||||
END_STATE();
|
||||
case 39:
|
||||
ACCEPT_TOKEN(anon_sym_file_COLON);
|
||||
END_STATE();
|
||||
case 40:
|
||||
ACCEPT_TOKEN(anon_sym_LF);
|
||||
if (lookahead == '\n') ADVANCE(40);
|
||||
END_STATE();
|
||||
case 41:
|
||||
ACCEPT_TOKEN(anon_sym_last_modified_COLON);
|
||||
END_STATE();
|
||||
case 42:
|
||||
ACCEPT_TOKEN(sym_date);
|
||||
END_STATE();
|
||||
case 43:
|
||||
ACCEPT_TOKEN(sym_filename);
|
||||
if (lookahead == ' ') ADVANCE(43);
|
||||
if (('-' <= lookahead && lookahead <= '9') ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
lookahead == '_' ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(44);
|
||||
END_STATE();
|
||||
case 44:
|
||||
ACCEPT_TOKEN(sym_filename);
|
||||
if (lookahead == ' ' ||
|
||||
('-' <= lookahead && lookahead <= '9') ||
|
||||
('A' <= lookahead && lookahead <= 'Z') ||
|
||||
lookahead == '_' ||
|
||||
('a' <= lookahead && lookahead <= 'z')) ADVANCE(44);
|
||||
END_STATE();
|
||||
case 45:
|
||||
ACCEPT_TOKEN(sym_number);
|
||||
if (lookahead == '-') ADVANCE(31);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(49);
|
||||
END_STATE();
|
||||
case 46:
|
||||
ACCEPT_TOKEN(sym_number);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(45);
|
||||
END_STATE();
|
||||
case 47:
|
||||
ACCEPT_TOKEN(sym_number);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(46);
|
||||
END_STATE();
|
||||
case 48:
|
||||
ACCEPT_TOKEN(sym_number);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(47);
|
||||
END_STATE();
|
||||
case 49:
|
||||
ACCEPT_TOKEN(sym_number);
|
||||
if (('0' <= lookahead && lookahead <= '9')) ADVANCE(49);
|
||||
END_STATE();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||
[0] = {.lex_state = 0},
|
||||
[1] = {.lex_state = 0},
|
||||
[2] = {.lex_state = 0},
|
||||
[3] = {.lex_state = 0},
|
||||
[4] = {.lex_state = 36},
|
||||
[5] = {.lex_state = 0},
|
||||
[6] = {.lex_state = 36},
|
||||
[7] = {.lex_state = 36},
|
||||
[8] = {.lex_state = 0},
|
||||
[9] = {.lex_state = 0},
|
||||
[10] = {.lex_state = 0},
|
||||
[11] = {.lex_state = 36},
|
||||
[12] = {.lex_state = 0},
|
||||
[13] = {.lex_state = 0},
|
||||
[14] = {.lex_state = 0},
|
||||
[15] = {.lex_state = 28},
|
||||
[16] = {.lex_state = 0},
|
||||
[17] = {.lex_state = 3},
|
||||
[18] = {.lex_state = 1},
|
||||
[19] = {.lex_state = 28},
|
||||
};
|
||||
|
||||
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
[0] = {
|
||||
[ts_builtin_sym_end] = ACTIONS(1),
|
||||
[anon_sym_today_COLON] = ACTIONS(1),
|
||||
[anon_sym_file_COLON] = ACTIONS(1),
|
||||
[anon_sym_last_modified_COLON] = ACTIONS(1),
|
||||
[sym_date] = ACTIONS(1),
|
||||
[sym_number] = ACTIONS(1),
|
||||
},
|
||||
[1] = {
|
||||
[sym_blame_info] = STATE(16),
|
||||
[sym__today] = STATE(8),
|
||||
[anon_sym_today_COLON] = ACTIONS(3),
|
||||
},
|
||||
};
|
||||
|
||||
static const uint16_t ts_small_parse_table[] = {
|
||||
[0] = 4,
|
||||
ACTIONS(7), 1,
|
||||
anon_sym_last_modified_COLON,
|
||||
STATE(3), 1,
|
||||
aux_sym_file_entry_repeat1,
|
||||
STATE(12), 1,
|
||||
sym_blame_entry,
|
||||
ACTIONS(5), 2,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
[14] = 4,
|
||||
ACTIONS(7), 1,
|
||||
anon_sym_last_modified_COLON,
|
||||
STATE(5), 1,
|
||||
aux_sym_file_entry_repeat1,
|
||||
STATE(12), 1,
|
||||
sym_blame_entry,
|
||||
ACTIONS(9), 2,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
[28] = 3,
|
||||
ACTIONS(13), 1,
|
||||
sym_number,
|
||||
STATE(6), 1,
|
||||
aux_sym_blame_entry_repeat1,
|
||||
ACTIONS(11), 3,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
anon_sym_last_modified_COLON,
|
||||
[40] = 4,
|
||||
ACTIONS(17), 1,
|
||||
anon_sym_last_modified_COLON,
|
||||
STATE(5), 1,
|
||||
aux_sym_file_entry_repeat1,
|
||||
STATE(12), 1,
|
||||
sym_blame_entry,
|
||||
ACTIONS(15), 2,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
[54] = 3,
|
||||
ACTIONS(13), 1,
|
||||
sym_number,
|
||||
STATE(7), 1,
|
||||
aux_sym_blame_entry_repeat1,
|
||||
ACTIONS(20), 3,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
anon_sym_last_modified_COLON,
|
||||
[66] = 3,
|
||||
ACTIONS(24), 1,
|
||||
sym_number,
|
||||
STATE(7), 1,
|
||||
aux_sym_blame_entry_repeat1,
|
||||
ACTIONS(22), 3,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
anon_sym_last_modified_COLON,
|
||||
[78] = 4,
|
||||
ACTIONS(27), 1,
|
||||
ts_builtin_sym_end,
|
||||
ACTIONS(29), 1,
|
||||
anon_sym_file_COLON,
|
||||
STATE(9), 1,
|
||||
aux_sym_blame_info_repeat1,
|
||||
STATE(14), 1,
|
||||
sym_file_entry,
|
||||
[91] = 4,
|
||||
ACTIONS(29), 1,
|
||||
anon_sym_file_COLON,
|
||||
ACTIONS(31), 1,
|
||||
ts_builtin_sym_end,
|
||||
STATE(10), 1,
|
||||
aux_sym_blame_info_repeat1,
|
||||
STATE(14), 1,
|
||||
sym_file_entry,
|
||||
[104] = 4,
|
||||
ACTIONS(33), 1,
|
||||
ts_builtin_sym_end,
|
||||
ACTIONS(35), 1,
|
||||
anon_sym_file_COLON,
|
||||
STATE(10), 1,
|
||||
aux_sym_blame_info_repeat1,
|
||||
STATE(14), 1,
|
||||
sym_file_entry,
|
||||
[117] = 1,
|
||||
ACTIONS(38), 4,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
anon_sym_last_modified_COLON,
|
||||
sym_number,
|
||||
[124] = 1,
|
||||
ACTIONS(40), 3,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
anon_sym_last_modified_COLON,
|
||||
[130] = 1,
|
||||
ACTIONS(42), 2,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
[135] = 1,
|
||||
ACTIONS(44), 2,
|
||||
ts_builtin_sym_end,
|
||||
anon_sym_file_COLON,
|
||||
[140] = 1,
|
||||
ACTIONS(46), 1,
|
||||
sym_date,
|
||||
[144] = 1,
|
||||
ACTIONS(48), 1,
|
||||
ts_builtin_sym_end,
|
||||
[148] = 1,
|
||||
ACTIONS(50), 1,
|
||||
sym_filename,
|
||||
[152] = 1,
|
||||
ACTIONS(52), 1,
|
||||
anon_sym_LF,
|
||||
[156] = 1,
|
||||
ACTIONS(54), 1,
|
||||
sym_date,
|
||||
};
|
||||
|
||||
static const uint32_t ts_small_parse_table_map[] = {
|
||||
[SMALL_STATE(2)] = 0,
|
||||
[SMALL_STATE(3)] = 14,
|
||||
[SMALL_STATE(4)] = 28,
|
||||
[SMALL_STATE(5)] = 40,
|
||||
[SMALL_STATE(6)] = 54,
|
||||
[SMALL_STATE(7)] = 66,
|
||||
[SMALL_STATE(8)] = 78,
|
||||
[SMALL_STATE(9)] = 91,
|
||||
[SMALL_STATE(10)] = 104,
|
||||
[SMALL_STATE(11)] = 117,
|
||||
[SMALL_STATE(12)] = 124,
|
||||
[SMALL_STATE(13)] = 130,
|
||||
[SMALL_STATE(14)] = 135,
|
||||
[SMALL_STATE(15)] = 140,
|
||||
[SMALL_STATE(16)] = 144,
|
||||
[SMALL_STATE(17)] = 148,
|
||||
[SMALL_STATE(18)] = 152,
|
||||
[SMALL_STATE(19)] = 156,
|
||||
};
|
||||
|
||||
static const TSParseActionEntry ts_parse_actions[] = {
|
||||
[0] = {.entry = {.count = 0, .reusable = false}},
|
||||
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
|
||||
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15),
|
||||
[5] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_file_entry, 3, .production_id = 6),
|
||||
[7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19),
|
||||
[9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_file_entry, 4, .production_id = 8),
|
||||
[11] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_blame_entry, 2, .production_id = 9),
|
||||
[13] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11),
|
||||
[15] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_file_entry_repeat1, 2, .production_id = 10),
|
||||
[17] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_file_entry_repeat1, 2, .production_id = 10), SHIFT_REPEAT(19),
|
||||
[20] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_blame_entry, 3, .production_id = 12),
|
||||
[22] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_blame_entry_repeat1, 2, .production_id = 13),
|
||||
[24] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_blame_entry_repeat1, 2, .production_id = 13), SHIFT_REPEAT(11),
|
||||
[27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_blame_info, 1, .production_id = 1),
|
||||
[29] = {.entry = {.count = 1, .reusable = true}}, SHIFT(17),
|
||||
[31] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_blame_info, 2, .production_id = 4),
|
||||
[33] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_blame_info_repeat1, 2, .production_id = 5),
|
||||
[35] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_blame_info_repeat1, 2, .production_id = 5), SHIFT_REPEAT(17),
|
||||
[38] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_blame_entry_repeat1, 1, .production_id = 11),
|
||||
[40] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_file_entry_repeat1, 1, .production_id = 7),
|
||||
[42] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__today, 2, .production_id = 2),
|
||||
[44] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_blame_info_repeat1, 1, .production_id = 3),
|
||||
[46] = {.entry = {.count = 1, .reusable = true}}, SHIFT(13),
|
||||
[48] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
|
||||
[50] = {.entry = {.count = 1, .reusable = true}}, SHIFT(18),
|
||||
[52] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2),
|
||||
[54] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#define extern __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
extern const TSLanguage *tree_sitter_blame(void) {
|
||||
static const TSLanguage language = {
|
||||
.version = LANGUAGE_VERSION,
|
||||
.symbol_count = SYMBOL_COUNT,
|
||||
.alias_count = ALIAS_COUNT,
|
||||
.token_count = TOKEN_COUNT,
|
||||
.external_token_count = EXTERNAL_TOKEN_COUNT,
|
||||
.state_count = STATE_COUNT,
|
||||
.large_state_count = LARGE_STATE_COUNT,
|
||||
.production_id_count = PRODUCTION_ID_COUNT,
|
||||
.field_count = FIELD_COUNT,
|
||||
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
||||
.parse_table = &ts_parse_table[0][0],
|
||||
.small_parse_table = ts_small_parse_table,
|
||||
.small_parse_table_map = ts_small_parse_table_map,
|
||||
.parse_actions = ts_parse_actions,
|
||||
.symbol_names = ts_symbol_names,
|
||||
.field_names = ts_field_names,
|
||||
.field_map_slices = ts_field_map_slices,
|
||||
.field_map_entries = ts_field_map_entries,
|
||||
.symbol_metadata = ts_symbol_metadata,
|
||||
.public_symbol_map = ts_symbol_map,
|
||||
.alias_map = ts_non_terminal_alias_map,
|
||||
.alias_sequences = &ts_alias_sequences[0][0],
|
||||
.lex_modes = ts_lex_modes,
|
||||
.lex_fn = ts_lex,
|
||||
.primary_state_ids = ts_primary_state_ids,
|
||||
};
|
||||
return &language;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
224
ql/buramu/tree-sitter-blame/src/tree_sitter/parser.h
Normal file
224
ql/buramu/tree-sitter-blame/src/tree_sitter/parser.h
Normal file
@@ -0,0 +1,224 @@
|
||||
#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
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
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
|
||||
*/
|
||||
|
||||
#define START_LEXER() \
|
||||
bool result = false; \
|
||||
bool skip = false; \
|
||||
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_
|
||||
24
ql/buramu/tree-sitter-blame/test.blame
Normal file
24
ql/buramu/tree-sitter-blame/test.blame
Normal file
@@ -0,0 +1,24 @@
|
||||
today: 2023-02-16
|
||||
file: go/ql/lib/semmle/go/security/FlowSources.qll
|
||||
blame: 33 2022-12-19
|
||||
file: python/ql/lib/semmle/python/security/BadTagFilterQuery.qll
|
||||
blame: 7 2022-11-01
|
||||
file: csharp/ql/lib/semmle/code/csharp/Assignable.qll
|
||||
blame: 128 2022-10-12
|
||||
blame: 499 2022-10-12
|
||||
file: python/ql/lib/semmle/python/frameworks/Starlette.qll
|
||||
blame: 164 2022-09-09
|
||||
file: ql/ql/src/queries/style/docs/PredicateDocs.ql
|
||||
blame: 21 2022-08-15
|
||||
file: java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll
|
||||
blame: 308 2022-09-07
|
||||
file: javascript/ql/lib/semmle/javascript/frameworks/AngularJS/AngularJSCore.qll
|
||||
blame: 627 2022-03-30
|
||||
blame: 633 2022-03-30
|
||||
blame: 636 2022-03-30
|
||||
blame: 639 2022-03-30
|
||||
file: javascript/ql/lib/semmle/javascript/frameworks/Testing.qll
|
||||
blame: 41 2022-08-24
|
||||
file: javascript/ql/lib/semmle/javascript/dataflow/DataFlow.qll
|
||||
blame: 145 2022-03-30
|
||||
blame: 1821 2022-03-13
|
||||
Reference in New Issue
Block a user