if (typeof exports == "object" && typeof module == "object")
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd)
define(["../../lib/codemirror"], mod);
})(function(CodeMirror) {
CodeMirror.defineMode("smarty", function(config, parserConf) {
var rightDelimiter = parserConf.rightDelimiter || "}";
var leftDelimiter = parserConf.leftDelimiter || "{";
var version = parserConf.version || 2;
var baseMode = CodeMirror.getMode(config, parserConf.baseMode || "null");
var keyFunctions = ["debug", "extends", "function", "include", "literal"];
operatorChars: /[+\-*&%=<>!?]/,
validIdentifier: /[a-zA-Z0-9_]/,
function cont(style, lastType) {
function chain(stream, state, parser) {
return parser(stream, state);
function doesNotCount(stream, pos) {
if (pos == null) pos = stream.pos;
return version === 3 && leftDelimiter == "{" &&
(pos == stream.string.length || /\s/.test(stream.string.charAt(pos)));
function tokenTop(stream, state) {
var string = stream.string;
for (var scan = stream.pos;;) {
var nextMatch = string.indexOf(leftDelimiter, scan);
scan = nextMatch + leftDelimiter.length;
if (nextMatch == -1 || !doesNotCount(stream, nextMatch + leftDelimiter.length)) break;
if (nextMatch == stream.pos) {
stream.match(leftDelimiter);
return chain(stream, state, tokenBlock("comment", "*" + rightDelimiter));
state.tokenize = tokenSmarty;