@octopusdeploy/ocl
Advanced tools
Comparing version 0.0.6 to 0.1.0
# Changelog | ||
## [0.1.0](https://www.github.com/OctopusDeploy/ocl.ts/compare/v0.0.6...v0.1.0) (2021-10-27) | ||
### Features | ||
* parse dictionary array ([cc6a797](https://www.github.com/OctopusDeploy/ocl.ts/commit/cc6a7972d11294a18bb9a089088aa4cfc44d1b46)) | ||
* tolerance on parsing arrays ([ee2973f](https://www.github.com/OctopusDeploy/ocl.ts/commit/ee2973f312f3619590e7d0066487b1ea86b2e48f)) | ||
* tolerance on parsing blocks ([fb69a50](https://www.github.com/OctopusDeploy/ocl.ts/commit/fb69a50b305ad15f38ed618aea86de0b6bd8f05e)) | ||
* tolerance on parsing dictionaries ([24b5663](https://www.github.com/OctopusDeploy/ocl.ts/commit/24b5663d4619256a6de5c92fc64e7bbe74754cee)) | ||
* tolerance on parsing symbols ([1a5f131](https://www.github.com/OctopusDeploy/ocl.ts/commit/1a5f13194cf9e420a71c5049c50fc67b4e71b5e2)) | ||
### [0.0.6](https://www.github.com/OctopusDeploy/ocl.ts/compare/v0.0.5...v0.0.6) (2021-10-25) | ||
@@ -4,0 +15,0 @@ |
@@ -33,3 +33,3 @@ import type { Token } from "./token"; | ||
type: NodeType.ARRAY_NODE; | ||
values: (LiteralNode | DictionaryNode)[]; | ||
values: (LiteralNode | DictionaryNode | RecoveryNode)[]; | ||
} | ||
@@ -56,3 +56,3 @@ export interface AttributeNode extends BaseNode { | ||
children: AST; | ||
entries: AttributeNode[]; | ||
entries: (AttributeNode | RecoveryNode)[]; | ||
type: NodeType.DICTIONARY_NODE; | ||
@@ -59,0 +59,0 @@ } |
@@ -34,2 +34,5 @@ "use strict"; | ||
} | ||
if (this.pc + i < 0) { | ||
return this.tokens[0]; | ||
} | ||
return this.tokens[this.pc + i]; | ||
@@ -70,3 +73,4 @@ }; | ||
default: { | ||
return this.handleAttribute(); | ||
this.nextToken(); | ||
return this.handleRecoveryNode('Unexpected token. Expected Arrtibute or Block definition.', this.currentToken); | ||
} | ||
@@ -153,6 +157,7 @@ } | ||
Parser.prototype.handleDictionaryNode = function () { | ||
var problems = []; | ||
var blockStart = this.currentToken; | ||
this.nextToken(); | ||
var entries = []; | ||
while (this.peekToken().tokenType !== token_1.TokenType.CLOSE_BRACKET) { | ||
while (![token_1.TokenType.CLOSE_BRACKET, token_1.TokenType.EOF].includes(this.peekToken().tokenType)) { | ||
if (this.currentToken.tokenType === token_1.TokenType.SYMBOL) { | ||
@@ -162,2 +167,6 @@ entries.push(this.handleAttribute()); | ||
else { | ||
if (this.currentToken.tokenType !== token_1.TokenType.NEW_LINE) { | ||
problems.push('Unexpected Token. Expected attribute.'); | ||
entries.push(this.handleRecoveryNode('Unexpected Token. Expected attribute.', this.currentToken)); | ||
} | ||
this.nextToken(); | ||
@@ -168,2 +177,14 @@ } | ||
var blockEnd = this.currentToken; | ||
if (this.currentToken.tokenType !== token_1.TokenType.CLOSE_BRACKET) { | ||
problems.push('Unexpected Token. Expected }.'); | ||
blockEnd = { | ||
value: '}', | ||
tokenType: token_1.TokenType.RECOVERY, | ||
col: this.currentToken.col, | ||
ln: this.currentToken.ln | ||
}; | ||
} | ||
if (this.peekToken().tokenType !== token_1.TokenType.NEW_LINE) { | ||
problems.push('Unexpected token. Expected new line.'); | ||
} | ||
var dictionaryNode = { | ||
@@ -174,3 +195,4 @@ children: entries, | ||
entries: entries, | ||
type: ast_1.NodeType.DICTIONARY_NODE | ||
type: ast_1.NodeType.DICTIONARY_NODE, | ||
problems: problems | ||
}; | ||
@@ -184,6 +206,13 @@ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { | ||
Parser.prototype.handleArrayNode = function () { | ||
var problems = []; | ||
var arrayStart = this.currentToken; | ||
this.nextToken(); | ||
var values = []; | ||
while (this.currentToken.tokenType !== token_1.TokenType.CLOSE_ARRAY) { | ||
while (![token_1.TokenType.CLOSE_ARRAY, token_1.TokenType.EOF].includes(this.currentToken.tokenType)) { | ||
while (this.currentToken.tokenType === token_1.TokenType.NEW_LINE) { | ||
this.nextToken(); | ||
} | ||
if ([token_1.TokenType.CLOSE_ARRAY].includes(this.currentToken.tokenType)) { | ||
break; | ||
} | ||
switch (this.currentToken.tokenType) { | ||
@@ -202,3 +231,35 @@ case token_1.TokenType.STRING: { | ||
} | ||
case token_1.TokenType.OPEN_BRACKET: { | ||
values.push(this.handleDictionaryNode()); | ||
break; | ||
} | ||
default: { | ||
problems.push('Unexpected Token. Expected literal.'); | ||
values.push(this.handleRecoveryNode('Unexpected Token. Expected literal.', this.currentToken)); | ||
break; | ||
} | ||
} | ||
if (values[values.length - 1].type === ast_1.NodeType.RECOVERY_NODE && this.currentToken.tokenType === token_1.TokenType.SYMBOL) { | ||
if (this.peekToken().tokenType === token_1.TokenType.ASSIGNMENT_OP) { | ||
this.currentToken = this.peekToken(-1); | ||
this.pc -= 1; | ||
break; | ||
} | ||
else if (this.peekToken().tokenType === token_1.TokenType.STRING) { | ||
var peekCounter = 2; | ||
while (this.peekToken(peekCounter).tokenType === token_1.TokenType.STRING) { | ||
peekCounter += 1; | ||
} | ||
if (this.peekToken(peekCounter).tokenType === token_1.TokenType.OPEN_BRACKET) { | ||
this.currentToken = this.peekToken(-1); | ||
this.pc -= 1; | ||
break; | ||
} | ||
} | ||
else if (this.peekToken().tokenType === token_1.TokenType.OPEN_BRACKET) { | ||
this.currentToken = this.peekToken(-1); | ||
this.pc -= 1; | ||
break; | ||
} | ||
} | ||
this.nextToken(); | ||
@@ -208,8 +269,25 @@ if (this.currentToken.tokenType === token_1.TokenType.ARRAY_ITEM_SEPERATOR) { | ||
} | ||
while (this.currentToken.tokenType === token_1.TokenType.NEW_LINE) { | ||
this.nextToken(); | ||
else if (![token_1.TokenType.CLOSE_ARRAY].includes(this.currentToken.tokenType)) { | ||
while (this.peekToken(0).tokenType === token_1.TokenType.NEW_LINE) { | ||
this.nextToken(); | ||
} | ||
if (this.peekToken(0).tokenType !== token_1.TokenType.CLOSE_ARRAY) { | ||
problems.push('Missing Token. Expected seperator.'); | ||
} | ||
} | ||
} | ||
var arrayEnd = this.currentToken; | ||
this.nextToken(); | ||
if (this.currentToken.tokenType !== token_1.TokenType.CLOSE_ARRAY) { | ||
problems.push('Missing Token. Expected ].'); | ||
arrayEnd = { | ||
value: ']', | ||
tokenType: token_1.TokenType.RECOVERY, | ||
tokenError: '', | ||
col: this.currentToken.col, | ||
ln: this.currentToken.ln | ||
}; | ||
} | ||
else { | ||
this.nextToken(); | ||
} | ||
var arrayNode = { | ||
@@ -220,3 +298,4 @@ children: values, | ||
arrayEnd: arrayEnd, | ||
values: values | ||
values: values, | ||
problems: problems, | ||
}; | ||
@@ -230,2 +309,3 @@ for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { | ||
Parser.prototype.handleBlockNode = function () { | ||
var problems = []; | ||
var name = this.currentToken; | ||
@@ -238,6 +318,16 @@ this.nextToken(); | ||
} | ||
var blockStart = this.currentToken; | ||
if (this.currentToken.tokenType !== token_1.TokenType.OPEN_BRACKET) { | ||
problems.push('Missing token. Expected {.'); | ||
var token = this.peekToken(-1); | ||
blockStart = { | ||
value: '{', | ||
tokenType: token_1.TokenType.RECOVERY, | ||
col: token.col, | ||
ln: token.ln, | ||
}; | ||
} | ||
var blockStart = this.currentToken; | ||
this.nextToken(); | ||
else { | ||
this.nextToken(); | ||
} | ||
if (this.currentToken.tokenType === token_1.TokenType.NEW_LINE) { | ||
@@ -247,2 +337,3 @@ this.nextToken(); | ||
else if (this.currentToken.tokenType !== token_1.TokenType.CLOSE_BRACKET) { | ||
problems.push('Missing token. Expected new line.'); | ||
} | ||
@@ -252,3 +343,8 @@ var block = []; | ||
![token_1.TokenType.CLOSE_BRACKET, token_1.TokenType.EOF].includes(this.currentToken.tokenType)) { | ||
block.push(this.nextNode()); | ||
if (this.currentToken.tokenType !== token_1.TokenType.NEW_LINE) { | ||
block.push(this.nextNode()); | ||
} | ||
else { | ||
this.nextToken(); | ||
} | ||
} | ||
@@ -259,3 +355,14 @@ if (![token_1.TokenType.CLOSE_BRACKET, token_1.TokenType.EOF].includes(this.currentToken.tokenType)) { | ||
var blockEnd = this.currentToken; | ||
this.nextToken(); | ||
if (this.currentToken.tokenType === token_1.TokenType.EOF) { | ||
problems.push('Missing token. Expected }.'); | ||
blockEnd = { | ||
value: '}', | ||
tokenType: token_1.TokenType.RECOVERY, | ||
col: this.currentToken.col, | ||
ln: this.currentToken.ln, | ||
}; | ||
} | ||
else { | ||
this.nextToken(); | ||
} | ||
var blockNode = { | ||
@@ -268,2 +375,3 @@ block: block, | ||
name: name, | ||
problems: problems, | ||
}; | ||
@@ -270,0 +378,0 @@ if (labels.length > 0) { |
@@ -15,3 +15,4 @@ export declare enum TokenType { | ||
STRING = 12, | ||
SYMBOL = 13 | ||
SYMBOL = 13, | ||
RECOVERY = 14 | ||
} | ||
@@ -18,0 +19,0 @@ export interface Token { |
@@ -20,3 +20,4 @@ "use strict"; | ||
TokenType[TokenType["SYMBOL"] = 13] = "SYMBOL"; | ||
TokenType[TokenType["RECOVERY"] = 14] = "RECOVERY"; | ||
})(TokenType = exports.TokenType || (exports.TokenType = {})); | ||
//# sourceMappingURL=token.js.map |
@@ -44,3 +44,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "0.0.6" | ||
"version": "0.1.0" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52552
801