Extended the binary operators.
This commit is contained in:
parent
65afcb20a3
commit
c89a00fd51
2 changed files with 16 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ function Hello($name) {
|
||||||
function add($left, $right=4) {
|
function add($left, $right=4) {
|
||||||
if ($right -ne 4) {
|
if ($right -ne 4) {
|
||||||
return $left
|
return $left
|
||||||
} elseif ($left -eq $right) {
|
} elseif ($left -eq $null -and $right -eq 2) {
|
||||||
return 3
|
return 3
|
||||||
} else {
|
} else {
|
||||||
return 2
|
return 2
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,19 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
|
||||||
var PowershellHighlightRules = function() {
|
var PowershellHighlightRules = function() {
|
||||||
|
|
||||||
var keywords = lang.arrayToMap(
|
var keywords = lang.arrayToMap(
|
||||||
("function|if|else|elseif|switch|while|default|for|do|until|break|continue|foreach|return|filter|in|trap|throw|param|begin|process|end").split("|")
|
("function|if|else|elseif|switch|while|default|for|do|until|break|continue|" +
|
||||||
|
"foreach|return|filter|in|trap|throw|param|begin|process|end").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var builtinFunctions = lang.arrayToMap(
|
||||||
|
("Write-Host").split("|")
|
||||||
|
);
|
||||||
|
|
||||||
|
var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" +
|
||||||
|
"ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" +
|
||||||
|
"is|isnot|as|" +
|
||||||
|
"and|or|band|bor|not";
|
||||||
|
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
|
|
||||||
|
|
@ -44,15 +54,17 @@ var PowershellHighlightRules = function() {
|
||||||
token : function(value) {
|
token : function(value) {
|
||||||
if (keywords.hasOwnProperty(value))
|
if (keywords.hasOwnProperty(value))
|
||||||
return "keyword";
|
return "keyword";
|
||||||
|
else if (builtinFunctions.hasOwnProperty(value))
|
||||||
|
return "support.function";
|
||||||
else
|
else
|
||||||
return "identifier";
|
return "identifier";
|
||||||
},
|
},
|
||||||
// TODO: Unicode escape sequences
|
// TODO: Unicode escape sequences
|
||||||
// TODO: Unicode identifiers
|
// TODO: Unicode identifiers
|
||||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator",
|
token : "keyword.operator",
|
||||||
regex : "\\-(?:" + "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace" + ")"
|
regex : "\\-(?:" + binaryOperatorsRe + ")"
|
||||||
}, {
|
}, {
|
||||||
token : "lparen",
|
token : "lparen",
|
||||||
regex : "[[({]"
|
regex : "[[({]"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue