Compare commits
10 commits
e1aa4dd51b
...
ae4cdb5d27
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae4cdb5d27 | ||
![]() |
8bd2056818 | ||
![]() |
7cff70bbcb | ||
![]() |
474fbbec27 | ||
![]() |
5366d870c1 | ||
![]() |
b3c2993eea | ||
![]() |
e8801768c1 | ||
![]() |
084da152d8 | ||
![]() |
02e774c911 | ||
![]() |
4993307f61 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/build
|
||||
/node_modules
|
||||
/target
|
||||
|
|
2
.gitmodules
vendored
2
.gitmodules
vendored
|
@ -1,4 +1,4 @@
|
|||
[submodule "tree-sitter"]
|
||||
path = tree-sitter
|
||||
url = https://github.com/ikatyang/tree-sitter
|
||||
branch = 0.16.7-custom
|
||||
branch = v0.19.3-custom
|
||||
|
|
32
CHANGELOG.md
32
CHANGELOG.md
|
@ -2,6 +2,38 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [0.5.1](https://github.com/ikatyang/tree-sitter-toml/compare/v0.5.0...v0.5.1) (2021-03-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add missing binding.gyp ([5366d87](https://github.com/ikatyang/tree-sitter-toml/commit/5366d87))
|
||||
|
||||
|
||||
|
||||
# [0.5.0](https://github.com/ikatyang/tree-sitter-toml/compare/v0.4.1...v0.5.0) (2021-03-14)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* upgrade to tree-sitter@0.19.3 ([e880176](https://github.com/ikatyang/tree-sitter-toml/commit/e880176))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* require tree-sitter 0.19+
|
||||
|
||||
|
||||
|
||||
## [0.4.1](https://github.com/ikatyang/tree-sitter-toml/compare/v0.4.0...v0.4.1) (2020-11-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* immediate hash in string is considered content instead of comment ([#18](https://github.com/ikatyang/tree-sitter-toml/issues/18)) ([4993307](https://github.com/ikatyang/tree-sitter-toml/commit/4993307))
|
||||
|
||||
|
||||
|
||||
# [0.4.0](https://github.com/ikatyang/tree-sitter-toml/compare/v0.3.0...v0.4.0) (2020-07-04)
|
||||
|
||||
|
||||
|
|
59
Cargo.lock
generated
Normal file
59
Cargo.lock
generated
Normal file
|
@ -0,0 +1,59 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c36be3222512d85a112491ae0cc280a38076022414f00b64582da1b7565ffd82"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-toml"
|
||||
version = "0.20.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
28
Cargo.toml
Normal file
28
Cargo.toml
Normal file
|
@ -0,0 +1,28 @@
|
|||
[package]
|
||||
name = "tree-sitter-toml"
|
||||
description = "TOML grammar for the tree-sitter parsing library"
|
||||
version = "0.20.0"
|
||||
license = "MIT"
|
||||
readme = "bindings/rust/README.md"
|
||||
keywords = ["incremental", "parsing", "toml"]
|
||||
categories = ["parsing", "text-editors"]
|
||||
repository = "https://github.com/Mathspy/tree-sitter-toml"
|
||||
edition = "2018"
|
||||
|
||||
build = "bindings/rust/build.rs"
|
||||
include = [
|
||||
"bindings/rust/*",
|
||||
"grammar.js",
|
||||
"queries/*",
|
||||
"src/*",
|
||||
]
|
||||
autoexamples = false
|
||||
|
||||
[lib]
|
||||
path = "bindings/rust/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
tree-sitter = "0.20"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
|
@ -9,7 +9,7 @@
|
|||
"sources": [
|
||||
"src/parser.c",
|
||||
"src/scanner.c",
|
||||
"src/binding.cc"
|
||||
"bindings/node/binding.cc"
|
||||
],
|
||||
"cflags_c": [
|
||||
"-std=c99",
|
||||
|
|
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_toml_binding");
|
||||
} catch (error1) {
|
||||
if (error1.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error1;
|
||||
}
|
||||
try {
|
||||
module.exports = require("../../build/Debug/tree_sitter_toml_binding");
|
||||
} catch (error2) {
|
||||
if (error2.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error2;
|
||||
}
|
||||
throw error1
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
||||
} catch (_) {}
|
39
bindings/rust/README.md
Normal file
39
bindings/rust/README.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
# tree-sitter-toml
|
||||
|
||||
This crate provides TOML grammar for the [tree-sitter][] parsing library. To
|
||||
use this crate, add it to the `[dependencies]` section of your `Cargo.toml`
|
||||
file. (Note that you will probably also need to depend on the
|
||||
[`tree-sitter`][tree-sitter crate] crate to use the parsed result in any useful
|
||||
way.)
|
||||
|
||||
``` toml
|
||||
[dependencies]
|
||||
tree-sitter = "0.17"
|
||||
tree-sitter-toml = "0.16"
|
||||
```
|
||||
|
||||
Typically, you will use the [language][language func] function to add this
|
||||
grammar to a tree-sitter [Parser][], and then use the parser to parse some code:
|
||||
|
||||
```rust
|
||||
let code = r#"
|
||||
[package]
|
||||
name = "cargo"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
"#;
|
||||
let mut parser = Parser::new();
|
||||
parser.set_language(tree_sitter_toml::language()).expect("Error loading TOML grammar");
|
||||
let parsed = parser.parse(code, None);
|
||||
```
|
||||
|
||||
It's based on the lovely bindings of [tree-sitter-rust][] and uses the awesome grammar
|
||||
defined by [tree-sitter-toml][].
|
||||
|
||||
[Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
||||
[language func]: https://docs.rs/tree-sitter-toml/*/tree_sitter_rust/fn.language.html
|
||||
[Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
|
||||
[tree-sitter]: https://tree-sitter.github.io/
|
||||
[tree-sitter crate]: https://crates.io/crates/tree-sitter
|
||||
[tree-sitter-rust]: https://github.com/tree-sitter/tree-sitter-rust/tree/master/bindings/rust
|
||||
[tree-sitter-toml]: https://github.com/ikatyang/tree-sitter-toml
|
16
bindings/rust/build.rs
Normal file
16
bindings/rust/build.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
fn main() {
|
||||
let src_dir = std::path::Path::new("src");
|
||||
let mut config = cc::Build::new();
|
||||
config.include(&src_dir);
|
||||
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");
|
||||
let scanner_path = src_dir.join("scanner.c");
|
||||
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
||||
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
||||
config.file(&parser_path);
|
||||
config.file(&scanner_path);
|
||||
config.compile("parser-scanner");
|
||||
}
|
70
bindings/rust/lib.rs
Normal file
70
bindings/rust/lib.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Modified from tree-sitter-rust under the permissive license of MIT.
|
||||
// Based on the grammar of tree-sitter-toml, used under the permissive license of MIT
|
||||
// Copyright © 2021, tree-sitter-toml authors.
|
||||
// Copyright © 2021, tree-sitter-rust authors.
|
||||
// See the LICENSE file in this repo for license details.
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
//! This crate provides TOML grammar for the [tree-sitter][] parsing library.
|
||||
//!
|
||||
//! Typically, you will use the [language][language func] function to add this grammar to a
|
||||
//! tree-sitter [Parser][], and then use the parser to parse some code:
|
||||
//!
|
||||
//! ```
|
||||
//! use tree_sitter::Parser;
|
||||
//!
|
||||
//! let code = r#"
|
||||
//! [package]
|
||||
//! name = "cargo"
|
||||
//! version = "0.1.0"
|
||||
//! edition = "2021"
|
||||
//! "#;
|
||||
//! let mut parser = Parser::new();
|
||||
//! parser.set_language(tree_sitter_toml::language()).expect("Error loading TOML grammar");
|
||||
//! let parsed = parser.parse(code, None);
|
||||
//! # let parsed = parsed.unwrap();
|
||||
//! # let root = parsed.root_node();
|
||||
//! # assert!(!root.has_error());
|
||||
//! ```
|
||||
//!
|
||||
//! [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_toml() -> Language;
|
||||
}
|
||||
|
||||
/// Returns 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_toml() }
|
||||
}
|
||||
|
||||
/// The source of the TOML tree-sitter grammar description.
|
||||
pub const GRAMMAR: &str = include_str!("../../grammar.js");
|
||||
|
||||
/// The syntax highlighting query for this language.
|
||||
pub const HIGHLIGHT_QUERY: &str = include_str!("../../queries/highlights.scm");
|
||||
|
||||
/// 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: &str = include_str!("../../src/node-types.json");
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn can_load_grammar() {
|
||||
let mut parser = tree_sitter::Parser::new();
|
||||
parser
|
||||
.set_language(super::language())
|
||||
.expect("Error loading TOML grammar");
|
||||
}
|
||||
}
|
19
corpus/issues.txt
Normal file
19
corpus/issues.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
================================================================================
|
||||
VALID - issue #17 - immediate hash in string is considered content instead of comment
|
||||
================================================================================
|
||||
|
||||
# This is a full-line comment
|
||||
key = "value" # This is a comment at the end of a line
|
||||
another = "# This is not a comment"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
(document
|
||||
(comment)
|
||||
(pair
|
||||
(bare_key)
|
||||
(string)
|
||||
(comment))
|
||||
(pair
|
||||
(bare_key)
|
||||
(string)))
|
|
@ -277,7 +277,7 @@ let tree;
|
|||
const startPosition = queryEditor.posFromIndex(error.index);
|
||||
const endPosition = {
|
||||
line: startPosition.line,
|
||||
ch: startPosition.ch + (error.length || 1)
|
||||
ch: startPosition.ch + (error.length || Infinity)
|
||||
};
|
||||
|
||||
if (error.index === queryText.length) {
|
Binary file not shown.
BIN
docs/assets/tree-sitter-toml-0.5.1/tree-sitter-toml.wasm
Executable file
BIN
docs/assets/tree-sitter-toml-0.5.1/tree-sitter-toml.wasm
Executable file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
1
docs/assets/web-tree-sitter-0.19.3/tree-sitter.js
Normal file
1
docs/assets/web-tree-sitter-0.19.3/tree-sitter.js
Normal file
File diff suppressed because one or more lines are too long
BIN
docs/assets/web-tree-sitter-0.19.3/tree-sitter.wasm
Executable file
BIN
docs/assets/web-tree-sitter-0.19.3/tree-sitter.wasm
Executable file
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<link rel="stylesheet" href="assets/tree-sitter-playground-0.16.7/style.css" media="screen" type="text/css">
|
||||
<link rel="stylesheet" href="assets/tree-sitter-playground-0.19.3/style.css" media="screen" type="text/css">
|
||||
<title>Tree-sitter TOML Playground</title>
|
||||
</head>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
</style>
|
||||
|
||||
<h1><a href="https://github.com/ikatyang/tree-sitter-toml">Tree-sitter TOML</a> <span class="version">v0.4.0</span></h1>
|
||||
<h1><a href="https://github.com/ikatyang/tree-sitter-toml">Tree-sitter TOML</a> <span class="version">v0.5.1</span></h1>
|
||||
|
||||
<div id="playground-container" style="visibility: hidden;">
|
||||
|
||||
|
@ -61,11 +61,11 @@
|
|||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.45.0/codemirror.min.js"></script>
|
||||
|
||||
<script>LANGUAGE_BASE_URL = "assets/tree-sitter-toml-0.4.0";</script>
|
||||
<script src="assets/web-tree-sitter-0.16.7/tree-sitter.js"></script>
|
||||
<script>LANGUAGE_BASE_URL = "assets/tree-sitter-toml-0.5.1";</script>
|
||||
<script src="assets/web-tree-sitter-0.19.3/tree-sitter.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clusterize.js/0.18.0/clusterize.min.js"></script>
|
||||
<script src="assets/tree-sitter-playground-0.16.7/playground.js"></script>
|
||||
<script src="assets/tree-sitter-playground-0.19.3/playground.js"></script>
|
||||
|
||||
<script>
|
||||
((codeExample, queryExample) => {
|
||||
|
|
|
@ -40,7 +40,10 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
comment: $ =>
|
||||
token(seq("#", repeat(getInverseRegex(control_chars.subtract("\t"))))),
|
||||
token(prec(-1, seq(
|
||||
"#",
|
||||
repeat(getInverseRegex(control_chars.subtract("\t"))),
|
||||
))),
|
||||
|
||||
table: $ =>
|
||||
seq(
|
||||
|
|
13
index.js
generated
13
index.js
generated
|
@ -1,13 +0,0 @@
|
|||
try {
|
||||
module.exports = require("./build/Release/tree_sitter_toml_binding");
|
||||
} catch (error) {
|
||||
try {
|
||||
module.exports = require("./build/Debug/tree_sitter_toml_binding");
|
||||
} catch (_) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module.exports.nodeTypeInfo = require("./src/node-types.json");
|
||||
} catch (_) {}
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "tree-sitter-toml",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.1",
|
||||
"description": "TOML grammar for tree-sitter",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"lexer"
|
||||
],
|
||||
"main": "index.js",
|
||||
"main": "bindings/node",
|
||||
"repository": "https://github.com/ikatyang/tree-sitter-toml",
|
||||
"homepage": "https://github.com/ikatyang/tree-sitter-toml#readme",
|
||||
"author": {
|
||||
|
@ -37,9 +37,9 @@
|
|||
"files": [
|
||||
"/src/",
|
||||
"/queries/",
|
||||
"/bindings/node/",
|
||||
"/binding.gyp",
|
||||
"/grammar.js",
|
||||
"/index.js"
|
||||
"/grammar.js"
|
||||
],
|
||||
"tree-sitter": [
|
||||
{
|
||||
|
|
31
src/grammar.json
generated
31
src/grammar.json
generated
|
@ -41,20 +41,24 @@
|
|||
"comment": {
|
||||
"type": "TOKEN",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\u0000-\\u0008\\u000a-\\u001f\\u007f]"
|
||||
"type": "PREC",
|
||||
"value": -1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "#"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "PATTERN",
|
||||
"value": "[^\\u0000-\\u0008\\u000a-\\u001f\\u007f]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"table": {
|
||||
|
@ -805,6 +809,7 @@
|
|||
}
|
||||
],
|
||||
"conflicts": [],
|
||||
"precedences": [],
|
||||
"externals": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
|
|
4
src/node-types.json
generated
4
src/node-types.json
generated
|
@ -320,6 +320,10 @@
|
|||
"type": "boolean",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "comment",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "escape_sequence",
|
||||
"named": true
|
||||
|
|
1578
src/parser.c
generated
1578
src/parser.c
generated
File diff suppressed because it is too large
Load diff
158
src/tree_sitter/parser.h
generated
158
src/tree_sitter/parser.h
generated
|
@ -13,6 +13,8 @@ extern "C" {
|
|||
#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;
|
||||
|
@ -30,11 +32,10 @@ typedef struct {
|
|||
uint16_t length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef uint16_t TSStateId;
|
||||
|
||||
typedef struct {
|
||||
bool visible : 1;
|
||||
bool named : 1;
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct TSLexer TSLexer;
|
||||
|
@ -56,21 +57,21 @@ typedef enum {
|
|||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
TSStateId state;
|
||||
bool extra : 1;
|
||||
bool repetition : 1;
|
||||
} shift;
|
||||
struct {
|
||||
TSSymbol symbol;
|
||||
int16_t dynamic_precedence;
|
||||
uint8_t child_count;
|
||||
uint8_t production_id;
|
||||
} reduce;
|
||||
} params;
|
||||
TSParseActionType type : 4;
|
||||
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 {
|
||||
|
@ -82,7 +83,7 @@ typedef union {
|
|||
TSParseAction action;
|
||||
struct {
|
||||
uint8_t count;
|
||||
bool reusable : 1;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
|
@ -92,13 +93,24 @@ struct TSLanguage {
|
|||
uint32_t alias_count;
|
||||
uint32_t token_count;
|
||||
uint32_t external_token_count;
|
||||
const char **symbol_names;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const uint16_t *parse_table;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const TSLexMode *lex_modes;
|
||||
const TSSymbol *alias_sequences;
|
||||
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 **symbol_names;
|
||||
const char **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;
|
||||
|
@ -111,14 +123,6 @@ struct TSLanguage {
|
|||
unsigned (*serialize)(void *, char *);
|
||||
void (*deserialize)(void *, const char *, unsigned);
|
||||
} external_scanner;
|
||||
uint32_t field_count;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const char **field_names;
|
||||
uint32_t large_state_count;
|
||||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSSymbol *public_symbol_map;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -167,66 +171,50 @@ struct TSLanguage {
|
|||
|
||||
#define ACTIONS(id) id
|
||||
|
||||
#define SHIFT(state_value) \
|
||||
{ \
|
||||
{ \
|
||||
.params = { \
|
||||
.shift = { \
|
||||
.state = state_value \
|
||||
} \
|
||||
}, \
|
||||
.type = TSParseActionTypeShift \
|
||||
} \
|
||||
}
|
||||
#define SHIFT(state_value) \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value \
|
||||
} \
|
||||
}}
|
||||
|
||||
#define SHIFT_REPEAT(state_value) \
|
||||
{ \
|
||||
{ \
|
||||
.params = { \
|
||||
.shift = { \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}, \
|
||||
.type = TSParseActionTypeShift \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.state = state_value, \
|
||||
.repetition = true \
|
||||
} \
|
||||
}
|
||||
|
||||
#define RECOVER() \
|
||||
{ \
|
||||
{ .type = TSParseActionTypeRecover } \
|
||||
}
|
||||
}}
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{ \
|
||||
{ \
|
||||
.params = { \
|
||||
.shift = { \
|
||||
.extra = true \
|
||||
} \
|
||||
}, \
|
||||
.type = TSParseActionTypeShift \
|
||||
{{ \
|
||||
.shift = { \
|
||||
.type = TSParseActionTypeShift, \
|
||||
.extra = true \
|
||||
} \
|
||||
}
|
||||
}}
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val, ...) \
|
||||
{ \
|
||||
{ \
|
||||
.params = { \
|
||||
.reduce = { \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}, \
|
||||
.type = TSParseActionTypeReduce \
|
||||
} \
|
||||
}
|
||||
{{ \
|
||||
.reduce = { \
|
||||
.type = TSParseActionTypeReduce, \
|
||||
.symbol = symbol_val, \
|
||||
.child_count = child_count_val, \
|
||||
__VA_ARGS__ \
|
||||
}, \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{ \
|
||||
{ .type = TSParseActionTypeAccept } \
|
||||
}
|
||||
#define RECOVER() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeRecover \
|
||||
}}
|
||||
|
||||
#define ACCEPT_INPUT() \
|
||||
{{ \
|
||||
.type = TSParseActionTypeAccept \
|
||||
}}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1ccb0ac0e840c58f23012dd495bd0180884077e1
|
||||
Subproject commit fc5a692b7d5f144cc531f5823b1c5a3b2f06cf01
|
18
yarn.lock
18
yarn.lock
|
@ -516,9 +516,9 @@ has-flag@^3.0.0:
|
|||
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
|
||||
|
||||
hosted-git-info@^2.1.4:
|
||||
version "2.8.4"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.4.tgz#44119abaf4bc64692a16ace34700fed9c03e2546"
|
||||
integrity sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==
|
||||
version "2.8.9"
|
||||
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
|
||||
integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==
|
||||
|
||||
indent-string@^2.1.0:
|
||||
version "2.1.0"
|
||||
|
@ -538,9 +538,9 @@ inherits@^2.0.3, inherits@~2.0.3:
|
|||
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
|
||||
|
||||
ini@^1.3.2:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
|
||||
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
|
||||
version "1.3.7"
|
||||
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84"
|
||||
integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==
|
||||
|
||||
is-arrayish@^0.2.1:
|
||||
version "0.2.1"
|
||||
|
@ -1297,9 +1297,9 @@ xtend@~4.0.1:
|
|||
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
|
||||
|
||||
y18n@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
|
||||
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
|
||||
integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
|
||||
|
||||
yargs-parser@^13.1.1:
|
||||
version "13.1.2"
|
||||
|
|
Loading…
Reference in a new issue