brighterscript 1.0.0-alpha.5 → 1.0.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -138
- package/bsconfig.schema.json +196 -5
- package/dist/ActionPipeline.d.ts +10 -0
- package/dist/ActionPipeline.js +40 -0
- package/dist/ActionPipeline.js.map +1 -0
- package/dist/AstValidationSegmenter.d.ts +45 -0
- package/dist/AstValidationSegmenter.js +322 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/BsConfig.d.ts +161 -43
- package/dist/BusyStatusTracker.d.ts +61 -0
- package/dist/BusyStatusTracker.js +148 -0
- package/dist/BusyStatusTracker.js.map +1 -0
- package/dist/Cache.d.ts +3 -8
- package/dist/Cache.js +9 -14
- package/dist/Cache.js.map +1 -1
- package/dist/CacheVerifier.d.ts +7 -0
- package/dist/CacheVerifier.js +20 -0
- package/dist/CacheVerifier.js.map +1 -0
- package/dist/CodeActionUtil.d.ts +29 -4
- package/dist/CodeActionUtil.js +22 -5
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +20 -15
- package/dist/CommentFlagProcessor.js +143 -58
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/CrossScopeValidator.d.ts +68 -0
- package/dist/CrossScopeValidator.js +650 -0
- package/dist/CrossScopeValidator.js.map +1 -0
- package/dist/DependencyGraph.d.ts +8 -3
- package/dist/DependencyGraph.js +49 -16
- package/dist/DependencyGraph.js.map +1 -1
- package/dist/DiagnosticCollection.d.ts +21 -5
- package/dist/DiagnosticCollection.js +77 -24
- package/dist/DiagnosticCollection.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +27 -6
- package/dist/DiagnosticFilterer.js +273 -60
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +83 -0
- package/dist/DiagnosticManager.js +422 -0
- package/dist/DiagnosticManager.js.map +1 -0
- package/dist/DiagnosticMessages.d.ts +602 -196
- package/dist/DiagnosticMessages.js +926 -342
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/DiagnosticSeverityAdjuster.d.ts +7 -0
- package/dist/DiagnosticSeverityAdjuster.js +45 -0
- package/dist/DiagnosticSeverityAdjuster.js.map +1 -0
- package/dist/FunctionScope.d.ts +28 -0
- package/dist/FunctionScope.js +52 -0
- package/dist/FunctionScope.js.map +1 -0
- package/dist/KeyedThrottler.d.ts +3 -3
- package/dist/KeyedThrottler.js +3 -3
- package/dist/KeyedThrottler.js.map +1 -1
- package/dist/LanguageServer.d.ts +136 -104
- package/dist/LanguageServer.js +577 -741
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Logger.d.ts +17 -13
- package/dist/Logger.js +64 -34
- package/dist/Logger.js.map +1 -1
- package/dist/PluginInterface.d.ts +32 -10
- package/dist/PluginInterface.js +117 -7
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +302 -98
- package/dist/Program.js +1613 -726
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +39 -22
- package/dist/ProgramBuilder.js +245 -179
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +227 -106
- package/dist/Scope.js +609 -557
- package/dist/Scope.js.map +1 -1
- package/dist/ScopeNamespaceLookup.d.ts +73 -0
- package/dist/ScopeNamespaceLookup.js +242 -0
- package/dist/ScopeNamespaceLookup.js.map +1 -0
- package/dist/SemanticTokenUtils.js +5 -1
- package/dist/SemanticTokenUtils.js.map +1 -1
- package/dist/Stopwatch.d.ts +4 -0
- package/dist/Stopwatch.js +8 -1
- package/dist/Stopwatch.js.map +1 -1
- package/dist/SymbolTable.d.ts +145 -26
- package/dist/SymbolTable.js +575 -64
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +9 -0
- package/dist/SymbolTypeFlag.js +14 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/Throttler.d.ts +12 -0
- package/dist/Throttler.js +39 -0
- package/dist/Throttler.js.map +1 -1
- package/dist/Watcher.d.ts +0 -3
- package/dist/Watcher.js +0 -3
- package/dist/Watcher.js.map +1 -1
- package/dist/XmlScope.d.ts +5 -15
- package/dist/XmlScope.js +34 -90
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +50 -0
- package/dist/astUtils/CachedLookups.js +337 -0
- package/dist/astUtils/CachedLookups.js.map +1 -0
- package/dist/astUtils/Editor.d.ts +69 -0
- package/dist/astUtils/Editor.js +245 -0
- package/dist/astUtils/Editor.js.map +1 -0
- package/dist/astUtils/creators.d.ts +54 -19
- package/dist/astUtils/creators.js +242 -42
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +199 -85
- package/dist/astUtils/reflection.js +518 -145
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/stackedVisitor.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +117 -53
- package/dist/astUtils/visitors.js +95 -15
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/xml.d.ts +9 -8
- package/dist/astUtils/xml.js +12 -7
- package/dist/astUtils/xml.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +26 -4
- package/dist/bscPlugin/BscPlugin.js +96 -4
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +36 -0
- package/dist/bscPlugin/CallExpressionInfo.js +142 -0
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -0
- package/dist/bscPlugin/FileWriter.d.ts +19 -0
- package/dist/bscPlugin/FileWriter.js +79 -0
- package/dist/bscPlugin/FileWriter.js.map +1 -0
- package/dist/bscPlugin/SignatureHelpUtil.d.ts +10 -0
- package/dist/bscPlugin/SignatureHelpUtil.js +137 -0
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -0
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +109 -7
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +676 -26
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.d.ts +17 -0
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js +66 -0
- package/dist/bscPlugin/codeActions/FixAllCodeActionsProcessor.js.map +1 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.d.ts +18 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.js +31 -0
- package/dist/bscPlugin/codeActions/codeActionHelpers.js.map +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +65 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +633 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -0
- package/dist/bscPlugin/definition/DefinitionProvider.d.ts +13 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js +220 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -0
- package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
- package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +18 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +238 -0
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +57 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.d.ts +7 -0
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js +77 -0
- package/dist/bscPlugin/selectionRanges/SelectionRangesProcessor.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +14 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +164 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -0
- package/dist/bscPlugin/serialize/BslibManager.d.ts +12 -0
- package/dist/bscPlugin/serialize/BslibManager.js +46 -0
- package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
- package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
- package/dist/bscPlugin/serialize/FileSerializer.js +80 -0
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js +22 -0
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.d.ts +7 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js +26 -0
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.js.map +1 -0
- package/dist/bscPlugin/symbols/symbolUtils.d.ts +5 -0
- package/dist/bscPlugin/symbols/symbolUtils.js +141 -0
- package/dist/bscPlugin/symbols/symbolUtils.js.map +1 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +34 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +504 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +12 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +99 -0
- package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.d.ts +7 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js +18 -0
- package/dist/bscPlugin/validation/BrsFileAfterValidator.js.map +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +51 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +714 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ProgramValidator.d.ts +11 -0
- package/dist/bscPlugin/validation/ProgramValidator.js +33 -0
- package/dist/bscPlugin/validation/ProgramValidator.js.map +1 -0
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +158 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +1481 -0
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -0
- package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js +50 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
- package/dist/cli.js +140 -28
- package/dist/cli.js.map +1 -1
- package/dist/common/Sequencer.d.ts +53 -0
- package/dist/common/Sequencer.js +233 -0
- package/dist/common/Sequencer.js.map +1 -0
- package/dist/deferred.d.ts +5 -3
- package/dist/deferred.js +10 -0
- package/dist/deferred.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +61 -4
- package/dist/diagnosticUtils.js +285 -25
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/examples/plugins/removePrint.d.ts +2 -2
- package/dist/examples/plugins/removePrint.js +8 -12
- package/dist/examples/plugins/removePrint.js.map +1 -1
- package/dist/files/AssetFile.d.ts +24 -0
- package/dist/files/AssetFile.js +25 -0
- package/dist/files/AssetFile.js.map +1 -0
- package/dist/files/BrsFile.d.ts +161 -87
- package/dist/files/BrsFile.js +919 -936
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BscFile.d.ts +102 -0
- package/dist/files/BscFile.js +15 -0
- package/dist/files/BscFile.js.map +1 -0
- package/dist/files/Factory.d.ts +25 -0
- package/dist/files/Factory.js +22 -0
- package/dist/files/Factory.js.map +1 -0
- package/dist/files/LazyFileData.d.ts +21 -0
- package/dist/files/LazyFileData.js +54 -0
- package/dist/files/LazyFileData.js.map +1 -0
- package/dist/files/XmlFile.d.ts +80 -41
- package/dist/files/XmlFile.js +162 -137
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/globalCallables.d.ts +3 -1
- package/dist/globalCallables.js +424 -184
- package/dist/globalCallables.js.map +1 -1
- package/dist/index.d.ts +32 -4
- package/dist/index.js +54 -7
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +987 -125
- package/dist/interfaces.js +21 -0
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +51 -12
- package/dist/lexer/Lexer.js +214 -65
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Token.d.ts +27 -11
- package/dist/lexer/Token.js +10 -2
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +48 -2
- package/dist/lexer/TokenKind.js +167 -10
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/logging.d.ts +14 -0
- package/dist/logging.js +29 -0
- package/dist/logging.js.map +1 -0
- package/dist/lsp/ActionQueue.d.ts +35 -0
- package/dist/lsp/ActionQueue.js +115 -0
- package/dist/lsp/ActionQueue.js.map +1 -0
- package/dist/lsp/DocumentManager.d.ts +63 -0
- package/dist/lsp/DocumentManager.js +122 -0
- package/dist/lsp/DocumentManager.js.map +1 -0
- package/dist/lsp/LspProject.d.ts +287 -0
- package/dist/lsp/LspProject.js +3 -0
- package/dist/lsp/LspProject.js.map +1 -0
- package/dist/lsp/PathFilterer.d.ts +75 -0
- package/dist/lsp/PathFilterer.js +196 -0
- package/dist/lsp/PathFilterer.js.map +1 -0
- package/dist/lsp/Project.d.ts +200 -0
- package/dist/lsp/Project.js +562 -0
- package/dist/lsp/Project.js.map +1 -0
- package/dist/lsp/ProjectManager.d.ts +288 -0
- package/dist/lsp/ProjectManager.js +967 -0
- package/dist/lsp/ProjectManager.js.map +1 -0
- package/dist/lsp/ReaderWriterManager.d.ts +21 -0
- package/dist/lsp/ReaderWriterManager.js +60 -0
- package/dist/lsp/ReaderWriterManager.js.map +1 -0
- package/dist/lsp/worker/MessageHandler.d.ts +99 -0
- package/dist/lsp/worker/MessageHandler.js +138 -0
- package/dist/lsp/worker/MessageHandler.js.map +1 -0
- package/dist/lsp/worker/WorkerPool.d.ts +38 -0
- package/dist/lsp/worker/WorkerPool.js +78 -0
- package/dist/lsp/worker/WorkerPool.js.map +1 -0
- package/dist/lsp/worker/WorkerThreadProject.d.ts +168 -0
- package/dist/lsp/worker/WorkerThreadProject.js +205 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.d.ts +15 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.js +58 -0
- package/dist/lsp/worker/WorkerThreadProjectRunner.js.map +1 -0
- package/dist/lsp/worker/run.js +14 -0
- package/dist/lsp/worker/run.js.map +1 -0
- package/dist/parser/AstNode.d.ts +205 -0
- package/dist/parser/AstNode.js +305 -0
- package/dist/parser/AstNode.js.map +1 -0
- package/dist/parser/BrightScriptDocParser.d.ts +56 -0
- package/dist/parser/BrightScriptDocParser.js +294 -0
- package/dist/parser/BrightScriptDocParser.js.map +1 -0
- package/dist/parser/BrsTranspileState.d.ts +22 -3
- package/dist/parser/BrsTranspileState.js +19 -0
- package/dist/parser/BrsTranspileState.js.map +1 -1
- package/dist/parser/Expression.d.ts +601 -220
- package/dist/parser/Expression.js +1516 -502
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.d.ts +137 -121
- package/dist/parser/Parser.js +1808 -982
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/SGParser.d.ts +30 -13
- package/dist/parser/SGParser.js +94 -56
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +134 -46
- package/dist/parser/SGTypes.js +206 -115
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +854 -267
- package/dist/parser/Statement.js +2416 -621
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +30 -14
- package/dist/parser/TranspileState.js +124 -27
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/preprocessor/Manifest.d.ts +6 -6
- package/dist/preprocessor/Manifest.js +17 -38
- package/dist/preprocessor/Manifest.js.map +1 -1
- package/dist/roku-types/data.json +20554 -0
- package/dist/roku-types/index.d.ts +5726 -0
- package/dist/roku-types/index.js +11 -0
- package/dist/roku-types/index.js.map +1 -0
- package/dist/types/ArrayType.d.ts +12 -5
- package/dist/types/ArrayType.js +95 -25
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +15 -0
- package/dist/types/AssociativeArrayType.js +64 -0
- package/dist/types/AssociativeArrayType.js.map +1 -0
- package/dist/types/BaseFunctionType.d.ts +10 -0
- package/dist/types/BaseFunctionType.js +26 -0
- package/dist/types/BaseFunctionType.js.map +1 -0
- package/dist/types/BooleanType.d.ts +9 -5
- package/dist/types/BooleanType.js +19 -8
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/BscType.d.ts +41 -3
- package/dist/types/BscType.js +152 -0
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BscTypeKind.d.ts +28 -0
- package/dist/types/BscTypeKind.js +33 -0
- package/dist/types/BscTypeKind.js.map +1 -0
- package/dist/types/BuiltInInterfaceAdder.d.ts +28 -0
- package/dist/types/BuiltInInterfaceAdder.js +212 -0
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
- package/dist/types/CallFuncableType.d.ts +24 -0
- package/dist/types/CallFuncableType.js +91 -0
- package/dist/types/CallFuncableType.js.map +1 -0
- package/dist/types/ClassType.d.ts +17 -0
- package/dist/types/ClassType.js +63 -0
- package/dist/types/ClassType.js.map +1 -0
- package/dist/types/ComponentType.d.ts +22 -0
- package/dist/types/ComponentType.js +110 -0
- package/dist/types/ComponentType.js.map +1 -0
- package/dist/types/DoubleType.d.ts +10 -5
- package/dist/types/DoubleType.js +21 -17
- package/dist/types/DoubleType.js.map +1 -1
- package/dist/types/DynamicType.d.ts +13 -5
- package/dist/types/DynamicType.js +26 -5
- package/dist/types/DynamicType.js.map +1 -1
- package/dist/types/EnumType.d.ts +42 -0
- package/dist/types/EnumType.js +101 -0
- package/dist/types/EnumType.js.map +1 -0
- package/dist/types/FloatType.d.ts +10 -5
- package/dist/types/FloatType.js +21 -17
- package/dist/types/FloatType.js.map +1 -1
- package/dist/types/FunctionType.d.ts +8 -22
- package/dist/types/FunctionType.js +25 -63
- package/dist/types/FunctionType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +29 -0
- package/dist/types/InheritableType.js +173 -0
- package/dist/types/InheritableType.js.map +1 -0
- package/dist/types/InlineInterfaceType.d.ts +5 -0
- package/dist/types/InlineInterfaceType.js +17 -0
- package/dist/types/InlineInterfaceType.js.map +1 -0
- package/dist/types/IntegerType.d.ts +10 -5
- package/dist/types/IntegerType.js +21 -17
- package/dist/types/IntegerType.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +14 -6
- package/dist/types/InterfaceType.js +30 -15
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/IntersectionType.d.ts +29 -0
- package/dist/types/IntersectionType.js +256 -0
- package/dist/types/IntersectionType.js.map +1 -0
- package/dist/types/InvalidType.d.ts +10 -5
- package/dist/types/InvalidType.js +21 -9
- package/dist/types/InvalidType.js.map +1 -1
- package/dist/types/LongIntegerType.d.ts +10 -5
- package/dist/types/LongIntegerType.js +21 -17
- package/dist/types/LongIntegerType.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +12 -0
- package/dist/types/NamespaceType.js +28 -0
- package/dist/types/NamespaceType.js.map +1 -0
- package/dist/types/ObjectType.d.ts +12 -5
- package/dist/types/ObjectType.js +25 -8
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +123 -0
- package/dist/types/ReferenceType.js +726 -0
- package/dist/types/ReferenceType.js.map +1 -0
- package/dist/types/StringType.d.ts +12 -5
- package/dist/types/StringType.js +23 -8
- package/dist/types/StringType.js.map +1 -1
- package/dist/types/TypeStatementType.d.ts +19 -0
- package/dist/types/TypeStatementType.js +56 -0
- package/dist/types/TypeStatementType.js.map +1 -0
- package/dist/types/TypedFunctionType.d.ts +34 -0
- package/dist/types/TypedFunctionType.js +157 -0
- package/dist/types/TypedFunctionType.js.map +1 -0
- package/dist/types/UninitializedType.d.ts +11 -6
- package/dist/types/UninitializedType.js +20 -11
- package/dist/types/UninitializedType.js.map +1 -1
- package/dist/types/UnionType.d.ts +27 -0
- package/dist/types/UnionType.js +196 -0
- package/dist/types/UnionType.js.map +1 -0
- package/dist/types/VoidType.d.ts +11 -5
- package/dist/types/VoidType.js +22 -8
- package/dist/types/VoidType.js.map +1 -1
- package/dist/types/helpers.d.ts +51 -0
- package/dist/types/helpers.js +329 -0
- package/dist/types/helpers.js.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +39 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/roFunctionType.d.ts +11 -0
- package/dist/types/roFunctionType.js +37 -0
- package/dist/types/roFunctionType.js.map +1 -0
- package/dist/util.d.ts +325 -185
- package/dist/util.js +2135 -568
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +9 -15
- package/dist/validators/ClassValidator.js +93 -138
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +183 -138
- package/CHANGELOG.md +0 -1188
- package/dist/astUtils/creators.spec.js +0 -21
- package/dist/astUtils/creators.spec.js.map +0 -1
- package/dist/astUtils/index.d.ts +0 -7
- package/dist/astUtils/index.js +0 -26
- package/dist/astUtils/index.js.map +0 -1
- package/dist/astUtils/reflection.spec.d.ts +0 -1
- package/dist/astUtils/reflection.spec.js +0 -292
- package/dist/astUtils/reflection.spec.js.map +0 -1
- package/dist/astUtils/stackedVisitor.spec.d.ts +0 -1
- package/dist/astUtils/stackedVisitor.spec.js +0 -79
- package/dist/astUtils/stackedVisitor.spec.js.map +0 -1
- package/dist/astUtils/visitors.spec.d.ts +0 -1
- package/dist/astUtils/visitors.spec.js +0 -854
- package/dist/astUtils/visitors.spec.js.map +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +0 -194
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.d.ts +0 -7
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js +0 -63
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js +0 -45
- package/dist/bscPlugin/semanticTokens/SemanticTokensProcessor.spec.js.map +0 -1
- package/dist/files/BrsFile.Class.spec.d.ts +0 -1
- package/dist/files/BrsFile.Class.spec.js +0 -1081
- package/dist/files/BrsFile.Class.spec.js.map +0 -1
- package/dist/files/BrsFile.spec.d.ts +0 -1
- package/dist/files/BrsFile.spec.js +0 -2524
- package/dist/files/BrsFile.spec.js.map +0 -1
- package/dist/files/XmlFile.spec.d.ts +0 -1
- package/dist/files/XmlFile.spec.js +0 -1065
- package/dist/files/XmlFile.spec.js.map +0 -1
- package/dist/files/tests/imports.spec.d.ts +0 -1
- package/dist/files/tests/imports.spec.js +0 -241
- package/dist/files/tests/imports.spec.js.map +0 -1
- package/dist/lexer/Character.spec.d.ts +0 -1
- package/dist/lexer/Character.spec.js +0 -27
- package/dist/lexer/Character.spec.js.map +0 -1
- package/dist/lexer/Lexer.spec.d.ts +0 -1
- package/dist/lexer/Lexer.spec.js +0 -1101
- package/dist/lexer/Lexer.spec.js.map +0 -1
- package/dist/lexer/index.d.ts +0 -3
- package/dist/lexer/index.js +0 -17
- package/dist/lexer/index.js.map +0 -1
- package/dist/parser/Parser.Class.spec.d.ts +0 -1
- package/dist/parser/Parser.Class.spec.js +0 -390
- package/dist/parser/Parser.Class.spec.js.map +0 -1
- package/dist/parser/Parser.spec.d.ts +0 -4
- package/dist/parser/Parser.spec.js +0 -1216
- package/dist/parser/Parser.spec.js.map +0 -1
- package/dist/parser/SGParser.spec.d.ts +0 -1
- package/dist/parser/SGParser.spec.js +0 -145
- package/dist/parser/SGParser.spec.js.map +0 -1
- package/dist/parser/SGTypes.spec.d.ts +0 -1
- package/dist/parser/SGTypes.spec.js +0 -351
- package/dist/parser/SGTypes.spec.js.map +0 -1
- package/dist/parser/Statement.spec.d.ts +0 -1
- package/dist/parser/Statement.spec.js +0 -94
- package/dist/parser/Statement.spec.js.map +0 -1
- package/dist/parser/index.d.ts +0 -3
- package/dist/parser/index.js +0 -16
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/tests/Parser.spec.d.ts +0 -18
- package/dist/parser/tests/Parser.spec.js +0 -35
- package/dist/parser/tests/Parser.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/For.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/For.spec.js +0 -161
- package/dist/parser/tests/controlFlow/For.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/ForEach.spec.js +0 -106
- package/dist/parser/tests/controlFlow/ForEach.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/If.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/If.spec.js +0 -551
- package/dist/parser/tests/controlFlow/If.spec.js.map +0 -1
- package/dist/parser/tests/controlFlow/While.spec.d.ts +0 -1
- package/dist/parser/tests/controlFlow/While.spec.js +0 -107
- package/dist/parser/tests/controlFlow/While.spec.js.map +0 -1
- package/dist/parser/tests/expression/Additive.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Additive.spec.js +0 -99
- package/dist/parser/tests/expression/Additive.spec.js.map +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +0 -254
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.d.ts +0 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +0 -266
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +0 -1
- package/dist/parser/tests/expression/Boolean.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Boolean.spec.js +0 -83
- package/dist/parser/tests/expression/Boolean.spec.js.map +0 -1
- package/dist/parser/tests/expression/Call.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Call.spec.js +0 -134
- package/dist/parser/tests/expression/Call.spec.js.map +0 -1
- package/dist/parser/tests/expression/Exponential.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Exponential.spec.js +0 -37
- package/dist/parser/tests/expression/Exponential.spec.js.map +0 -1
- package/dist/parser/tests/expression/Function.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Function.spec.js +0 -403
- package/dist/parser/tests/expression/Function.spec.js.map +0 -1
- package/dist/parser/tests/expression/Indexing.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Indexing.spec.js +0 -219
- package/dist/parser/tests/expression/Indexing.spec.js.map +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Multiplicative.spec.js +0 -67
- package/dist/parser/tests/expression/Multiplicative.spec.js.map +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +0 -201
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/PrefixUnary.spec.js +0 -105
- package/dist/parser/tests/expression/PrefixUnary.spec.js.map +0 -1
- package/dist/parser/tests/expression/Primary.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Primary.spec.js +0 -149
- package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
- package/dist/parser/tests/expression/Relational.spec.d.ts +0 -1
- package/dist/parser/tests/expression/Relational.spec.js +0 -83
- package/dist/parser/tests/expression/Relational.spec.js.map +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +0 -201
- package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +0 -202
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TernaryExpression.spec.js +0 -323
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.d.ts +0 -1
- package/dist/parser/tests/statement/AssignmentOperators.spec.js +0 -79
- package/dist/parser/tests/statement/AssignmentOperators.spec.js.map +0 -1
- package/dist/parser/tests/statement/Declaration.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Declaration.spec.js +0 -108
- package/dist/parser/tests/statement/Declaration.spec.js.map +0 -1
- package/dist/parser/tests/statement/Dim.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Dim.spec.js +0 -73
- package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
- package/dist/parser/tests/statement/Function.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Function.spec.js +0 -332
- package/dist/parser/tests/statement/Function.spec.js.map +0 -1
- package/dist/parser/tests/statement/Goto.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Goto.spec.js +0 -50
- package/dist/parser/tests/statement/Goto.spec.js.map +0 -1
- package/dist/parser/tests/statement/Increment.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Increment.spec.js +0 -117
- package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/LibraryStatement.spec.js +0 -74
- package/dist/parser/tests/statement/LibraryStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Misc.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Misc.spec.js +0 -333
- package/dist/parser/tests/statement/Misc.spec.js.map +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/PrintStatement.spec.js +0 -181
- package/dist/parser/tests/statement/PrintStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ReturnStatement.spec.js +0 -94
- package/dist/parser/tests/statement/ReturnStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Set.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Set.spec.js +0 -218
- package/dist/parser/tests/statement/Set.spec.js.map +0 -1
- package/dist/parser/tests/statement/Stop.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Stop.spec.js +0 -37
- package/dist/parser/tests/statement/Stop.spec.js.map +0 -1
- package/dist/parser/tests/statement/Throw.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Throw.spec.js +0 -35
- package/dist/parser/tests/statement/Throw.spec.js.map +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.d.ts +0 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +0 -140
- package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
- package/dist/preprocessor/Chunk.d.ts +0 -82
- package/dist/preprocessor/Chunk.js +0 -77
- package/dist/preprocessor/Chunk.js.map +0 -1
- package/dist/preprocessor/Manifest.spec.d.ts +0 -0
- package/dist/preprocessor/Manifest.spec.js +0 -105
- package/dist/preprocessor/Manifest.spec.js.map +0 -1
- package/dist/preprocessor/Preprocessor.d.ts +0 -60
- package/dist/preprocessor/Preprocessor.js +0 -156
- package/dist/preprocessor/Preprocessor.js.map +0 -1
- package/dist/preprocessor/Preprocessor.spec.d.ts +0 -1
- package/dist/preprocessor/Preprocessor.spec.js +0 -152
- package/dist/preprocessor/Preprocessor.spec.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.d.ts +0 -61
- package/dist/preprocessor/PreprocessorParser.js +0 -194
- package/dist/preprocessor/PreprocessorParser.js.map +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.d.ts +0 -1
- package/dist/preprocessor/PreprocessorParser.spec.js +0 -116
- package/dist/preprocessor/PreprocessorParser.spec.js.map +0 -1
- package/dist/preprocessor/index.d.ts +0 -3
- package/dist/preprocessor/index.js +0 -16
- package/dist/preprocessor/index.js.map +0 -1
- package/dist/types/ArrayType.spec.d.ts +0 -1
- package/dist/types/ArrayType.spec.js +0 -30
- package/dist/types/ArrayType.spec.js.map +0 -1
- package/dist/types/BooleanType.spec.d.ts +0 -1
- package/dist/types/BooleanType.spec.js +0 -12
- package/dist/types/BooleanType.spec.js.map +0 -1
- package/dist/types/CustomType.d.ts +0 -10
- package/dist/types/CustomType.js +0 -35
- package/dist/types/CustomType.js.map +0 -1
- package/dist/types/DoubleType.spec.d.ts +0 -1
- package/dist/types/DoubleType.spec.js +0 -12
- package/dist/types/DoubleType.spec.js.map +0 -1
- package/dist/types/DynamicType.spec.d.ts +0 -1
- package/dist/types/DynamicType.spec.js +0 -12
- package/dist/types/DynamicType.spec.js.map +0 -1
- package/dist/types/FloatType.spec.d.ts +0 -1
- package/dist/types/FloatType.spec.js +0 -12
- package/dist/types/FloatType.spec.js.map +0 -1
- package/dist/types/FunctionType.spec.d.ts +0 -1
- package/dist/types/FunctionType.spec.js +0 -29
- package/dist/types/FunctionType.spec.js.map +0 -1
- package/dist/types/IntegerType.spec.d.ts +0 -1
- package/dist/types/IntegerType.spec.js +0 -12
- package/dist/types/IntegerType.spec.js.map +0 -1
- package/dist/types/InvalidType.spec.d.ts +0 -1
- package/dist/types/InvalidType.spec.js +0 -12
- package/dist/types/InvalidType.spec.js.map +0 -1
- package/dist/types/LazyType.d.ts +0 -15
- package/dist/types/LazyType.js +0 -32
- package/dist/types/LazyType.js.map +0 -1
- package/dist/types/LongIntegerType.spec.d.ts +0 -1
- package/dist/types/LongIntegerType.spec.js +0 -12
- package/dist/types/LongIntegerType.spec.js.map +0 -1
- package/dist/types/ObjectType.spec.d.ts +0 -1
- package/dist/types/ObjectType.spec.js +0 -12
- package/dist/types/ObjectType.spec.js.map +0 -1
- package/dist/types/StringType.spec.d.ts +0 -1
- package/dist/types/StringType.spec.js +0 -12
- package/dist/types/StringType.spec.js.map +0 -1
- package/dist/types/VoidType.spec.d.ts +0 -1
- package/dist/types/VoidType.spec.js +0 -12
- package/dist/types/VoidType.spec.js.map +0 -1
- /package/dist/{astUtils/creators.spec.d.ts → lsp/worker/run.d.ts} +0 -0
package/dist/lexer/Lexer.spec.js
DELETED
|
@@ -1,1101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint no-template-curly-in-string: 0 */
|
|
4
|
-
const chai_1 = require("chai");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const Lexer_1 = require("./Lexer");
|
|
7
|
-
const Token_1 = require("./Token");
|
|
8
|
-
const Parser_spec_1 = require("../parser/Parser.spec");
|
|
9
|
-
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
10
|
-
const util_1 = require("../util");
|
|
11
|
-
describe('lexer', () => {
|
|
12
|
-
it('recognizes namespace keywords', () => {
|
|
13
|
-
let { tokens } = Lexer_1.Lexer.scan('namespace end namespace endnamespace end namespace');
|
|
14
|
-
chai_1.expect(tokens.map(x => x.kind)).to.eql([
|
|
15
|
-
_1.TokenKind.Namespace,
|
|
16
|
-
_1.TokenKind.EndNamespace,
|
|
17
|
-
_1.TokenKind.EndNamespace,
|
|
18
|
-
_1.TokenKind.EndNamespace,
|
|
19
|
-
_1.TokenKind.Eof
|
|
20
|
-
]);
|
|
21
|
-
});
|
|
22
|
-
it('recognizes the callfunc operator', () => {
|
|
23
|
-
let { tokens } = Lexer_1.Lexer.scan('@.');
|
|
24
|
-
chai_1.expect(tokens[0].kind).to.equal(_1.TokenKind.Callfunc);
|
|
25
|
-
});
|
|
26
|
-
it('recognizes the import token', () => {
|
|
27
|
-
let { tokens } = Lexer_1.Lexer.scan('import');
|
|
28
|
-
chai_1.expect(tokens[0].kind).to.eql(_1.TokenKind.Import);
|
|
29
|
-
});
|
|
30
|
-
it('recognizes library token', () => {
|
|
31
|
-
let { tokens } = Lexer_1.Lexer.scan('library');
|
|
32
|
-
chai_1.expect(tokens[0].kind).to.eql(_1.TokenKind.Library);
|
|
33
|
-
});
|
|
34
|
-
it('recognizes the question mark operator', () => {
|
|
35
|
-
let { tokens } = Lexer_1.Lexer.scan('?');
|
|
36
|
-
chai_1.expect(tokens[0].kind).to.equal(_1.TokenKind.Question);
|
|
37
|
-
});
|
|
38
|
-
it('produces an at symbol token', () => {
|
|
39
|
-
let { tokens } = Lexer_1.Lexer.scan('@');
|
|
40
|
-
chai_1.expect(tokens[0].kind).to.equal(_1.TokenKind.At);
|
|
41
|
-
});
|
|
42
|
-
it('produces a semicolon token', () => {
|
|
43
|
-
let { tokens } = Lexer_1.Lexer.scan(';');
|
|
44
|
-
chai_1.expect(tokens[0].kind).to.equal(_1.TokenKind.Semicolon);
|
|
45
|
-
});
|
|
46
|
-
it('emits error on unknown character type', () => {
|
|
47
|
-
let { diagnostics } = Lexer_1.Lexer.scan('\0');
|
|
48
|
-
chai_1.expect(diagnostics).to.be.lengthOf(1);
|
|
49
|
-
});
|
|
50
|
-
it('includes an end-of-file marker', () => {
|
|
51
|
-
let { tokens } = Lexer_1.Lexer.scan('');
|
|
52
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Eof]);
|
|
53
|
-
});
|
|
54
|
-
it('ignores tabs and spaces', () => {
|
|
55
|
-
let { tokens } = Lexer_1.Lexer.scan('\t\t \t \t');
|
|
56
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Eof]);
|
|
57
|
-
});
|
|
58
|
-
it('retains every single newline', () => {
|
|
59
|
-
let { tokens } = Lexer_1.Lexer.scan('\n\n\'foo\n\n\nprint 2\n\n');
|
|
60
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
61
|
-
_1.TokenKind.Newline,
|
|
62
|
-
_1.TokenKind.Newline,
|
|
63
|
-
_1.TokenKind.Comment,
|
|
64
|
-
_1.TokenKind.Newline,
|
|
65
|
-
_1.TokenKind.Newline,
|
|
66
|
-
_1.TokenKind.Newline,
|
|
67
|
-
_1.TokenKind.Print,
|
|
68
|
-
_1.TokenKind.IntegerLiteral,
|
|
69
|
-
_1.TokenKind.Newline,
|
|
70
|
-
_1.TokenKind.Newline,
|
|
71
|
-
_1.TokenKind.Eof
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
it('does not insert double newlines with the windows \\r\\n newline', () => {
|
|
75
|
-
let kinds = Lexer_1.Lexer.scan('function boolToNumber() as string\r\n' +
|
|
76
|
-
' if true then\r\n' +
|
|
77
|
-
' print 1\r\n' +
|
|
78
|
-
' else\r\n' +
|
|
79
|
-
' print 0\r\n' +
|
|
80
|
-
' end if\r\n' +
|
|
81
|
-
'end function\r\n').tokens.map(x => x.kind);
|
|
82
|
-
chai_1.expect(kinds).to.eql([
|
|
83
|
-
_1.TokenKind.Function, _1.TokenKind.Identifier, _1.TokenKind.LeftParen, _1.TokenKind.RightParen, _1.TokenKind.As, _1.TokenKind.String, _1.TokenKind.Newline,
|
|
84
|
-
_1.TokenKind.If, _1.TokenKind.True, _1.TokenKind.Then, _1.TokenKind.Newline,
|
|
85
|
-
_1.TokenKind.Print, _1.TokenKind.IntegerLiteral, _1.TokenKind.Newline,
|
|
86
|
-
_1.TokenKind.Else, _1.TokenKind.Newline,
|
|
87
|
-
_1.TokenKind.Print, _1.TokenKind.IntegerLiteral, _1.TokenKind.Newline,
|
|
88
|
-
_1.TokenKind.EndIf, _1.TokenKind.Newline,
|
|
89
|
-
_1.TokenKind.EndFunction, _1.TokenKind.Newline,
|
|
90
|
-
_1.TokenKind.Eof
|
|
91
|
-
]);
|
|
92
|
-
});
|
|
93
|
-
it('computes range properly both with and without whitespace', () => {
|
|
94
|
-
let withoutWhitespace = Lexer_1.Lexer.scan(`sub Main()\n bob = true\nend sub`).tokens
|
|
95
|
-
.map(x => Parser_spec_1.rangeToArray(x.range));
|
|
96
|
-
let withWhitespace = Lexer_1.Lexer.scan(`sub Main()\n bob = true\nend sub`).tokens
|
|
97
|
-
//filter out the whitespace...we only care that it was computed during the scan
|
|
98
|
-
.filter(x => x.kind !== _1.TokenKind.Whitespace)
|
|
99
|
-
.map(x => Parser_spec_1.rangeToArray(x.range));
|
|
100
|
-
/*eslint-disable */
|
|
101
|
-
let expectedLocations = [
|
|
102
|
-
[0, 0, 0, 3],
|
|
103
|
-
[0, 4, 0, 8],
|
|
104
|
-
[0, 8, 0, 9],
|
|
105
|
-
[0, 9, 0, 10],
|
|
106
|
-
[0, 10, 0, 11],
|
|
107
|
-
[1, 4, 1, 7],
|
|
108
|
-
[1, 8, 1, 9],
|
|
109
|
-
[1, 10, 1, 14],
|
|
110
|
-
[1, 14, 1, 15],
|
|
111
|
-
[2, 0, 2, 7],
|
|
112
|
-
[2, 7, 2, 8] //Eof
|
|
113
|
-
];
|
|
114
|
-
/*eslint-enable*/
|
|
115
|
-
chai_1.expect(withoutWhitespace, 'Without whitespace').to.eql(expectedLocations);
|
|
116
|
-
chai_1.expect(withWhitespace, 'With whitespace').to.eql(expectedLocations);
|
|
117
|
-
});
|
|
118
|
-
it('retains original line endings', () => {
|
|
119
|
-
let { tokens } = Lexer_1.Lexer.scan('print "hello"\r\nprint "world"\n');
|
|
120
|
-
chai_1.expect([
|
|
121
|
-
tokens[2].text.charCodeAt(0),
|
|
122
|
-
tokens[2].text.charCodeAt(1)
|
|
123
|
-
], 'should contain \\r\\n').to.eql([13, 10]);
|
|
124
|
-
chai_1.expect(tokens[5].text.charCodeAt(0), 'should contain \\r\\n').to.eql(10);
|
|
125
|
-
});
|
|
126
|
-
it('correctly splits the elseif token', () => {
|
|
127
|
-
let { tokens } = Lexer_1.Lexer.scan('else if elseif else if');
|
|
128
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
129
|
-
_1.TokenKind.Else,
|
|
130
|
-
_1.TokenKind.If,
|
|
131
|
-
_1.TokenKind.Else,
|
|
132
|
-
_1.TokenKind.If,
|
|
133
|
-
_1.TokenKind.Else,
|
|
134
|
-
_1.TokenKind.If,
|
|
135
|
-
_1.TokenKind.Eof
|
|
136
|
-
]);
|
|
137
|
-
});
|
|
138
|
-
it('gives the `as` keyword its own TokenKind', () => {
|
|
139
|
-
let { tokens } = Lexer_1.Lexer.scan('as');
|
|
140
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.As, _1.TokenKind.Eof]);
|
|
141
|
-
});
|
|
142
|
-
it('gives the `stop` keyword its own TokenKind', () => {
|
|
143
|
-
let { tokens } = Lexer_1.Lexer.scan('stop');
|
|
144
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Stop, _1.TokenKind.Eof]);
|
|
145
|
-
});
|
|
146
|
-
it('does not alias \'?\' to \'print\' - the parser will do that', () => {
|
|
147
|
-
let { tokens } = Lexer_1.Lexer.scan('?2');
|
|
148
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Question, _1.TokenKind.IntegerLiteral, _1.TokenKind.Eof]);
|
|
149
|
-
});
|
|
150
|
-
describe('comments', () => {
|
|
151
|
-
it('does not include carriage return character', () => {
|
|
152
|
-
let tokens = Lexer_1.Lexer.scan(`'someComment\r\nprint "hello"`).tokens;
|
|
153
|
-
chai_1.expect(tokens[0].text).to.equal(`'someComment`);
|
|
154
|
-
});
|
|
155
|
-
it('includes the comment characters in the text', () => {
|
|
156
|
-
let text = Lexer_1.Lexer.scan(`
|
|
157
|
-
'comment
|
|
158
|
-
REM some comment
|
|
159
|
-
`).tokens
|
|
160
|
-
.filter(x => ![_1.TokenKind.Newline, _1.TokenKind.Eof].includes(x.kind))
|
|
161
|
-
.map(x => x.text);
|
|
162
|
-
chai_1.expect(text).to.eql([
|
|
163
|
-
`'comment`,
|
|
164
|
-
'REM some comment'
|
|
165
|
-
]);
|
|
166
|
-
});
|
|
167
|
-
it('tracks the correct location', () => {
|
|
168
|
-
let tokens = Lexer_1.Lexer.scan(`
|
|
169
|
-
sub main() 'first comment
|
|
170
|
-
k = 2 ' second comment
|
|
171
|
-
REM third comment
|
|
172
|
-
end sub
|
|
173
|
-
`, {
|
|
174
|
-
includeWhitespace: true
|
|
175
|
-
}).tokens.map(x => [...Parser_spec_1.rangeToArray(x.range), x.text]);
|
|
176
|
-
chai_1.expect(tokens).to.eql([
|
|
177
|
-
[0, 0, 0, 1, '\n'],
|
|
178
|
-
[1, 0, 1, 16, ' '],
|
|
179
|
-
[1, 16, 1, 19, 'sub'],
|
|
180
|
-
[1, 19, 1, 20, ' '],
|
|
181
|
-
[1, 20, 1, 24, 'main'],
|
|
182
|
-
[1, 24, 1, 25, '('],
|
|
183
|
-
[1, 25, 1, 26, ')'],
|
|
184
|
-
[1, 26, 1, 27, ' '],
|
|
185
|
-
[1, 27, 1, 41, `'first comment`],
|
|
186
|
-
[1, 41, 1, 42, '\n'],
|
|
187
|
-
[2, 0, 2, 20, ' '],
|
|
188
|
-
[2, 20, 2, 21, 'k'],
|
|
189
|
-
[2, 21, 2, 22, ' '],
|
|
190
|
-
[2, 22, 2, 23, '='],
|
|
191
|
-
[2, 23, 2, 24, ' '],
|
|
192
|
-
[2, 24, 2, 25, '2'],
|
|
193
|
-
[2, 25, 2, 26, ' '],
|
|
194
|
-
[2, 26, 2, 42, `' second comment`],
|
|
195
|
-
[2, 42, 2, 43, '\n'],
|
|
196
|
-
[3, 0, 3, 20, ' '],
|
|
197
|
-
[3, 20, 3, 37, 'REM third comment'],
|
|
198
|
-
[3, 37, 3, 38, '\n'],
|
|
199
|
-
[4, 0, 4, 16, ' '],
|
|
200
|
-
[4, 16, 4, 23, 'end sub'],
|
|
201
|
-
[4, 23, 4, 24, '\n'],
|
|
202
|
-
[5, 0, 5, 12, ' '],
|
|
203
|
-
[5, 12, 5, 13, ''] //EOF
|
|
204
|
-
]);
|
|
205
|
-
});
|
|
206
|
-
it('tracks the correct location for comments', () => {
|
|
207
|
-
let tokens = Lexer_1.Lexer.scan(`
|
|
208
|
-
'comment
|
|
209
|
-
REM some comment
|
|
210
|
-
`).tokens.filter(x => ![_1.TokenKind.Newline, _1.TokenKind.Eof].includes(x.kind));
|
|
211
|
-
chai_1.expect(tokens[0].range).to.eql(vscode_languageserver_1.Range.create(1, 16, 1, 24));
|
|
212
|
-
chai_1.expect(tokens[1].range).to.eql(vscode_languageserver_1.Range.create(2, 16, 2, 32));
|
|
213
|
-
});
|
|
214
|
-
it('finds correct location for newlines', () => {
|
|
215
|
-
let tokens = Lexer_1.Lexer.scan('sub\nsub\r\nsub\n\n').tokens
|
|
216
|
-
//ignore the Eof token
|
|
217
|
-
.filter(x => x.kind !== _1.TokenKind.Eof);
|
|
218
|
-
chai_1.expect(tokens.map(x => x.range)).to.eql([
|
|
219
|
-
vscode_languageserver_1.Range.create(0, 0, 0, 3),
|
|
220
|
-
vscode_languageserver_1.Range.create(0, 3, 0, 4),
|
|
221
|
-
vscode_languageserver_1.Range.create(1, 0, 1, 3),
|
|
222
|
-
vscode_languageserver_1.Range.create(1, 3, 1, 5),
|
|
223
|
-
vscode_languageserver_1.Range.create(2, 0, 2, 3),
|
|
224
|
-
vscode_languageserver_1.Range.create(2, 3, 2, 4),
|
|
225
|
-
vscode_languageserver_1.Range.create(3, 0, 3, 1) // /n
|
|
226
|
-
]);
|
|
227
|
-
});
|
|
228
|
-
it('finds correct location for comment after if statement', () => {
|
|
229
|
-
let { tokens } = Lexer_1.Lexer.scan(`
|
|
230
|
-
sub a()
|
|
231
|
-
if true then
|
|
232
|
-
print false
|
|
233
|
-
else if true then
|
|
234
|
-
print "true"
|
|
235
|
-
else
|
|
236
|
-
print "else"
|
|
237
|
-
end if 'comment
|
|
238
|
-
end sub
|
|
239
|
-
`);
|
|
240
|
-
let comments = tokens.filter(x => x.kind === _1.TokenKind.Comment);
|
|
241
|
-
chai_1.expect(comments).to.be.lengthOf(1);
|
|
242
|
-
chai_1.expect(comments[0].range).to.eql(vscode_languageserver_1.Range.create(8, 27, 8, 35));
|
|
243
|
-
});
|
|
244
|
-
it('ignores everything after `\'`', () => {
|
|
245
|
-
let { tokens } = Lexer_1.Lexer.scan('= \' (');
|
|
246
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Equal, _1.TokenKind.Comment, _1.TokenKind.Eof]);
|
|
247
|
-
});
|
|
248
|
-
it('ignores everything after `REM`', () => {
|
|
249
|
-
let { tokens } = Lexer_1.Lexer.scan('= REM (');
|
|
250
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Equal, _1.TokenKind.Comment, _1.TokenKind.Eof]);
|
|
251
|
-
});
|
|
252
|
-
it('ignores everything after `rem`', () => {
|
|
253
|
-
let { tokens } = Lexer_1.Lexer.scan('= rem (');
|
|
254
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.Equal, _1.TokenKind.Comment, _1.TokenKind.Eof]);
|
|
255
|
-
});
|
|
256
|
-
}); // comments
|
|
257
|
-
describe('non-literals', () => {
|
|
258
|
-
it('reads parens & braces', () => {
|
|
259
|
-
let { tokens } = Lexer_1.Lexer.scan('(){}');
|
|
260
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
261
|
-
_1.TokenKind.LeftParen,
|
|
262
|
-
_1.TokenKind.RightParen,
|
|
263
|
-
_1.TokenKind.LeftCurlyBrace,
|
|
264
|
-
_1.TokenKind.RightCurlyBrace,
|
|
265
|
-
_1.TokenKind.Eof
|
|
266
|
-
]);
|
|
267
|
-
});
|
|
268
|
-
it('reads operators', () => {
|
|
269
|
-
let { tokens } = Lexer_1.Lexer.scan('^ - + * MOD / \\ -- ++');
|
|
270
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
271
|
-
_1.TokenKind.Caret,
|
|
272
|
-
_1.TokenKind.Minus,
|
|
273
|
-
_1.TokenKind.Plus,
|
|
274
|
-
_1.TokenKind.Star,
|
|
275
|
-
_1.TokenKind.Mod,
|
|
276
|
-
_1.TokenKind.Forwardslash,
|
|
277
|
-
_1.TokenKind.Backslash,
|
|
278
|
-
_1.TokenKind.MinusMinus,
|
|
279
|
-
_1.TokenKind.PlusPlus,
|
|
280
|
-
_1.TokenKind.Eof
|
|
281
|
-
]);
|
|
282
|
-
});
|
|
283
|
-
it('reads bitshift operators', () => {
|
|
284
|
-
let { tokens } = Lexer_1.Lexer.scan('<< >> <<');
|
|
285
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
286
|
-
_1.TokenKind.LeftShift,
|
|
287
|
-
_1.TokenKind.RightShift,
|
|
288
|
-
_1.TokenKind.LeftShift,
|
|
289
|
-
_1.TokenKind.Eof
|
|
290
|
-
]);
|
|
291
|
-
});
|
|
292
|
-
it('reads bitshift assignment operators', () => {
|
|
293
|
-
let { tokens } = Lexer_1.Lexer.scan('<<= >>=');
|
|
294
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
295
|
-
_1.TokenKind.LeftShiftEqual,
|
|
296
|
-
_1.TokenKind.RightShiftEqual,
|
|
297
|
-
_1.TokenKind.Eof
|
|
298
|
-
]);
|
|
299
|
-
});
|
|
300
|
-
it('reads comparators', () => {
|
|
301
|
-
let { tokens } = Lexer_1.Lexer.scan('< <= > >= = <>');
|
|
302
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
303
|
-
_1.TokenKind.Less,
|
|
304
|
-
_1.TokenKind.LessEqual,
|
|
305
|
-
_1.TokenKind.Greater,
|
|
306
|
-
_1.TokenKind.GreaterEqual,
|
|
307
|
-
_1.TokenKind.Equal,
|
|
308
|
-
_1.TokenKind.LessGreater,
|
|
309
|
-
_1.TokenKind.Eof
|
|
310
|
-
]);
|
|
311
|
-
});
|
|
312
|
-
}); // non-literals
|
|
313
|
-
describe('string literals', () => {
|
|
314
|
-
it('produces string literal tokens', () => {
|
|
315
|
-
let { tokens } = Lexer_1.Lexer.scan(`"hello world"`);
|
|
316
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([_1.TokenKind.StringLiteral, _1.TokenKind.Eof]);
|
|
317
|
-
});
|
|
318
|
-
it(`safely escapes " literals`, () => {
|
|
319
|
-
let { tokens } = Lexer_1.Lexer.scan(`"the cat says ""meow"""`);
|
|
320
|
-
chai_1.expect(tokens[0].kind).to.equal(_1.TokenKind.StringLiteral);
|
|
321
|
-
});
|
|
322
|
-
it('captures text to end of line for unterminated strings with LF', () => {
|
|
323
|
-
let { tokens } = Lexer_1.Lexer.scan(`"unterminated!\n`);
|
|
324
|
-
chai_1.expect(tokens[0].kind).to.eql(_1.TokenKind.StringLiteral);
|
|
325
|
-
});
|
|
326
|
-
it('captures text to end of line for unterminated strings with CRLF', () => {
|
|
327
|
-
let { tokens } = Lexer_1.Lexer.scan(`"unterminated!\r\n`);
|
|
328
|
-
chai_1.expect(tokens[0].text).to.equal('"unterminated!');
|
|
329
|
-
});
|
|
330
|
-
it('disallows multiline strings', () => {
|
|
331
|
-
let { diagnostics } = Lexer_1.Lexer.scan(`"multi-line\n\n`);
|
|
332
|
-
chai_1.expect(diagnostics.map(err => err.message)).to.deep.equal([
|
|
333
|
-
'Unterminated string at end of line'
|
|
334
|
-
]);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
// template string literals
|
|
338
|
-
describe('template string literals', () => {
|
|
339
|
-
it('supports escaped chars', () => {
|
|
340
|
-
let { tokens } = Lexer_1.Lexer.scan('`\\n\\`\\r\\n`');
|
|
341
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
342
|
-
_1.TokenKind.BackTick,
|
|
343
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
344
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
345
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
346
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
347
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
348
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
349
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
350
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
351
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
352
|
-
_1.TokenKind.BackTick,
|
|
353
|
-
_1.TokenKind.Eof
|
|
354
|
-
]);
|
|
355
|
-
chai_1.expect(tokens.map(x => x.charCode).filter(x => !!x)).to.eql([
|
|
356
|
-
10,
|
|
357
|
-
96,
|
|
358
|
-
13,
|
|
359
|
-
10
|
|
360
|
-
]);
|
|
361
|
-
});
|
|
362
|
-
it('prevents expressions when escaping the dollar sign', () => {
|
|
363
|
-
let { tokens } = Lexer_1.Lexer.scan('`\\${just text}`');
|
|
364
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
365
|
-
_1.TokenKind.BackTick,
|
|
366
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
367
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
368
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
369
|
-
_1.TokenKind.BackTick,
|
|
370
|
-
_1.TokenKind.Eof
|
|
371
|
-
]);
|
|
372
|
-
});
|
|
373
|
-
it('supports escaping unicode char codes', () => {
|
|
374
|
-
let { tokens } = Lexer_1.Lexer.scan('`\\c1\\c12\\c123`');
|
|
375
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
376
|
-
_1.TokenKind.BackTick,
|
|
377
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
378
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
379
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
380
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
381
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
382
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
383
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
384
|
-
_1.TokenKind.BackTick,
|
|
385
|
-
_1.TokenKind.Eof
|
|
386
|
-
]);
|
|
387
|
-
chai_1.expect(tokens.map(x => x.charCode).filter(x => !!x)).to.eql([
|
|
388
|
-
1,
|
|
389
|
-
12,
|
|
390
|
-
123
|
|
391
|
-
]);
|
|
392
|
-
});
|
|
393
|
-
it('converts doublequote to EscapedCharCodeLiteral', () => {
|
|
394
|
-
let { tokens } = Lexer_1.Lexer.scan('`"`');
|
|
395
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
396
|
-
_1.TokenKind.BackTick,
|
|
397
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
398
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
399
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
400
|
-
_1.TokenKind.BackTick,
|
|
401
|
-
_1.TokenKind.Eof
|
|
402
|
-
]);
|
|
403
|
-
chai_1.expect(tokens[2].charCode).to.equal(34);
|
|
404
|
-
});
|
|
405
|
-
it(`safely escapes \` literals`, () => {
|
|
406
|
-
let { tokens } = Lexer_1.Lexer.scan('`the cat says \\`meow\\` a lot`');
|
|
407
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
408
|
-
_1.TokenKind.BackTick,
|
|
409
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
410
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
411
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
412
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
413
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
414
|
-
_1.TokenKind.BackTick,
|
|
415
|
-
_1.TokenKind.Eof
|
|
416
|
-
]);
|
|
417
|
-
chai_1.expect(tokens.map(x => x.text)).to.eql([
|
|
418
|
-
'`',
|
|
419
|
-
'the cat says ',
|
|
420
|
-
'\\`',
|
|
421
|
-
'meow',
|
|
422
|
-
'\\`',
|
|
423
|
-
' a lot',
|
|
424
|
-
'`',
|
|
425
|
-
'' //EOF
|
|
426
|
-
]);
|
|
427
|
-
});
|
|
428
|
-
it('produces template string literal tokens', () => {
|
|
429
|
-
let { tokens } = Lexer_1.Lexer.scan('`hello world`');
|
|
430
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
431
|
-
_1.TokenKind.BackTick,
|
|
432
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
433
|
-
_1.TokenKind.BackTick,
|
|
434
|
-
_1.TokenKind.Eof
|
|
435
|
-
]);
|
|
436
|
-
chai_1.expect(tokens[1].text).to.deep.equal('hello world');
|
|
437
|
-
});
|
|
438
|
-
it('collects quasis outside and expressions inside of template strings', () => {
|
|
439
|
-
let { tokens } = Lexer_1.Lexer.scan('`hello ${"world"}!`');
|
|
440
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
441
|
-
_1.TokenKind.BackTick,
|
|
442
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
443
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
444
|
-
_1.TokenKind.StringLiteral,
|
|
445
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
446
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
447
|
-
_1.TokenKind.BackTick,
|
|
448
|
-
_1.TokenKind.Eof
|
|
449
|
-
]);
|
|
450
|
-
chai_1.expect(tokens[1].text).to.deep.equal(`hello `);
|
|
451
|
-
});
|
|
452
|
-
it('real example, which is causing issues in the formatter', () => {
|
|
453
|
-
let { tokens } = Lexer_1.Lexer.scan(`
|
|
454
|
-
function getItemXML(item)
|
|
455
|
-
return \`
|
|
456
|
-
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
|
|
457
|
-
<channel>
|
|
458
|
-
<title>smithsonian</title>
|
|
459
|
-
<item>
|
|
460
|
-
<title>\${item.title}</title>
|
|
461
|
-
<guid>\${item.vamsId}</guid>
|
|
462
|
-
<media:rating scheme="urn:v-chip">\${item.ratings.first.code.name}</media:rating>
|
|
463
|
-
</item>
|
|
464
|
-
</channel>
|
|
465
|
-
</rss>
|
|
466
|
-
\`
|
|
467
|
-
end function
|
|
468
|
-
`);
|
|
469
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
470
|
-
_1.TokenKind.Newline,
|
|
471
|
-
_1.TokenKind.Function,
|
|
472
|
-
_1.TokenKind.Identifier,
|
|
473
|
-
_1.TokenKind.LeftParen,
|
|
474
|
-
_1.TokenKind.Identifier,
|
|
475
|
-
_1.TokenKind.RightParen,
|
|
476
|
-
_1.TokenKind.Newline,
|
|
477
|
-
_1.TokenKind.Return,
|
|
478
|
-
_1.TokenKind.BackTick,
|
|
479
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
480
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
481
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
482
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
483
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
484
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
485
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
486
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
487
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
488
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
489
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
490
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
491
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
492
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
493
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
494
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
495
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
496
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
497
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
498
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
499
|
-
_1.TokenKind.Identifier,
|
|
500
|
-
_1.TokenKind.Dot,
|
|
501
|
-
_1.TokenKind.Identifier,
|
|
502
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
503
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
504
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
505
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
506
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
507
|
-
_1.TokenKind.Identifier,
|
|
508
|
-
_1.TokenKind.Dot,
|
|
509
|
-
_1.TokenKind.Identifier,
|
|
510
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
511
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
512
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
513
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
514
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
515
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
516
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
517
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
518
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
519
|
-
_1.TokenKind.Identifier,
|
|
520
|
-
_1.TokenKind.Dot,
|
|
521
|
-
_1.TokenKind.Identifier,
|
|
522
|
-
_1.TokenKind.Dot,
|
|
523
|
-
_1.TokenKind.Identifier,
|
|
524
|
-
_1.TokenKind.Dot,
|
|
525
|
-
_1.TokenKind.Identifier,
|
|
526
|
-
_1.TokenKind.Dot,
|
|
527
|
-
_1.TokenKind.Identifier,
|
|
528
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
529
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
530
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
531
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
532
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
533
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
534
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
535
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
536
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
537
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
538
|
-
_1.TokenKind.BackTick,
|
|
539
|
-
_1.TokenKind.Newline,
|
|
540
|
-
_1.TokenKind.EndFunction,
|
|
541
|
-
_1.TokenKind.Newline,
|
|
542
|
-
_1.TokenKind.Eof
|
|
543
|
-
]);
|
|
544
|
-
});
|
|
545
|
-
it('complicated example', () => {
|
|
546
|
-
let { tokens } = Lexer_1.Lexer.scan('`hello ${"world"}!I am a ${"template" + "string"} and I am very ${["pleased"][0]} to meet you ${m.top.getChildCount()}.The end`');
|
|
547
|
-
chai_1.expect(tokens.map(t => t.kind)).to.eql([
|
|
548
|
-
_1.TokenKind.BackTick,
|
|
549
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
550
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
551
|
-
_1.TokenKind.StringLiteral,
|
|
552
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
553
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
554
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
555
|
-
_1.TokenKind.StringLiteral,
|
|
556
|
-
_1.TokenKind.Plus,
|
|
557
|
-
_1.TokenKind.StringLiteral,
|
|
558
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
559
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
560
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
561
|
-
_1.TokenKind.LeftSquareBracket,
|
|
562
|
-
_1.TokenKind.StringLiteral,
|
|
563
|
-
_1.TokenKind.RightSquareBracket,
|
|
564
|
-
_1.TokenKind.LeftSquareBracket,
|
|
565
|
-
_1.TokenKind.IntegerLiteral,
|
|
566
|
-
_1.TokenKind.RightSquareBracket,
|
|
567
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
568
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
569
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
570
|
-
_1.TokenKind.Identifier,
|
|
571
|
-
_1.TokenKind.Dot,
|
|
572
|
-
_1.TokenKind.Identifier,
|
|
573
|
-
_1.TokenKind.Dot,
|
|
574
|
-
_1.TokenKind.Identifier,
|
|
575
|
-
_1.TokenKind.LeftParen,
|
|
576
|
-
_1.TokenKind.RightParen,
|
|
577
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
578
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
579
|
-
_1.TokenKind.BackTick,
|
|
580
|
-
_1.TokenKind.Eof
|
|
581
|
-
]);
|
|
582
|
-
});
|
|
583
|
-
it('allows multiline strings', () => {
|
|
584
|
-
let { tokens } = Lexer_1.Lexer.scan('`multi-line\n\n`');
|
|
585
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
586
|
-
_1.TokenKind.BackTick,
|
|
587
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
588
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
589
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
590
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
591
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
592
|
-
_1.TokenKind.BackTick,
|
|
593
|
-
_1.TokenKind.Eof
|
|
594
|
-
]);
|
|
595
|
-
chai_1.expect(tokens.map(x => x.text)).to.eql([
|
|
596
|
-
'`',
|
|
597
|
-
'multi-line',
|
|
598
|
-
'\n',
|
|
599
|
-
'',
|
|
600
|
-
'\n',
|
|
601
|
-
'',
|
|
602
|
-
'`',
|
|
603
|
-
'' //EOF
|
|
604
|
-
]);
|
|
605
|
-
});
|
|
606
|
-
it('maintains proper line/column locations for multiline strings', () => {
|
|
607
|
-
let { tokens } = Lexer_1.Lexer.scan('123 `multi\nline\r\nstrings` true\nfalse');
|
|
608
|
-
chai_1.expect(tokens.map(x => {
|
|
609
|
-
return {
|
|
610
|
-
range: x.range,
|
|
611
|
-
kind: x.kind
|
|
612
|
-
};
|
|
613
|
-
})).to.eql([
|
|
614
|
-
{ range: vscode_languageserver_1.Range.create(0, 0, 0, 3), kind: _1.TokenKind.IntegerLiteral },
|
|
615
|
-
{ range: vscode_languageserver_1.Range.create(0, 4, 0, 5), kind: _1.TokenKind.BackTick },
|
|
616
|
-
{ range: vscode_languageserver_1.Range.create(0, 5, 0, 10), kind: _1.TokenKind.TemplateStringQuasi },
|
|
617
|
-
{ range: vscode_languageserver_1.Range.create(0, 10, 0, 11), kind: _1.TokenKind.EscapedCharCodeLiteral },
|
|
618
|
-
{ range: vscode_languageserver_1.Range.create(1, 0, 1, 4), kind: _1.TokenKind.TemplateStringQuasi },
|
|
619
|
-
{ range: vscode_languageserver_1.Range.create(1, 4, 1, 5), kind: _1.TokenKind.EscapedCharCodeLiteral },
|
|
620
|
-
{ range: vscode_languageserver_1.Range.create(1, 5, 1, 6), kind: _1.TokenKind.EscapedCharCodeLiteral },
|
|
621
|
-
{ range: vscode_languageserver_1.Range.create(2, 0, 2, 7), kind: _1.TokenKind.TemplateStringQuasi },
|
|
622
|
-
{ range: vscode_languageserver_1.Range.create(2, 7, 2, 8), kind: _1.TokenKind.BackTick },
|
|
623
|
-
{ range: vscode_languageserver_1.Range.create(2, 9, 2, 13), kind: _1.TokenKind.True },
|
|
624
|
-
{ range: vscode_languageserver_1.Range.create(2, 13, 2, 14), kind: _1.TokenKind.Newline },
|
|
625
|
-
{ range: vscode_languageserver_1.Range.create(3, 0, 3, 5), kind: _1.TokenKind.False },
|
|
626
|
-
{ range: vscode_languageserver_1.Range.create(3, 5, 3, 6), kind: _1.TokenKind.Eof }
|
|
627
|
-
]);
|
|
628
|
-
});
|
|
629
|
-
it('Example that tripped up the expression tests', () => {
|
|
630
|
-
let { tokens } = Lexer_1.Lexer.scan('`I am a complex example\n${a.isRunning(["a","b","c"])}\nmore ${m.finish(true)}`');
|
|
631
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
632
|
-
_1.TokenKind.BackTick,
|
|
633
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
634
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
635
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
636
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
637
|
-
_1.TokenKind.Identifier,
|
|
638
|
-
_1.TokenKind.Dot,
|
|
639
|
-
_1.TokenKind.Identifier,
|
|
640
|
-
_1.TokenKind.LeftParen,
|
|
641
|
-
_1.TokenKind.LeftSquareBracket,
|
|
642
|
-
_1.TokenKind.StringLiteral,
|
|
643
|
-
_1.TokenKind.Comma,
|
|
644
|
-
_1.TokenKind.StringLiteral,
|
|
645
|
-
_1.TokenKind.Comma,
|
|
646
|
-
_1.TokenKind.StringLiteral,
|
|
647
|
-
_1.TokenKind.RightSquareBracket,
|
|
648
|
-
_1.TokenKind.RightParen,
|
|
649
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
650
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
651
|
-
_1.TokenKind.EscapedCharCodeLiteral,
|
|
652
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
653
|
-
_1.TokenKind.TemplateStringExpressionBegin,
|
|
654
|
-
_1.TokenKind.Identifier,
|
|
655
|
-
_1.TokenKind.Dot,
|
|
656
|
-
_1.TokenKind.Identifier,
|
|
657
|
-
_1.TokenKind.LeftParen,
|
|
658
|
-
_1.TokenKind.True,
|
|
659
|
-
_1.TokenKind.RightParen,
|
|
660
|
-
_1.TokenKind.TemplateStringExpressionEnd,
|
|
661
|
-
_1.TokenKind.TemplateStringQuasi,
|
|
662
|
-
_1.TokenKind.BackTick,
|
|
663
|
-
_1.TokenKind.Eof
|
|
664
|
-
]);
|
|
665
|
-
});
|
|
666
|
-
}); // string literals
|
|
667
|
-
describe('double literals', () => {
|
|
668
|
-
it('respects \'#\' suffix', () => {
|
|
669
|
-
let d = Lexer_1.Lexer.scan('123#').tokens[0];
|
|
670
|
-
chai_1.expect(d.kind).to.equal(_1.TokenKind.DoubleLiteral);
|
|
671
|
-
chai_1.expect(d.text).to.eql('123#');
|
|
672
|
-
});
|
|
673
|
-
it('forces literals >= 10 digits into doubles', () => {
|
|
674
|
-
let d = Lexer_1.Lexer.scan('0000000005').tokens[0];
|
|
675
|
-
chai_1.expect(d.kind).to.equal(_1.TokenKind.DoubleLiteral);
|
|
676
|
-
chai_1.expect(d.text).to.eql('0000000005');
|
|
677
|
-
});
|
|
678
|
-
it('forces literals with \'D\' in exponent into doubles', () => {
|
|
679
|
-
let d = Lexer_1.Lexer.scan('2.5d3').tokens[0];
|
|
680
|
-
chai_1.expect(d.kind).to.equal(_1.TokenKind.DoubleLiteral);
|
|
681
|
-
chai_1.expect(d.text).to.eql('2.5d3');
|
|
682
|
-
});
|
|
683
|
-
it('allows digits before `.` to be elided', () => {
|
|
684
|
-
let f = Lexer_1.Lexer.scan('.123#').tokens[0];
|
|
685
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.DoubleLiteral);
|
|
686
|
-
chai_1.expect(f.text).to.eql('.123#');
|
|
687
|
-
});
|
|
688
|
-
it('allows digits after `.` to be elided', () => {
|
|
689
|
-
let f = Lexer_1.Lexer.scan('12.#').tokens[0];
|
|
690
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.DoubleLiteral);
|
|
691
|
-
chai_1.expect(f.text).to.eql('12.#');
|
|
692
|
-
});
|
|
693
|
-
});
|
|
694
|
-
describe('float literals', () => {
|
|
695
|
-
it('respects \'!\' suffix', () => {
|
|
696
|
-
let f = Lexer_1.Lexer.scan('0.00000008!').tokens[0];
|
|
697
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
698
|
-
// Floating precision will make this *not* equal
|
|
699
|
-
chai_1.expect(f.text).not.to.equal(8e-8);
|
|
700
|
-
chai_1.expect(f.text).to.eql('0.00000008!');
|
|
701
|
-
});
|
|
702
|
-
it('forces literals with a decimal into floats', () => {
|
|
703
|
-
let f = Lexer_1.Lexer.scan('1.0').tokens[0];
|
|
704
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
705
|
-
chai_1.expect(f.text).to.equal('1.0');
|
|
706
|
-
});
|
|
707
|
-
it('forces literals with \'E\' in exponent into floats', () => {
|
|
708
|
-
let f = Lexer_1.Lexer.scan('2.5e3').tokens[0];
|
|
709
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
710
|
-
chai_1.expect(f.text).to.eql('2.5e3');
|
|
711
|
-
});
|
|
712
|
-
it('supports larger-than-supported-precision floats to be defined with exponents', () => {
|
|
713
|
-
let f = Lexer_1.Lexer.scan('2.3659475627512424e-38').tokens[0];
|
|
714
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
715
|
-
chai_1.expect(f.text).to.eql('2.3659475627512424e-38');
|
|
716
|
-
});
|
|
717
|
-
it('allows digits before `.` to be elided', () => {
|
|
718
|
-
let f = Lexer_1.Lexer.scan('.123').tokens[0];
|
|
719
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
720
|
-
chai_1.expect(f.text).to.equal('.123');
|
|
721
|
-
});
|
|
722
|
-
it('allows digits after `.` to be elided', () => {
|
|
723
|
-
let f = Lexer_1.Lexer.scan('12.').tokens[0];
|
|
724
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
725
|
-
chai_1.expect(f.text).to.equal('12.');
|
|
726
|
-
});
|
|
727
|
-
});
|
|
728
|
-
describe('long integer literals', () => {
|
|
729
|
-
it('respects \'&\' suffix', () => {
|
|
730
|
-
let f = Lexer_1.Lexer.scan('1&').tokens[0];
|
|
731
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.LongIntegerLiteral);
|
|
732
|
-
chai_1.expect(f.text).to.eql('1&');
|
|
733
|
-
});
|
|
734
|
-
it('supports hexadecimal literals', () => {
|
|
735
|
-
let i = Lexer_1.Lexer.scan('&hf00d&').tokens[0];
|
|
736
|
-
chai_1.expect(i.kind).to.equal(_1.TokenKind.LongIntegerLiteral);
|
|
737
|
-
chai_1.expect(i.text).to.equal('&hf00d&');
|
|
738
|
-
});
|
|
739
|
-
it('allows very long Int64 literals', () => {
|
|
740
|
-
let li = Lexer_1.Lexer.scan('9876543210&').tokens[0];
|
|
741
|
-
chai_1.expect(li.kind).to.equal(_1.TokenKind.LongIntegerLiteral);
|
|
742
|
-
chai_1.expect(li.text).to.equal('9876543210&');
|
|
743
|
-
});
|
|
744
|
-
it('forces literals with \'&\' suffix into Int64s', () => {
|
|
745
|
-
let li = Lexer_1.Lexer.scan('123&').tokens[0];
|
|
746
|
-
chai_1.expect(li.kind).to.equal(_1.TokenKind.LongIntegerLiteral);
|
|
747
|
-
chai_1.expect(li.text).to.deep.equal('123&');
|
|
748
|
-
});
|
|
749
|
-
});
|
|
750
|
-
describe('integer literals', () => {
|
|
751
|
-
it('respects \'%\' suffix', () => {
|
|
752
|
-
let f = Lexer_1.Lexer.scan('1%').tokens[0];
|
|
753
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.IntegerLiteral);
|
|
754
|
-
chai_1.expect(f.text).to.eql('1%');
|
|
755
|
-
});
|
|
756
|
-
it('does not allow decimal numbers to end with %', () => {
|
|
757
|
-
let f = Lexer_1.Lexer.scan('1.2%').tokens[0];
|
|
758
|
-
chai_1.expect(f.kind).to.equal(_1.TokenKind.FloatLiteral);
|
|
759
|
-
chai_1.expect(f.text).to.eql('1.2');
|
|
760
|
-
});
|
|
761
|
-
it('supports hexadecimal literals', () => {
|
|
762
|
-
let i = Lexer_1.Lexer.scan('&hFf').tokens[0];
|
|
763
|
-
chai_1.expect(i.kind).to.equal(_1.TokenKind.IntegerLiteral);
|
|
764
|
-
chai_1.expect(i.text).to.deep.equal('&hFf');
|
|
765
|
-
});
|
|
766
|
-
it('falls back to a regular integer', () => {
|
|
767
|
-
let i = Lexer_1.Lexer.scan('123').tokens[0];
|
|
768
|
-
chai_1.expect(i.kind).to.equal(_1.TokenKind.IntegerLiteral);
|
|
769
|
-
chai_1.expect(i.text).to.deep.equal('123');
|
|
770
|
-
});
|
|
771
|
-
});
|
|
772
|
-
describe('types', () => {
|
|
773
|
-
it('captures type tokens', () => {
|
|
774
|
-
chai_1.expect(Lexer_1.Lexer.scan(`
|
|
775
|
-
void boolean integer longinteger float double string object interface invalid dynamic
|
|
776
|
-
`.trim()).tokens.map(x => x.kind)).to.eql([
|
|
777
|
-
_1.TokenKind.Void,
|
|
778
|
-
_1.TokenKind.Boolean,
|
|
779
|
-
_1.TokenKind.Integer,
|
|
780
|
-
_1.TokenKind.LongInteger,
|
|
781
|
-
_1.TokenKind.Float,
|
|
782
|
-
_1.TokenKind.Double,
|
|
783
|
-
_1.TokenKind.String,
|
|
784
|
-
_1.TokenKind.Object,
|
|
785
|
-
_1.TokenKind.Interface,
|
|
786
|
-
_1.TokenKind.Invalid,
|
|
787
|
-
_1.TokenKind.Dynamic,
|
|
788
|
-
_1.TokenKind.Eof
|
|
789
|
-
]);
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
describe('identifiers', () => {
|
|
793
|
-
it('matches single-word keywords', () => {
|
|
794
|
-
// test just a sample of single-word reserved words for now.
|
|
795
|
-
// if we find any that we've missed
|
|
796
|
-
let { tokens } = Lexer_1.Lexer.scan('and then or if else endif return true false line_num');
|
|
797
|
-
chai_1.expect(tokens.map(w => w.kind)).to.deep.equal([
|
|
798
|
-
_1.TokenKind.And,
|
|
799
|
-
_1.TokenKind.Then,
|
|
800
|
-
_1.TokenKind.Or,
|
|
801
|
-
_1.TokenKind.If,
|
|
802
|
-
_1.TokenKind.Else,
|
|
803
|
-
_1.TokenKind.EndIf,
|
|
804
|
-
_1.TokenKind.Return,
|
|
805
|
-
_1.TokenKind.True,
|
|
806
|
-
_1.TokenKind.False,
|
|
807
|
-
_1.TokenKind.LineNumLiteral,
|
|
808
|
-
_1.TokenKind.Eof
|
|
809
|
-
]);
|
|
810
|
-
});
|
|
811
|
-
it('matches multi-word keywords', () => {
|
|
812
|
-
let { tokens } = Lexer_1.Lexer.scan('end if end while End Sub end Function Exit wHILe');
|
|
813
|
-
chai_1.expect(tokens.map(w => w.kind)).to.deep.equal([
|
|
814
|
-
_1.TokenKind.EndIf,
|
|
815
|
-
_1.TokenKind.EndWhile,
|
|
816
|
-
_1.TokenKind.EndSub,
|
|
817
|
-
_1.TokenKind.EndFunction,
|
|
818
|
-
_1.TokenKind.ExitWhile,
|
|
819
|
-
_1.TokenKind.Eof
|
|
820
|
-
]);
|
|
821
|
-
});
|
|
822
|
-
it('accepts \'exit for\' but not \'exitfor\'', () => {
|
|
823
|
-
let { tokens } = Lexer_1.Lexer.scan('exit for exitfor');
|
|
824
|
-
chai_1.expect(tokens.map(w => w.kind)).to.deep.equal([
|
|
825
|
-
_1.TokenKind.ExitFor,
|
|
826
|
-
_1.TokenKind.Identifier,
|
|
827
|
-
_1.TokenKind.Eof
|
|
828
|
-
]);
|
|
829
|
-
});
|
|
830
|
-
it('matches keywords with silly capitalization', () => {
|
|
831
|
-
let { tokens } = Lexer_1.Lexer.scan('iF ELSE eNDIf FUncTioN');
|
|
832
|
-
chai_1.expect(tokens.map(w => w.kind)).to.deep.equal([
|
|
833
|
-
_1.TokenKind.If,
|
|
834
|
-
_1.TokenKind.Else,
|
|
835
|
-
_1.TokenKind.EndIf,
|
|
836
|
-
_1.TokenKind.Function,
|
|
837
|
-
_1.TokenKind.Eof
|
|
838
|
-
]);
|
|
839
|
-
});
|
|
840
|
-
it('allows alpha-numeric (plus \'_\') identifiers', () => {
|
|
841
|
-
let identifier = Lexer_1.Lexer.scan('_abc_123_').tokens[0];
|
|
842
|
-
chai_1.expect(identifier.kind).to.equal(_1.TokenKind.Identifier);
|
|
843
|
-
chai_1.expect(identifier.text).to.equal('_abc_123_');
|
|
844
|
-
});
|
|
845
|
-
it('allows identifiers with trailing type designators', () => {
|
|
846
|
-
let { tokens } = Lexer_1.Lexer.scan('lorem$ ipsum% dolor! sit# amet&');
|
|
847
|
-
let identifiers = tokens.filter(t => t.kind !== _1.TokenKind.Eof);
|
|
848
|
-
chai_1.expect(identifiers.every(t => t.kind === _1.TokenKind.Identifier));
|
|
849
|
-
chai_1.expect(identifiers.map(t => t.text)).to.deep.equal([
|
|
850
|
-
'lorem$',
|
|
851
|
-
'ipsum%',
|
|
852
|
-
'dolor!',
|
|
853
|
-
'sit#',
|
|
854
|
-
'amet&'
|
|
855
|
-
]);
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
describe('conditional compilation', () => {
|
|
859
|
-
it('reads constant declarations', () => {
|
|
860
|
-
let { tokens } = Lexer_1.Lexer.scan('#const foo true');
|
|
861
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
862
|
-
_1.TokenKind.HashConst,
|
|
863
|
-
_1.TokenKind.Identifier,
|
|
864
|
-
_1.TokenKind.True,
|
|
865
|
-
_1.TokenKind.Eof
|
|
866
|
-
]);
|
|
867
|
-
});
|
|
868
|
-
it('reads constant aliases', () => {
|
|
869
|
-
let { tokens } = Lexer_1.Lexer.scan('#const bar foo');
|
|
870
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
871
|
-
_1.TokenKind.HashConst,
|
|
872
|
-
_1.TokenKind.Identifier,
|
|
873
|
-
_1.TokenKind.Identifier,
|
|
874
|
-
_1.TokenKind.Eof
|
|
875
|
-
]);
|
|
876
|
-
});
|
|
877
|
-
it('reads conditional directives', () => {
|
|
878
|
-
let { tokens } = Lexer_1.Lexer.scan(`
|
|
879
|
-
#if
|
|
880
|
-
#else if
|
|
881
|
-
#elseif
|
|
882
|
-
#else
|
|
883
|
-
#end if
|
|
884
|
-
#endif
|
|
885
|
-
`, {
|
|
886
|
-
includeWhitespace: false
|
|
887
|
-
});
|
|
888
|
-
chai_1.expect(tokens.map(t => t.kind).filter(x => x !== _1.TokenKind.Newline)).to.deep.equal([
|
|
889
|
-
_1.TokenKind.HashIf,
|
|
890
|
-
_1.TokenKind.HashElseIf,
|
|
891
|
-
_1.TokenKind.HashElseIf,
|
|
892
|
-
_1.TokenKind.HashElse,
|
|
893
|
-
_1.TokenKind.HashEndIf,
|
|
894
|
-
_1.TokenKind.HashEndIf,
|
|
895
|
-
_1.TokenKind.Eof
|
|
896
|
-
]);
|
|
897
|
-
});
|
|
898
|
-
it('treats text "constructor" as an identifier', () => {
|
|
899
|
-
let lexer = Lexer_1.Lexer.scan(`function constructor()\nend function`);
|
|
900
|
-
chai_1.expect(lexer.tokens[1].kind).to.equal(_1.TokenKind.Identifier);
|
|
901
|
-
});
|
|
902
|
-
it('reads upper case conditional directives', () => {
|
|
903
|
-
let { tokens } = Lexer_1.Lexer.scan(`
|
|
904
|
-
#IF
|
|
905
|
-
#ELSE IF
|
|
906
|
-
#ELSEIF
|
|
907
|
-
#ELSE
|
|
908
|
-
#END IF
|
|
909
|
-
#ENDIF
|
|
910
|
-
`, {
|
|
911
|
-
includeWhitespace: false
|
|
912
|
-
});
|
|
913
|
-
chai_1.expect(tokens.map(t => t.kind).filter(x => x !== _1.TokenKind.Newline)).to.deep.equal([
|
|
914
|
-
_1.TokenKind.HashIf,
|
|
915
|
-
_1.TokenKind.HashElseIf,
|
|
916
|
-
_1.TokenKind.HashElseIf,
|
|
917
|
-
_1.TokenKind.HashElse,
|
|
918
|
-
_1.TokenKind.HashEndIf,
|
|
919
|
-
_1.TokenKind.HashEndIf,
|
|
920
|
-
_1.TokenKind.Eof
|
|
921
|
-
]);
|
|
922
|
-
});
|
|
923
|
-
it('supports various spacings between #endif', () => {
|
|
924
|
-
let { tokens } = Lexer_1.Lexer.scan('#endif #end if #end\tif #end if #end\t\t if');
|
|
925
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
926
|
-
_1.TokenKind.HashEndIf,
|
|
927
|
-
_1.TokenKind.HashEndIf,
|
|
928
|
-
_1.TokenKind.HashEndIf,
|
|
929
|
-
_1.TokenKind.HashEndIf,
|
|
930
|
-
_1.TokenKind.HashEndIf,
|
|
931
|
-
_1.TokenKind.Eof
|
|
932
|
-
]);
|
|
933
|
-
});
|
|
934
|
-
it('reads forced compilation diagnostics with messages', () => {
|
|
935
|
-
let { tokens } = Lexer_1.Lexer.scan('#error a message goes here\n', {
|
|
936
|
-
includeWhitespace: true
|
|
937
|
-
});
|
|
938
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
939
|
-
_1.TokenKind.HashError,
|
|
940
|
-
_1.TokenKind.Whitespace,
|
|
941
|
-
_1.TokenKind.HashErrorMessage,
|
|
942
|
-
_1.TokenKind.Newline,
|
|
943
|
-
_1.TokenKind.Eof
|
|
944
|
-
]);
|
|
945
|
-
chai_1.expect(tokens[2].text).to.equal('a message goes here');
|
|
946
|
-
});
|
|
947
|
-
});
|
|
948
|
-
describe('location tracking', () => {
|
|
949
|
-
it('tracks starting and ending locations including whitespace', () => {
|
|
950
|
-
let { tokens } = Lexer_1.Lexer.scan(`sub foo()\n print "bar"\r\nend sub`, { includeWhitespace: true });
|
|
951
|
-
chai_1.expect(tokens.map(t => t.range)).to.eql([
|
|
952
|
-
vscode_languageserver_1.Range.create(0, 0, 0, 3),
|
|
953
|
-
vscode_languageserver_1.Range.create(0, 3, 0, 4),
|
|
954
|
-
vscode_languageserver_1.Range.create(0, 4, 0, 7),
|
|
955
|
-
vscode_languageserver_1.Range.create(0, 7, 0, 8),
|
|
956
|
-
vscode_languageserver_1.Range.create(0, 8, 0, 9),
|
|
957
|
-
vscode_languageserver_1.Range.create(0, 9, 0, 10),
|
|
958
|
-
vscode_languageserver_1.Range.create(1, 0, 1, 4),
|
|
959
|
-
vscode_languageserver_1.Range.create(1, 4, 1, 9),
|
|
960
|
-
vscode_languageserver_1.Range.create(1, 9, 1, 10),
|
|
961
|
-
vscode_languageserver_1.Range.create(1, 10, 1, 15),
|
|
962
|
-
vscode_languageserver_1.Range.create(1, 15, 1, 17),
|
|
963
|
-
vscode_languageserver_1.Range.create(2, 0, 2, 7),
|
|
964
|
-
vscode_languageserver_1.Range.create(2, 7, 2, 8) // EOF
|
|
965
|
-
]);
|
|
966
|
-
});
|
|
967
|
-
it('tracks starting and ending locations excluding whitespace', () => {
|
|
968
|
-
let { tokens } = Lexer_1.Lexer.scan(`sub foo()\n print "bar"\r\nend sub`, { includeWhitespace: false });
|
|
969
|
-
chai_1.expect(tokens.map(t => t.range)).to.eql([
|
|
970
|
-
vscode_languageserver_1.Range.create(0, 0, 0, 3),
|
|
971
|
-
vscode_languageserver_1.Range.create(0, 4, 0, 7),
|
|
972
|
-
vscode_languageserver_1.Range.create(0, 7, 0, 8),
|
|
973
|
-
vscode_languageserver_1.Range.create(0, 8, 0, 9),
|
|
974
|
-
vscode_languageserver_1.Range.create(0, 9, 0, 10),
|
|
975
|
-
vscode_languageserver_1.Range.create(1, 4, 1, 9),
|
|
976
|
-
vscode_languageserver_1.Range.create(1, 10, 1, 15),
|
|
977
|
-
vscode_languageserver_1.Range.create(1, 15, 1, 17),
|
|
978
|
-
vscode_languageserver_1.Range.create(2, 0, 2, 7),
|
|
979
|
-
vscode_languageserver_1.Range.create(2, 7, 2, 8) // EOF
|
|
980
|
-
]);
|
|
981
|
-
});
|
|
982
|
-
});
|
|
983
|
-
describe('two word keywords', () => {
|
|
984
|
-
it('supports various spacing between for each', () => {
|
|
985
|
-
let { tokens } = Lexer_1.Lexer.scan('for each for each for each for\teach for\t each for \teach for \t each');
|
|
986
|
-
chai_1.expect(tokens.map(t => t.kind)).to.deep.equal([
|
|
987
|
-
_1.TokenKind.ForEach,
|
|
988
|
-
_1.TokenKind.ForEach,
|
|
989
|
-
_1.TokenKind.ForEach,
|
|
990
|
-
_1.TokenKind.ForEach,
|
|
991
|
-
_1.TokenKind.ForEach,
|
|
992
|
-
_1.TokenKind.ForEach,
|
|
993
|
-
_1.TokenKind.ForEach,
|
|
994
|
-
_1.TokenKind.Eof
|
|
995
|
-
]);
|
|
996
|
-
});
|
|
997
|
-
});
|
|
998
|
-
it('detects rem when used as keyword', () => {
|
|
999
|
-
let { tokens } = Lexer_1.Lexer.scan('person.rem=true');
|
|
1000
|
-
chai_1.expect(tokens.map(t => t.kind)).to.eql([
|
|
1001
|
-
_1.TokenKind.Identifier,
|
|
1002
|
-
_1.TokenKind.Dot,
|
|
1003
|
-
_1.TokenKind.Identifier,
|
|
1004
|
-
_1.TokenKind.Equal,
|
|
1005
|
-
_1.TokenKind.True,
|
|
1006
|
-
_1.TokenKind.Eof
|
|
1007
|
-
]);
|
|
1008
|
-
//verify the location of `rem`
|
|
1009
|
-
chai_1.expect(tokens.map(t => [t.range.start.character, t.range.end.character])).to.eql([
|
|
1010
|
-
[0, 6],
|
|
1011
|
-
[6, 7],
|
|
1012
|
-
[7, 10],
|
|
1013
|
-
[10, 11],
|
|
1014
|
-
[11, 15],
|
|
1015
|
-
[15, 16] // EOF
|
|
1016
|
-
]);
|
|
1017
|
-
});
|
|
1018
|
-
describe('isToken', () => {
|
|
1019
|
-
it('works', () => {
|
|
1020
|
-
let range = vscode_languageserver_1.Range.create(0, 0, 0, 2);
|
|
1021
|
-
chai_1.expect(Token_1.isToken({ kind: _1.TokenKind.And, text: 'and', range: range })).is.true;
|
|
1022
|
-
chai_1.expect(Token_1.isToken({ text: 'and', range: range })).is.false;
|
|
1023
|
-
});
|
|
1024
|
-
});
|
|
1025
|
-
it('recognizes class-related keywords', () => {
|
|
1026
|
-
chai_1.expect(Lexer_1.Lexer.scan('class public protected private end class endclass new override').tokens.map(x => x.kind)).to.eql([
|
|
1027
|
-
_1.TokenKind.Class,
|
|
1028
|
-
_1.TokenKind.Public,
|
|
1029
|
-
_1.TokenKind.Protected,
|
|
1030
|
-
_1.TokenKind.Private,
|
|
1031
|
-
_1.TokenKind.EndClass,
|
|
1032
|
-
_1.TokenKind.EndClass,
|
|
1033
|
-
_1.TokenKind.New,
|
|
1034
|
-
_1.TokenKind.Override,
|
|
1035
|
-
_1.TokenKind.Eof
|
|
1036
|
-
]);
|
|
1037
|
-
});
|
|
1038
|
-
describe('whitespace', () => {
|
|
1039
|
-
it('preserves the exact number of whitespace characterswhitespace', () => {
|
|
1040
|
-
let { tokens } = Lexer_1.Lexer.scan(' ', { includeWhitespace: true });
|
|
1041
|
-
chai_1.expect(tokens[0]).to.include({
|
|
1042
|
-
kind: _1.TokenKind.Whitespace,
|
|
1043
|
-
text: ' '
|
|
1044
|
-
});
|
|
1045
|
-
});
|
|
1046
|
-
it('tokenizes whitespace between things', () => {
|
|
1047
|
-
let { tokens } = Lexer_1.Lexer.scan('sub main ( ) \n end sub', { includeWhitespace: true });
|
|
1048
|
-
chai_1.expect(tokens.map(x => x.kind)).to.eql([
|
|
1049
|
-
_1.TokenKind.Sub,
|
|
1050
|
-
_1.TokenKind.Whitespace,
|
|
1051
|
-
_1.TokenKind.Identifier,
|
|
1052
|
-
_1.TokenKind.Whitespace,
|
|
1053
|
-
_1.TokenKind.LeftParen,
|
|
1054
|
-
_1.TokenKind.Whitespace,
|
|
1055
|
-
_1.TokenKind.RightParen,
|
|
1056
|
-
_1.TokenKind.Whitespace,
|
|
1057
|
-
_1.TokenKind.Newline,
|
|
1058
|
-
_1.TokenKind.Whitespace,
|
|
1059
|
-
_1.TokenKind.EndSub,
|
|
1060
|
-
_1.TokenKind.Eof
|
|
1061
|
-
]);
|
|
1062
|
-
});
|
|
1063
|
-
});
|
|
1064
|
-
it('identifies brighterscript source literals', () => {
|
|
1065
|
-
let { tokens } = Lexer_1.Lexer.scan('LINE_NUM SOURCE_FILE_PATH SOURCE_LINE_NUM FUNCTION_NAME SOURCE_FUNCTION_NAME SOURCE_LOCATION PKG_PATH PKG_LOCATION');
|
|
1066
|
-
chai_1.expect(tokens.map(x => x.kind)).to.eql([
|
|
1067
|
-
_1.TokenKind.LineNumLiteral,
|
|
1068
|
-
_1.TokenKind.SourceFilePathLiteral,
|
|
1069
|
-
_1.TokenKind.SourceLineNumLiteral,
|
|
1070
|
-
_1.TokenKind.FunctionNameLiteral,
|
|
1071
|
-
_1.TokenKind.SourceFunctionNameLiteral,
|
|
1072
|
-
_1.TokenKind.SourceLocationLiteral,
|
|
1073
|
-
_1.TokenKind.PkgPathLiteral,
|
|
1074
|
-
_1.TokenKind.PkgLocationLiteral,
|
|
1075
|
-
_1.TokenKind.Eof
|
|
1076
|
-
]);
|
|
1077
|
-
});
|
|
1078
|
-
it('properly tracks leadingWhitespace', () => {
|
|
1079
|
-
const text = `
|
|
1080
|
-
sub main()
|
|
1081
|
-
|
|
1082
|
-
print "main"\r\n\n
|
|
1083
|
-
|
|
1084
|
-
end sub
|
|
1085
|
-
`;
|
|
1086
|
-
const { tokens } = Lexer_1.Lexer.scan(text, { includeWhitespace: false });
|
|
1087
|
-
chai_1.expect(util_1.default.tokensToString(tokens)).to.equal(text);
|
|
1088
|
-
});
|
|
1089
|
-
it('properly detects try/catch tokens', () => {
|
|
1090
|
-
const { tokens } = Lexer_1.Lexer.scan(`try catch endtry end try throw`, { includeWhitespace: false });
|
|
1091
|
-
chai_1.expect(tokens.map(x => x.kind)).to.eql([
|
|
1092
|
-
_1.TokenKind.Try,
|
|
1093
|
-
_1.TokenKind.Catch,
|
|
1094
|
-
_1.TokenKind.EndTry,
|
|
1095
|
-
_1.TokenKind.EndTry,
|
|
1096
|
-
_1.TokenKind.Throw,
|
|
1097
|
-
_1.TokenKind.Eof
|
|
1098
|
-
]);
|
|
1099
|
-
});
|
|
1100
|
-
});
|
|
1101
|
-
//# sourceMappingURL=Lexer.spec.js.map
|