CodeMirror.defineMode("alphasimple", function(config, parserConfig) {
	var indentUnit = config.indentUnit;
	var jsonMode = parserConfig.json;

	var keywords = [ 'abstract', 'aggregation', 'alias', 'any', 'association',
			'as', 'attribute', 'begin', 'by', 'class', 'datatype', 'derived',
			'composition', 'constant', 'dependency', 'end', 'enumeration',
			'extends', 'function', 'implements', 'interface', 'in', 'inout',
			'model', 'navigable', 'nonunique', 'operation', 'ordered', 'out',
			'package', 'postcondition', 'precondition', 'private', 'primitive',
			'profile', 'property', 'protected', 'public', 'raises',
			'reference', 'required', 'role', 'specializes', 'static',
			'stereotype', 'subsets', 'type', 'unique', 'unordered', 'var' ];

	var constants = [ 'null', 'false', 'true' ];

	var types = [ 'String', 'Integer', 'Boolean', 'Date', 'Double' ];

	var statements = [ 'apply', 'destroy', 'do', 'else', 'elseif', 'if',
			'import', 'link', 'load', 'new', 'raise', 'repeat', 'return',
			'then', 'unlink', 'until', 'while', 'and', 'or', 'extent', 'not',
			'self' ];

	function tokenize(stream, state) {
		var ch = stream.next();
		
		// handle strings
		if (ch == '"' || ch == "'") {
			if (!state.parsingComment) {
				if (state.parsingString) {
					if (state.currentStringChar == ch) {
						state.parsingString = false;
					}
				} else {
					state.parsingString = true;
					state.currentStringChar = ch;
				}
				return "as-string";
			}
		}
		if (state.parsingString) {
			return "as-string";
		}

		// handle comments
		if (state.parsingComment) {
			if (ch == '*') {
				var next = stream.peek();
				if (next == '/') {
					state.parsingComment = false;
					stream.next();
				}
			}
			return "as-comment";
		}
		if (ch == '/') {
			var next = stream.peek();
			if (next == '*') {
				state.parsingComment = true;
				stream.next();
				return "as-comment";
			}
		}
		
		stream.eatWhile(/[\w\$_]/);
		var word = stream.current();
		
		if ($.inArray(word, keywords) >= 0) {
			return "as-keyword";
		}
		
		if ($.inArray(word, constants) >= 0) {
			return "as-constants";
		}
		
		if ($.inArray(word, types) >= 0) {
			return "as-types";
		}
		
		if ($.inArray(word, statements) >= 0) {
			return "as-statements";
		}
		
		return "as-other";
	}

	return {
		startState : function(basecolumn) {
			return {
				indented : 0,
				parsingString : false,
				currentStringChar : '"',
				parsingComment : false
			};
		},

		token : function(stream, state) {
			if (stream.sol()) {
				state.indented = stream.indentation();
			}
			if (stream.eatSpace())
				return null;
			var style = tokenize(stream, state);
			return style;
		},

		indent : function(state, textAfter) {
			return state.indented;
		}
	};
});

