|
@ -68,9 +68,23 @@ String.prototype.regexIndexOf = function (pattern, startIndex) { |
|
|
return (-1 === searchResult) ? -1 : searchResult + startIndex; |
|
|
return (-1 === searchResult) ? -1 : searchResult + startIndex; |
|
|
}; |
|
|
}; |
|
|
String.prototype.regexLastIndexOf = function (pattern, startIndex) { |
|
|
String.prototype.regexLastIndexOf = function (pattern, startIndex) { |
|
|
startIndex = startIndex === undefined ? this.length : startIndex; |
|
|
|
|
|
var searchResult = this.substr(0, startIndex).reverse().regexIndexOf(pattern, 0); |
|
|
|
|
|
return (-1 === searchResult) ? -1 : this.length - ++searchResult; |
|
|
|
|
|
|
|
|
pattern = (pattern.global) ? pattern : |
|
|
|
|
|
new RegExp(pattern.source, 'g' + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '')); |
|
|
|
|
|
if (typeof (startIndex) === 'undefined') { |
|
|
|
|
|
startIndex = this.length; |
|
|
|
|
|
} |
|
|
|
|
|
else if (startIndex < 0) { |
|
|
|
|
|
startIndex = 0; |
|
|
|
|
|
} |
|
|
|
|
|
const stringToWorkWith = this.substring(0, startIndex + 1); |
|
|
|
|
|
let lastIndexOf = -1; |
|
|
|
|
|
let nextStop = 0; |
|
|
|
|
|
let result; |
|
|
|
|
|
while ((result = pattern.exec(stringToWorkWith)) != null) { |
|
|
|
|
|
lastIndexOf = result.index; |
|
|
|
|
|
pattern.lastIndex = ++nextStop; |
|
|
|
|
|
} |
|
|
|
|
|
return lastIndexOf; |
|
|
}; |
|
|
}; |
|
|
String.prototype.reverse = function () { |
|
|
String.prototype.reverse = function () { |
|
|
return this.split('').reverse().join(''); |
|
|
return this.split('').reverse().join(''); |
|
@ -96,6 +110,66 @@ function EscapeComments(arr) { |
|
|
count++; |
|
|
count++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
var isInComment = false; |
|
|
|
|
|
var commentRegex = new RegExp("(?<=" + ILCommentPrefix + "[\\d]+)."); |
|
|
|
|
|
for (var i = 0; i < arr.length; i++) { |
|
|
|
|
|
var commentStartIndex = 0; |
|
|
|
|
|
var hasComment = true; |
|
|
|
|
|
var commentEndInlineIndex = 0; |
|
|
|
|
|
while (hasComment) { |
|
|
|
|
|
var line = arr[i]; |
|
|
|
|
|
if (!isInComment) { |
|
|
|
|
|
commentStartIndex = line.indexOf("/*"); |
|
|
|
|
|
var commentEndIndex = line.indexOf("*/", commentStartIndex); |
|
|
|
|
|
if (commentStartIndex >= 0) { |
|
|
|
|
|
if (commentEndIndex >= 0) { |
|
|
|
|
|
commentEndInlineIndex = commentEndIndex + 2; |
|
|
|
|
|
isInComment = false; |
|
|
|
|
|
comments.push(line.substring(commentStartIndex, commentEndInlineIndex)); |
|
|
|
|
|
arr[i] = line.substr(0, commentStartIndex) + ILCommentPrefix + count + line.substr(commentEndInlineIndex); |
|
|
|
|
|
count++; |
|
|
|
|
|
hasComment = true; |
|
|
|
|
|
if (commentStartIndex + 2 == line.length) { |
|
|
|
|
|
hasComment = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
isInComment = true; |
|
|
|
|
|
comments.push(line.substr(commentStartIndex)); |
|
|
|
|
|
arr[i] = line.substr(0, commentStartIndex) + ILCommentPrefix + count; |
|
|
|
|
|
count++; |
|
|
|
|
|
hasComment = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
hasComment = false; |
|
|
|
|
|
} |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if (isInComment) { |
|
|
|
|
|
var lastCommentEndIndex = line.regexLastIndexOf(commentRegex, line.length); |
|
|
|
|
|
if (commentStartIndex == 0) { |
|
|
|
|
|
var commentEndIndex = line.indexOf("*/", lastCommentEndIndex); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var commentEndIndex = line.indexOf("*/", commentStartIndex); |
|
|
|
|
|
} |
|
|
|
|
|
if (commentEndIndex >= 0) { |
|
|
|
|
|
isInComment = false; |
|
|
|
|
|
comments.push(line.substr(0, commentEndIndex + 2)); |
|
|
|
|
|
arr[i] = ILCommentPrefix + count + line.substr(commentEndIndex + 2); |
|
|
|
|
|
count++; |
|
|
|
|
|
hasComment = true; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
comments.push(line); |
|
|
|
|
|
arr[i] = ILCommentPrefix + count; |
|
|
|
|
|
count++; |
|
|
|
|
|
hasComment = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return comments; |
|
|
return comments; |
|
|
} |
|
|
} |
|
|
function ToLowerCases(arr) { |
|
|
function ToLowerCases(arr) { |
|
@ -623,6 +697,10 @@ function beautify3(inputs, result, settings, startIndex, indent, endIndex) { |
|
|
Mode = modeCache; |
|
|
Mode = modeCache; |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
if (input.regexStartsWith(/.*?\:\=\s*\($/)) { |
|
|
|
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, ":="); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
if (input.regexStartsWith(/[\w\s:]*\bPORT\b([\s]|$)/)) { |
|
|
if (input.regexStartsWith(/[\w\s:]*\bPORT\b([\s]|$)/)) { |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "PORT"); |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "PORT"); |
|
|
continue; |
|
|
continue; |
|
@ -635,10 +713,6 @@ function beautify3(inputs, result, settings, startIndex, indent, endIndex) { |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "GENERIC"); |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "GENERIC"); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
if (input.regexStartsWith(/.*?\:\=\s*\($/)) { |
|
|
|
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, ":="); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if (input.regexStartsWith(/[\w\s:]*PROCEDURE[\s\w]+\($/)) { |
|
|
if (input.regexStartsWith(/[\w\s:]*PROCEDURE[\s\w]+\($/)) { |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "PROCEDURE"); |
|
|
[i, endIndex] = beautifyPortGenericBlock(inputs, result, settings, i, endIndex, indent, "PROCEDURE"); |
|
|
if (inputs[i].regexStartsWith(/.*\)[\s]*IS/)) { |
|
|
if (inputs[i].regexStartsWith(/.*\)[\s]*IS/)) { |
|
@ -764,4 +838,4 @@ function RemoveExtraNewLines(input) { |
|
|
input = input.replace(/\r\n\r\n\r\n/g, '\r\n'); |
|
|
input = input.replace(/\r\n\r\n\r\n/g, '\r\n'); |
|
|
return input; |
|
|
return input; |
|
|
} |
|
|
} |
|
|
//# sourceMappingURL=VHDLFormatter.js.map
|
|
|
|
|
|
|
|
|
//# sourceMappingURL=VHDLFormatter.js.map
|