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) {
|
||||
if ($right -ne 4) {
|
||||
return $left
|
||||
} elseif ($left -eq $right) {
|
||||
} elseif ($left -eq $null -and $right -eq 2) {
|
||||
return 3
|
||||
} else {
|
||||
return 2
|
||||
|
|
|
|||
|
|
@ -8,9 +8,19 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
|
|||
var PowershellHighlightRules = function() {
|
||||
|
||||
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.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
|
|
@ -44,15 +54,17 @@ var PowershellHighlightRules = function() {
|
|||
token : function(value) {
|
||||
if (keywords.hasOwnProperty(value))
|
||||
return "keyword";
|
||||
else if (builtinFunctions.hasOwnProperty(value))
|
||||
return "support.function";
|
||||
else
|
||||
return "identifier";
|
||||
},
|
||||
// TODO: Unicode escape sequences
|
||||
// TODO: Unicode identifiers
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "\\-(?:" + "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace" + ")"
|
||||
regex : "\\-(?:" + binaryOperatorsRe + ")"
|
||||
}, {
|
||||
token : "lparen",
|
||||
regex : "[[({]"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue