feat: with base
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
commit
8d8a40a3a3
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
target/
|
||||
node_modules/
|
26
Cargo.toml
Normal file
26
Cargo.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "tree-sitter-hurl"
|
||||
description = "hurl grammar for the tree-sitter parsing library"
|
||||
version = "0.0.1"
|
||||
keywords = ["incremental", "parsing", "hurl"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/tree-sitter/tree-sitter-hurl"
|
||||
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.10"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
19
binding.gyp
Normal file
19
binding.gyp
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "tree_sitter_hurl_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
bindings/node/binding.cc
Normal file
28
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_hurl();
|
||||
|
||||
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_hurl());
|
||||
|
||||
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("hurl").ToLocalChecked());
|
||||
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
||||
}
|
||||
|
||||
NODE_MODULE(tree_sitter_hurl_binding, Init)
|
||||
|
||||
} // namespace
|
19
bindings/node/index.js
Normal file
19
bindings/node/index.js
Normal file
@ -0,0 +1,19 @@
|
||||
try {
|
||||
module.exports = require("../../build/Release/tree_sitter_hurl_binding");
|
||||
} catch (error1) {
|
||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error1;
|
||||
}
|
||||
try {
|
||||
module.exports = require("../../build/Debug/tree_sitter_hurl_binding");
|
||||
} catch (error2) {
|
||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error2;
|
||||
}
|
||||
throw error1
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||
} catch (_) {}
|
40
bindings/rust/build.rs
Normal file
40
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
bindings/rust/lib.rs
Normal file
52
bindings/rust/lib.rs
Normal file
@ -0,0 +1,52 @@
|
||||
//! This crate provides hurl 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_hurl::language()).expect("Error loading hurl 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_hurl() -> 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_hurl() }
|
||||
}
|
||||
|
||||
/// 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 hurl language");
|
||||
}
|
||||
}
|
23
corpus/requests.txt
Normal file
23
corpus/requests.txt
Normal file
@ -0,0 +1,23 @@
|
||||
===
|
||||
GET request
|
||||
===
|
||||
|
||||
GET https://somewhere.com
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(request_declaration
|
||||
(request_literal)))
|
||||
|
||||
===
|
||||
GET request
|
||||
===
|
||||
|
||||
POST https://somewhere.com?query=something
|
||||
|
||||
---
|
||||
|
||||
(source_file
|
||||
(request_declaration
|
||||
(request_literal)))
|
41
grammar.js
Normal file
41
grammar.js
Normal file
@ -0,0 +1,41 @@
|
||||
module.exports = grammar({
|
||||
name: "hurl",
|
||||
|
||||
rules: {
|
||||
source_file: ($) => repeat($._statement),
|
||||
|
||||
// statements
|
||||
|
||||
_statement: ($) =>
|
||||
choice($._declaration_statement),
|
||||
|
||||
_declaration_statement: ($) =>
|
||||
choice($.request_declaration),
|
||||
|
||||
request_declaration: ($) =>
|
||||
seq($._literal, field("url", $._url)),
|
||||
|
||||
_literal: ($) => choice($.request_literal),
|
||||
|
||||
request_literal: (_$) =>
|
||||
choice(
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"CONNECT",
|
||||
"OPTIONS",
|
||||
"TRACE",
|
||||
"PATCH",
|
||||
"LINK",
|
||||
"UNLINK",
|
||||
"PURGE",
|
||||
"LOCK",
|
||||
"UNLOCK",
|
||||
"PROPFIND",
|
||||
"VIEW"
|
||||
),
|
||||
|
||||
_url: ($) => /\S+/,
|
||||
},
|
||||
});
|
50
package-lock.json
generated
Normal file
50
package-lock.json
generated
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "tree-sitter-hurl",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tree-sitter-hurl",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"nan": "^2.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.8",
|
||||
"tree-sitter-cli": "^0.20.8"
|
||||
}
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.17.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz",
|
||||
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ=="
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/tree-sitter-cli": {
|
||||
"version": "0.20.8",
|
||||
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.8.tgz",
|
||||
"integrity": "sha512-XjTcS3wdTy/2cc/ptMLc/WRyOLECRYcMTrSWyhZnj1oGSOWbHLTklgsgRICU3cPfb0vy+oZCC33M43u6R1HSCA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"tree-sitter": "cli.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
package.json
Normal file
30
package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "tree-sitter-hurl",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "bindings/node",
|
||||
"scripts": {
|
||||
"test": "tree-sitter test",
|
||||
"generate": "tree-sitter generate",
|
||||
"format": "prettier -w --print-width=50 grammar.js",
|
||||
"ci": "npm run generate && npm run test"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"nan": "^2.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.8.8",
|
||||
"tree-sitter-cli": "^0.20.8"
|
||||
},
|
||||
"tree-sitter": [
|
||||
{
|
||||
"scope": "source.hurl",
|
||||
"file-types": [
|
||||
"hurl"
|
||||
],
|
||||
"injection-regex": "hurl"
|
||||
}
|
||||
]
|
||||
}
|
17
queries/highlights.scm
Normal file
17
queries/highlights.scm
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
"GET"
|
||||
"POST"
|
||||
"PUT"
|
||||
"DELETE"
|
||||
"CONNECT"
|
||||
"OPTIONS"
|
||||
"TRACE"
|
||||
"PATCH"
|
||||
"LINK"
|
||||
"UNLINK"
|
||||
"PURGE"
|
||||
"LOCK"
|
||||
"UNLOCK"
|
||||
"PROPFIND"
|
||||
"VIEW"
|
||||
] @keyword
|
137
src/grammar.json
Normal file
137
src/grammar.json
Normal file
@ -0,0 +1,137 @@
|
||||
{
|
||||
"name": "hurl",
|
||||
"rules": {
|
||||
"source_file": {
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_statement"
|
||||
}
|
||||
},
|
||||
"_statement": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_declaration_statement"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_declaration_statement": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "request_declaration"
|
||||
}
|
||||
]
|
||||
},
|
||||
"request_declaration": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "_literal"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "url",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "_url"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"_literal": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "request_literal"
|
||||
}
|
||||
]
|
||||
},
|
||||
"request_literal": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "GET"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "POST"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "PUT"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "DELETE"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "CONNECT"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "OPTIONS"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "TRACE"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "PATCH"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "LINK"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "UNLINK"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "PURGE"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "LOCK"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "UNLOCK"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "PROPFIND"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "VIEW"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_url": {
|
||||
"type": "PATTERN",
|
||||
"value": "\\S+"
|
||||
}
|
||||
},
|
||||
"extras": [
|
||||
{
|
||||
"type": "PATTERN",
|
||||
"value": "\\s"
|
||||
}
|
||||
],
|
||||
"conflicts": [],
|
||||
"precedences": [],
|
||||
"externals": [],
|
||||
"inline": [],
|
||||
"supertypes": []
|
||||
}
|
||||
|
97
src/node-types.json
Normal file
97
src/node-types.json
Normal file
@ -0,0 +1,97 @@
|
||||
[
|
||||
{
|
||||
"type": "request_declaration",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "request_literal",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "request_literal",
|
||||
"named": true,
|
||||
"fields": {}
|
||||
},
|
||||
{
|
||||
"type": "source_file",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "request_declaration",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CONNECT",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "DELETE",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "GET",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "LINK",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "LOCK",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "OPTIONS",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "PATCH",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "POST",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "PROPFIND",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "PURGE",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "PUT",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "TRACE",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "UNLINK",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "UNLOCK",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "VIEW",
|
||||
"named": false
|
||||
}
|
||||
]
|
682
src/parser.c
Normal file
682
src/parser.c
Normal file
@ -0,0 +1,682 @@
|
||||
#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 8
|
||||
#define LARGE_STATE_COUNT 5
|
||||
#define SYMBOL_COUNT 24
|
||||
#define ALIAS_COUNT 0
|
||||
#define TOKEN_COUNT 17
|
||||
#define EXTERNAL_TOKEN_COUNT 0
|
||||
#define FIELD_COUNT 1
|
||||
#define MAX_ALIAS_SEQUENCE_LENGTH 2
|
||||
#define PRODUCTION_ID_COUNT 2
|
||||
|
||||
enum {
|
||||
anon_sym_GET = 1,
|
||||
anon_sym_POST = 2,
|
||||
anon_sym_PUT = 3,
|
||||
anon_sym_DELETE = 4,
|
||||
anon_sym_CONNECT = 5,
|
||||
anon_sym_OPTIONS = 6,
|
||||
anon_sym_TRACE = 7,
|
||||
anon_sym_PATCH = 8,
|
||||
anon_sym_LINK = 9,
|
||||
anon_sym_UNLINK = 10,
|
||||
anon_sym_PURGE = 11,
|
||||
anon_sym_LOCK = 12,
|
||||
anon_sym_UNLOCK = 13,
|
||||
anon_sym_PROPFIND = 14,
|
||||
anon_sym_VIEW = 15,
|
||||
sym__url = 16,
|
||||
sym_source_file = 17,
|
||||
sym__statement = 18,
|
||||
sym__declaration_statement = 19,
|
||||
sym_request_declaration = 20,
|
||||
sym__literal = 21,
|
||||
sym_request_literal = 22,
|
||||
aux_sym_source_file_repeat1 = 23,
|
||||
};
|
||||
|
||||
static const char * const ts_symbol_names[] = {
|
||||
[ts_builtin_sym_end] = "end",
|
||||
[anon_sym_GET] = "GET",
|
||||
[anon_sym_POST] = "POST",
|
||||
[anon_sym_PUT] = "PUT",
|
||||
[anon_sym_DELETE] = "DELETE",
|
||||
[anon_sym_CONNECT] = "CONNECT",
|
||||
[anon_sym_OPTIONS] = "OPTIONS",
|
||||
[anon_sym_TRACE] = "TRACE",
|
||||
[anon_sym_PATCH] = "PATCH",
|
||||
[anon_sym_LINK] = "LINK",
|
||||
[anon_sym_UNLINK] = "UNLINK",
|
||||
[anon_sym_PURGE] = "PURGE",
|
||||
[anon_sym_LOCK] = "LOCK",
|
||||
[anon_sym_UNLOCK] = "UNLOCK",
|
||||
[anon_sym_PROPFIND] = "PROPFIND",
|
||||
[anon_sym_VIEW] = "VIEW",
|
||||
[sym__url] = "_url",
|
||||
[sym_source_file] = "source_file",
|
||||
[sym__statement] = "_statement",
|
||||
[sym__declaration_statement] = "_declaration_statement",
|
||||
[sym_request_declaration] = "request_declaration",
|
||||
[sym__literal] = "_literal",
|
||||
[sym_request_literal] = "request_literal",
|
||||
[aux_sym_source_file_repeat1] = "source_file_repeat1",
|
||||
};
|
||||
|
||||
static const TSSymbol ts_symbol_map[] = {
|
||||
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
||||
[anon_sym_GET] = anon_sym_GET,
|
||||
[anon_sym_POST] = anon_sym_POST,
|
||||
[anon_sym_PUT] = anon_sym_PUT,
|
||||
[anon_sym_DELETE] = anon_sym_DELETE,
|
||||
[anon_sym_CONNECT] = anon_sym_CONNECT,
|
||||
[anon_sym_OPTIONS] = anon_sym_OPTIONS,
|
||||
[anon_sym_TRACE] = anon_sym_TRACE,
|
||||
[anon_sym_PATCH] = anon_sym_PATCH,
|
||||
[anon_sym_LINK] = anon_sym_LINK,
|
||||
[anon_sym_UNLINK] = anon_sym_UNLINK,
|
||||
[anon_sym_PURGE] = anon_sym_PURGE,
|
||||
[anon_sym_LOCK] = anon_sym_LOCK,
|
||||
[anon_sym_UNLOCK] = anon_sym_UNLOCK,
|
||||
[anon_sym_PROPFIND] = anon_sym_PROPFIND,
|
||||
[anon_sym_VIEW] = anon_sym_VIEW,
|
||||
[sym__url] = sym__url,
|
||||
[sym_source_file] = sym_source_file,
|
||||
[sym__statement] = sym__statement,
|
||||
[sym__declaration_statement] = sym__declaration_statement,
|
||||
[sym_request_declaration] = sym_request_declaration,
|
||||
[sym__literal] = sym__literal,
|
||||
[sym_request_literal] = sym_request_literal,
|
||||
[aux_sym_source_file_repeat1] = aux_sym_source_file_repeat1,
|
||||
};
|
||||
|
||||
static const TSSymbolMetadata ts_symbol_metadata[] = {
|
||||
[ts_builtin_sym_end] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[anon_sym_GET] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_POST] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_PUT] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_DELETE] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_CONNECT] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_OPTIONS] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_TRACE] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_PATCH] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_LINK] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_UNLINK] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_PURGE] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_LOCK] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_UNLOCK] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_PROPFIND] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[anon_sym_VIEW] = {
|
||||
.visible = true,
|
||||
.named = false,
|
||||
},
|
||||
[sym__url] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym_source_file] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym__statement] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym__declaration_statement] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym_request_declaration] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[sym__literal] = {
|
||||
.visible = false,
|
||||
.named = true,
|
||||
},
|
||||
[sym_request_literal] = {
|
||||
.visible = true,
|
||||
.named = true,
|
||||
},
|
||||
[aux_sym_source_file_repeat1] = {
|
||||
.visible = false,
|
||||
.named = false,
|
||||
},
|
||||
};
|
||||
|
||||
enum {
|
||||
field_url = 1,
|
||||
};
|
||||
|
||||
static const char * const ts_field_names[] = {
|
||||
[0] = NULL,
|
||||
[field_url] = "url",
|
||||
};
|
||||
|
||||
static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = {
|
||||
[1] = {.index = 0, .length = 1},
|
||||
};
|
||||
|
||||
static const TSFieldMapEntry ts_field_map_entries[] = {
|
||||
[0] =
|
||||
{field_url, 1},
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
||||
START_LEXER();
|
||||
eof = lexer->eof(lexer);
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (eof) ADVANCE(55);
|
||||
if (lookahead == 'C') ADVANCE(39);
|
||||
if (lookahead == 'D') ADVANCE(9);
|
||||
if (lookahead == 'G') ADVANCE(10);
|
||||
if (lookahead == 'L') ADVANCE(21);
|
||||
if (lookahead == 'O') ADVANCE(42);
|
||||
if (lookahead == 'P') ADVANCE(1);
|
||||
if (lookahead == 'T') ADVANCE(43);
|
||||
if (lookahead == 'U') ADVANCE(33);
|
||||
if (lookahead == 'V') ADVANCE(20);
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(0)
|
||||
END_STATE();
|
||||
case 1:
|
||||
if (lookahead == 'A') ADVANCE(51);
|
||||
if (lookahead == 'O') ADVANCE(46);
|
||||
if (lookahead == 'R') ADVANCE(38);
|
||||
if (lookahead == 'U') ADVANCE(44);
|
||||
END_STATE();
|
||||
case 2:
|
||||
if (lookahead == 'A') ADVANCE(7);
|
||||
END_STATE();
|
||||
case 3:
|
||||
if (lookahead == 'C') ADVANCE(19);
|
||||
END_STATE();
|
||||
case 4:
|
||||
if (lookahead == 'C') ADVANCE(26);
|
||||
END_STATE();
|
||||
case 5:
|
||||
if (lookahead == 'C') ADVANCE(28);
|
||||
END_STATE();
|
||||
case 6:
|
||||
if (lookahead == 'C') ADVANCE(49);
|
||||
END_STATE();
|
||||
case 7:
|
||||
if (lookahead == 'C') ADVANCE(13);
|
||||
END_STATE();
|
||||
case 8:
|
||||
if (lookahead == 'D') ADVANCE(69);
|
||||
END_STATE();
|
||||
case 9:
|
||||
if (lookahead == 'E') ADVANCE(29);
|
||||
END_STATE();
|
||||
case 10:
|
||||
if (lookahead == 'E') ADVANCE(47);
|
||||
END_STATE();
|
||||
case 11:
|
||||
if (lookahead == 'E') ADVANCE(53);
|
||||
END_STATE();
|
||||
case 12:
|
||||
if (lookahead == 'E') ADVANCE(66);
|
||||
END_STATE();
|
||||
case 13:
|
||||
if (lookahead == 'E') ADVANCE(62);
|
||||
END_STATE();
|
||||
case 14:
|
||||
if (lookahead == 'E') ADVANCE(59);
|
||||
END_STATE();
|
||||
case 15:
|
||||
if (lookahead == 'E') ADVANCE(6);
|
||||
END_STATE();
|
||||
case 16:
|
||||
if (lookahead == 'E') ADVANCE(52);
|
||||
END_STATE();
|
||||
case 17:
|
||||
if (lookahead == 'F') ADVANCE(23);
|
||||
END_STATE();
|
||||
case 18:
|
||||
if (lookahead == 'G') ADVANCE(12);
|
||||
END_STATE();
|
||||
case 19:
|
||||
if (lookahead == 'H') ADVANCE(63);
|
||||
END_STATE();
|
||||
case 20:
|
||||
if (lookahead == 'I') ADVANCE(11);
|
||||
END_STATE();
|
||||
case 21:
|
||||
if (lookahead == 'I') ADVANCE(31);
|
||||
if (lookahead == 'O') ADVANCE(4);
|
||||
END_STATE();
|
||||
case 22:
|
||||
if (lookahead == 'I') ADVANCE(35);
|
||||
if (lookahead == 'O') ADVANCE(5);
|
||||
END_STATE();
|
||||
case 23:
|
||||
if (lookahead == 'I') ADVANCE(32);
|
||||
END_STATE();
|
||||
case 24:
|
||||
if (lookahead == 'I') ADVANCE(40);
|
||||
END_STATE();
|
||||
case 25:
|
||||
if (lookahead == 'K') ADVANCE(64);
|
||||
END_STATE();
|
||||
case 26:
|
||||
if (lookahead == 'K') ADVANCE(67);
|
||||
END_STATE();
|
||||
case 27:
|
||||
if (lookahead == 'K') ADVANCE(65);
|
||||
END_STATE();
|
||||
case 28:
|
||||
if (lookahead == 'K') ADVANCE(68);
|
||||
END_STATE();
|
||||
case 29:
|
||||
if (lookahead == 'L') ADVANCE(16);
|
||||
END_STATE();
|
||||
case 30:
|
||||
if (lookahead == 'L') ADVANCE(22);
|
||||
END_STATE();
|
||||
case 31:
|
||||
if (lookahead == 'N') ADVANCE(25);
|
||||
END_STATE();
|
||||
case 32:
|
||||
if (lookahead == 'N') ADVANCE(8);
|
||||
END_STATE();
|
||||
case 33:
|
||||
if (lookahead == 'N') ADVANCE(30);
|
||||
END_STATE();
|
||||
case 34:
|
||||
if (lookahead == 'N') ADVANCE(45);
|
||||
END_STATE();
|
||||
case 35:
|
||||
if (lookahead == 'N') ADVANCE(27);
|
||||
END_STATE();
|
||||
case 36:
|
||||
if (lookahead == 'N') ADVANCE(37);
|
||||
END_STATE();
|
||||
case 37:
|
||||
if (lookahead == 'N') ADVANCE(15);
|
||||
END_STATE();
|
||||
case 38:
|
||||
if (lookahead == 'O') ADVANCE(41);
|
||||
END_STATE();
|
||||
case 39:
|
||||
if (lookahead == 'O') ADVANCE(36);
|
||||
END_STATE();
|
||||
case 40:
|
||||
if (lookahead == 'O') ADVANCE(34);
|
||||
END_STATE();
|
||||
case 41:
|
||||
if (lookahead == 'P') ADVANCE(17);
|
||||
END_STATE();
|
||||
case 42:
|
||||
if (lookahead == 'P') ADVANCE(50);
|
||||
END_STATE();
|
||||
case 43:
|
||||
if (lookahead == 'R') ADVANCE(2);
|
||||
END_STATE();
|
||||
case 44:
|
||||
if (lookahead == 'R') ADVANCE(18);
|
||||
if (lookahead == 'T') ADVANCE(58);
|
||||
END_STATE();
|
||||
case 45:
|
||||
if (lookahead == 'S') ADVANCE(61);
|
||||
END_STATE();
|
||||
case 46:
|
||||
if (lookahead == 'S') ADVANCE(48);
|
||||
END_STATE();
|
||||
case 47:
|
||||
if (lookahead == 'T') ADVANCE(56);
|
||||
END_STATE();
|
||||
case 48:
|
||||
if (lookahead == 'T') ADVANCE(57);
|
||||
END_STATE();
|
||||
case 49:
|
||||
if (lookahead == 'T') ADVANCE(60);
|
||||
END_STATE();
|
||||
case 50:
|
||||
if (lookahead == 'T') ADVANCE(24);
|
||||
END_STATE();
|
||||
case 51:
|
||||
if (lookahead == 'T') ADVANCE(3);
|
||||
END_STATE();
|
||||
case 52:
|
||||
if (lookahead == 'T') ADVANCE(14);
|
||||
END_STATE();
|
||||
case 53:
|
||||
if (lookahead == 'W') ADVANCE(70);
|
||||
END_STATE();
|
||||
case 54:
|
||||
if (lookahead == '\t' ||
|
||||
lookahead == '\n' ||
|
||||
lookahead == '\r' ||
|
||||
lookahead == ' ') SKIP(54)
|
||||
if (lookahead != 0) ADVANCE(71);
|
||||
END_STATE();
|
||||
case 55:
|
||||
ACCEPT_TOKEN(ts_builtin_sym_end);
|
||||
END_STATE();
|
||||
case 56:
|
||||
ACCEPT_TOKEN(anon_sym_GET);
|
||||
END_STATE();
|
||||
case 57:
|
||||
ACCEPT_TOKEN(anon_sym_POST);
|
||||
END_STATE();
|
||||
case 58:
|
||||
ACCEPT_TOKEN(anon_sym_PUT);
|
||||
END_STATE();
|
||||
case 59:
|
||||
ACCEPT_TOKEN(anon_sym_DELETE);
|
||||
END_STATE();
|
||||
case 60:
|
||||
ACCEPT_TOKEN(anon_sym_CONNECT);
|
||||
END_STATE();
|
||||
case 61:
|
||||
ACCEPT_TOKEN(anon_sym_OPTIONS);
|
||||
END_STATE();
|
||||
case 62:
|
||||
ACCEPT_TOKEN(anon_sym_TRACE);
|
||||
END_STATE();
|
||||
case 63:
|
||||
ACCEPT_TOKEN(anon_sym_PATCH);
|
||||
END_STATE();
|
||||
case 64:
|
||||
ACCEPT_TOKEN(anon_sym_LINK);
|
||||
END_STATE();
|
||||
case 65:
|
||||
ACCEPT_TOKEN(anon_sym_UNLINK);
|
||||
END_STATE();
|
||||
case 66:
|
||||
ACCEPT_TOKEN(anon_sym_PURGE);
|
||||
END_STATE();
|
||||
case 67:
|
||||
ACCEPT_TOKEN(anon_sym_LOCK);
|
||||
END_STATE();
|
||||
case 68:
|
||||
ACCEPT_TOKEN(anon_sym_UNLOCK);
|
||||
END_STATE();
|
||||
case 69:
|
||||
ACCEPT_TOKEN(anon_sym_PROPFIND);
|
||||
END_STATE();
|
||||
case 70:
|
||||
ACCEPT_TOKEN(anon_sym_VIEW);
|
||||
END_STATE();
|
||||
case 71:
|
||||
ACCEPT_TOKEN(sym__url);
|
||||
if (lookahead != 0 &&
|
||||
lookahead != '\t' &&
|
||||
lookahead != '\n' &&
|
||||
lookahead != '\r' &&
|
||||
lookahead != ' ') ADVANCE(71);
|
||||
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 = 0},
|
||||
[5] = {.lex_state = 54},
|
||||
[6] = {.lex_state = 0},
|
||||
[7] = {.lex_state = 54},
|
||||
};
|
||||
|
||||
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
[0] = {
|
||||
[ts_builtin_sym_end] = ACTIONS(1),
|
||||
[anon_sym_GET] = ACTIONS(1),
|
||||
[anon_sym_POST] = ACTIONS(1),
|
||||
[anon_sym_PUT] = ACTIONS(1),
|
||||
[anon_sym_DELETE] = ACTIONS(1),
|
||||
[anon_sym_CONNECT] = ACTIONS(1),
|
||||
[anon_sym_OPTIONS] = ACTIONS(1),
|
||||
[anon_sym_TRACE] = ACTIONS(1),
|
||||
[anon_sym_PATCH] = ACTIONS(1),
|
||||
[anon_sym_LINK] = ACTIONS(1),
|
||||
[anon_sym_UNLINK] = ACTIONS(1),
|
||||
[anon_sym_PURGE] = ACTIONS(1),
|
||||
[anon_sym_LOCK] = ACTIONS(1),
|
||||
[anon_sym_UNLOCK] = ACTIONS(1),
|
||||
[anon_sym_PROPFIND] = ACTIONS(1),
|
||||
[anon_sym_VIEW] = ACTIONS(1),
|
||||
},
|
||||
[1] = {
|
||||
[sym_source_file] = STATE(6),
|
||||
[sym__statement] = STATE(2),
|
||||
[sym__declaration_statement] = STATE(2),
|
||||
[sym_request_declaration] = STATE(2),
|
||||
[sym__literal] = STATE(7),
|
||||
[sym_request_literal] = STATE(7),
|
||||
[aux_sym_source_file_repeat1] = STATE(2),
|
||||
[ts_builtin_sym_end] = ACTIONS(3),
|
||||
[anon_sym_GET] = ACTIONS(5),
|
||||
[anon_sym_POST] = ACTIONS(5),
|
||||
[anon_sym_PUT] = ACTIONS(5),
|
||||
[anon_sym_DELETE] = ACTIONS(5),
|
||||
[anon_sym_CONNECT] = ACTIONS(5),
|
||||
[anon_sym_OPTIONS] = ACTIONS(5),
|
||||
[anon_sym_TRACE] = ACTIONS(5),
|
||||
[anon_sym_PATCH] = ACTIONS(5),
|
||||
[anon_sym_LINK] = ACTIONS(5),
|
||||
[anon_sym_UNLINK] = ACTIONS(5),
|
||||
[anon_sym_PURGE] = ACTIONS(5),
|
||||
[anon_sym_LOCK] = ACTIONS(5),
|
||||
[anon_sym_UNLOCK] = ACTIONS(5),
|
||||
[anon_sym_PROPFIND] = ACTIONS(5),
|
||||
[anon_sym_VIEW] = ACTIONS(5),
|
||||
},
|
||||
[2] = {
|
||||
[sym__statement] = STATE(3),
|
||||
[sym__declaration_statement] = STATE(3),
|
||||
[sym_request_declaration] = STATE(3),
|
||||
[sym__literal] = STATE(7),
|
||||
[sym_request_literal] = STATE(7),
|
||||
[aux_sym_source_file_repeat1] = STATE(3),
|
||||
[ts_builtin_sym_end] = ACTIONS(7),
|
||||
[anon_sym_GET] = ACTIONS(5),
|
||||
[anon_sym_POST] = ACTIONS(5),
|
||||
[anon_sym_PUT] = ACTIONS(5),
|
||||
[anon_sym_DELETE] = ACTIONS(5),
|
||||
[anon_sym_CONNECT] = ACTIONS(5),
|
||||
[anon_sym_OPTIONS] = ACTIONS(5),
|
||||
[anon_sym_TRACE] = ACTIONS(5),
|
||||
[anon_sym_PATCH] = ACTIONS(5),
|
||||
[anon_sym_LINK] = ACTIONS(5),
|
||||
[anon_sym_UNLINK] = ACTIONS(5),
|
||||
[anon_sym_PURGE] = ACTIONS(5),
|
||||
[anon_sym_LOCK] = ACTIONS(5),
|
||||
[anon_sym_UNLOCK] = ACTIONS(5),
|
||||
[anon_sym_PROPFIND] = ACTIONS(5),
|
||||
[anon_sym_VIEW] = ACTIONS(5),
|
||||
},
|
||||
[3] = {
|
||||
[sym__statement] = STATE(3),
|
||||
[sym__declaration_statement] = STATE(3),
|
||||
[sym_request_declaration] = STATE(3),
|
||||
[sym__literal] = STATE(7),
|
||||
[sym_request_literal] = STATE(7),
|
||||
[aux_sym_source_file_repeat1] = STATE(3),
|
||||
[ts_builtin_sym_end] = ACTIONS(9),
|
||||
[anon_sym_GET] = ACTIONS(11),
|
||||
[anon_sym_POST] = ACTIONS(11),
|
||||
[anon_sym_PUT] = ACTIONS(11),
|
||||
[anon_sym_DELETE] = ACTIONS(11),
|
||||
[anon_sym_CONNECT] = ACTIONS(11),
|
||||
[anon_sym_OPTIONS] = ACTIONS(11),
|
||||
[anon_sym_TRACE] = ACTIONS(11),
|
||||
[anon_sym_PATCH] = ACTIONS(11),
|
||||
[anon_sym_LINK] = ACTIONS(11),
|
||||
[anon_sym_UNLINK] = ACTIONS(11),
|
||||
[anon_sym_PURGE] = ACTIONS(11),
|
||||
[anon_sym_LOCK] = ACTIONS(11),
|
||||
[anon_sym_UNLOCK] = ACTIONS(11),
|
||||
[anon_sym_PROPFIND] = ACTIONS(11),
|
||||
[anon_sym_VIEW] = ACTIONS(11),
|
||||
},
|
||||
[4] = {
|
||||
[ts_builtin_sym_end] = ACTIONS(14),
|
||||
[anon_sym_GET] = ACTIONS(14),
|
||||
[anon_sym_POST] = ACTIONS(14),
|
||||
[anon_sym_PUT] = ACTIONS(14),
|
||||
[anon_sym_DELETE] = ACTIONS(14),
|
||||
[anon_sym_CONNECT] = ACTIONS(14),
|
||||
[anon_sym_OPTIONS] = ACTIONS(14),
|
||||
[anon_sym_TRACE] = ACTIONS(14),
|
||||
[anon_sym_PATCH] = ACTIONS(14),
|
||||
[anon_sym_LINK] = ACTIONS(14),
|
||||
[anon_sym_UNLINK] = ACTIONS(14),
|
||||
[anon_sym_PURGE] = ACTIONS(14),
|
||||
[anon_sym_LOCK] = ACTIONS(14),
|
||||
[anon_sym_UNLOCK] = ACTIONS(14),
|
||||
[anon_sym_PROPFIND] = ACTIONS(14),
|
||||
[anon_sym_VIEW] = ACTIONS(14),
|
||||
},
|
||||
};
|
||||
|
||||
static const uint16_t ts_small_parse_table[] = {
|
||||
[0] = 1,
|
||||
ACTIONS(16), 1,
|
||||
sym__url,
|
||||
[4] = 1,
|
||||
ACTIONS(18), 1,
|
||||
ts_builtin_sym_end,
|
||||
[8] = 1,
|
||||
ACTIONS(20), 1,
|
||||
sym__url,
|
||||
};
|
||||
|
||||
static const uint32_t ts_small_parse_table_map[] = {
|
||||
[SMALL_STATE(5)] = 0,
|
||||
[SMALL_STATE(6)] = 4,
|
||||
[SMALL_STATE(7)] = 8,
|
||||
};
|
||||
|
||||
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}}, REDUCE(sym_source_file, 0),
|
||||
[5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(5),
|
||||
[7] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source_file, 1),
|
||||
[9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2),
|
||||
[11] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_file_repeat1, 2), SHIFT_REPEAT(5),
|
||||
[14] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_request_declaration, 2, .production_id = 1),
|
||||
[16] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_request_literal, 1),
|
||||
[18] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(),
|
||||
[20] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4),
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#define extern __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
extern const TSLanguage *tree_sitter_hurl(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
src/tree_sitter/parser.h
Normal file
224
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_
|
Loading…
Reference in New Issue
Block a user