brighterscript 1.0.0-alpha.50 → 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 +3 -0
- package/bsconfig.schema.json +75 -0
- package/dist/BsConfig.d.ts +90 -5
- package/dist/CodeActionUtil.d.ts +17 -0
- package/dist/CodeActionUtil.js.map +1 -1
- package/dist/CommentFlagProcessor.d.ts +16 -12
- package/dist/CommentFlagProcessor.js +141 -59
- package/dist/CommentFlagProcessor.js.map +1 -1
- package/dist/CrossScopeValidator.js +13 -5
- package/dist/CrossScopeValidator.js.map +1 -1
- package/dist/DiagnosticManager.d.ts +1 -0
- package/dist/DiagnosticManager.js +25 -9
- package/dist/DiagnosticManager.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +61 -17
- package/dist/DiagnosticMessages.js +78 -24
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.d.ts +39 -2
- package/dist/LanguageServer.js +142 -5
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +62 -1
- package/dist/Program.js +185 -13
- package/dist/Program.js.map +1 -1
- package/dist/ProgramBuilder.d.ts +1 -8
- package/dist/ProgramBuilder.js +31 -11
- package/dist/ProgramBuilder.js.map +1 -1
- package/dist/Scope.d.ts +87 -6
- package/dist/Scope.js +76 -31
- 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/SymbolTable.d.ts +9 -2
- package/dist/SymbolTable.js +24 -14
- package/dist/SymbolTable.js.map +1 -1
- package/dist/astUtils/CachedLookups.js +3 -0
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +4 -1
- package/dist/astUtils/reflection.js +24 -4
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +2 -1
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +4 -2
- package/dist/bscPlugin/BscPlugin.js +10 -2
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/CallExpressionInfo.d.ts +1 -1
- package/dist/bscPlugin/CallExpressionInfo.js +1 -2
- package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
- package/dist/bscPlugin/FileWriter.d.ts +13 -0
- package/dist/bscPlugin/FileWriter.js +56 -1
- package/dist/bscPlugin/FileWriter.js.map +1 -1
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.d.ts +106 -5
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +630 -126
- 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 +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.js +5 -5
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/definition/DefinitionProvider.js +8 -0
- package/dist/bscPlugin/definition/DefinitionProvider.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +11 -3
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- 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/serialize/FileSerializer.d.ts +1 -1
- package/dist/bscPlugin/serialize/FileSerializer.js +12 -7
- package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.d.ts +7 -0
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +87 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +14 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +97 -21
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +17 -0
- package/dist/bscPlugin/validation/ScopeValidator.js +162 -4
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.js +14 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +51 -1
- package/dist/diagnosticUtils.js +222 -1
- package/dist/diagnosticUtils.js.map +1 -1
- package/dist/files/BrsFile.d.ts +18 -2
- package/dist/files/BrsFile.js +87 -6
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/XmlFile.js +2 -1
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/interfaces.d.ts +68 -23
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.js +4 -5
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Token.d.ts +1 -1
- package/dist/lexer/TokenKind.d.ts +8 -0
- package/dist/lexer/TokenKind.js +21 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/lsp/LspProject.d.ts +49 -1
- package/dist/lsp/Project.d.ts +33 -1
- package/dist/lsp/Project.js +129 -4
- package/dist/lsp/Project.js.map +1 -1
- package/dist/lsp/ProjectManager.d.ts +48 -2
- package/dist/lsp/ProjectManager.js +152 -9
- package/dist/lsp/ProjectManager.js.map +1 -1
- package/dist/lsp/worker/WorkerThreadProject.d.ts +27 -2
- package/dist/lsp/worker/WorkerThreadProject.js +16 -0
- package/dist/lsp/worker/WorkerThreadProject.js.map +1 -1
- package/dist/parser/AstNode.d.ts +3 -1
- package/dist/parser/AstNode.js +2 -0
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/Expression.d.ts +54 -5
- package/dist/parser/Expression.js +112 -7
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.d.ts +24 -1
- package/dist/parser/Parser.js +180 -41
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/SGParser.d.ts +1 -0
- package/dist/parser/SGParser.js +9 -0
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/Statement.d.ts +6 -1
- package/dist/parser/Statement.js +22 -14
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +4 -2
- package/dist/parser/TranspileState.js +10 -4
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/roku-types/data.json +210 -3
- package/dist/types/ArrayType.js +6 -1
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/BooleanType.js +1 -1
- package/dist/types/BooleanType.js.map +1 -1
- package/dist/types/CallFuncableType.d.ts +1 -1
- package/dist/types/ClassType.js +3 -0
- package/dist/types/ClassType.js.map +1 -1
- package/dist/types/ComponentType.js +3 -0
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +3 -0
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/IntersectionType.js +3 -0
- package/dist/types/IntersectionType.js.map +1 -1
- package/dist/types/ReferenceType.js +6 -0
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/TypeStatementType.d.ts +1 -0
- package/dist/types/TypeStatementType.js +12 -1
- package/dist/types/TypeStatementType.js.map +1 -1
- package/dist/types/TypedFunctionType.js +20 -10
- package/dist/types/TypedFunctionType.js.map +1 -1
- package/dist/types/UnionType.js +3 -0
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/helpers.js +6 -0
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +42 -3
- package/dist/util.js +131 -7
- package/dist/util.js.map +1 -1
- package/package.json +24 -26
- package/dist/astUtils/CachedLookups.spec.d.ts +0 -1
- package/dist/astUtils/CachedLookups.spec.js +0 -39
- package/dist/astUtils/CachedLookups.spec.js.map +0 -1
- package/dist/astUtils/Editor.spec.d.ts +0 -1
- package/dist/astUtils/Editor.spec.js +0 -258
- package/dist/astUtils/Editor.spec.js.map +0 -1
- package/dist/astUtils/creators.spec.d.ts +0 -1
- package/dist/astUtils/creators.spec.js +0 -21
- package/dist/astUtils/creators.spec.js.map +0 -1
- package/dist/astUtils/reflection.spec.d.ts +0 -1
- package/dist/astUtils/reflection.spec.js +0 -392
- 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 -1432
- 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 -311
- package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +0 -2512
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js +0 -87
- package/dist/bscPlugin/definition/DefinitionProvider.spec.js.map +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +0 -991
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +0 -1
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +0 -51
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +0 -564
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.d.ts +0 -1
- package/dist/bscPlugin/serialize/BslibInjector.spec.js +0 -33
- package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js +0 -291
- package/dist/bscPlugin/symbols/DocumentSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js +0 -245
- package/dist/bscPlugin/symbols/WorkspaceSymbolProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +0 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +0 -75
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.d.ts +0 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +0 -1517
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +0 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +0 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +0 -6135
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +0 -1
- package/dist/common/Sequencer.spec.d.ts +0 -1
- package/dist/common/Sequencer.spec.js +0 -75
- package/dist/common/Sequencer.spec.js.map +0 -1
- package/dist/files/BrsFile.Class.spec.d.ts +0 -1
- package/dist/files/BrsFile.Class.spec.js +0 -2035
- 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 -5848
- package/dist/files/BrsFile.spec.js.map +0 -1
- package/dist/files/LazyFileData.spec.d.ts +0 -1
- package/dist/files/LazyFileData.spec.js +0 -27
- package/dist/files/LazyFileData.spec.js.map +0 -1
- package/dist/files/XmlFile.spec.d.ts +0 -1
- package/dist/files/XmlFile.spec.js +0 -1173
- 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 -251
- package/dist/files/tests/imports.spec.js.map +0 -1
- package/dist/files/tests/optionalChaning.spec.d.ts +0 -1
- package/dist/files/tests/optionalChaning.spec.js +0 -152
- package/dist/files/tests/optionalChaning.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 -1345
- package/dist/lexer/Lexer.spec.js.map +0 -1
- package/dist/lsp/ActionQueue.spec.d.ts +0 -1
- package/dist/lsp/ActionQueue.spec.js +0 -80
- package/dist/lsp/ActionQueue.spec.js.map +0 -1
- package/dist/lsp/DocumentManager.spec.d.ts +0 -1
- package/dist/lsp/DocumentManager.spec.js +0 -103
- package/dist/lsp/DocumentManager.spec.js.map +0 -1
- package/dist/lsp/PathFilterer.spec.d.ts +0 -1
- package/dist/lsp/PathFilterer.spec.js +0 -182
- package/dist/lsp/PathFilterer.spec.js.map +0 -1
- package/dist/lsp/Project.spec.d.ts +0 -1
- package/dist/lsp/Project.spec.js +0 -267
- package/dist/lsp/Project.spec.js.map +0 -1
- package/dist/lsp/ProjectManager.spec.d.ts +0 -1
- package/dist/lsp/ProjectManager.spec.js +0 -913
- package/dist/lsp/ProjectManager.spec.js.map +0 -1
- package/dist/lsp/worker/MessageHandler.spec.d.ts +0 -1
- package/dist/lsp/worker/MessageHandler.spec.js +0 -64
- package/dist/lsp/worker/MessageHandler.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerPool.spec.d.ts +0 -1
- package/dist/lsp/worker/WorkerPool.spec.js +0 -59
- package/dist/lsp/worker/WorkerPool.spec.js.map +0 -1
- package/dist/lsp/worker/WorkerThreadProject.spec.d.ts +0 -2
- package/dist/lsp/worker/WorkerThreadProject.spec.js +0 -71
- package/dist/lsp/worker/WorkerThreadProject.spec.js.map +0 -1
- package/dist/parser/AstNode.spec.d.ts +0 -1
- package/dist/parser/AstNode.spec.js +0 -1455
- package/dist/parser/AstNode.spec.js.map +0 -1
- package/dist/parser/BrightScriptDocParser.spec.d.ts +0 -1
- package/dist/parser/BrightScriptDocParser.spec.js +0 -310
- package/dist/parser/BrightScriptDocParser.spec.js.map +0 -1
- package/dist/parser/Expression.spec.d.ts +0 -1
- package/dist/parser/Expression.spec.js +0 -40
- package/dist/parser/Expression.spec.js.map +0 -1
- package/dist/parser/Parser.Class.spec.d.ts +0 -1
- package/dist/parser/Parser.Class.spec.js +0 -520
- package/dist/parser/Parser.Class.spec.js.map +0 -1
- package/dist/parser/Parser.spec.d.ts +0 -6
- package/dist/parser/Parser.spec.js +0 -2802
- 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 -130
- package/dist/parser/SGParser.spec.js.map +0 -1
- package/dist/parser/Statement.spec.d.ts +0 -1
- package/dist/parser/Statement.spec.js +0 -191
- package/dist/parser/Statement.spec.js.map +0 -1
- package/dist/parser/tests/Parser.spec.d.ts +0 -12
- package/dist/parser/tests/Parser.spec.js +0 -29
- 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 -169
- 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 -140
- 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 -694
- 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 -114
- 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 -107
- 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 -304
- 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 -342
- 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 -90
- 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 -252
- 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 -412
- 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 -302
- 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 -346
- 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 -111
- 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 -165
- package/dist/parser/tests/expression/Primary.spec.js.map +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +0 -171
- package/dist/parser/tests/expression/RegexLiteralExpression.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 -389
- 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 -878
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/TypeExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +0 -126
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +0 -1
- package/dist/parser/tests/expression/UnaryExpression.spec.js +0 -52
- package/dist/parser/tests/expression/UnaryExpression.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/ConstStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +0 -500
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +0 -1
- package/dist/parser/tests/statement/Continue.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Continue.spec.js +0 -119
- package/dist/parser/tests/statement/Continue.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 -114
- 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 -80
- package/dist/parser/tests/statement/Dim.spec.js.map +0 -1
- package/dist/parser/tests/statement/Enum.spec.d.ts +0 -1
- package/dist/parser/tests/statement/Enum.spec.js +0 -744
- package/dist/parser/tests/statement/Enum.spec.js.map +0 -1
- package/dist/parser/tests/statement/For.spec.d.ts +0 -1
- package/dist/parser/tests/statement/For.spec.js +0 -45
- package/dist/parser/tests/statement/For.spec.js.map +0 -1
- package/dist/parser/tests/statement/ForEach.spec.d.ts +0 -1
- package/dist/parser/tests/statement/ForEach.spec.js +0 -36
- package/dist/parser/tests/statement/ForEach.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 -343
- 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 -51
- 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 -120
- package/dist/parser/tests/statement/Increment.spec.js.map +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.d.ts +0 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +0 -110
- package/dist/parser/tests/statement/InterfaceStatement.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 -292
- 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 -200
- 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 -97
- 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 -232
- 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 -38
- 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 -38
- 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 -151
- package/dist/parser/tests/statement/TryCatch.spec.js.map +0 -1
- package/dist/preprocessor/Manifest.spec.d.ts +0 -1
- package/dist/preprocessor/Manifest.spec.js +0 -80
- package/dist/preprocessor/Manifest.spec.js.map +0 -1
- package/dist/types/ArrayType.spec.d.ts +0 -1
- package/dist/types/ArrayType.spec.js +0 -58
- 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 -18
- package/dist/types/BooleanType.spec.js.map +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.d.ts +0 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +0 -115
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +0 -1
- package/dist/types/ClassType.spec.d.ts +0 -1
- package/dist/types/ClassType.spec.js +0 -76
- package/dist/types/ClassType.spec.js.map +0 -1
- package/dist/types/DoubleType.spec.d.ts +0 -1
- package/dist/types/DoubleType.spec.js +0 -20
- 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 -23
- package/dist/types/DynamicType.spec.js.map +0 -1
- package/dist/types/EnumType.spec.d.ts +0 -1
- package/dist/types/EnumType.spec.js +0 -33
- package/dist/types/EnumType.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/IntegerType.spec.d.ts +0 -1
- package/dist/types/IntegerType.spec.js +0 -16
- package/dist/types/IntegerType.spec.js.map +0 -1
- package/dist/types/InterfaceType.spec.d.ts +0 -1
- package/dist/types/InterfaceType.spec.js +0 -227
- package/dist/types/InterfaceType.spec.js.map +0 -1
- package/dist/types/IntersectionType.spec.d.ts +0 -1
- package/dist/types/IntersectionType.spec.js +0 -150
- package/dist/types/IntersectionType.spec.js.map +0 -1
- package/dist/types/InvalidType.spec.d.ts +0 -1
- package/dist/types/InvalidType.spec.js +0 -16
- package/dist/types/InvalidType.spec.js.map +0 -1
- package/dist/types/LongIntegerType.spec.d.ts +0 -1
- package/dist/types/LongIntegerType.spec.js +0 -18
- 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/ReferenceType.spec.d.ts +0 -1
- package/dist/types/ReferenceType.spec.js +0 -151
- package/dist/types/ReferenceType.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/TypedFunctionType.spec.d.ts +0 -1
- package/dist/types/TypedFunctionType.spec.js +0 -122
- package/dist/types/TypedFunctionType.spec.js.map +0 -1
- package/dist/types/UnionType.spec.d.ts +0 -1
- package/dist/types/UnionType.spec.js +0 -205
- package/dist/types/UnionType.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/types/helper.spec.d.ts +0 -1
- package/dist/types/helper.spec.js +0 -174
- package/dist/types/helper.spec.js.map +0 -1
- package/dist/types/roFunctionType.spec.d.ts +0 -1
- package/dist/types/roFunctionType.spec.js +0 -20
- package/dist/types/roFunctionType.spec.js.map +0 -1
package/dist/parser/Parser.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ import type { Logger } from '../logging';
|
|
|
5
5
|
import type { Statement } from './AstNode';
|
|
6
6
|
import type { BsDiagnostic } from '../interfaces';
|
|
7
7
|
export declare class Parser {
|
|
8
|
+
/**
|
|
9
|
+
* The minimum Roku firmware version that added native support for multi-line expressions
|
|
10
|
+
* (line continuation) in plain BrightScript (`.brs`) files.
|
|
11
|
+
*/
|
|
12
|
+
private static readonly LINE_CONTINUATION_MIN_FIRMWARE_VERSION;
|
|
8
13
|
/**
|
|
9
14
|
* The array of tokens passed to `parse()`
|
|
10
15
|
*/
|
|
@@ -34,6 +39,16 @@ export declare class Parser {
|
|
|
34
39
|
* The options used to parse the file
|
|
35
40
|
*/
|
|
36
41
|
options: ParseOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Whether line continuation after binary operators is allowed.
|
|
44
|
+
* Enabled in BrighterScript mode, or when minFirmwareVersion >= 15.3.
|
|
45
|
+
*/
|
|
46
|
+
private allowLineContinuation;
|
|
47
|
+
/**
|
|
48
|
+
* If line continuation is enabled, consumes all immediately following Newline tokens.
|
|
49
|
+
* Call this after matching a binary operator to allow the right-hand operand on the next line.
|
|
50
|
+
*/
|
|
51
|
+
private consumeNewlinesIfAllowed;
|
|
37
52
|
private globalTerminators;
|
|
38
53
|
/**
|
|
39
54
|
* A list of identifiers that are permitted to be used as local variables. We store this in a property because we augment the list in the constructor
|
|
@@ -231,6 +246,7 @@ export declare class Parser {
|
|
|
231
246
|
* @returns an expression that was successfully parsed
|
|
232
247
|
*/
|
|
233
248
|
private getTypeExpressionPart;
|
|
249
|
+
private typedFunctionTypeExpression;
|
|
234
250
|
private inlineInterface;
|
|
235
251
|
private inlineInterfaceMember;
|
|
236
252
|
private primary;
|
|
@@ -325,7 +341,14 @@ export interface ParseOptions {
|
|
|
325
341
|
*/
|
|
326
342
|
trackLocations?: boolean;
|
|
327
343
|
/**
|
|
328
|
-
*
|
|
344
|
+
* A map of BrightScript constants. If a constant is present in this map, it will be treated as a compile-time constant.
|
|
329
345
|
*/
|
|
330
346
|
bsConsts?: Map<string, boolean>;
|
|
347
|
+
/**
|
|
348
|
+
* The minimum Roku firmware version required to run this project.
|
|
349
|
+
* When set to '15.3' or higher, line continuation (multi-line expressions in `.brs` files)
|
|
350
|
+
* is enabled even in BrightScript mode because Roku OS 15.3 added native support for it.
|
|
351
|
+
* Should be a semver-compatible string (e.g. '15.3.0').
|
|
352
|
+
*/
|
|
353
|
+
minFirmwareVersion?: string;
|
|
331
354
|
}
|
package/dist/parser/Parser.js
CHANGED
|
@@ -11,6 +11,7 @@ const Expression_1 = require("./Expression");
|
|
|
11
11
|
const logging_1 = require("../logging");
|
|
12
12
|
const reflection_1 = require("../astUtils/reflection");
|
|
13
13
|
const creators_1 = require("../astUtils/creators");
|
|
14
|
+
const semver = require("semver");
|
|
14
15
|
const declarableTypesLower = TokenKind_1.DeclarableTypes.map(tokenKind => tokenKind.toLowerCase());
|
|
15
16
|
class Parser {
|
|
16
17
|
constructor() {
|
|
@@ -42,6 +43,15 @@ class Parser {
|
|
|
42
43
|
get symbolTable() {
|
|
43
44
|
return this.ast.symbolTable;
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* If line continuation is enabled, consumes all immediately following Newline tokens.
|
|
48
|
+
* Call this after matching a binary operator to allow the right-hand operand on the next line.
|
|
49
|
+
*/
|
|
50
|
+
consumeNewlinesIfAllowed() {
|
|
51
|
+
if (this.allowLineContinuation) {
|
|
52
|
+
while (this.match(TokenKind_1.TokenKind.Newline)) { }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
45
55
|
/**
|
|
46
56
|
* Get the currently active global terminators
|
|
47
57
|
*/
|
|
@@ -65,6 +75,8 @@ class Parser {
|
|
|
65
75
|
this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : (0, logging_1.createLogger)();
|
|
66
76
|
options = this.sanitizeParseOptions(options);
|
|
67
77
|
this.options = options;
|
|
78
|
+
const coercedMinFirmwareVersion = semver.coerce(this.options.minFirmwareVersion);
|
|
79
|
+
this.allowLineContinuation = options.mode === ParseMode.BrighterScript || (!!coercedMinFirmwareVersion && semver.gte(coercedMinFirmwareVersion, Parser.LINE_CONTINUATION_MIN_FIRMWARE_VERSION));
|
|
68
80
|
let tokens;
|
|
69
81
|
if (typeof toParse === 'string') {
|
|
70
82
|
tokens = Lexer_1.Lexer.scan(toParse, {
|
|
@@ -791,6 +803,9 @@ class Parser {
|
|
|
791
803
|
if (this.checkAlias()) {
|
|
792
804
|
return this.aliasStatement();
|
|
793
805
|
}
|
|
806
|
+
if (this.checkTypeStatement()) {
|
|
807
|
+
return this.typeStatement();
|
|
808
|
+
}
|
|
794
809
|
if (this.check(TokenKind_1.TokenKind.Stop)) {
|
|
795
810
|
return this.stopStatement();
|
|
796
811
|
}
|
|
@@ -896,20 +911,27 @@ class Parser {
|
|
|
896
911
|
return this.setStatement();
|
|
897
912
|
}
|
|
898
913
|
whileStatement() {
|
|
914
|
+
var _a, _b;
|
|
899
915
|
const whileKeyword = this.advance();
|
|
900
916
|
const condition = this.expression();
|
|
901
917
|
this.consumeStatementSeparators();
|
|
902
|
-
const whileBlock = this.block(TokenKind_1.TokenKind.EndWhile);
|
|
918
|
+
const whileBlock = this.block(TokenKind_1.TokenKind.EndWhile, TokenKind_1.TokenKind.Next);
|
|
903
919
|
let endWhile;
|
|
904
|
-
if (
|
|
905
|
-
|
|
920
|
+
if (whileBlock && this.peek().kind === TokenKind_1.TokenKind.EndWhile) {
|
|
921
|
+
endWhile = this.advance();
|
|
922
|
+
}
|
|
923
|
+
else if (whileBlock && this.peek().kind === TokenKind_1.TokenKind.Next) {
|
|
924
|
+
//recover: a stray `next` is a common mistake when the user means `end while`.
|
|
925
|
+
//emit a targeted diagnostic and consume the `next` so the rest of the file parses cleanly.
|
|
926
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndingToken(['end while'], 'next')), { location: (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.location }));
|
|
927
|
+
endWhile = this.advance();
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.couldNotFindMatchingEndKeyword('while')), { location: (_b = this.peek()) === null || _b === void 0 ? void 0 : _b.location }));
|
|
906
931
|
if (!whileBlock) {
|
|
907
932
|
throw this.lastDiagnosticAsError();
|
|
908
933
|
}
|
|
909
934
|
}
|
|
910
|
-
else {
|
|
911
|
-
endWhile = this.advance();
|
|
912
|
-
}
|
|
913
935
|
return new Statement_1.WhileStatement({
|
|
914
936
|
while: whileKeyword,
|
|
915
937
|
endWhile: endWhile,
|
|
@@ -941,6 +963,7 @@ class Parser {
|
|
|
941
963
|
});
|
|
942
964
|
}
|
|
943
965
|
forStatement() {
|
|
966
|
+
var _a, _b;
|
|
944
967
|
const forToken = this.advance();
|
|
945
968
|
const initializer = this.assignment();
|
|
946
969
|
//TODO: newline allowed?
|
|
@@ -956,17 +979,22 @@ class Parser {
|
|
|
956
979
|
// BrightScript for/to/step loops default to a step of 1 if no `step` is provided
|
|
957
980
|
}
|
|
958
981
|
this.consumeStatementSeparators();
|
|
959
|
-
let body = this.block(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next);
|
|
982
|
+
let body = this.block(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next, TokenKind_1.TokenKind.EndWhile);
|
|
960
983
|
let endForToken;
|
|
961
|
-
if (
|
|
962
|
-
|
|
984
|
+
if (body && this.checkAny(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next)) {
|
|
985
|
+
endForToken = this.advance();
|
|
986
|
+
}
|
|
987
|
+
else if (body && this.peek().kind === TokenKind_1.TokenKind.EndWhile) {
|
|
988
|
+
//recover: a stray `end while` is a common mistake when the user means `end for`.
|
|
989
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndingToken(['end for', 'next'], 'end while')), { location: (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.location }));
|
|
990
|
+
endForToken = this.advance();
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedEndForOrNextToTerminateForLoop(forToken.text)), { location: (_b = this.peek()) === null || _b === void 0 ? void 0 : _b.location }));
|
|
963
994
|
if (!body) {
|
|
964
995
|
throw this.lastDiagnosticAsError();
|
|
965
996
|
}
|
|
966
997
|
}
|
|
967
|
-
else {
|
|
968
|
-
endForToken = this.advance();
|
|
969
|
-
}
|
|
970
998
|
// WARNING: BrightScript doesn't delete the loop initial value after a for/to loop! It just
|
|
971
999
|
// stays around in scope with whatever value it was when the loop exited.
|
|
972
1000
|
return new Statement_1.ForStatement({
|
|
@@ -981,6 +1009,7 @@ class Parser {
|
|
|
981
1009
|
});
|
|
982
1010
|
}
|
|
983
1011
|
forEachStatement() {
|
|
1012
|
+
var _a;
|
|
984
1013
|
let forEach = this.advance();
|
|
985
1014
|
let name = this.advance();
|
|
986
1015
|
let asToken;
|
|
@@ -1004,19 +1033,26 @@ class Parser {
|
|
|
1004
1033
|
throw this.lastDiagnosticAsError();
|
|
1005
1034
|
}
|
|
1006
1035
|
this.consumeStatementSeparators();
|
|
1007
|
-
let body = this.block(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next);
|
|
1008
|
-
let
|
|
1009
|
-
if (
|
|
1036
|
+
let body = this.block(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next, TokenKind_1.TokenKind.EndWhile);
|
|
1037
|
+
let endFor;
|
|
1038
|
+
if (body && this.checkAny(TokenKind_1.TokenKind.EndFor, TokenKind_1.TokenKind.Next)) {
|
|
1039
|
+
endFor = this.advance();
|
|
1040
|
+
}
|
|
1041
|
+
else if (body && this.peek().kind === TokenKind_1.TokenKind.EndWhile) {
|
|
1042
|
+
//recover: a stray `end while` is a common mistake when the user means `end for`.
|
|
1043
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndingToken(['end for', 'next'], 'end while')), { location: (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.location }));
|
|
1044
|
+
endFor = this.advance();
|
|
1045
|
+
}
|
|
1046
|
+
else {
|
|
1010
1047
|
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedEndForOrNextToTerminateForLoop(forEach.text)), { location: this.peek().location }));
|
|
1011
1048
|
throw this.lastDiagnosticAsError();
|
|
1012
1049
|
}
|
|
1013
|
-
endForToken = this.advance();
|
|
1014
1050
|
return new Statement_1.ForEachStatement({
|
|
1015
1051
|
forEach: forEach,
|
|
1016
1052
|
as: asToken,
|
|
1017
1053
|
typeExpression: typeExpression,
|
|
1018
1054
|
in: maybeIn,
|
|
1019
|
-
endFor:
|
|
1055
|
+
endFor: endFor,
|
|
1020
1056
|
item: name,
|
|
1021
1057
|
target: target,
|
|
1022
1058
|
body: body
|
|
@@ -1821,7 +1857,25 @@ class Parser {
|
|
|
1821
1857
|
if (this.checkAny(...TokenKind_1.BinaryExpressionOperatorTokens)) {
|
|
1822
1858
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: this.advance(), right: this.expression() });
|
|
1823
1859
|
}
|
|
1824
|
-
//
|
|
1860
|
+
//you're not allowed to do dottedGet or XmlAttrGet after a function call
|
|
1861
|
+
if ((0, reflection_1.isDottedGetExpression)(expr)) {
|
|
1862
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.propAccessNotPermittedAfterFunctionCallInExpressionStatement('Property')), { location: util_1.util.createBoundingLocation(expr.tokens.dot, expr.tokens.name) }));
|
|
1863
|
+
//we can recover gracefully here even though it's invalid syntax
|
|
1864
|
+
return new Statement_1.ExpressionStatement({ expression: expr });
|
|
1865
|
+
//you're not allowed to do indexedGet expressions after a function call
|
|
1866
|
+
}
|
|
1867
|
+
else if ((0, reflection_1.isIndexedGetExpression)(expr)) {
|
|
1868
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.propAccessNotPermittedAfterFunctionCallInExpressionStatement('Index')), { location: util_1.util.createBoundingLocation(expr.tokens.openingSquare, ...expr.indexes, expr.tokens.closingSquare) }));
|
|
1869
|
+
//we can recover gracefully here even though it's invalid syntax
|
|
1870
|
+
return new Statement_1.ExpressionStatement({ expression: expr });
|
|
1871
|
+
//you're not allowed to do XmlAttrGet after a function call
|
|
1872
|
+
}
|
|
1873
|
+
else if ((0, reflection_1.isXmlAttributeGetExpression)(expr)) {
|
|
1874
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.propAccessNotPermittedAfterFunctionCallInExpressionStatement('XML attribute')), { location: util_1.util.createBoundingLocation(expr.tokens.at, expr.tokens.name) }));
|
|
1875
|
+
//we can recover gracefully here even though it's invalid syntax
|
|
1876
|
+
return new Statement_1.ExpressionStatement({ expression: expr });
|
|
1877
|
+
}
|
|
1878
|
+
//at this point, it's probably an error. However, we recover a little more gracefully by creating an assignment
|
|
1825
1879
|
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.expectedStatement()), { location: expressionStart.location }));
|
|
1826
1880
|
return new Statement_1.ExpressionStatement({ expression: expr });
|
|
1827
1881
|
}
|
|
@@ -2086,6 +2140,7 @@ class Parser {
|
|
|
2086
2140
|
let expr = this.relational();
|
|
2087
2141
|
while (this.matchAny(TokenKind_1.TokenKind.And, TokenKind_1.TokenKind.Or)) {
|
|
2088
2142
|
let operator = this.previous();
|
|
2143
|
+
this.consumeNewlinesIfAllowed();
|
|
2089
2144
|
let right = this.relational();
|
|
2090
2145
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: operator, right: right });
|
|
2091
2146
|
}
|
|
@@ -2095,6 +2150,7 @@ class Parser {
|
|
|
2095
2150
|
let expr = this.additive();
|
|
2096
2151
|
while (this.matchAny(TokenKind_1.TokenKind.Equal, TokenKind_1.TokenKind.LessGreater, TokenKind_1.TokenKind.Greater, TokenKind_1.TokenKind.GreaterEqual, TokenKind_1.TokenKind.Less, TokenKind_1.TokenKind.LessEqual)) {
|
|
2097
2152
|
let operator = this.previous();
|
|
2153
|
+
this.consumeNewlinesIfAllowed();
|
|
2098
2154
|
let right = this.additive();
|
|
2099
2155
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: operator, right: right });
|
|
2100
2156
|
}
|
|
@@ -2105,6 +2161,7 @@ class Parser {
|
|
|
2105
2161
|
let expr = this.multiplicative();
|
|
2106
2162
|
while (this.matchAny(TokenKind_1.TokenKind.Plus, TokenKind_1.TokenKind.Minus)) {
|
|
2107
2163
|
let operator = this.previous();
|
|
2164
|
+
this.consumeNewlinesIfAllowed();
|
|
2108
2165
|
let right = this.multiplicative();
|
|
2109
2166
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: operator, right: right });
|
|
2110
2167
|
}
|
|
@@ -2114,6 +2171,7 @@ class Parser {
|
|
|
2114
2171
|
let expr = this.exponential();
|
|
2115
2172
|
while (this.matchAny(TokenKind_1.TokenKind.Forwardslash, TokenKind_1.TokenKind.Backslash, TokenKind_1.TokenKind.Star, TokenKind_1.TokenKind.Mod, TokenKind_1.TokenKind.LeftShift, TokenKind_1.TokenKind.RightShift)) {
|
|
2116
2173
|
let operator = this.previous();
|
|
2174
|
+
this.consumeNewlinesIfAllowed();
|
|
2117
2175
|
let right = this.exponential();
|
|
2118
2176
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: operator, right: right });
|
|
2119
2177
|
}
|
|
@@ -2123,6 +2181,7 @@ class Parser {
|
|
|
2123
2181
|
let expr = this.prefixUnary();
|
|
2124
2182
|
while (this.match(TokenKind_1.TokenKind.Caret)) {
|
|
2125
2183
|
let operator = this.previous();
|
|
2184
|
+
this.consumeNewlinesIfAllowed();
|
|
2126
2185
|
let right = this.prefixUnary();
|
|
2127
2186
|
expr = new Expression_1.BinaryExpression({ left: expr, operator: operator, right: right });
|
|
2128
2187
|
}
|
|
@@ -2269,16 +2328,31 @@ class Parser {
|
|
|
2269
2328
|
return expr;
|
|
2270
2329
|
}
|
|
2271
2330
|
finishCall(openingParen, callee, addToCallExpressionList = true) {
|
|
2272
|
-
var _a;
|
|
2331
|
+
var _a, _b, _c;
|
|
2273
2332
|
let args = [];
|
|
2274
|
-
|
|
2333
|
+
this.consumeNewlinesIfAllowed();
|
|
2275
2334
|
if (!this.check(TokenKind_1.TokenKind.RightParen)) {
|
|
2276
2335
|
do {
|
|
2277
|
-
|
|
2336
|
+
this.consumeNewlinesIfAllowed();
|
|
2278
2337
|
if (args.length >= Expression_1.CallExpression.MaximumArguments) {
|
|
2279
2338
|
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableArguments(args.length, Expression_1.CallExpression.MaximumArguments)), { location: (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.location }));
|
|
2280
2339
|
throw this.lastDiagnosticAsError();
|
|
2281
2340
|
}
|
|
2341
|
+
//if a newline appears where we'd next read an argument and line continuation isn't
|
|
2342
|
+
//allowed in this mode, peek past the newlines: if the following token can't begin an
|
|
2343
|
+
//argument expression (e.g. `end function`, `end sub`, EOF), this is clearly an
|
|
2344
|
+
//unclosed-paren situation and we swallow the newlines so the diagnostic from
|
|
2345
|
+
//expression() reports the surprising token rather than the newline itself.
|
|
2346
|
+
if (!this.allowLineContinuation && this.check(TokenKind_1.TokenKind.Newline)) {
|
|
2347
|
+
let lookahead = this.current;
|
|
2348
|
+
while (((_b = this.tokens[lookahead]) === null || _b === void 0 ? void 0 : _b.kind) === TokenKind_1.TokenKind.Newline) {
|
|
2349
|
+
lookahead++;
|
|
2350
|
+
}
|
|
2351
|
+
const followingKind = (_c = this.tokens[lookahead]) === null || _c === void 0 ? void 0 : _c.kind;
|
|
2352
|
+
if (followingKind === TokenKind_1.TokenKind.EndFunction || followingKind === TokenKind_1.TokenKind.EndSub || followingKind === TokenKind_1.TokenKind.Eof) {
|
|
2353
|
+
while (this.match(TokenKind_1.TokenKind.Newline)) { }
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2282
2356
|
try {
|
|
2283
2357
|
args.push(this.expression());
|
|
2284
2358
|
}
|
|
@@ -2289,7 +2363,16 @@ class Parser {
|
|
|
2289
2363
|
}
|
|
2290
2364
|
} while (this.match(TokenKind_1.TokenKind.Comma));
|
|
2291
2365
|
}
|
|
2292
|
-
|
|
2366
|
+
this.consumeNewlinesIfAllowed();
|
|
2367
|
+
//if no closing `)` is in sight (e.g. we hit a newline that line-continuation is not allowed
|
|
2368
|
+
//to swallow), consume newlines anyway as part of error recovery so the unmatched-left-token
|
|
2369
|
+
//diagnostic points at the surprising token (e.g. `end sub`) rather than the `\n`. This also
|
|
2370
|
+
//ensures the surrounding block sees a non-separator next token and emits its own
|
|
2371
|
+
//`expectedNewlineOrColon` diagnostic.
|
|
2372
|
+
const recoveredFromMissingRightParen = !this.check(TokenKind_1.TokenKind.RightParen);
|
|
2373
|
+
if (recoveredFromMissingRightParen) {
|
|
2374
|
+
while (this.match(TokenKind_1.TokenKind.Newline)) { }
|
|
2375
|
+
}
|
|
2293
2376
|
const closingParen = this.tryConsume(DiagnosticMessages_1.DiagnosticMessages.unmatchedLeftToken(openingParen.text, 'function call arguments'), TokenKind_1.TokenKind.RightParen);
|
|
2294
2377
|
let expression = new Expression_1.CallExpression({
|
|
2295
2378
|
callee: callee,
|
|
@@ -2362,16 +2445,25 @@ class Parser {
|
|
|
2362
2445
|
getTypeExpressionPart(changedTokens) {
|
|
2363
2446
|
var _a, _b;
|
|
2364
2447
|
let expr;
|
|
2365
|
-
if (this.checkAny(
|
|
2448
|
+
if (this.checkAny(TokenKind_1.TokenKind.Sub, TokenKind_1.TokenKind.Function) && this.checkNext(TokenKind_1.TokenKind.LeftParen)) {
|
|
2449
|
+
// this is a tyyed function type expression, eg. "function(type1, type2) as type3"
|
|
2450
|
+
this.warnIfNotBrighterScriptMode('typed function types');
|
|
2451
|
+
expr = this.typedFunctionTypeExpression();
|
|
2452
|
+
}
|
|
2453
|
+
else if (this.checkAny(...TokenKind_1.DeclarableTypes)) {
|
|
2366
2454
|
// if this is just a type, just use directly
|
|
2367
2455
|
expr = new Expression_1.VariableExpression({ name: this.advance() });
|
|
2368
2456
|
}
|
|
2369
2457
|
else {
|
|
2370
2458
|
if (this.options.mode === ParseMode.BrightScript && !declarableTypesLower.includes((_b = (_a = this.peek()) === null || _a === void 0 ? void 0 : _a.text) === null || _b === void 0 ? void 0 : _b.toLowerCase())) {
|
|
2371
|
-
//
|
|
2372
|
-
|
|
2373
|
-
this.
|
|
2374
|
-
|
|
2459
|
+
//inline interfaces have their own diagnostic ('inline interface'); let `{`
|
|
2460
|
+
//flow through to the matcher below so it fires the more-specific warning.
|
|
2461
|
+
if (!this.check(TokenKind_1.TokenKind.LeftCurlyBrace)) {
|
|
2462
|
+
// custom types arrays not allowed in Brightscript
|
|
2463
|
+
this.warnIfNotBrighterScriptMode('custom types');
|
|
2464
|
+
this.advance(); // skip custom type token
|
|
2465
|
+
return expr;
|
|
2466
|
+
}
|
|
2375
2467
|
}
|
|
2376
2468
|
if (this.match(TokenKind_1.TokenKind.LeftCurlyBrace)) {
|
|
2377
2469
|
expr = this.inlineInterface();
|
|
@@ -2413,9 +2505,37 @@ class Parser {
|
|
|
2413
2505
|
}
|
|
2414
2506
|
return expr;
|
|
2415
2507
|
}
|
|
2508
|
+
typedFunctionTypeExpression() {
|
|
2509
|
+
const funcOrSub = this.advance();
|
|
2510
|
+
const openParen = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedToken(TokenKind_1.TokenKind.LeftParen), TokenKind_1.TokenKind.LeftParen);
|
|
2511
|
+
const params = [];
|
|
2512
|
+
if (!this.check(TokenKind_1.TokenKind.RightParen)) {
|
|
2513
|
+
do {
|
|
2514
|
+
if (params.length >= Expression_1.CallExpression.MaximumArguments) {
|
|
2515
|
+
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.tooManyCallableParameters(params.length, Expression_1.CallExpression.MaximumArguments)), { location: this.peek().location }));
|
|
2516
|
+
}
|
|
2517
|
+
params.push(this.functionParameter());
|
|
2518
|
+
} while (this.match(TokenKind_1.TokenKind.Comma));
|
|
2519
|
+
}
|
|
2520
|
+
const closeParen = this.consume(DiagnosticMessages_1.DiagnosticMessages.unmatchedLeftToken(openParen.text, 'function type expression'), TokenKind_1.TokenKind.RightParen);
|
|
2521
|
+
let asToken;
|
|
2522
|
+
let returnType;
|
|
2523
|
+
if (this.check(TokenKind_1.TokenKind.As)) {
|
|
2524
|
+
[asToken, returnType] = this.consumeAsTokenAndTypeExpression();
|
|
2525
|
+
}
|
|
2526
|
+
return new Expression_1.TypedFunctionTypeExpression({
|
|
2527
|
+
functionType: funcOrSub,
|
|
2528
|
+
rightParen: openParen,
|
|
2529
|
+
params: params,
|
|
2530
|
+
leftParen: closeParen,
|
|
2531
|
+
as: asToken,
|
|
2532
|
+
returnType: returnType
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2416
2535
|
inlineInterface() {
|
|
2417
2536
|
let expr;
|
|
2418
2537
|
const openToken = this.previous();
|
|
2538
|
+
this.warnIfNotBrighterScriptMode('inline interface');
|
|
2419
2539
|
const members = [];
|
|
2420
2540
|
while (this.match(TokenKind_1.TokenKind.Newline)) { }
|
|
2421
2541
|
while (this.checkAny(TokenKind_1.TokenKind.Identifier, ...TokenKind_1.AllowedProperties, TokenKind_1.TokenKind.StringLiteral, TokenKind_1.TokenKind.Optional)) {
|
|
@@ -2560,12 +2680,22 @@ class Parser {
|
|
|
2560
2680
|
let openingBrace = this.previous();
|
|
2561
2681
|
let members = [];
|
|
2562
2682
|
let key = () => {
|
|
2683
|
+
var _a;
|
|
2563
2684
|
let result = {
|
|
2564
|
-
|
|
2685
|
+
colon: null,
|
|
2565
2686
|
keyToken: null,
|
|
2687
|
+
key: null,
|
|
2688
|
+
leftBracket: null,
|
|
2689
|
+
rightBracket: null,
|
|
2566
2690
|
range: null
|
|
2567
2691
|
};
|
|
2568
|
-
if (this.
|
|
2692
|
+
if (this.check(TokenKind_1.TokenKind.LeftSquareBracket)) {
|
|
2693
|
+
// Computed key: [expr]
|
|
2694
|
+
result.leftBracket = this.advance();
|
|
2695
|
+
result.key = this.expression();
|
|
2696
|
+
result.rightBracket = this.tryConsumeToken(TokenKind_1.TokenKind.RightSquareBracket);
|
|
2697
|
+
}
|
|
2698
|
+
else if (this.checkAny(TokenKind_1.TokenKind.Identifier, ...TokenKind_1.AllowedProperties)) {
|
|
2569
2699
|
result.keyToken = this.identifier(...TokenKind_1.AllowedProperties);
|
|
2570
2700
|
}
|
|
2571
2701
|
else if (this.check(TokenKind_1.TokenKind.StringLiteral)) {
|
|
@@ -2575,8 +2705,8 @@ class Parser {
|
|
|
2575
2705
|
this.diagnostics.push(Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.unexpectedAAKey()), { location: this.peek().location }));
|
|
2576
2706
|
throw this.lastDiagnosticAsError();
|
|
2577
2707
|
}
|
|
2578
|
-
result.
|
|
2579
|
-
result.range = util_1.util.createBoundingRange(result.keyToken, result.
|
|
2708
|
+
result.colon = this.consume(DiagnosticMessages_1.DiagnosticMessages.expectedColonBetweenAAKeyAndvalue(), TokenKind_1.TokenKind.Colon);
|
|
2709
|
+
result.range = util_1.util.createBoundingRange((_a = result.keyToken) !== null && _a !== void 0 ? _a : result.leftBracket, result.colon);
|
|
2580
2710
|
return result;
|
|
2581
2711
|
};
|
|
2582
2712
|
while (this.match(TokenKind_1.TokenKind.Newline)) { }
|
|
@@ -2586,11 +2716,13 @@ class Parser {
|
|
|
2586
2716
|
try {
|
|
2587
2717
|
let k = key();
|
|
2588
2718
|
let expr = this.expression();
|
|
2589
|
-
lastAAMember =
|
|
2590
|
-
key: k.
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2719
|
+
lastAAMember = k.key
|
|
2720
|
+
? new Expression_1.AAIndexedMemberExpression({ leftBracket: k.leftBracket, key: k.key, rightBracket: k.rightBracket, colon: k.colon, value: expr })
|
|
2721
|
+
: new Expression_1.AAMemberExpression({
|
|
2722
|
+
key: k.keyToken,
|
|
2723
|
+
colon: k.colon,
|
|
2724
|
+
value: expr
|
|
2725
|
+
});
|
|
2594
2726
|
members.push(lastAAMember);
|
|
2595
2727
|
while (this.matchAny(TokenKind_1.TokenKind.Comma, TokenKind_1.TokenKind.Newline, TokenKind_1.TokenKind.Colon, TokenKind_1.TokenKind.Comment)) {
|
|
2596
2728
|
// collect comma at end of expression
|
|
@@ -2603,11 +2735,13 @@ class Parser {
|
|
|
2603
2735
|
}
|
|
2604
2736
|
let k = key();
|
|
2605
2737
|
let expr = this.expression();
|
|
2606
|
-
lastAAMember =
|
|
2607
|
-
key: k.
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2738
|
+
lastAAMember = k.key
|
|
2739
|
+
? new Expression_1.AAIndexedMemberExpression({ leftBracket: k.leftBracket, key: k.key, rightBracket: k.rightBracket, colon: k.colon, value: expr })
|
|
2740
|
+
: new Expression_1.AAMemberExpression({
|
|
2741
|
+
key: k.keyToken,
|
|
2742
|
+
colon: k.colon,
|
|
2743
|
+
value: expr
|
|
2744
|
+
});
|
|
2611
2745
|
members.push(lastAAMember);
|
|
2612
2746
|
}
|
|
2613
2747
|
}
|
|
@@ -2834,6 +2968,11 @@ class Parser {
|
|
|
2834
2968
|
}
|
|
2835
2969
|
}
|
|
2836
2970
|
exports.Parser = Parser;
|
|
2971
|
+
/**
|
|
2972
|
+
* The minimum Roku firmware version that added native support for multi-line expressions
|
|
2973
|
+
* (line continuation) in plain BrightScript (`.brs`) files.
|
|
2974
|
+
*/
|
|
2975
|
+
Parser.LINE_CONTINUATION_MIN_FIRMWARE_VERSION = '15.3.0';
|
|
2837
2976
|
var ParseMode;
|
|
2838
2977
|
(function (ParseMode) {
|
|
2839
2978
|
ParseMode["BrightScript"] = "BrightScript";
|