return new ASPNetSpanParser (doc, mode, line, spanStack);
59
return new ASPNetSpanParser (doc, mode, spanStack ?? line.StartSpan.Clone ());
60
60
}
61
61
62
62
protected class ASPNetSpanParser : SpanParser
63
63
{
64
public ASPNetSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, LineSegment line, Stack<Span> spanStack) : base (doc, mode, line, spanStack)
64
public ASPNetSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, CloneableStack<Span> spanStack) : base (doc, mode, spanStack)
65
65
{}
66
66
67
67
class CodeExpressionSpan : Span
71
71
Rule = "mode:" + language;
72
72
Begin = new Regex ("<%");
73
73
End = new Regex ("<%");
74
Color = "text";
75
TagColor = "text.markup.tag";
74
Color = "template";
75
TagColor = "template.tag";
76
76
}
77
77
}
78
78
139
139
{
140
140
if (!spanStack.Any (s => s is CodeDeclarationSpan || s is CodeExpressionSpan) && i + 3 < doc.Length && doc.GetTextAt (i, 2) == "<%" && doc.GetCharAt (i + 2) != '@') {
141
141
var span = new CodeExpressionSpan (GetDefaultMime ());
142
spanStack.Push (span);
143
ruleStack.Push (GetRule (span));
144
OnFoundSpanBegin (span, i, doc.GetCharAt (i + 2) == '=' ? 3 : 2);
142
FoundSpanBegin (span, i, "#$=:".IndexOf (doc.GetCharAt (i + 2)) >= 0? 3 : 2);
145
143
return;
146
144
}
147
145
176
174
177
175
if (mime != null) {
178
176
CodeDeclarationSpan span = new CodeDeclarationSpan (mime);
179
spanStack.Push (span);
180
ruleStack.Push (GetRule (span));
181
OnFoundSpanBegin (span, i, 0);
177
FoundSpanBegin (span, i, 0);
182
178
return;
183
179
}
184
180
}
191
187
{
192
188
if (spanStack.Any (s => s is CodeDeclarationSpan) && i + 9 <= doc.Length && doc.GetTextAt (i, 9) == "</script>") {
193
189
while (!(spanStack.Peek () is CodeDeclarationSpan)) {
194
OnFoundSpanEnd (spanStack.Peek (), i, 0);
195
spanStack.Pop ();
196
if (ruleStack.Count > 1)
197
ruleStack.Pop ();
190
FoundSpanEnd (spanStack.Peek (), i, 0);
198
191
}
199
192
cur = spanStack.Peek ();
200
OnFoundSpanEnd (cur, i, "</script>".Length);
201
193
i += "</script>".Length;
202
spanStack.Pop ();
203
if (ruleStack.Count > 1)
204
ruleStack.Pop ();
194
FoundSpanEnd (cur, i, "</script>".Length);
205
195
return true;
206
196
}
207
197
208
198
if (spanStack.Any (s => s is CodeExpressionSpan) && i + 2 < doc.Length && doc.GetTextAt (i, 2) == "%>") {
209
199
while (!(spanStack.Peek () is CodeExpressionSpan)) {