|
|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
CodeMirror.defineMode("python", function(conf) {
|
|
|
|
|
CodeMirror.defineMode("python", function(conf, parserConf) {
|
|
|
|
|
var ERRORCLASS = 'error';
|
|
|
|
|
|
|
|
|
|
function wordRegexp(words) {
|
|
|
|
|
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!\\?]");
|
|
|
|
|
var singleOperators = new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
|
|
|
|
|
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
|
|
|
|
var doubleOperators = new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
|
|
|
|
var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
|
|
|
|
@ -29,7 +29,7 @@ CodeMirror.defineMode("python", function(conf) {
|
|
|
|
|
'open', 'range', 'zip'],
|
|
|
|
|
'keywords': ['nonlocal']};
|
|
|
|
|
|
|
|
|
|
if (!!conf.mode.version && parseInt(conf.mode.version, 10) === 3) {
|
|
|
|
|
if (!!parserConf.version && parseInt(parserConf.version, 10) === 3) {
|
|
|
|
|
commonkeywords = commonkeywords.concat(py3.keywords);
|
|
|
|
|
commontypes = commontypes.concat(py3.types);
|
|
|
|
|
var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
|
|
|
|
|
@ -147,10 +147,9 @@ CodeMirror.defineMode("python", function(conf) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function tokenStringFactory(delimiter) {
|
|
|
|
|
while ('rub'.indexOf(delimiter[0].toLowerCase()) >= 0) {
|
|
|
|
|
while ('rub'.indexOf(delimiter.charAt(0).toLowerCase()) >= 0) {
|
|
|
|
|
delimiter = delimiter.substr(1);
|
|
|
|
|
}
|
|
|
|
|
var delim_re = new RegExp(delimiter);
|
|
|
|
|
var singleline = delimiter.length == 1;
|
|
|
|
|
var OUTCLASS = 'string';
|
|
|
|
|
|
|
|
|
|
@ -162,7 +161,7 @@ CodeMirror.defineMode("python", function(conf) {
|
|
|
|
|
if (singleline && stream.eol()) {
|
|
|
|
|
return OUTCLASS;
|
|
|
|
|
}
|
|
|
|
|
} else if (stream.match(delim_re)) {
|
|
|
|
|
} else if (stream.match(delimiter)) {
|
|
|
|
|
state.tokenize = tokenBase;
|
|
|
|
|
return OUTCLASS;
|
|
|
|
|
} else {
|
|
|
|
|
@ -170,8 +169,8 @@ CodeMirror.defineMode("python", function(conf) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (singleline) {
|
|
|
|
|
if (conf.mode.singleLineStringErrors) {
|
|
|
|
|
OUTCLASS = ERRORCLASS
|
|
|
|
|
if (parserConf.singleLineStringErrors) {
|
|
|
|
|
return ERRORCLASS;
|
|
|
|
|
} else {
|
|
|
|
|
state.tokenize = tokenBase;
|
|
|
|
|
}
|
|
|
|
|
|