1.0.7 • Published 4 years ago
tree-sitter-v v1.0.7
tree-sitter-v
V language grammar for tree-sitter
Existing grammars
This grammar is heavily derived from the following language grammars:
Installation
npm install tree-sitter-vUsage (node-tree-sitter)
const Parser = require('tree-sitter');
const V = require('tree-sitter-v');
const parser = new Parser();
parser.setLanguage(V);Usage with V v-tree-sitter (soon)
// TODO:
import treesitter
import tree_sitter_v.bindings.v
fn main() {
mut parser := treesitter.new_parser()
parser.set_language(v.language)
}Limitations
Statements outside functions (akavsh/scriptmode) are not yet supported.- It does not support all deprecated/outdated syntaxes to avoid any ambiguities and to enforce the one-way philosophy as much as possible.
- Assembly/SQL code in ASM/SQL block nodes are loosely checked and parsed immediately regardless of the content.
Syntaxes related to generics support (e.g template) are not yet implemented.
Node Support (Checked means already been verified and tested)
- AliasTypeDecl (
type_declaration) - AnonFn (
fn_literal) - ArrayDecompose (
decomposed_element) - ArrayFixed (
array_initializer) - ArrayInit (
array/type_initializer) - AsCast (
as_type_cast_expression) - AsmAddressing
- AsmAlias
- AsmClobbered
- AsmDisp
- AsmIO
- AsmRegister
- AsmStmt (
asm_statement. See Limitations3) - AsmTemplate
- AssertStmt (
assert_statement) - AssignStmt (
assignment_statement,short_var_declaration) - Assoc
- AtExpr (
pseudo_comptime_expression) - Attr (
attribute_declaration) - Block (
block) - BoolLiteral (
true/false) - BranchStmt (
blockfor if /expression_casefor match) - CallArg (
argument_list) - CallExpr (
call_expression) - CastExpr (
type_cast_expression) - Chan (
channel_type) - ChanInit (
type_initializer) - CharLiteral (
rune_literal) - Comment (
comment) - CompFor (
comptime_for_statement) - ComptimeCall (
call_expression->comptime_identifieras field) - ComptimeSelector(
selector_expression->comptime_selector_expressionas field) - ConcatExpr
- ConstDecl (
const_declaration) - ConstField (
const_spec) - DeferStmt (
defer_statement) - DumpExpr (
call_expression) - EmbeddedFile (
call_expression->comptime_identifieras name) - EnumDecl (
enum_declaration) - EnumField (
enum_member) - EnumVal (
enum_identifier) - ExprStmt
- FloatLiteral (
float_literal) - FnDecl (
function_declaration) - FnTypeDecl (
function_type) - ForCStmt (
for_statement:cstyle_for_clause) - ForInStmt (
for_statement:in_operator) - ForStmt (
for_statement) - GlobalDecl (
global_var_declaration) - GlobalField (
global_var_declaration->global_var_type_initializer) - GoExpr (
go_statement) - GotoLabel (
labeled_statement,empty_labeled_statement) - GotoStmt (
goto_statement) - HashStmt (Currently supported:
c_include_clause,c_flag_clause,c_define_clause) - Ident (
identifier) - IfBranch (
if_expression) - IfExpr (
if_expression) - IfGuardExpr (
if statement:is_expression) - Import (
import_declaration) - ImportSymbol (
import_symbol) - IndexExpr (
index_expression/slice_expression) - InfixExpr
- IntegerLiteral (
int_literal) - InterfaceDecl (
interface_declaration) - InterfaceEmbedding (
interface_declaration->type_identifier) - Likely (
call_expression) - LockExpr
- MapInit (
type_initializer) - MatchBranch (
expression_case) - MatchExpr (
match_expression) - Module (
module_clause) - MultiReturn (
multi_return_type) (NOTE: shouldn't be used in arguments) - NodeError (
[ERROR]) - None (
none) - OffsetOf (
call_expression) - OrExpr (
or_block) - Param (
parameter_declaration) - ParExpr (
parenthesized_expression) - PostfixExpr (
inc_statement,dec_statement) - PrefixExpr
- RangeExpr (
range) - Return (
return_statement) - SelectBranch (
select_branch,select_default_branch) - SelectExpr (
select_expression, TODO support forifandfor) - SelectorExpr (
selector_expression) - SizeOf (
call_expression) - SqlExpr (
sql_expression. See Limitations3) - SqlStmt (
sql_expression. See Limitations3) - SqlStmtLine (
sql_expression. See Limitations3) - StringInterLiteral (
interpreted_string_literal) - StringLiteral (
_string_literal) - StructDecl (
struct_declaration) - StructField (
struct_field_declaration) - StructInit (
type_initializer) - StructInitEmbed (
decomposed_element) - StructInitField (
literal_value) - SumTypeDecl (
type_declaration) - TypeNode (
type_identifier) - TypeOf (
call_expression) - UnsafeExpr (
unsafe_expression)