1 CodeMirror.defineMode('z80', function() {
2 var keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
3 var keywords2 = /^(call|j[pr]|ret[in]?)\b/i;
4 var keywords3 = /^b_?(call|jump)\b/i;
5 var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
6 var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
7 var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
8 var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+)\b/i;
11 startState: function() {
14 token: function(stream, state) {
18 if (stream.eatSpace())
23 if (stream.eatWhile(/\w/)) {
26 if (stream.indentation()) {
27 if (state.context == 1 && variables1.test(w))
30 if (state.context == 2 && variables2.test(w))
33 if (keywords1.test(w)) {
36 } else if (keywords2.test(w)) {
39 } else if (keywords3.test(w)) {
46 } else if (numbers.test(w)) {
51 } else if (stream.eat(';')) {
54 } else if (stream.eat('"')) {
55 while (w = stream.next()) {
63 } else if (stream.eat('\'')) {
64 if (stream.match(/\\?.'/))
66 } else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
69 if (stream.eatWhile(/\w/))
71 } else if (stream.eat('$')) {
72 if (stream.eatWhile(/[\da-f]/i))
74 } else if (stream.eat('%')) {
75 if (stream.eatWhile(/[01]/))
85 CodeMirror.defineMIME("text/x-z80", "z80");