5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode('z80', function(_config, parserConfig) {
15
var ez80 = parserConfig.ez80;
16
var keywords1, keywords2;
18
keywords1 = /^(exx?|(ld|cp)([di]r?)?|[lp]ea|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|[de]i|halt|im|in([di]mr?|ir?|irx|2r?)|ot(dmr?|[id]rx|imr?)|out(0?|[di]r?|[di]2r?)|tst(io)?|slp)(\.([sl]?i)?[sl])?\b/i;
19
keywords2 = /^(((call|j[pr]|rst|ret[in]?)(\.([sl]?i)?[sl])?)|(rs|st)mix)\b/i;
21
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;
22
keywords2 = /^(call|j[pr]|ret[in]?|b_?(call|jump))\b/i;
25
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
26
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
27
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
28
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+d?)\b/i;
31
startState: function() {
36
token: function(stream, state) {
40
if (stream.eatSpace())
45
if (stream.eatWhile(/\w/)) {
46
if (ez80 && stream.eat('.')) {
47
stream.eatWhile(/\w/);
51
if (stream.indentation()) {
52
if ((state.context == 1 || state.context == 4) && variables1.test(w)) {
57
if (state.context == 2 && variables2.test(w)) {
62
if (keywords1.test(w)) {
65
} else if (keywords2.test(w)) {
68
} else if (state.context == 4 && numbers.test(w)) {
74
} else if (stream.match(numbers)) {
79
} else if (stream.eat(';')) {
82
} else if (stream.eat('"')) {
83
while (w = stream.next()) {
91
} else if (stream.eat('\'')) {
92
if (stream.match(/\\?.'/))
94
} else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
97
if (stream.eatWhile(/\w/))
99
} else if (stream.eat('$')) {
100
if (stream.eatWhile(/[\da-f]/i))
102
} else if (stream.eat('%')) {
103
if (stream.eatWhile(/[01]/))
113
CodeMirror.defineMIME("text/x-z80", "z80");
114
CodeMirror.defineMIME("text/x-ez80", { name: "z80", ez80: true });