Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
5c907055
Commit
5c907055
authored
10 years ago
by
Christopher Mitchell
Committed by
Marijn Haverbeke
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[z80 mode] Improved, fixed ASM example, added ez80 mode
parent
e22891bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mode/z80/index.html
+8
-7
8 additions, 7 deletions
mode/z80/index.html
mode/z80/z80.js
+34
-18
34 additions, 18 deletions
mode/z80/z80.js
with
42 additions
and
25 deletions
mode/z80/index.html
+
8
−
7
View file @
5c907055
...
...
@@ -29,17 +29,18 @@
<div><textarea
id=
"code"
name=
"code"
>
#include "ti83plus.inc"
#define progStart $9D95
.org progStart-2
.db $BB,$6D
.org progStart-2
.db $BB,$6D
bcall(_ClrLCDFull)
ld
HL,
0
ld
(PenCol), HL
ld
HL,
Message
ld
hl,
0
ld
(CurCol),hl
ld
hl,
Message
bcall(_PutS) ; Displays the string
bcall(_NewLine)
ret
Message:
.db
"Hello world!",0
.db
"Hello world!",0
</textarea></div>
<script>
...
...
@@ -48,5 +49,5 @@ Message:
});
</script>
<p><strong>
MIME type defined:
</strong>
<code>
text/x-z80
</code>
.
</p>
<p><strong>
MIME type
s
defined:
</strong>
<code>
text/x-z80
</code>
,
<code>
text/x-ez80
</code>
.
</p>
</article>
This diff is collapsed.
Click to expand it.
mode/z80/z80.js
+
34
−
18
View file @
5c907055
...
...
@@ -3,26 +3,35 @@
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineMode
(
'
z80
'
,
function
()
{
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
;
var
keywords2
=
/^
(
call|j
[
pr
]
|ret
[
in
]?)\b
/i
;
var
keywords3
=
/^b_
?(
call|jump
)\b
/i
;
CodeMirror
.
defineMode
(
'
z80
'
,
function
(
_config
,
parserConfig
)
{
var
ez80
=
parserConfig
.
ez80
;
var
keywords1
,
keywords2
;
if
(
ez80
)
{
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
;
keywords2
=
/^
(((
call|j
[
pr
]
|rst|ret
[
in
]?)(\.([
sl
]?
i
)?[
sl
])?)
|
(
rs|st
)
mix
)\b
/i
;
}
else
{
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
;
keywords2
=
/^
(
call|j
[
pr
]
|ret
[
in
]?
|b_
?(
call|jump
))\b
/i
;
}
var
variables1
=
/^
(
af
?
|bc
?
|c|de
?
|e|hl
?
|l|i
[
xy
]?
|r|sp
)\b
/i
;
var
variables2
=
/^
(
n
?[
zc
]
|p
[
oe
]?
|m
)\b
/i
;
var
errors
=
/^
([
hl
][
xy
]
|i
[
xy
][
hl
]
|slia|sll
)\b
/i
;
var
numbers
=
/^
([\d
a-f
]
+h|
[
0-7
]
+o|
[
01
]
+b|
\d
+
)\b
/i
;
var
numbers
=
/^
([\d
a-f
]
+h|
[
0-7
]
+o|
[
01
]
+b|
\d
+
d
?
)\b
/i
;
return
{
startState
:
function
()
{
return
{
context
:
0
};
return
{
context
:
0
};
},
token
:
function
(
stream
,
state
)
{
if
(
!
stream
.
column
())
...
...
@@ -34,14 +43,21 @@ CodeMirror.defineMode('z80', function() {
var
w
;
if
(
stream
.
eatWhile
(
/
\w
/
))
{
if
(
ez80
&&
stream
.
eat
(
'
.
'
))
{
stream
.
eatWhile
(
/
\w
/
);
}
w
=
stream
.
current
();
if
(
stream
.
indentation
())
{
if
(
state
.
context
==
1
&&
variables1
.
test
(
w
))
return
'
variable-2
'
;
if
((
state
.
context
==
1
||
state
.
context
==
4
)
&&
variables1
.
test
(
w
))
{
state
.
context
=
4
;
return
'
var2
'
;
}
if
(
state
.
context
==
2
&&
variables2
.
test
(
w
))
return
'
variable-3
'
;
if
(
state
.
context
==
2
&&
variables2
.
test
(
w
))
{
state
.
context
=
4
;
return
'
var3
'
;
}
if
(
keywords1
.
test
(
w
))
{
state
.
context
=
1
;
...
...
@@ -49,14 +65,13 @@ CodeMirror.defineMode('z80', function() {
}
else
if
(
keywords2
.
test
(
w
))
{
state
.
context
=
2
;
return
'
keyword
'
;
}
else
if
(
keywords3
.
test
(
w
))
{
state
.
context
=
3
;
return
'
keyword
'
;
}
else
if
(
state
.
context
==
4
&&
numbers
.
test
(
w
))
{
return
'
number
'
;
}
if
(
errors
.
test
(
w
))
return
'
error
'
;
}
else
if
(
numbers
.
test
(
w
))
{
}
else
if
(
stream
.
match
(
numbers
))
{
return
'
number
'
;
}
else
{
return
null
;
...
...
@@ -77,7 +92,7 @@ CodeMirror.defineMode('z80', function() {
if
(
stream
.
match
(
/
\\?
.'/
))
return
'
number
'
;
}
else
if
(
stream
.
eat
(
'
.
'
)
||
stream
.
sol
()
&&
stream
.
eat
(
'
#
'
))
{
state
.
context
=
4
;
state
.
context
=
5
;
if
(
stream
.
eatWhile
(
/
\w
/
))
return
'
def
'
;
...
...
@@ -96,5 +111,6 @@ CodeMirror.defineMode('z80', function() {
});
CodeMirror
.
defineMIME
(
"
text/x-z80
"
,
"
z80
"
);
CodeMirror
.
defineMIME
(
"
text/x-ez80
"
,
{
name
:
"
z80
"
,
ez80
:
true
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment