From 9cca91bc72abb705c33e4d6c00fa70e8a9b00a96 Mon Sep 17 00:00:00 2001 From: Aditya Giri Date: Thu, 31 Mar 2022 11:02:09 +0530 Subject: [PATCH 1/4] Update all dependencies to use tree-sitter v0.20 --- Cargo.lock | 50 +-- Cargo.toml | 14 +- enums/Cargo.lock | 50 +-- enums/Cargo.toml | 14 +- src/languages/language_java.rs | 470 ++++++++++++++------------ src/languages/language_javascript.rs | 338 ++++++++++--------- src/languages/language_python.rs | 486 ++++++++++++++------------- src/languages/language_rust.rs | 16 +- src/languages/language_tsx.rs | 24 +- src/languages/language_typescript.rs | 24 +- tree-sitter-ccomment/Cargo.toml | 4 +- tree-sitter-ccomment/package.json | 2 +- tree-sitter-mozjs/Cargo.toml | 4 +- tree-sitter-mozjs/package.json | 2 +- tree-sitter-preproc/Cargo.toml | 4 +- tree-sitter-preproc/package.json | 2 +- 16 files changed, 793 insertions(+), 711 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87eb01836..36327e1c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1584,10 +1584,10 @@ dependencies = [ "serde", "serde_json", "termcolor", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", "tree-sitter-ccomment", "tree-sitter-java", - "tree-sitter-javascript", + "tree-sitter-javascript 0.20.0", "tree-sitter-mozcpp", "tree-sitter-mozjs", "tree-sitter-preproc", @@ -2100,10 +2100,10 @@ dependencies = [ [[package]] name = "tree-sitter-ccomment" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -2118,12 +2118,11 @@ dependencies = [ [[package]] name = "tree-sitter-java" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301ae2ee7813e1bf935dc06db947642400645bbea8878431e1b31131488d5430" +version = "0.20.0" +source = "git+https://github.com/hyperlog/tree-sitter-java?branch=master#d7c9707b978570e977f621db28e84c512f344850" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -2136,50 +2135,59 @@ dependencies = [ "tree-sitter 0.19.3", ] +[[package]] +name = "tree-sitter-javascript" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2490fab08630b2c8943c320f7b63473cbf65511c8d83aec551beb9b4375906ed" +dependencies = [ + "cc", + "tree-sitter 0.20.2", +] + [[package]] name = "tree-sitter-mozcpp" version = "0.20.1" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", "tree-sitter-cpp", ] [[package]] name = "tree-sitter-mozjs" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", - "tree-sitter-javascript", + "tree-sitter 0.20.2", + "tree-sitter-javascript 0.19.0", ] [[package]] name = "tree-sitter-preproc" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] name = "tree-sitter-python" version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5646bfe71c4eb1c21b714ce0c38334c311eab767095582859e85da6281e9fd6c" +source = "git+https://github.com/tree-sitter/tree-sitter-python?branch=master#78c4e9b6b2f08e1be23b541ffced47b15e2972ad" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] name = "tree-sitter-rust" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784f7ef9cdbd4c895dc2d4bb785e95b4a5364a602eec803681db83d1927ddf15" +checksum = "3df540a493d754015d22eaf57c38f58804be3713a22f6062db983ec15f85c3c9" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -2189,7 +2197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8935efd97c92067c9b2b6d7acb647607590996ba80f3a7be09a197f9c1fdab73" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 864372b63..b41fe5d50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,15 +27,15 @@ termcolor = "^1.1" walkdir = "^2.3" tree-sitter = ">= 0.19, < 0.21" -tree-sitter-java = "=0.19.0" tree-sitter-typescript = "=0.20.0" -tree-sitter-javascript = "=0.19.0" -tree-sitter-python = "=0.19.0" -tree-sitter-rust = "=0.19.0" -tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "=0.19.0" } -tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "=0.19.0" } +tree-sitter-javascript = "=0.20.0" +tree-sitter-rust = "=0.20.0" +tree-sitter-python = { git = "https://github.com/tree-sitter/tree-sitter-python", branch = "master" } +tree-sitter-java = { git = "https://github.com/hyperlog/tree-sitter-java", branch = "master" } +tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "=0.20.0" } +tree-sitter-ccomment = { path = "./tree-sitter-ccomment", version = "=0.20.0" } tree-sitter-mozcpp = { path = "./tree-sitter-mozcpp", version = "=0.20.1" } -tree-sitter-mozjs = { path = "./tree-sitter-mozjs", version = "=0.19.0" } +tree-sitter-mozjs = { path = "./tree-sitter-mozjs", version = "=0.20.0" } [dev-dependencies] pretty_assertions = "^1.0" diff --git a/enums/Cargo.lock b/enums/Cargo.lock index 9cebbdf0b..0fac254f2 100644 --- a/enums/Cargo.lock +++ b/enums/Cargo.lock @@ -116,10 +116,10 @@ version = "0.0.1" dependencies = [ "askama", "clap", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", "tree-sitter-ccomment", "tree-sitter-java", - "tree-sitter-javascript", + "tree-sitter-javascript 0.20.0", "tree-sitter-mozcpp", "tree-sitter-mozjs", "tree-sitter-preproc", @@ -299,10 +299,10 @@ dependencies = [ [[package]] name = "tree-sitter-ccomment" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -317,12 +317,11 @@ dependencies = [ [[package]] name = "tree-sitter-java" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301ae2ee7813e1bf935dc06db947642400645bbea8878431e1b31131488d5430" +version = "0.20.0" +source = "git+https://github.com/hyperlog/tree-sitter-java?branch=master#d7c9707b978570e977f621db28e84c512f344850" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -335,50 +334,59 @@ dependencies = [ "tree-sitter 0.19.3", ] +[[package]] +name = "tree-sitter-javascript" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2490fab08630b2c8943c320f7b63473cbf65511c8d83aec551beb9b4375906ed" +dependencies = [ + "cc", + "tree-sitter 0.20.2", +] + [[package]] name = "tree-sitter-mozcpp" version = "0.20.1" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", "tree-sitter-cpp", ] [[package]] name = "tree-sitter-mozjs" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", - "tree-sitter-javascript", + "tree-sitter 0.20.2", + "tree-sitter-javascript 0.19.0", ] [[package]] name = "tree-sitter-preproc" -version = "0.19.0" +version = "0.20.0" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] name = "tree-sitter-python" version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5646bfe71c4eb1c21b714ce0c38334c311eab767095582859e85da6281e9fd6c" +source = "git+https://github.com/tree-sitter/tree-sitter-python?branch=master#78c4e9b6b2f08e1be23b541ffced47b15e2972ad" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] name = "tree-sitter-rust" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784f7ef9cdbd4c895dc2d4bb785e95b4a5364a602eec803681db83d1927ddf15" +checksum = "3df540a493d754015d22eaf57c38f58804be3713a22f6062db983ec15f85c3c9" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] @@ -388,7 +396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8935efd97c92067c9b2b6d7acb647607590996ba80f3a7be09a197f9c1fdab73" dependencies = [ "cc", - "tree-sitter 0.19.3", + "tree-sitter 0.20.2", ] [[package]] diff --git a/enums/Cargo.toml b/enums/Cargo.toml index d1aace38e..eafa3fce0 100644 --- a/enums/Cargo.toml +++ b/enums/Cargo.toml @@ -9,15 +9,15 @@ clap = "^2.34" askama = "^0.11" tree-sitter = ">= 0.19, < 0.21" -tree-sitter-java = "=0.19.0" tree-sitter-typescript = "=0.20.0" -tree-sitter-javascript = "=0.19.0" -tree-sitter-python = "=0.19.0" -tree-sitter-rust = "=0.19.0" -tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "=0.19.0" } -tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "=0.19.0" } +tree-sitter-javascript = "=0.20.0" +tree-sitter-rust = "=0.20.0" +tree-sitter-python = { git = "https://github.com/tree-sitter/tree-sitter-python", branch = "master" } +tree-sitter-java = { git = "https://github.com/hyperlog/tree-sitter-java", branch = "master" } +tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "=0.20.0" } +tree-sitter-ccomment = { path = "../tree-sitter-ccomment", version = "=0.20.0" } tree-sitter-mozcpp = { path = "../tree-sitter-mozcpp", version = "=0.20.1" } -tree-sitter-mozjs = { path = "../tree-sitter-mozjs", version = "=0.19.0" } +tree-sitter-mozjs = { path = "../tree-sitter-mozjs", version = "=0.20.0" } [profile.release] strip = "debuginfo" diff --git a/src/languages/language_java.rs b/src/languages/language_java.rs index 7a60983ff..3853ccd45 100644 --- a/src/languages/language_java.rs +++ b/src/languages/language_java.rs @@ -34,9 +34,9 @@ pub enum Java { GTGTGTEQ = 27, GT = 28, LT = 29, - EQEQ = 30, - GTEQ = 31, - LTEQ = 32, + GTEQ = 30, + LTEQ = 31, + EQEQ = 32, BANGEQ = 33, AMPAMP = 34, PIPEPIPE = 35, @@ -66,217 +66,232 @@ pub enum Java { Class = 59, COLONCOLON = 60, Extends = 61, - SEMI = 62, + Switch = 62, LBRACE = 63, RBRACE = 64, - Assert = 65, - Switch = 66, - Case = 67, - Default = 68, + Case = 65, + Default = 66, + SEMI = 67, + Assert = 68, Do = 69, While = 70, Break = 71, Continue = 72, Return = 73, - Synchronized = 74, - Throw = 75, - Try = 76, - Catch = 77, - Finally = 78, - If = 79, - Else = 80, - For = 81, - AT = 82, - Open = 83, - Module = 84, - Requires = 85, - Exports = 86, - To = 87, - Opens = 88, - Uses = 89, - Provides = 90, - With = 91, - Transitive = 92, - Static = 93, - Package = 94, - Import = 95, - Enum = 96, - Public = 97, - Protected = 98, - Private = 99, - Abstract = 100, - Final = 101, - Strictfp = 102, - Native = 103, - Transient = 104, - Volatile = 105, - Implements = 106, - ATinterface = 107, - Interface = 108, - Byte = 109, - Short = 110, - Int = 111, - Long = 112, - Char = 113, - Float = 114, - Double = 115, - BooleanType = 116, - VoidType = 117, - DOTDOTDOT = 118, - Throws2 = 119, - This = 120, - Super = 121, - Comment = 122, - Program = 123, - Literal = 124, - Expression = 125, - CastExpression = 126, - AssignmentExpression = 127, - BinaryExpression = 128, - InstanceofExpression = 129, - LambdaExpression = 130, - InferredParameters = 131, - TernaryExpression = 132, - UnaryExpression = 133, - UpdateExpression = 134, - PrimaryExpression = 135, - ArrayCreationExpression = 136, - DimensionsExpr = 137, - ParenthesizedExpression = 138, - ClassLiteral = 139, - ObjectCreationExpression = 140, - UnqualifiedObjectCreationExpression = 141, - FieldAccess = 142, - ArrayAccess = 143, - MethodInvocation = 144, - ArgumentList = 145, - MethodReference = 146, - TypeArguments = 147, - Wildcard = 148, - WildcardBounds = 149, - Dimensions = 150, - Statement = 151, - Block = 152, - ExpressionStatement = 153, - LabeledStatement = 154, - AssertStatement = 155, - SwitchStatement = 156, - SwitchBlock = 157, + Yield = 74, + Synchronized = 75, + Throw = 76, + Try = 77, + Catch = 78, + Finally = 79, + If = 80, + Else = 81, + For = 82, + AT = 83, + Open = 84, + Module = 85, + Requires = 86, + Transitive = 87, + Static = 88, + Exports = 89, + To = 90, + Opens = 91, + Uses = 92, + Provides = 93, + With = 94, + Package = 95, + Import = 96, + Enum = 97, + Public = 98, + Protected = 99, + Private = 100, + Abstract = 101, + Final = 102, + Strictfp = 103, + Native = 104, + Transient = 105, + Volatile = 106, + Implements = 107, + Record = 108, + ATinterface = 109, + Interface = 110, + Byte = 111, + Short = 112, + Int = 113, + Long = 114, + Char = 115, + Float = 116, + Double = 117, + BooleanType = 118, + VoidType = 119, + DOTDOTDOT = 120, + Throws2 = 121, + This = 122, + Super = 123, + LineComment = 124, + BlockComment = 125, + Program = 126, + Literal = 127, + Expression = 128, + CastExpression = 129, + AssignmentExpression = 130, + BinaryExpression = 131, + InstanceofExpression = 132, + LambdaExpression = 133, + InferredParameters = 134, + TernaryExpression = 135, + UnaryExpression = 136, + UpdateExpression = 137, + PrimaryExpression = 138, + ArrayCreationExpression = 139, + DimensionsExpr = 140, + ParenthesizedExpression = 141, + ClassLiteral = 142, + ObjectCreationExpression = 143, + UnqualifiedObjectCreationExpression = 144, + FieldAccess = 145, + ArrayAccess = 146, + MethodInvocation = 147, + ArgumentList = 148, + MethodReference = 149, + TypeArguments = 150, + Wildcard = 151, + WildcardBounds = 152, + Dimensions = 153, + SwitchExpression = 154, + SwitchBlock = 155, + SwitchBlockStatementGroup = 156, + SwitchRule = 157, SwitchLabel = 158, - DoStatement = 159, - BreakStatement = 160, - ContinueStatement = 161, - ReturnStatement = 162, - SynchronizedStatement = 163, - ThrowStatement = 164, - TryStatement = 165, - CatchClause = 166, - CatchFormalParameter = 167, - CatchType = 168, - FinallyClause = 169, - TryWithResourcesStatement = 170, - ResourceSpecification = 171, - Resource = 172, - IfStatement = 173, - WhileStatement = 174, - ForStatement = 175, - EnhancedForStatement = 176, - Annotation = 177, - MarkerAnnotation = 178, - Annotation2 = 179, - AnnotationArgumentList = 180, - ElementValuePair = 181, - ElementValue = 182, - ElementValueArrayInitializer = 183, - Declaration = 184, - ModuleDeclaration = 185, - ModuleBody = 186, - ModuleDirective = 187, - RequiresModifier = 188, - PackageDeclaration = 189, - ImportDeclaration = 190, - Asterisk = 191, - EnumDeclaration = 192, - EnumBody = 193, - EnumBodyDeclarations = 194, - EnumConstant = 195, - ClassDeclaration = 196, - Modifiers = 197, - TypeParameters = 198, - TypeParameter = 199, - TypeBound = 200, - Superclass = 201, - SuperInterfaces = 202, - InterfaceTypeList = 203, - ClassBody = 204, - StaticInitializer = 205, - ConstructorDeclaration = 206, - ConstructorDeclarator = 207, - ConstructorBody = 208, - ExplicitConstructorInvocation = 209, - ScopedIdentifier = 210, - FieldDeclaration = 211, - AnnotationTypeDeclaration = 212, - AnnotationTypeBody = 213, - AnnotationTypeElementDeclaration = 214, - DefaultValue = 215, - InterfaceDeclaration = 216, - ExtendsInterfaces = 217, - InterfaceBody = 218, - ConstantDeclaration = 219, - VariableDeclaratorList = 220, - VariableDeclarator = 221, - VariableDeclaratorId = 222, - ArrayInitializer = 223, - Type = 224, - UnannotatedType = 225, - AnnotatedType = 226, - ScopedTypeIdentifier = 227, - GenericType = 228, - ArrayType = 229, - IntegralType = 230, - FloatingPointType = 231, - MethodHeader = 232, - MethodDeclarator = 233, - FormalParameters = 234, - FormalParameter = 235, - ReceiverParameter = 236, - SpreadParameter = 237, - Throws = 238, - LocalVariableDeclaration = 239, - MethodDeclaration = 240, - ProgramRepeat1 = 241, - CastExpressionRepeat1 = 242, - InferredParametersRepeat1 = 243, - ArrayCreationExpressionRepeat1 = 244, - DimensionsExprRepeat1 = 245, - ArgumentListRepeat1 = 246, - TypeArgumentsRepeat1 = 247, - DimensionsRepeat1 = 248, - SwitchBlockRepeat1 = 249, - TryStatementRepeat1 = 250, - CatchTypeRepeat1 = 251, - ResourceSpecificationRepeat1 = 252, - ForStatementRepeat1 = 253, - ForStatementRepeat2 = 254, - AnnotationArgumentListRepeat1 = 255, - ElementValueArrayInitializerRepeat1 = 256, - ModuleBodyRepeat1 = 257, - ModuleDirectiveRepeat1 = 258, - ModuleDirectiveRepeat2 = 259, - EnumBodyRepeat1 = 260, - EnumBodyDeclarationsRepeat1 = 261, - ModifiersRepeat1 = 262, - TypeParametersRepeat1 = 263, - TypeBoundRepeat1 = 264, - InterfaceTypeListRepeat1 = 265, - AnnotationTypeBodyRepeat1 = 266, - InterfaceBodyRepeat1 = 267, - VariableDeclaratorListRepeat1 = 268, - ArrayInitializerRepeat1 = 269, - FormalParametersRepeat1 = 270, - TypeIdentifier = 271, - Error = 272, + Statement = 159, + Block = 160, + ExpressionStatement = 161, + LabeledStatement = 162, + AssertStatement = 163, + DoStatement = 164, + BreakStatement = 165, + ContinueStatement = 166, + ReturnStatement = 167, + YieldStatement = 168, + SynchronizedStatement = 169, + ThrowStatement = 170, + TryStatement = 171, + CatchClause = 172, + CatchFormalParameter = 173, + CatchType = 174, + FinallyClause = 175, + TryWithResourcesStatement = 176, + ResourceSpecification = 177, + Resource = 178, + IfStatement = 179, + WhileStatement = 180, + ForStatement = 181, + EnhancedForStatement = 182, + Annotation2 = 183, + MarkerAnnotation = 184, + Annotation = 185, + AnnotationArgumentList = 186, + ElementValuePair = 187, + ElementValue = 188, + ElementValueArrayInitializer = 189, + Declaration = 190, + ModuleDeclaration = 191, + ModuleBody = 192, + ModuleDirective = 193, + RequiresModuleDirective = 194, + RequiresModifier = 195, + ExportsModuleDirective = 196, + OpensModuleDirective = 197, + UsesModuleDirective = 198, + ProvidesModuleDirective = 199, + PackageDeclaration = 200, + ImportDeclaration = 201, + Asterisk = 202, + EnumDeclaration = 203, + EnumBody = 204, + EnumBodyDeclarations = 205, + EnumConstant = 206, + ClassDeclaration = 207, + Modifiers = 208, + TypeParameters = 209, + TypeParameter = 210, + TypeBound = 211, + Superclass = 212, + SuperInterfaces = 213, + InterfaceTypeList = 214, + ClassBody = 215, + StaticInitializer = 216, + ConstructorDeclaration = 217, + ConstructorDeclarator = 218, + ConstructorBody = 219, + ExplicitConstructorInvocation = 220, + ScopedIdentifier = 221, + FieldDeclaration = 222, + RecordDeclaration = 223, + AnnotationTypeDeclaration = 224, + AnnotationTypeBody = 225, + AnnotationTypeElementDeclaration = 226, + DefaultValue = 227, + InterfaceDeclaration = 228, + ExtendsInterfaces = 229, + InterfaceBody = 230, + ConstantDeclaration = 231, + VariableDeclaratorList = 232, + VariableDeclarator = 233, + VariableDeclaratorId = 234, + ArrayInitializer = 235, + Type = 236, + UnannotatedType = 237, + AnnotatedType = 238, + ScopedTypeIdentifier = 239, + GenericType = 240, + ArrayType = 241, + IntegralType = 242, + FloatingPointType = 243, + MethodHeader = 244, + MethodDeclarator = 245, + FormalParameters = 246, + FormalParameter = 247, + ReceiverParameter = 248, + SpreadParameter = 249, + Throws = 250, + LocalVariableDeclaration = 251, + MethodDeclaration = 252, + ProgramRepeat1 = 253, + CastExpressionRepeat1 = 254, + InferredParametersRepeat1 = 255, + ArrayCreationExpressionRepeat1 = 256, + DimensionsExprRepeat1 = 257, + ArgumentListRepeat1 = 258, + TypeArgumentsRepeat1 = 259, + DimensionsRepeat1 = 260, + SwitchBlockRepeat1 = 261, + SwitchBlockRepeat2 = 262, + SwitchBlockStatementGroupRepeat1 = 263, + TryStatementRepeat1 = 264, + CatchTypeRepeat1 = 265, + ResourceSpecificationRepeat1 = 266, + ForStatementRepeat1 = 267, + ForStatementRepeat2 = 268, + AnnotationArgumentListRepeat1 = 269, + ElementValueArrayInitializerRepeat1 = 270, + ModuleBodyRepeat1 = 271, + RequiresModuleDirectiveRepeat1 = 272, + ExportsModuleDirectiveRepeat1 = 273, + ProvidesModuleDirectiveRepeat1 = 274, + EnumBodyRepeat1 = 275, + EnumBodyDeclarationsRepeat1 = 276, + ModifiersRepeat1 = 277, + TypeParametersRepeat1 = 278, + TypeBoundRepeat1 = 279, + InterfaceTypeListRepeat1 = 280, + AnnotationTypeBodyRepeat1 = 281, + InterfaceBodyRepeat1 = 282, + VariableDeclaratorListRepeat1 = 283, + ArrayInitializerRepeat1 = 284, + FormalParametersRepeat1 = 285, + TypeIdentifier = 286, + Error = 287, } impl From for &'static str { @@ -313,9 +328,9 @@ impl From for &'static str { Java::GTGTGTEQ => ">>>=", Java::GT => ">", Java::LT => "<", - Java::EQEQ => "==", Java::GTEQ => ">=", Java::LTEQ => "<=", + Java::EQEQ => "==", Java::BANGEQ => "!=", Java::AMPAMP => "&&", Java::PIPEPIPE => "||", @@ -345,18 +360,19 @@ impl From for &'static str { Java::Class => "class", Java::COLONCOLON => "::", Java::Extends => "extends", - Java::SEMI => ";", + Java::Switch => "switch", Java::LBRACE => "{", Java::RBRACE => "}", - Java::Assert => "assert", - Java::Switch => "switch", Java::Case => "case", Java::Default => "default", + Java::SEMI => ";", + Java::Assert => "assert", Java::Do => "do", Java::While => "while", Java::Break => "break", Java::Continue => "continue", Java::Return => "return", + Java::Yield => "yield", Java::Synchronized => "synchronized", Java::Throw => "throw", Java::Try => "try", @@ -369,14 +385,14 @@ impl From for &'static str { Java::Open => "open", Java::Module => "module", Java::Requires => "requires", + Java::Transitive => "transitive", + Java::Static => "static", Java::Exports => "exports", Java::To => "to", Java::Opens => "opens", Java::Uses => "uses", Java::Provides => "provides", Java::With => "with", - Java::Transitive => "transitive", - Java::Static => "static", Java::Package => "package", Java::Import => "import", Java::Enum => "enum", @@ -390,6 +406,7 @@ impl From for &'static str { Java::Transient => "transient", Java::Volatile => "volatile", Java::Implements => "implements", + Java::Record => "record", Java::ATinterface => "@interface", Java::Interface => "interface", Java::Byte => "byte", @@ -405,7 +422,8 @@ impl From for &'static str { Java::Throws2 => "throws", Java::This => "this", Java::Super => "super", - Java::Comment => "comment", + Java::LineComment => "line_comment", + Java::BlockComment => "block_comment", Java::Program => "program", Java::Literal => "_literal", Java::Expression => "expression", @@ -434,18 +452,21 @@ impl From for &'static str { Java::Wildcard => "wildcard", Java::WildcardBounds => "_wildcard_bounds", Java::Dimensions => "dimensions", + Java::SwitchExpression => "switch_expression", + Java::SwitchBlock => "switch_block", + Java::SwitchBlockStatementGroup => "switch_block_statement_group", + Java::SwitchRule => "switch_rule", + Java::SwitchLabel => "switch_label", Java::Statement => "statement", Java::Block => "block", Java::ExpressionStatement => "expression_statement", Java::LabeledStatement => "labeled_statement", Java::AssertStatement => "assert_statement", - Java::SwitchStatement => "switch_statement", - Java::SwitchBlock => "switch_block", - Java::SwitchLabel => "switch_label", Java::DoStatement => "do_statement", Java::BreakStatement => "break_statement", Java::ContinueStatement => "continue_statement", Java::ReturnStatement => "return_statement", + Java::YieldStatement => "yield_statement", Java::SynchronizedStatement => "synchronized_statement", Java::ThrowStatement => "throw_statement", Java::TryStatement => "try_statement", @@ -460,9 +481,9 @@ impl From for &'static str { Java::WhileStatement => "while_statement", Java::ForStatement => "for_statement", Java::EnhancedForStatement => "enhanced_for_statement", - Java::Annotation => "_annotation", + Java::Annotation2 => "_annotation", Java::MarkerAnnotation => "marker_annotation", - Java::Annotation2 => "annotation", + Java::Annotation => "annotation", Java::AnnotationArgumentList => "annotation_argument_list", Java::ElementValuePair => "element_value_pair", Java::ElementValue => "_element_value", @@ -471,7 +492,12 @@ impl From for &'static str { Java::ModuleDeclaration => "module_declaration", Java::ModuleBody => "module_body", Java::ModuleDirective => "module_directive", + Java::RequiresModuleDirective => "requires_module_directive", Java::RequiresModifier => "requires_modifier", + Java::ExportsModuleDirective => "exports_module_directive", + Java::OpensModuleDirective => "opens_module_directive", + Java::UsesModuleDirective => "uses_module_directive", + Java::ProvidesModuleDirective => "provides_module_directive", Java::PackageDeclaration => "package_declaration", Java::ImportDeclaration => "import_declaration", Java::Asterisk => "asterisk", @@ -495,6 +521,7 @@ impl From for &'static str { Java::ExplicitConstructorInvocation => "explicit_constructor_invocation", Java::ScopedIdentifier => "scoped_identifier", Java::FieldDeclaration => "field_declaration", + Java::RecordDeclaration => "record_declaration", Java::AnnotationTypeDeclaration => "annotation_type_declaration", Java::AnnotationTypeBody => "annotation_type_body", Java::AnnotationTypeElementDeclaration => "annotation_type_element_declaration", @@ -533,6 +560,8 @@ impl From for &'static str { Java::TypeArgumentsRepeat1 => "type_arguments_repeat1", Java::DimensionsRepeat1 => "dimensions_repeat1", Java::SwitchBlockRepeat1 => "switch_block_repeat1", + Java::SwitchBlockRepeat2 => "switch_block_repeat2", + Java::SwitchBlockStatementGroupRepeat1 => "switch_block_statement_group_repeat1", Java::TryStatementRepeat1 => "try_statement_repeat1", Java::CatchTypeRepeat1 => "catch_type_repeat1", Java::ResourceSpecificationRepeat1 => "resource_specification_repeat1", @@ -541,8 +570,9 @@ impl From for &'static str { Java::AnnotationArgumentListRepeat1 => "annotation_argument_list_repeat1", Java::ElementValueArrayInitializerRepeat1 => "element_value_array_initializer_repeat1", Java::ModuleBodyRepeat1 => "module_body_repeat1", - Java::ModuleDirectiveRepeat1 => "module_directive_repeat1", - Java::ModuleDirectiveRepeat2 => "module_directive_repeat2", + Java::RequiresModuleDirectiveRepeat1 => "requires_module_directive_repeat1", + Java::ExportsModuleDirectiveRepeat1 => "exports_module_directive_repeat1", + Java::ProvidesModuleDirectiveRepeat1 => "provides_module_directive_repeat1", Java::EnumBodyRepeat1 => "enum_body_repeat1", Java::EnumBodyDeclarationsRepeat1 => "enum_body_declarations_repeat1", Java::ModifiersRepeat1 => "modifiers_repeat1", diff --git a/src/languages/language_javascript.rs b/src/languages/language_javascript.rs index b42507db2..40d948f71 100644 --- a/src/languages/language_javascript.rs +++ b/src/languages/language_javascript.rs @@ -75,46 +75,46 @@ pub enum Javascript { PIPEPIPEEQ = 68, QMARKQMARKEQ = 69, DOTDOTDOT = 70, - QMARK = 71, - AMPAMP = 72, - PIPEPIPE = 73, - GTGT = 74, - GTGTGT = 75, - LTLT = 76, - AMP = 77, - CARET = 78, - PIPE = 79, - PLUS = 80, - DASH = 81, - PERCENT = 82, - STARSTAR = 83, - LTEQ = 84, - EQEQ = 85, - EQEQEQ = 86, - BANGEQ = 87, - BANGEQEQ = 88, - GTEQ = 89, - QMARKQMARK = 90, - Instanceof = 91, - BANG = 92, - TILDE = 93, - Typeof = 94, - Void = 95, - Delete = 96, - PLUSPLUS = 97, - DASHDASH = 98, - DQUOTE = 99, - StringToken1 = 100, - SQUOTE = 101, - StringToken2 = 102, - EscapeSequence = 103, - Comment = 104, - BQUOTE = 105, - DOLLARLBRACE = 106, - SLASH2 = 107, - RegexPattern = 108, - RegexFlags = 109, - Number = 110, + AMPAMP = 71, + PIPEPIPE = 72, + GTGT = 73, + GTGTGT = 74, + LTLT = 75, + AMP = 76, + CARET = 77, + PIPE = 78, + PLUS = 79, + DASH = 80, + PERCENT = 81, + STARSTAR = 82, + LTEQ = 83, + EQEQ = 84, + EQEQEQ = 85, + BANGEQ = 86, + BANGEQEQ = 87, + GTEQ = 88, + QMARKQMARK = 89, + Instanceof = 90, + BANG = 91, + TILDE = 92, + Typeof = 93, + Void = 94, + Delete = 95, + PLUSPLUS = 96, + DASHDASH = 97, + DQUOTE = 98, + SQUOTE = 99, + StringFragment = 100, + StringFragment2 = 101, + EscapeSequence = 102, + Comment = 103, + BQUOTE = 104, + DOLLARLBRACE = 105, + SLASH2 = 106, + RegexPattern = 107, + RegexFlags = 108, + Number = 109, + PrivatePropertyIdentifier = 110, Target = 111, This = 112, Super = 113, @@ -128,129 +128,131 @@ pub enum Javascript { Set = 121, AutomaticSemicolon = 122, TemplateChars = 123, - Program = 124, - ExportStatement = 125, - ExportClause = 126, - ExportSpecifier = 127, - Declaration = 128, - Import = 129, - ImportStatement = 130, - ImportClause = 131, - FromClause = 132, - NamespaceImport = 133, - NamedImports = 134, - ExpressionStatement = 135, - VariableDeclaration = 136, - LexicalDeclaration = 137, - VariableDeclarator = 138, - StatementBlock = 139, - ElseClause = 140, - IfStatement = 141, - SwitchStatement = 142, - ForStatement = 143, - ForInStatement = 144, - ForHeader = 145, - WhileStatement = 146, - DoStatement = 147, - TryStatement = 148, - WithStatement = 149, - BreakStatement = 150, - ContinueStatement = 151, - DebuggerStatement = 152, - ReturnStatement = 153, - ThrowStatement = 154, - EmptyStatement = 155, - LabeledStatement = 156, - SwitchBody = 157, - SwitchCase = 158, - SwitchDefault = 159, - CatchClause = 160, - FinallyClause = 161, - ParenthesizedExpression = 162, - Expression = 163, - PrimaryExpression = 164, - YieldExpression = 165, - Object = 166, - ObjectPattern = 167, - AssignmentPattern = 168, - ObjectAssignmentPattern = 169, - Array = 170, - ArrayPattern = 171, - JsxElement = 172, - JsxFragment = 173, - JsxExpression = 174, - JsxOpeningElement = 175, - NestedIdentifier = 176, - JsxNamespaceName = 177, - JsxClosingElement = 178, - JsxSelfClosingElement = 179, - JsxAttribute = 180, - Class = 181, - ClassDeclaration = 182, - ClassHeritage = 183, - Function = 184, - FunctionDeclaration = 185, - GeneratorFunction = 186, - GeneratorFunctionDeclaration = 187, - ArrowFunction = 188, - CallExpression = 189, - NewExpression = 190, - AwaitExpression = 191, - MemberExpression = 192, - SubscriptExpression = 193, - AssignmentExpression = 194, - AugmentedAssignmentLhs = 195, - AugmentedAssignmentExpression = 196, - Initializer = 197, - DestructuringPattern = 198, - SpreadElement = 199, - TernaryExpression = 200, - BinaryExpression = 201, - UnaryExpression = 202, - UpdateExpression = 203, - SequenceExpression = 204, - String = 205, - TemplateString = 206, - TemplateSubstitution = 207, - Regex = 208, - MetaProperty = 209, - Arguments = 210, - Decorator = 211, - MemberExpression2 = 212, - CallExpression2 = 213, - ClassBody = 214, - PublicFieldDefinition = 215, - FormalParameters = 216, - Pattern = 217, - RestPattern = 218, - MethodDefinition = 219, - Pair = 220, - PairPattern = 221, - PropertyName = 222, - ComputedPropertyName = 223, - ProgramRepeat1 = 224, - ExportStatementRepeat1 = 225, - ExportClauseRepeat1 = 226, - NamedImportsRepeat1 = 227, - VariableDeclarationRepeat1 = 228, - SwitchBodyRepeat1 = 229, - ObjectRepeat1 = 230, - ObjectPatternRepeat1 = 231, - ArrayRepeat1 = 232, - ArrayPatternRepeat1 = 233, - JsxElementRepeat1 = 234, - JsxOpeningElementRepeat1 = 235, - StringRepeat1 = 236, - StringRepeat2 = 237, - TemplateStringRepeat1 = 238, - ClassBodyRepeat1 = 239, - FormalParametersRepeat1 = 240, - ImportSpecifier = 241, - PropertyIdentifier = 242, - ShorthandPropertyIdentifier = 243, - ShorthandPropertyIdentifierPattern = 244, - StatementIdentifier = 245, - Error = 246, + QMARK = 124, + Program = 125, + ExportStatement = 126, + ExportClause = 127, + ExportSpecifier = 128, + Declaration = 129, + Import = 130, + ImportStatement = 131, + ImportClause = 132, + FromClause = 133, + NamespaceImport = 134, + NamedImports = 135, + ExpressionStatement = 136, + VariableDeclaration = 137, + LexicalDeclaration = 138, + VariableDeclarator = 139, + StatementBlock = 140, + ElseClause = 141, + IfStatement = 142, + SwitchStatement = 143, + ForStatement = 144, + ForInStatement = 145, + ForHeader = 146, + WhileStatement = 147, + DoStatement = 148, + TryStatement = 149, + WithStatement = 150, + BreakStatement = 151, + ContinueStatement = 152, + DebuggerStatement = 153, + ReturnStatement = 154, + ThrowStatement = 155, + EmptyStatement = 156, + LabeledStatement = 157, + SwitchBody = 158, + SwitchCase = 159, + SwitchDefault = 160, + CatchClause = 161, + FinallyClause = 162, + ParenthesizedExpression = 163, + Expression = 164, + PrimaryExpression = 165, + YieldExpression = 166, + Object = 167, + ObjectPattern = 168, + AssignmentPattern = 169, + ObjectAssignmentPattern = 170, + Array = 171, + ArrayPattern = 172, + JsxElement = 173, + JsxFragment = 174, + JsxExpression = 175, + JsxOpeningElement = 176, + NestedIdentifier = 177, + JsxNamespaceName = 178, + JsxClosingElement = 179, + JsxSelfClosingElement = 180, + JsxAttribute = 181, + Class = 182, + ClassDeclaration = 183, + ClassHeritage = 184, + Function = 185, + FunctionDeclaration = 186, + GeneratorFunction = 187, + GeneratorFunctionDeclaration = 188, + ArrowFunction = 189, + CallExpression = 190, + NewExpression = 191, + AwaitExpression = 192, + MemberExpression = 193, + SubscriptExpression = 194, + AssignmentExpression = 195, + AugmentedAssignmentLhs = 196, + AugmentedAssignmentExpression = 197, + Initializer = 198, + DestructuringPattern = 199, + SpreadElement = 200, + TernaryExpression = 201, + BinaryExpression = 202, + UnaryExpression = 203, + UpdateExpression = 204, + SequenceExpression = 205, + String = 206, + TemplateString = 207, + TemplateSubstitution = 208, + Regex = 209, + MetaProperty = 210, + Arguments = 211, + Decorator = 212, + MemberExpression2 = 213, + CallExpression2 = 214, + ClassBody = 215, + FieldDefinition = 216, + FormalParameters = 217, + Pattern = 218, + RestPattern = 219, + MethodDefinition = 220, + Pair = 221, + PairPattern = 222, + PropertyName = 223, + ComputedPropertyName = 224, + ProgramRepeat1 = 225, + ExportStatementRepeat1 = 226, + ExportClauseRepeat1 = 227, + NamedImportsRepeat1 = 228, + VariableDeclarationRepeat1 = 229, + SwitchBodyRepeat1 = 230, + ObjectRepeat1 = 231, + ObjectPatternRepeat1 = 232, + ArrayRepeat1 = 233, + ArrayPatternRepeat1 = 234, + JsxElementRepeat1 = 235, + JsxOpeningElementRepeat1 = 236, + StringRepeat1 = 237, + StringRepeat2 = 238, + TemplateStringRepeat1 = 239, + ClassBodyRepeat1 = 240, + FormalParametersRepeat1 = 241, + ImportSpecifier = 242, + NamespaceExport = 243, + PropertyIdentifier = 244, + ShorthandPropertyIdentifier = 245, + ShorthandPropertyIdentifierPattern = 246, + StatementIdentifier = 247, + Error = 248, } impl From for &'static str { @@ -328,7 +330,6 @@ impl From for &'static str { Javascript::PIPEPIPEEQ => "||=", Javascript::QMARKQMARKEQ => "??=", Javascript::DOTDOTDOT => "...", - Javascript::QMARK => "?", Javascript::AMPAMP => "&&", Javascript::PIPEPIPE => "||", Javascript::GTGT => ">>", @@ -357,9 +358,9 @@ impl From for &'static str { Javascript::PLUSPLUS => "++", Javascript::DASHDASH => "--", Javascript::DQUOTE => "\"", - Javascript::StringToken1 => "string_token1", Javascript::SQUOTE => "'", - Javascript::StringToken2 => "string_token2", + Javascript::StringFragment => "string_fragment", + Javascript::StringFragment2 => "string_fragment", Javascript::EscapeSequence => "escape_sequence", Javascript::Comment => "comment", Javascript::BQUOTE => "`", @@ -368,6 +369,7 @@ impl From for &'static str { Javascript::RegexPattern => "regex_pattern", Javascript::RegexFlags => "regex_flags", Javascript::Number => "number", + Javascript::PrivatePropertyIdentifier => "private_property_identifier", Javascript::Target => "target", Javascript::This => "this", Javascript::Super => "super", @@ -381,6 +383,7 @@ impl From for &'static str { Javascript::Set => "set", Javascript::AutomaticSemicolon => "_automatic_semicolon", Javascript::TemplateChars => "_template_chars", + Javascript::QMARK => "?", Javascript::Program => "program", Javascript::ExportStatement => "export_statement", Javascript::ExportClause => "export_clause", @@ -472,7 +475,7 @@ impl From for &'static str { Javascript::MemberExpression2 => "member_expression", Javascript::CallExpression2 => "call_expression", Javascript::ClassBody => "class_body", - Javascript::PublicFieldDefinition => "public_field_definition", + Javascript::FieldDefinition => "field_definition", Javascript::FormalParameters => "formal_parameters", Javascript::Pattern => "pattern", Javascript::RestPattern => "rest_pattern", @@ -499,6 +502,7 @@ impl From for &'static str { Javascript::ClassBodyRepeat1 => "class_body_repeat1", Javascript::FormalParametersRepeat1 => "formal_parameters_repeat1", Javascript::ImportSpecifier => "import_specifier", + Javascript::NamespaceExport => "namespace_export", Javascript::PropertyIdentifier => "property_identifier", Javascript::ShorthandPropertyIdentifier => "shorthand_property_identifier", Javascript::ShorthandPropertyIdentifierPattern => { diff --git a/src/languages/language_python.rs b/src/languages/language_python.rs index 153ffabb4..febf47077 100644 --- a/src/languages/language_python.rs +++ b/src/languages/language_python.rs @@ -6,232 +6,248 @@ use num_derive::FromPrimitive; pub enum Python { End = 0, Identifier = 1, - Import = 2, - DOT = 3, - From = 4, - Future = 5, - LPAREN = 6, - RPAREN = 7, - COMMA = 8, - As = 9, - STAR = 10, - Print = 11, - GTGT = 12, - Assert = 13, - COLONEQ = 14, - Return = 15, - Del = 16, - Raise = 17, - Pass = 18, - Break = 19, - Continue = 20, - If = 21, - COLON = 22, - Elif = 23, - Else = 24, - Async = 25, - For = 26, - In = 27, - While = 28, - Try = 29, - Except = 30, - Finally = 31, - With = 32, - Def = 33, - DASHGT = 34, - STARSTAR = 35, - Global = 36, - Nonlocal = 37, - Exec = 38, - Class = 39, - AT = 40, - LBRACK = 41, - RBRACK = 42, - EQ = 43, - Not = 44, - And = 45, - Or = 46, - PLUS = 47, - DASH = 48, - SLASH = 49, - PERCENT = 50, - SLASHSLASH = 51, - PIPE = 52, - AMP = 53, - CARET = 54, - LTLT = 55, - TILDE = 56, - LT = 57, - LTEQ = 58, - EQEQ = 59, - BANGEQ = 60, - GTEQ = 61, - GT = 62, - LTGT = 63, - Is = 64, - Lambda3 = 65, - PLUSEQ = 66, - DASHEQ = 67, - STAREQ = 68, - SLASHEQ = 69, - ATEQ = 70, - SLASHSLASHEQ = 71, - PERCENTEQ = 72, - STARSTAREQ = 73, - GTGTEQ = 74, - LTLTEQ = 75, - AMPEQ = 76, - CARETEQ = 77, - PIPEEQ = 78, - Yield2 = 79, - Ellipsis = 80, - LBRACE = 81, - RBRACE = 82, - EscapeSequence = 83, - NotEscapeSequence = 84, - FormatSpecifierToken1 = 85, - TypeConversion = 86, - Integer = 87, - Float = 88, - Await2 = 89, - True = 90, - False = 91, - None = 92, - Comment = 93, - Semicolon = 94, - Newline = 95, - Indent = 96, - Dedent = 97, - DQUOTE = 98, - StringContent = 99, - DQUOTE2 = 100, - Module = 101, - Statement = 102, - SimpleStatements = 103, - ImportStatement = 104, - ImportPrefix = 105, - RelativeImport = 106, - FutureImportStatement = 107, - ImportFromStatement = 108, - ImportList = 109, - AliasedImport = 110, - WildcardImport = 111, - PrintStatement = 112, - Chevron = 113, - AssertStatement = 114, - ExpressionStatement = 115, - NamedExpression = 116, - ReturnStatement = 117, - DeleteStatement = 118, - RaiseStatement = 119, - PassStatement = 120, - BreakStatement = 121, - ContinueStatement = 122, - IfStatement = 123, - ElifClause = 124, - ElseClause = 125, - ForStatement = 126, - WhileStatement = 127, - TryStatement = 128, - ExceptClause = 129, - FinallyClause = 130, - WithStatement = 131, - WithClause = 132, - WithItem = 133, - FunctionDefinition = 134, - Parameters = 135, - LambdaParameters = 136, - ListSplat = 137, - DictionarySplat = 138, - GlobalStatement = 139, - NonlocalStatement = 140, - ExecStatement = 141, - ClassDefinition = 142, - ParenthesizedListSplat = 143, - ArgumentList = 144, - DecoratedDefinition = 145, - Decorator = 146, - Block = 147, - ExpressionList = 148, - DottedName = 149, - Parameters2 = 150, - Patterns = 151, - Parameter = 152, - Pattern = 153, - TuplePattern = 154, - ListPattern = 155, - DefaultParameter = 156, - TypedDefaultParameter = 157, - ListSplatPattern = 158, - DictionarySplatPattern = 159, - ExpressionWithinForInClause = 160, - Expression = 161, - PrimaryExpression = 162, - NotOperator = 163, - BooleanOperator = 164, - BinaryOperator = 165, - UnaryOperator = 166, - ComparisonOperator = 167, - Lambda = 168, - Lambda2 = 169, - Assignment = 170, - AugmentedAssignment = 171, - PatternList = 172, - RightHandSide = 173, - Yield = 174, - Attribute = 175, - Subscript = 176, - Slice = 177, - Call = 178, - TypedParameter = 179, - Type = 180, - KeywordArgument = 181, - List = 182, - Set = 183, - Tuple = 184, - Dictionary = 185, - Pair = 186, - ListComprehension = 187, - DictionaryComprehension = 188, - SetComprehension = 189, - GeneratorExpression = 190, - ComprehensionClauses = 191, - ParenthesizedExpression = 192, - CollectionElements = 193, - ForInClause = 194, - IfClause = 195, - ConditionalExpression = 196, - ConcatenatedString = 197, - String = 198, - Interpolation = 199, - FormatSpecifier = 200, - FormatExpression = 201, - Await = 202, - ModuleRepeat1 = 203, - SimpleStatementsRepeat1 = 204, - ImportPrefixRepeat1 = 205, - ImportListRepeat1 = 206, - PrintStatementRepeat1 = 207, - AssertStatementRepeat1 = 208, - IfStatementRepeat1 = 209, - TryStatementRepeat1 = 210, - WithClauseRepeat1 = 211, - GlobalStatementRepeat1 = 212, - ArgumentListRepeat1 = 213, - DecoratedDefinitionRepeat1 = 214, - DottedNameRepeat1 = 215, - ParametersRepeat1 = 216, - PatternsRepeat1 = 217, - ComparisonOperatorRepeat1 = 218, - SubscriptRepeat1 = 219, - DictionaryRepeat1 = 220, - ComprehensionClausesRepeat1 = 221, - CollectionElementsRepeat1 = 222, - ForInClauseRepeat1 = 223, - ConcatenatedStringRepeat1 = 224, - StringRepeat1 = 225, - FormatSpecifierRepeat1 = 226, - Error = 227, + SEMI = 2, + Import = 3, + DOT = 4, + From = 5, + Future = 6, + LPAREN = 7, + RPAREN = 8, + COMMA = 9, + As = 10, + STAR = 11, + Print = 12, + GTGT = 13, + Assert = 14, + COLONEQ = 15, + Match = 16, + Return = 17, + Del = 18, + Raise = 19, + Pass = 20, + Break = 21, + Continue = 22, + If = 23, + COLON = 24, + Elif = 25, + Else = 26, + Case = 27, + Async = 28, + For = 29, + In = 30, + While = 31, + Try = 32, + Except = 33, + Finally = 34, + With = 35, + Def = 36, + DASHGT = 37, + STARSTAR = 38, + Global = 39, + Nonlocal = 40, + Exec = 41, + Class = 42, + AT = 43, + LBRACK = 44, + RBRACK = 45, + EQ = 46, + Not = 47, + And = 48, + Or = 49, + PLUS = 50, + DASH = 51, + SLASH = 52, + PERCENT = 53, + SLASHSLASH = 54, + PIPE = 55, + AMP = 56, + CARET = 57, + LTLT = 58, + TILDE = 59, + LT = 60, + LTEQ = 61, + EQEQ = 62, + BANGEQ = 63, + GTEQ = 64, + GT = 65, + LTGT = 66, + Is = 67, + Lambda3 = 68, + PLUSEQ = 69, + DASHEQ = 70, + STAREQ = 71, + SLASHEQ = 72, + ATEQ = 73, + SLASHSLASHEQ = 74, + PERCENTEQ = 75, + STARSTAREQ = 76, + GTGTEQ = 77, + LTLTEQ = 78, + AMPEQ = 79, + CARETEQ = 80, + PIPEEQ = 81, + Yield2 = 82, + Ellipsis = 83, + LBRACE = 84, + RBRACE = 85, + LBRACELBRACE = 86, + RBRACERBRACE = 87, + EscapeSequence = 88, + NotEscapeSequence = 89, + FormatSpecifierToken1 = 90, + TypeConversion = 91, + Integer = 92, + Float = 93, + Await2 = 94, + True = 95, + False = 96, + None = 97, + Comment = 98, + Newline = 99, + Indent = 100, + Dedent = 101, + DQUOTE = 102, + StringContent = 103, + DQUOTE2 = 104, + Module = 105, + Statement = 106, + SimpleStatements = 107, + ImportStatement = 108, + ImportPrefix = 109, + RelativeImport = 110, + FutureImportStatement = 111, + ImportFromStatement = 112, + ImportList = 113, + AliasedImport = 114, + WildcardImport = 115, + PrintStatement = 116, + Chevron = 117, + AssertStatement = 118, + ExpressionStatement = 119, + NamedExpression = 120, + NamedExpresssionLhs = 121, + ReturnStatement = 122, + DeleteStatement = 123, + RaiseStatement = 124, + PassStatement = 125, + BreakStatement = 126, + ContinueStatement = 127, + IfStatement = 128, + ElifClause = 129, + ElseClause = 130, + MatchStatement = 131, + CaseClause = 132, + ForStatement = 133, + WhileStatement = 134, + TryStatement = 135, + ExceptClause = 136, + FinallyClause = 137, + WithStatement = 138, + WithClause = 139, + WithItem = 140, + FunctionDefinition = 141, + Parameters = 142, + LambdaParameters = 143, + ListSplat = 144, + DictionarySplat = 145, + GlobalStatement = 146, + NonlocalStatement = 147, + ExecStatement = 148, + ClassDefinition = 149, + ParenthesizedListSplat = 150, + ArgumentList = 151, + DecoratedDefinition = 152, + Decorator = 153, + Block = 154, + ExpressionList = 155, + DottedName = 156, + Parameters2 = 157, + Patterns = 158, + Parameter = 159, + Pattern = 160, + TuplePattern = 161, + ListPattern = 162, + DefaultParameter = 163, + TypedDefaultParameter = 164, + ListSplatPattern = 165, + DictionarySplatPattern = 166, + AsPattern = 167, + ExpressionWithinForInClause = 168, + Expression = 169, + PrimaryExpression = 170, + NotOperator = 171, + BooleanOperator = 172, + BinaryOperator = 173, + UnaryOperator = 174, + ComparisonOperator = 175, + Lambda = 176, + Lambda2 = 177, + Assignment = 178, + AugmentedAssignment = 179, + PatternList = 180, + RightHandSide = 181, + Yield = 182, + Attribute = 183, + Subscript = 184, + Slice = 185, + Call = 186, + TypedParameter = 187, + Type = 188, + KeywordArgument = 189, + List = 190, + Set = 191, + Tuple = 192, + Dictionary = 193, + Pair = 194, + ListComprehension = 195, + DictionaryComprehension = 196, + SetComprehension = 197, + GeneratorExpression = 198, + ComprehensionClauses = 199, + ParenthesizedExpression = 200, + CollectionElements = 201, + ForInClause = 202, + IfClause = 203, + ConditionalExpression = 204, + ConcatenatedString = 205, + String = 206, + Interpolation = 207, + EscapeInterpolation = 208, + FormatSpecifier = 209, + FormatExpression = 210, + Await = 211, + PositionalSeparator = 212, + KeywordSeparator = 213, + ModuleRepeat1 = 214, + SimpleStatementsRepeat1 = 215, + ImportPrefixRepeat1 = 216, + ImportListRepeat1 = 217, + PrintStatementRepeat1 = 218, + AssertStatementRepeat1 = 219, + IfStatementRepeat1 = 220, + MatchStatementRepeat1 = 221, + MatchStatementRepeat2 = 222, + CaseClauseRepeat1 = 223, + TryStatementRepeat1 = 224, + WithClauseRepeat1 = 225, + GlobalStatementRepeat1 = 226, + ArgumentListRepeat1 = 227, + DecoratedDefinitionRepeat1 = 228, + DottedNameRepeat1 = 229, + ParametersRepeat1 = 230, + PatternsRepeat1 = 231, + ComparisonOperatorRepeat1 = 232, + SubscriptRepeat1 = 233, + DictionaryRepeat1 = 234, + ComprehensionClausesRepeat1 = 235, + CollectionElementsRepeat1 = 236, + ForInClauseRepeat1 = 237, + ConcatenatedStringRepeat1 = 238, + StringRepeat1 = 239, + FormatSpecifierRepeat1 = 240, + AsPatternTarget = 241, + CasePattern = 242, + Error = 243, } impl From for &'static str { @@ -240,6 +256,7 @@ impl From for &'static str { match tok { Python::End => "end", Python::Identifier => "identifier", + Python::SEMI => ";", Python::Import => "import", Python::DOT => ".", Python::From => "from", @@ -253,6 +270,7 @@ impl From for &'static str { Python::GTGT => ">>", Python::Assert => "assert", Python::COLONEQ => ":=", + Python::Match => "match", Python::Return => "return", Python::Del => "del", Python::Raise => "raise", @@ -263,6 +281,7 @@ impl From for &'static str { Python::COLON => ":", Python::Elif => "elif", Python::Else => "else", + Python::Case => "case", Python::Async => "async", Python::For => "for", Python::In => "in", @@ -321,6 +340,8 @@ impl From for &'static str { Python::Ellipsis => "ellipsis", Python::LBRACE => "{", Python::RBRACE => "}", + Python::LBRACELBRACE => "{{", + Python::RBRACERBRACE => "}}", Python::EscapeSequence => "escape_sequence", Python::NotEscapeSequence => "_not_escape_sequence", Python::FormatSpecifierToken1 => "format_specifier_token1", @@ -332,7 +353,6 @@ impl From for &'static str { Python::False => "false", Python::None => "none", Python::Comment => "comment", - Python::Semicolon => "_semicolon", Python::Newline => "_newline", Python::Indent => "_indent", Python::Dedent => "_dedent", @@ -355,6 +375,7 @@ impl From for &'static str { Python::AssertStatement => "assert_statement", Python::ExpressionStatement => "expression_statement", Python::NamedExpression => "named_expression", + Python::NamedExpresssionLhs => "_named_expresssion_lhs", Python::ReturnStatement => "return_statement", Python::DeleteStatement => "delete_statement", Python::RaiseStatement => "raise_statement", @@ -364,6 +385,8 @@ impl From for &'static str { Python::IfStatement => "if_statement", Python::ElifClause => "elif_clause", Python::ElseClause => "else_clause", + Python::MatchStatement => "match_statement", + Python::CaseClause => "case_clause", Python::ForStatement => "for_statement", Python::WhileStatement => "while_statement", Python::TryStatement => "try_statement", @@ -398,6 +421,7 @@ impl From for &'static str { Python::TypedDefaultParameter => "typed_default_parameter", Python::ListSplatPattern => "list_splat_pattern", Python::DictionarySplatPattern => "dictionary_splat_pattern", + Python::AsPattern => "as_pattern", Python::ExpressionWithinForInClause => "_expression_within_for_in_clause", Python::Expression => "expression", Python::PrimaryExpression => "primary_expression", @@ -438,9 +462,12 @@ impl From for &'static str { Python::ConcatenatedString => "concatenated_string", Python::String => "string", Python::Interpolation => "interpolation", + Python::EscapeInterpolation => "_escape_interpolation", Python::FormatSpecifier => "format_specifier", Python::FormatExpression => "format_expression", Python::Await => "await", + Python::PositionalSeparator => "positional_separator", + Python::KeywordSeparator => "keyword_separator", Python::ModuleRepeat1 => "module_repeat1", Python::SimpleStatementsRepeat1 => "_simple_statements_repeat1", Python::ImportPrefixRepeat1 => "import_prefix_repeat1", @@ -448,6 +475,9 @@ impl From for &'static str { Python::PrintStatementRepeat1 => "print_statement_repeat1", Python::AssertStatementRepeat1 => "assert_statement_repeat1", Python::IfStatementRepeat1 => "if_statement_repeat1", + Python::MatchStatementRepeat1 => "match_statement_repeat1", + Python::MatchStatementRepeat2 => "match_statement_repeat2", + Python::CaseClauseRepeat1 => "case_clause_repeat1", Python::TryStatementRepeat1 => "try_statement_repeat1", Python::WithClauseRepeat1 => "with_clause_repeat1", Python::GlobalStatementRepeat1 => "global_statement_repeat1", @@ -465,6 +495,8 @@ impl From for &'static str { Python::ConcatenatedStringRepeat1 => "concatenated_string_repeat1", Python::StringRepeat1 => "string_repeat1", Python::FormatSpecifierRepeat1 => "format_specifier_repeat1", + Python::AsPatternTarget => "as_pattern_target", + Python::CasePattern => "case_pattern", Python::Error => "ERROR", } } diff --git a/src/languages/language_rust.rs b/src/languages/language_rust.rs index c29674b19..d3a5f41bc 100644 --- a/src/languages/language_rust.rs +++ b/src/languages/language_rust.rs @@ -26,7 +26,7 @@ pub enum Rust { Ident = 19, Item = 20, Lifetime2 = 21, - Literal2 = 22, + Literal = 22, Meta = 23, Pat = 24, Path = 25, @@ -74,7 +74,7 @@ pub enum Rust { Static = 67, Struct = 68, Trait = 69, - Type2 = 70, + Type = 70, Union = 71, Unsafe = 72, Use = 73, @@ -202,7 +202,7 @@ pub enum Rust { Parameter = 195, ExternModifier = 196, VisibilityModifier = 197, - Type = 198, + Type2 = 198, BracketedType = 199, QualifiedType = 200, Lifetime = 201, @@ -284,7 +284,7 @@ pub enum Rust { CapturedPattern = 277, ReferencePattern = 278, OrPattern = 279, - Literal = 280, + Literal2 = 280, LiteralPattern = 281, NegativeLiteral = 282, StringLiteral = 283, @@ -349,7 +349,7 @@ impl From for &'static str { Rust::Ident => "ident", Rust::Item => "item", Rust::Lifetime2 => "lifetime", - Rust::Literal2 => "literal", + Rust::Literal => "literal", Rust::Meta => "meta", Rust::Pat => "pat", Rust::Path => "path", @@ -397,7 +397,7 @@ impl From for &'static str { Rust::Static => "static", Rust::Struct => "struct", Rust::Trait => "trait", - Rust::Type2 => "type", + Rust::Type => "type", Rust::Union => "union", Rust::Unsafe => "unsafe", Rust::Use => "use", @@ -525,7 +525,7 @@ impl From for &'static str { Rust::Parameter => "parameter", Rust::ExternModifier => "extern_modifier", Rust::VisibilityModifier => "visibility_modifier", - Rust::Type => "_type", + Rust::Type2 => "_type", Rust::BracketedType => "bracketed_type", Rust::QualifiedType => "qualified_type", Rust::Lifetime => "lifetime", @@ -607,7 +607,7 @@ impl From for &'static str { Rust::CapturedPattern => "captured_pattern", Rust::ReferencePattern => "reference_pattern", Rust::OrPattern => "or_pattern", - Rust::Literal => "_literal", + Rust::Literal2 => "_literal", Rust::LiteralPattern => "_literal_pattern", Rust::NegativeLiteral => "negative_literal", Rust::StringLiteral => "string_literal", diff --git a/src/languages/language_tsx.rs b/src/languages/language_tsx.rs index 5fca410be..f066138f0 100644 --- a/src/languages/language_tsx.rs +++ b/src/languages/language_tsx.rs @@ -10,7 +10,7 @@ pub enum Tsx { Export = 3, STAR = 4, Default = 5, - Type2 = 6, + Type = 6, EQ = 7, As = 8, Namespace = 9, @@ -134,7 +134,7 @@ pub enum Tsx { Private = 127, Protected = 128, Override = 129, - Module3 = 130, + Module2 = 130, Any = 131, Number2 = 132, Boolean = 133, @@ -226,7 +226,7 @@ pub enum Tsx { GeneratorFunction = 219, GeneratorFunctionDeclaration = 220, ArrowFunction = 221, - CallSignature = 222, + CallSignature2 = 222, FormalParameter = 223, CallExpression = 224, NewExpression = 225, @@ -274,7 +274,7 @@ pub enum Tsx { AbstractClassDeclaration = 267, Module = 268, InternalModule = 269, - Module2 = 270, + Module3 = 270, ImportAlias = 271, NestedTypeIdentifier = 272, InterfaceDeclaration = 273, @@ -294,7 +294,7 @@ pub enum Tsx { OptingTypeAnnotation = 287, TypeAnnotation = 288, Asserts = 289, - Type = 290, + Type2 = 290, RequiredParameter2 = 291, OptionalParameter2 = 292, OptionalType = 293, @@ -324,7 +324,7 @@ pub enum Tsx { PredefinedType = 317, TypeArguments = 318, ObjectType = 319, - CallSignature2 = 320, + CallSignature = 320, PropertySignature = 321, TypeParameters = 322, TypeParameter = 323, @@ -381,7 +381,7 @@ impl From for &'static str { Tsx::Export => "export", Tsx::STAR => "*", Tsx::Default => "default", - Tsx::Type2 => "type", + Tsx::Type => "type", Tsx::EQ => "=", Tsx::As => "as", Tsx::Namespace => "namespace", @@ -505,7 +505,7 @@ impl From for &'static str { Tsx::Private => "private", Tsx::Protected => "protected", Tsx::Override => "override", - Tsx::Module3 => "module", + Tsx::Module2 => "module", Tsx::Any => "any", Tsx::Number2 => "number", Tsx::Boolean => "boolean", @@ -597,7 +597,7 @@ impl From for &'static str { Tsx::GeneratorFunction => "generator_function", Tsx::GeneratorFunctionDeclaration => "generator_function_declaration", Tsx::ArrowFunction => "arrow_function", - Tsx::CallSignature => "_call_signature", + Tsx::CallSignature2 => "_call_signature", Tsx::FormalParameter => "_formal_parameter", Tsx::CallExpression => "call_expression", Tsx::NewExpression => "new_expression", @@ -645,7 +645,7 @@ impl From for &'static str { Tsx::AbstractClassDeclaration => "abstract_class_declaration", Tsx::Module => "module", Tsx::InternalModule => "internal_module", - Tsx::Module2 => "_module", + Tsx::Module3 => "_module", Tsx::ImportAlias => "import_alias", Tsx::NestedTypeIdentifier => "nested_type_identifier", Tsx::InterfaceDeclaration => "interface_declaration", @@ -665,7 +665,7 @@ impl From for &'static str { Tsx::OptingTypeAnnotation => "opting_type_annotation", Tsx::TypeAnnotation => "type_annotation", Tsx::Asserts => "asserts", - Tsx::Type => "_type", + Tsx::Type2 => "_type", Tsx::RequiredParameter2 => "required_parameter", Tsx::OptionalParameter2 => "optional_parameter", Tsx::OptionalType => "optional_type", @@ -695,7 +695,7 @@ impl From for &'static str { Tsx::PredefinedType => "predefined_type", Tsx::TypeArguments => "type_arguments", Tsx::ObjectType => "object_type", - Tsx::CallSignature2 => "call_signature", + Tsx::CallSignature => "call_signature", Tsx::PropertySignature => "property_signature", Tsx::TypeParameters => "type_parameters", Tsx::TypeParameter => "type_parameter", diff --git a/src/languages/language_typescript.rs b/src/languages/language_typescript.rs index 89a34e351..f53e6b916 100644 --- a/src/languages/language_typescript.rs +++ b/src/languages/language_typescript.rs @@ -10,7 +10,7 @@ pub enum Typescript { Export = 3, STAR = 4, Default = 5, - Type2 = 6, + Type = 6, EQ = 7, As = 8, Namespace = 9, @@ -132,7 +132,7 @@ pub enum Typescript { Private = 125, Protected = 126, Override = 127, - Module3 = 128, + Module2 = 128, Any = 129, Number2 = 130, Boolean = 131, @@ -216,7 +216,7 @@ pub enum Typescript { GeneratorFunction = 209, GeneratorFunctionDeclaration = 210, ArrowFunction = 211, - CallSignature = 212, + CallSignature2 = 212, FormalParameter = 213, CallExpression = 214, NewExpression = 215, @@ -265,7 +265,7 @@ pub enum Typescript { AbstractClassDeclaration = 258, Module = 259, InternalModule = 260, - Module2 = 261, + Module3 = 261, ImportAlias = 262, NestedTypeIdentifier = 263, InterfaceDeclaration = 264, @@ -285,7 +285,7 @@ pub enum Typescript { OptingTypeAnnotation = 278, TypeAnnotation = 279, Asserts = 280, - Type = 281, + Type2 = 281, RequiredParameter2 = 282, OptionalParameter2 = 283, OptionalType = 284, @@ -315,7 +315,7 @@ pub enum Typescript { PredefinedType = 308, TypeArguments = 309, ObjectType = 310, - CallSignature2 = 311, + CallSignature = 311, PropertySignature = 312, TypeParameters = 313, TypeParameter = 314, @@ -370,7 +370,7 @@ impl From for &'static str { Typescript::Export => "export", Typescript::STAR => "*", Typescript::Default => "default", - Typescript::Type2 => "type", + Typescript::Type => "type", Typescript::EQ => "=", Typescript::As => "as", Typescript::Namespace => "namespace", @@ -492,7 +492,7 @@ impl From for &'static str { Typescript::Private => "private", Typescript::Protected => "protected", Typescript::Override => "override", - Typescript::Module3 => "module", + Typescript::Module2 => "module", Typescript::Any => "any", Typescript::Number2 => "number", Typescript::Boolean => "boolean", @@ -578,7 +578,7 @@ impl From for &'static str { Typescript::GeneratorFunction => "generator_function", Typescript::GeneratorFunctionDeclaration => "generator_function_declaration", Typescript::ArrowFunction => "arrow_function", - Typescript::CallSignature => "_call_signature", + Typescript::CallSignature2 => "_call_signature", Typescript::FormalParameter => "_formal_parameter", Typescript::CallExpression => "call_expression", Typescript::NewExpression => "new_expression", @@ -627,7 +627,7 @@ impl From for &'static str { Typescript::AbstractClassDeclaration => "abstract_class_declaration", Typescript::Module => "module", Typescript::InternalModule => "internal_module", - Typescript::Module2 => "_module", + Typescript::Module3 => "_module", Typescript::ImportAlias => "import_alias", Typescript::NestedTypeIdentifier => "nested_type_identifier", Typescript::InterfaceDeclaration => "interface_declaration", @@ -647,7 +647,7 @@ impl From for &'static str { Typescript::OptingTypeAnnotation => "opting_type_annotation", Typescript::TypeAnnotation => "type_annotation", Typescript::Asserts => "asserts", - Typescript::Type => "_type", + Typescript::Type2 => "_type", Typescript::RequiredParameter2 => "required_parameter", Typescript::OptionalParameter2 => "optional_parameter", Typescript::OptionalType => "optional_type", @@ -677,7 +677,7 @@ impl From for &'static str { Typescript::PredefinedType => "predefined_type", Typescript::TypeArguments => "type_arguments", Typescript::ObjectType => "object_type", - Typescript::CallSignature2 => "call_signature", + Typescript::CallSignature => "call_signature", Typescript::PropertySignature => "property_signature", Typescript::TypeParameters => "type_parameters", Typescript::TypeParameter => "type_parameter", diff --git a/tree-sitter-ccomment/Cargo.toml b/tree-sitter-ccomment/Cargo.toml index c679e3ab9..0b7d1865d 100644 --- a/tree-sitter-ccomment/Cargo.toml +++ b/tree-sitter-ccomment/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-ccomment" description = "Ccomment grammar for the tree-sitter parsing library" -version = "0.19.0" +version = "0.20.0" authors = ["Calixte Denizet "] license = "MIT" readme = "bindings/rust/README.md" @@ -21,7 +21,7 @@ include = [ path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "0.19.3" +tree-sitter = ">= 0.19, < 0.21" [build-dependencies] cc = "^1.0" diff --git a/tree-sitter-ccomment/package.json b/tree-sitter-ccomment/package.json index 35afdd702..f96ff873d 100644 --- a/tree-sitter-ccomment/package.json +++ b/tree-sitter-ccomment/package.json @@ -13,7 +13,7 @@ "nan": "^2.14.2" }, "devDependencies": { - "tree-sitter-cli": "^0.19.3" + "tree-sitter-cli": "^0.20.1" }, "scripts": { "build": "tree-sitter generate && node-gyp build", diff --git a/tree-sitter-mozjs/Cargo.toml b/tree-sitter-mozjs/Cargo.toml index 9a93ecb4a..0af3c0b04 100644 --- a/tree-sitter-mozjs/Cargo.toml +++ b/tree-sitter-mozjs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-mozjs" description = "Mozjs grammar for the tree-sitter parsing library" -version = "0.19.0" +version = "0.20.0" authors = ["Calixte Denizet "] license = "MIT" readme = "bindings/rust/README.md" @@ -21,7 +21,7 @@ include = [ path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "0.19.3" +tree-sitter = ">= 0.19, < 0.21" [build-dependencies] cc = "^1.0" diff --git a/tree-sitter-mozjs/package.json b/tree-sitter-mozjs/package.json index ef3d956af..372b6b27d 100644 --- a/tree-sitter-mozjs/package.json +++ b/tree-sitter-mozjs/package.json @@ -13,7 +13,7 @@ "nan": "^2.14.2" }, "devDependencies": { - "tree-sitter-cli": "^0.19.3" + "tree-sitter-cli": "^0.20.1" }, "scripts": { "build": "tree-sitter generate && node-gyp build", diff --git a/tree-sitter-preproc/Cargo.toml b/tree-sitter-preproc/Cargo.toml index 7cfeac326..66a9bda99 100644 --- a/tree-sitter-preproc/Cargo.toml +++ b/tree-sitter-preproc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-preproc" description = "Preproc grammar for the tree-sitter parsing library" -version = "0.19.0" +version = "0.20.0" authors = ["Calixte Denizet "] license = "MIT" readme = "bindings/rust/README.md" @@ -21,7 +21,7 @@ include = [ path = "bindings/rust/lib.rs" [dependencies] -tree-sitter = "0.19.3" +tree-sitter = ">= 0.19, < 0.21" [build-dependencies] cc = "^1.0" diff --git a/tree-sitter-preproc/package.json b/tree-sitter-preproc/package.json index 99de973ba..afc84d07c 100644 --- a/tree-sitter-preproc/package.json +++ b/tree-sitter-preproc/package.json @@ -13,7 +13,7 @@ "nan": "^2.14.2" }, "devDependencies": { - "tree-sitter-cli": "^0.19.3" + "tree-sitter-cli": "^0.20.1" }, "scripts": { "build": "tree-sitter generate && node-gyp build", From a8440321a3550bf47217df130391a537f68b5194 Mon Sep 17 00:00:00 2001 From: Aditya Giri Date: Thu, 31 Mar 2022 11:50:25 +0530 Subject: [PATCH 2/4] Fix Java Support for tree-sitter v0.20 --- src/checker.rs | 2 +- src/metrics/loc.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/checker.rs b/src/checker.rs index ba99cbb04..78f770072 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -204,7 +204,7 @@ impl Checker for PythonCode { } impl Checker for JavaCode { - mk_checker!(is_comment, Comment); + mk_checker!(is_comment, LineComment, BlockComment); mk_checker!(is_string, StringLiteral); mk_checker!(is_call, MethodInvocation); mk_checker!(is_func, MethodDeclaration); diff --git a/src/metrics/loc.rs b/src/metrics/loc.rs index 9bf0ddb59..6fd7f351c 100644 --- a/src/metrics/loc.rs +++ b/src/metrics/loc.rs @@ -820,12 +820,15 @@ impl Loc for JavaCode { // https://docs.oracle.com/javase/tutorial/java/nutsandbolts/expressions.html match kind_id { Program => {} - Comment => { + LineComment => { + add_cloc_lines(stats, start, end); + } + BlockComment => { add_cloc_lines(stats, start, end); } AssertStatement | BreakStatement | ContinueStatement | DoStatement | EnhancedForStatement | ExpressionStatement | ForStatement | IfStatement - | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement + | ReturnStatement | SwitchExpression | ThrowStatement | TryStatement | WhileStatement => { stats.lloc.logical_lines += 1; } From b5a05c9b9b993e949c1b2b1e8eaa9f64c7326dbe Mon Sep 17 00:00:00 2001 From: Aditya Giri Date: Thu, 31 Mar 2022 16:35:39 +0530 Subject: [PATCH 3/4] Fix javascript tests JavaScript and Mozjs tests in the previous version had wrong code provided. The code that was provided previously was in the typescript style. With tree-sitter v0.19, it created an extra `expression_statement` and due to that, the false positive saying the `lloc` is 7 was provided. --- src/metrics/loc.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/metrics/loc.rs b/src/metrics/loc.rs index 6fd7f351c..d68f32ca1 100644 --- a/src/metrics/loc.rs +++ b/src/metrics/loc.rs @@ -1846,7 +1846,7 @@ mod tests { fn javascript_real_loc() { check_metrics!( "assert.throws(Test262Error, function() { - for (let { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) { + for (let { poisoned = ++initEvalCount } = poisonedProperty; ; ) { return; } });", @@ -1856,24 +1856,24 @@ mod tests { [ (sloc, 5, usize), // The number of lines is 5 (ploc, 5, usize), // The number of code lines is 5 - (lloc, 7, usize), // The number of statements is 7 + (lloc, 6, usize), // The number of statements is 6 (cloc, 0, usize), // The number of comments is 0 (blank, 0, usize), // The number of blank lines is 0 (sloc_min, 5, usize), (ploc_min, 5, usize), - (lloc_min, 6, usize), + (lloc_min, 5, usize), (cloc_min, 0, usize), (blank_min, 0, usize), (sloc_max, 5, usize), (ploc_max, 5, usize), - (lloc_max, 6, usize), + (lloc_max, 5, usize), (cloc_max, 0, usize), (blank_max, 0, usize) ], [ (sloc_average, 2.5), // The number of spaces is 2 (ploc_average, 2.5), - (lloc_average, 3.5), + (lloc_average, 3.0), (cloc_average, 0.0), (blank_average, 0.0) ] @@ -1884,7 +1884,7 @@ mod tests { fn mozjs_real_loc() { check_metrics!( "assert.throws(Test262Error, function() { - for (let { poisoned: x = ++initEvalCount } = poisonedProperty; ; ) { + for (let { poisoned = ++initEvalCount } = poisonedProperty; ; ) { return; } });", @@ -1894,24 +1894,24 @@ mod tests { [ (sloc, 5, usize), // The number of lines is 5 (ploc, 5, usize), // The number of code lines is 5 - (lloc, 7, usize), // The number of statements is 7 + (lloc, 6, usize), // The number of statements is 7 (cloc, 0, usize), // The number of comments is 0 (blank, 0, usize), // The number of blank lines is 0 (sloc_min, 5, usize), (ploc_min, 5, usize), - (lloc_min, 6, usize), + (lloc_min, 5, usize), (cloc_min, 0, usize), (blank_min, 0, usize), (sloc_max, 5, usize), (ploc_max, 5, usize), - (lloc_max, 6, usize), + (lloc_max, 5, usize), (cloc_max, 0, usize), (blank_max, 0, usize) ], [ (sloc_average, 2.5), // The number of spaces is 2 (ploc_average, 2.5), - (lloc_average, 3.5), + (lloc_average, 3.0), (cloc_average, 0.0), (blank_average, 0.0) ] From acd2447d5cd63f5e5138572de1fde7cd27ccff92 Mon Sep 17 00:00:00 2001 From: Aditya Giri Date: Fri, 1 Apr 2022 12:44:26 +0530 Subject: [PATCH 4/4] Update tree-sitter-rust to v0.20.1 --- Cargo.lock | 4 +- Cargo.toml | 2 +- enums/Cargo.lock | 4 +- enums/Cargo.toml | 2 +- src/languages/language_rust.rs | 406 +++++++++++++++++---------------- src/metrics/cyclomatic.rs | 1 + src/metrics/loc.rs | 1 - 7 files changed, 213 insertions(+), 207 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36327e1c1..fea156445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2182,9 +2182,9 @@ dependencies = [ [[package]] name = "tree-sitter-rust" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df540a493d754015d22eaf57c38f58804be3713a22f6062db983ec15f85c3c9" +checksum = "13470fafb7327a3acf96f5bc1013b5539a899a182f01c59b5af53f6b93195717" dependencies = [ "cc", "tree-sitter 0.20.2", diff --git a/Cargo.toml b/Cargo.toml index b41fe5d50..19086c33d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ walkdir = "^2.3" tree-sitter = ">= 0.19, < 0.21" tree-sitter-typescript = "=0.20.0" tree-sitter-javascript = "=0.20.0" -tree-sitter-rust = "=0.20.0" +tree-sitter-rust = "=0.20.1" tree-sitter-python = { git = "https://github.com/tree-sitter/tree-sitter-python", branch = "master" } tree-sitter-java = { git = "https://github.com/hyperlog/tree-sitter-java", branch = "master" } tree-sitter-preproc = { path = "./tree-sitter-preproc", version = "=0.20.0" } diff --git a/enums/Cargo.lock b/enums/Cargo.lock index 0fac254f2..9ea2d1304 100644 --- a/enums/Cargo.lock +++ b/enums/Cargo.lock @@ -381,9 +381,9 @@ dependencies = [ [[package]] name = "tree-sitter-rust" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df540a493d754015d22eaf57c38f58804be3713a22f6062db983ec15f85c3c9" +checksum = "13470fafb7327a3acf96f5bc1013b5539a899a182f01c59b5af53f6b93195717" dependencies = [ "cc", "tree-sitter 0.20.2", diff --git a/enums/Cargo.toml b/enums/Cargo.toml index eafa3fce0..1a294eec7 100644 --- a/enums/Cargo.toml +++ b/enums/Cargo.toml @@ -11,7 +11,7 @@ askama = "^0.11" tree-sitter = ">= 0.19, < 0.21" tree-sitter-typescript = "=0.20.0" tree-sitter-javascript = "=0.20.0" -tree-sitter-rust = "=0.20.0" +tree-sitter-rust = "=0.20.1" tree-sitter-python = { git = "https://github.com/tree-sitter/tree-sitter-python", branch = "master" } tree-sitter-java = { git = "https://github.com/hyperlog/tree-sitter-java", branch = "master" } tree-sitter-preproc = { path = "../tree-sitter-preproc", version = "=0.20.0" } diff --git a/src/languages/language_rust.rs b/src/languages/language_rust.rs index d3a5f41bc..a92669341 100644 --- a/src/languages/language_rust.rs +++ b/src/languages/language_rust.rs @@ -122,205 +122,208 @@ pub enum Rust { CARETEQ = 115, LTLTEQ = 116, GTGTEQ = 117, - Else = 118, - Move = 119, - DOT = 120, - AT = 121, - IntegerLiteral = 122, - DQUOTE = 123, - DQUOTE2 = 124, - CharLiteral = 125, - EscapeSequence = 126, - True = 127, - False = 128, - LineComment = 129, - Zelf = 130, - Super = 131, - Crate = 132, - Metavariable = 133, - StringContent = 134, - RawStringLiteral = 135, - FloatLiteral = 136, - BlockComment = 137, - SourceFile = 138, - Statement = 139, - EmptyStatement = 140, - ExpressionStatement = 141, - MacroDefinition = 142, - MacroRule = 143, - TokenPattern = 144, - TokenTreePattern = 145, - TokenBindingPattern = 146, - TokenRepetitionPattern = 147, - FragmentSpecifier = 148, - TokenTree = 149, - TokenRepetition = 150, - AttributeItem = 151, - InnerAttributeItem = 152, - MetaItem = 153, - MetaArguments = 154, - ModItem = 155, - ForeignModItem = 156, - DeclarationList = 157, - StructItem = 158, - UnionItem = 159, - EnumItem = 160, - EnumVariantList = 161, - EnumVariant = 162, - FieldDeclarationList = 163, - FieldDeclaration = 164, - OrderedFieldDeclarationList = 165, - ExternCrateDeclaration = 166, - ConstItem = 167, - StaticItem = 168, - TypeItem = 169, - FunctionItem = 170, - FunctionSignatureItem = 171, - FunctionModifiers = 172, - WhereClause = 173, - WherePredicate = 174, - ImplItem = 175, - TraitItem = 176, - AssociatedType = 177, - TraitBounds = 178, - HigherRankedTraitBound = 179, - RemovedTraitBound = 180, - TypeParameters = 181, - ConstParameter = 182, - ConstrainedTypeParameter = 183, - OptionalTypeParameter = 184, - LetDeclaration = 185, - UseDeclaration = 186, - UseClause = 187, - ScopedUseList = 188, - UseList = 189, - UseAsClause = 190, - UseWildcard = 191, - Parameters = 192, - SelfParameter = 193, - VariadicParameter = 194, - Parameter = 195, - ExternModifier = 196, - VisibilityModifier = 197, - Type2 = 198, - BracketedType = 199, - QualifiedType = 200, - Lifetime = 201, - ArrayType = 202, - ForLifetimes = 203, - FunctionType = 204, - TupleType = 205, - UnitType = 206, - GenericFunction = 207, - GenericType = 208, - GenericTypeWithTurbofish = 209, - BoundedType = 210, - TypeArguments = 211, - TypeBinding = 212, - ReferenceType = 213, - PointerType = 214, - EmptyType = 215, - AbstractType = 216, - DynamicType = 217, - Expression = 218, - MacroInvocation = 219, - ScopedIdentifier = 220, - ScopedTypeIdentifier = 221, - ScopedTypeIdentifier2 = 222, - RangeExpression = 223, - UnaryExpression = 224, - TryExpression = 225, - ReferenceExpression = 226, - BinaryExpression = 227, - AssignmentExpression = 228, - CompoundAssignmentExpr = 229, - TypeCastExpression = 230, - ReturnExpression = 231, - CallExpression = 232, - Arguments = 233, - ArrayExpression = 234, - ParenthesizedExpression = 235, - TupleExpression = 236, - UnitExpression = 237, - StructExpression = 238, - FieldInitializerList = 239, - ShorthandFieldInitializer = 240, - FieldInitializer = 241, - BaseFieldInitializer = 242, - IfExpression = 243, - IfLetExpression = 244, - ElseClause = 245, - MatchExpression = 246, - MatchBlock = 247, - MatchArm = 248, - MatchArm2 = 249, - MatchPattern = 250, - WhileExpression = 251, - WhileLetExpression = 252, - LoopExpression = 253, - ForExpression = 254, - ConstBlock = 255, - ClosureExpression = 256, - ClosureParameters = 257, - LoopLabel = 258, - BreakExpression = 259, - ContinueExpression = 260, - IndexExpression = 261, - AwaitExpression = 262, - FieldExpression = 263, - UnsafeBlock = 264, - AsyncBlock = 265, - Block = 266, - Pattern = 267, - TuplePattern = 268, - SlicePattern = 269, - TupleStructPattern = 270, - StructPattern = 271, - FieldPattern = 272, - RemainingFieldPattern = 273, - MutPattern = 274, - RangePattern = 275, - RefPattern = 276, - CapturedPattern = 277, - ReferencePattern = 278, - OrPattern = 279, - Literal2 = 280, - LiteralPattern = 281, - NegativeLiteral = 282, - StringLiteral = 283, - BooleanLiteral = 284, - SourceFileRepeat1 = 285, - MacroDefinitionRepeat1 = 286, - TokenTreePatternRepeat1 = 287, - TokenTreeRepeat1 = 288, - MetaArgumentsRepeat1 = 289, - DeclarationListRepeat1 = 290, - EnumVariantListRepeat1 = 291, - EnumVariantListRepeat2 = 292, - FieldDeclarationListRepeat1 = 293, - OrderedFieldDeclarationListRepeat1 = 294, - FunctionModifiersRepeat1 = 295, - WhereClauseRepeat1 = 296, - TraitBoundsRepeat1 = 297, - TypeParametersRepeat1 = 298, - UseListRepeat1 = 299, - ParametersRepeat1 = 300, - ForLifetimesRepeat1 = 301, - TupleTypeRepeat1 = 302, - TypeArgumentsRepeat1 = 303, - ArgumentsRepeat1 = 304, - ArrayExpressionRepeat1 = 305, - TupleExpressionRepeat1 = 306, - FieldInitializerListRepeat1 = 307, - MatchBlockRepeat1 = 308, - ClosureParametersRepeat1 = 309, - TuplePatternRepeat1 = 310, - StructPatternRepeat1 = 311, - StringLiteralRepeat1 = 312, - FieldIdentifier = 313, - ShorthandFieldIdentifier = 314, - TypeIdentifier = 315, - Error = 316, + Yield = 118, + Else = 119, + Move = 120, + DOT = 121, + AT = 122, + IntegerLiteral = 123, + DQUOTE = 124, + DQUOTE2 = 125, + CharLiteral = 126, + EscapeSequence = 127, + True = 128, + False = 129, + LineComment = 130, + Zelf = 131, + Super = 132, + Crate = 133, + Metavariable = 134, + StringContent = 135, + RawStringLiteral = 136, + FloatLiteral = 137, + BlockComment = 138, + SourceFile = 139, + Statement = 140, + EmptyStatement = 141, + ExpressionStatement = 142, + MacroDefinition = 143, + MacroRule = 144, + TokenPattern = 145, + TokenTreePattern = 146, + TokenBindingPattern = 147, + TokenRepetitionPattern = 148, + FragmentSpecifier = 149, + TokenTree = 150, + TokenRepetition = 151, + AttributeItem = 152, + InnerAttributeItem = 153, + MetaItem = 154, + MetaArguments = 155, + ModItem = 156, + ForeignModItem = 157, + DeclarationList = 158, + StructItem = 159, + UnionItem = 160, + EnumItem = 161, + EnumVariantList = 162, + EnumVariant = 163, + FieldDeclarationList = 164, + FieldDeclaration = 165, + OrderedFieldDeclarationList = 166, + ExternCrateDeclaration = 167, + ConstItem = 168, + StaticItem = 169, + TypeItem = 170, + FunctionItem = 171, + FunctionSignatureItem = 172, + FunctionModifiers = 173, + WhereClause = 174, + WherePredicate = 175, + ImplItem = 176, + TraitItem = 177, + AssociatedType = 178, + TraitBounds = 179, + HigherRankedTraitBound = 180, + RemovedTraitBound = 181, + TypeParameters = 182, + ConstParameter = 183, + ConstrainedTypeParameter = 184, + OptionalTypeParameter = 185, + LetDeclaration = 186, + UseDeclaration = 187, + UseClause = 188, + ScopedUseList = 189, + UseList = 190, + UseAsClause = 191, + UseWildcard = 192, + Parameters = 193, + SelfParameter = 194, + VariadicParameter = 195, + Parameter = 196, + ExternModifier = 197, + VisibilityModifier = 198, + Type2 = 199, + BracketedType = 200, + QualifiedType = 201, + Lifetime = 202, + ArrayType = 203, + ForLifetimes = 204, + FunctionType = 205, + TupleType = 206, + UnitType = 207, + GenericFunction = 208, + GenericType = 209, + GenericTypeWithTurbofish = 210, + BoundedType = 211, + TypeArguments = 212, + TypeBinding = 213, + ReferenceType = 214, + PointerType = 215, + EmptyType = 216, + AbstractType = 217, + DynamicType = 218, + ExpressionExceptRange = 219, + Expression = 220, + MacroInvocation = 221, + ScopedIdentifier = 222, + ScopedTypeIdentifier = 223, + ScopedTypeIdentifier2 = 224, + RangeExpression = 225, + UnaryExpression = 226, + TryExpression = 227, + ReferenceExpression = 228, + BinaryExpression = 229, + AssignmentExpression = 230, + CompoundAssignmentExpr = 231, + TypeCastExpression = 232, + ReturnExpression = 233, + YieldExpression = 234, + CallExpression = 235, + Arguments = 236, + ArrayExpression = 237, + ParenthesizedExpression = 238, + TupleExpression = 239, + UnitExpression = 240, + StructExpression = 241, + FieldInitializerList = 242, + ShorthandFieldInitializer = 243, + FieldInitializer = 244, + BaseFieldInitializer = 245, + IfExpression = 246, + IfLetExpression = 247, + ElseClause = 248, + MatchExpression = 249, + MatchBlock = 250, + MatchArm = 251, + MatchArm2 = 252, + MatchPattern = 253, + WhileExpression = 254, + WhileLetExpression = 255, + LoopExpression = 256, + ForExpression = 257, + ConstBlock = 258, + ClosureExpression = 259, + ClosureParameters = 260, + LoopLabel = 261, + BreakExpression = 262, + ContinueExpression = 263, + IndexExpression = 264, + AwaitExpression = 265, + FieldExpression = 266, + UnsafeBlock = 267, + AsyncBlock = 268, + Block = 269, + Pattern = 270, + TuplePattern = 271, + SlicePattern = 272, + TupleStructPattern = 273, + StructPattern = 274, + FieldPattern = 275, + RemainingFieldPattern = 276, + MutPattern = 277, + RangePattern = 278, + RefPattern = 279, + CapturedPattern = 280, + ReferencePattern = 281, + OrPattern = 282, + Literal2 = 283, + LiteralPattern = 284, + NegativeLiteral = 285, + StringLiteral = 286, + BooleanLiteral = 287, + SourceFileRepeat1 = 288, + MacroDefinitionRepeat1 = 289, + TokenTreePatternRepeat1 = 290, + TokenTreeRepeat1 = 291, + MetaArgumentsRepeat1 = 292, + DeclarationListRepeat1 = 293, + EnumVariantListRepeat1 = 294, + EnumVariantListRepeat2 = 295, + FieldDeclarationListRepeat1 = 296, + OrderedFieldDeclarationListRepeat1 = 297, + FunctionModifiersRepeat1 = 298, + WhereClauseRepeat1 = 299, + TraitBoundsRepeat1 = 300, + TypeParametersRepeat1 = 301, + UseListRepeat1 = 302, + ParametersRepeat1 = 303, + ForLifetimesRepeat1 = 304, + TupleTypeRepeat1 = 305, + TypeArgumentsRepeat1 = 306, + ArgumentsRepeat1 = 307, + ArrayExpressionRepeat1 = 308, + TupleExpressionRepeat1 = 309, + FieldInitializerListRepeat1 = 310, + MatchBlockRepeat1 = 311, + ClosureParametersRepeat1 = 312, + TuplePatternRepeat1 = 313, + StructPatternRepeat1 = 314, + StringLiteralRepeat1 = 315, + FieldIdentifier = 316, + ShorthandFieldIdentifier = 317, + TypeIdentifier = 318, + Error = 319, } impl From for &'static str { @@ -445,6 +448,7 @@ impl From for &'static str { Rust::CARETEQ => "^=", Rust::LTLTEQ => "<<=", Rust::GTGTEQ => ">>=", + Rust::Yield => "yield", Rust::Else => "else", Rust::Move => "move", Rust::DOT => ".", @@ -468,7 +472,7 @@ impl From for &'static str { Rust::SourceFile => "source_file", Rust::Statement => "_statement", Rust::EmptyStatement => "empty_statement", - Rust::ExpressionStatement => "_expression_statement", + Rust::ExpressionStatement => "expression_statement", Rust::MacroDefinition => "macro_definition", Rust::MacroRule => "macro_rule", Rust::TokenPattern => "_token_pattern", @@ -545,6 +549,7 @@ impl From for &'static str { Rust::EmptyType => "empty_type", Rust::AbstractType => "abstract_type", Rust::DynamicType => "dynamic_type", + Rust::ExpressionExceptRange => "_expression_except_range", Rust::Expression => "_expression", Rust::MacroInvocation => "macro_invocation", Rust::ScopedIdentifier => "scoped_identifier", @@ -559,6 +564,7 @@ impl From for &'static str { Rust::CompoundAssignmentExpr => "compound_assignment_expr", Rust::TypeCastExpression => "type_cast_expression", Rust::ReturnExpression => "return_expression", + Rust::YieldExpression => "yield_expression", Rust::CallExpression => "call_expression", Rust::Arguments => "arguments", Rust::ArrayExpression => "array_expression", diff --git a/src/metrics/cyclomatic.rs b/src/metrics/cyclomatic.rs index 3623b1ea8..3d74f8928 100644 --- a/src/metrics/cyclomatic.rs +++ b/src/metrics/cyclomatic.rs @@ -185,6 +185,7 @@ impl Cyclomatic for RustCode { match node.object().kind_id().into() { If | For | While | Loop | MatchArm | MatchArm2 | QMARK | AMPAMP | PIPEPIPE => { + println!("Found the if case at position: {} {}", node.object().start_position(), node.object().end_position()); stats.cyclomatic += 1.; } _ => {} diff --git a/src/metrics/loc.rs b/src/metrics/loc.rs index d68f32ca1..df00c1a3f 100644 --- a/src/metrics/loc.rs +++ b/src/metrics/loc.rs @@ -730,7 +730,6 @@ impl Loc for RustCode { } Statement | EmptyStatement - | ExpressionStatement | LetDeclaration | AssignmentExpression | CompoundAssignmentExpr