@ -4,8 +4,11 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
function wordRegexp ( words ) {
return new RegExp ( "^((" + words . join ( ")|(" ) + "))\\b" ) ;
}
// IPython-specific changes: add '?' as recognized character.
var singleOperators = new RegExp ( "^[\\+\\-\\*/%&|\\^~<>!\\?]" ) ;
// End IPython changes.
var singleDelimiters = new RegExp ( '^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]' ) ;
var doubleOperators = new RegExp ( "^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))" ) ;
var doubleDelimiters = new RegExp ( "^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))" ) ;
@ -249,32 +252,30 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
// Handle '.' connected identifiers
if ( current === '.' ) {
style = state . tokenize ( stream , state ) ;
current = stream . current ( ) ;
if ( style === 'variable' || style === 'builtin' ) {
return 'variable' ;
} else {
return ERRORCLASS ;
style = stream . match ( identifiers , false ) ? null : ERRORCLASS ;
if ( style === null && state . lastToken === 'meta' ) {
// Apply 'meta' style to '.' connected identifiers when
// appropriate.
style = 'meta' ;
}
return style ;
}
// Handle decorators
if ( current === '@' ) {
style = state . tokenize ( stream , state ) ;
current = stream . current ( ) ;
if ( style === 'variable'
|| current === '@staticmethod'
|| current === '@classmethod' ) {
return 'meta' ;
} else {
return ERRORCLASS ;
}
return stream . match ( identifiers , false ) ? 'meta' : ERRORCLASS ;
}
if ( ( style === 'variable' || style === 'builtin' )
&& state . lastToken === 'meta' ) {
style = 'meta' ;
}
// Handle scope changes.
if ( current === 'pass' || current === 'return' ) {
state . dedent += 1 ;
}
if ( current === 'lambda' ) state . lambda = true ;
if ( ( current === ':' && ! state . lambda && state . scopes [ 0 ] . type == 'py' )
|| indentInfo === 'indent' ) {
indent ( stream , state ) ;
@ -316,7 +317,7 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
token : function ( stream , state ) {
var style = tokenLexer ( stream , state ) ;
state . lastToken = { style : style , content : stream . current ( ) } ;
state . lastToken = style ;
if ( stream . eol ( ) && stream . lambda ) {
state . lambda = false ;