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
90bc10bf
Commit
90bc10bf
authored
9 years ago
by
Marijn Haverbeke
Browse files
Options
Downloads
Patches
Plain Diff
[elm mode] Add
Original code by Evan Czaplicki
parent
bb517878
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
doc/compress.html
+1
-0
1 addition, 0 deletions
doc/compress.html
mode/elm/elm.js
+205
-0
205 additions, 0 deletions
mode/elm/elm.js
mode/elm/index.html
+61
-0
61 additions, 0 deletions
mode/elm/index.html
mode/index.html
+1
-0
1 addition, 0 deletions
mode/index.html
mode/meta.js
+1
-0
1 addition, 0 deletions
mode/meta.js
with
269 additions
and
0 deletions
doc/compress.html
+
1
−
0
View file @
90bc10bf
...
...
@@ -127,6 +127,7 @@
<option
value=
"http://codemirror.net/mode/ebnf/ebnf.js"
>
ebnf.js
</option>
<option
value=
"http://codemirror.net/mode/ecl/ecl.js"
>
ecl.js
</option>
<option
value=
"http://codemirror.net/mode/eiffel/eiffel.js"
>
eiffel.js
</option>
<option
value=
"http://codemirror.net/mode/elm/elm.js"
>
eml.js
</option>
<option
value=
"http://codemirror.net/mode/erlang/erlang.js"
>
erlang.js
</option>
<option
value=
"http://codemirror.net/mode/forth/forth.js"
>
forth.js
</option>
<option
value=
"http://codemirror.net/mode/fortran/fortran.js"
>
fortran.js
</option>
...
...
This diff is collapsed.
Click to expand it.
mode/elm/elm.js
0 → 100644
+
205
−
0
View file @
90bc10bf
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
CodeMirror
.
defineMode
(
"
elm
"
,
function
()
{
function
switchState
(
source
,
setState
,
f
)
{
setState
(
f
);
return
f
(
source
,
setState
);
}
// These should all be Unicode extended, as per the Haskell 2010 report
var
smallRE
=
/
[
a-z_
]
/
;
var
largeRE
=
/
[
A-Z
]
/
;
var
digitRE
=
/
[
0-9
]
/
;
var
hexitRE
=
/
[
0-9A-Fa-f
]
/
;
var
octitRE
=
/
[
0-7
]
/
;
var
idRE
=
/
[
a-z_A-Z0-9
\']
/
;
var
symbolRE
=
/
[
-!#$%&*+.
\/
<=>?@
\\
^|~:
\u
03BB
\u
2192
]
/
;
var
specialRE
=
/
[
(),;[
\]
`{}
]
/
;
var
whiteCharRE
=
/
[
\t\v\f]
/
;
// newlines are handled in tokenizer
function
normal
()
{
return
function
(
source
,
setState
)
{
if
(
source
.
eatWhile
(
whiteCharRE
))
{
return
null
;
}
var
ch
=
source
.
next
();
if
(
specialRE
.
test
(
ch
))
{
if
(
ch
==
'
{
'
&&
source
.
eat
(
'
-
'
))
{
var
t
=
"
comment
"
;
if
(
source
.
eat
(
'
#
'
))
t
=
"
meta
"
;
return
switchState
(
source
,
setState
,
ncomment
(
t
,
1
));
}
return
null
;
}
if
(
ch
==
'
\'
'
)
{
if
(
source
.
eat
(
'
\\
'
))
source
.
next
();
// should handle other escapes here
else
source
.
next
();
if
(
source
.
eat
(
'
\'
'
))
return
"
string
"
;
return
"
error
"
;
}
if
(
ch
==
'
"
'
)
{
return
switchState
(
source
,
setState
,
stringLiteral
);
}
if
(
largeRE
.
test
(
ch
))
{
source
.
eatWhile
(
idRE
);
if
(
source
.
eat
(
'
.
'
))
return
"
qualifier
"
;
return
"
variable-2
"
;
}
if
(
smallRE
.
test
(
ch
))
{
var
isDef
=
source
.
pos
===
1
;
source
.
eatWhile
(
idRE
);
return
isDef
?
"
variable-3
"
:
"
variable
"
;
}
if
(
digitRE
.
test
(
ch
))
{
if
(
ch
==
'
0
'
)
{
if
(
source
.
eat
(
/
[
xX
]
/
))
{
source
.
eatWhile
(
hexitRE
);
// should require at least 1
return
"
integer
"
;
}
if
(
source
.
eat
(
/
[
oO
]
/
))
{
source
.
eatWhile
(
octitRE
);
// should require at least 1
return
"
number
"
;
}
}
source
.
eatWhile
(
digitRE
);
var
t
=
"
number
"
;
if
(
source
.
eat
(
'
.
'
))
{
t
=
"
number
"
;
source
.
eatWhile
(
digitRE
);
// should require at least 1
}
if
(
source
.
eat
(
/
[
eE
]
/
))
{
t
=
"
number
"
;
source
.
eat
(
/
[
-+
]
/
);
source
.
eatWhile
(
digitRE
);
// should require at least 1
}
return
t
;
}
if
(
symbolRE
.
test
(
ch
))
{
if
(
ch
==
'
-
'
&&
source
.
eat
(
/-/
))
{
source
.
eatWhile
(
/-/
);
if
(
!
source
.
eat
(
symbolRE
))
{
source
.
skipToEnd
();
return
"
comment
"
;
}
}
source
.
eatWhile
(
symbolRE
);
return
"
builtin
"
;
}
return
"
error
"
;
}
}
function
ncomment
(
type
,
nest
)
{
if
(
nest
==
0
)
{
return
normal
();
}
return
function
(
source
,
setState
)
{
var
currNest
=
nest
;
while
(
!
source
.
eol
())
{
var
ch
=
source
.
next
();
if
(
ch
==
'
{
'
&&
source
.
eat
(
'
-
'
))
{
++
currNest
;
}
else
if
(
ch
==
'
-
'
&&
source
.
eat
(
'
}
'
))
{
--
currNest
;
if
(
currNest
==
0
)
{
setState
(
normal
());
return
type
;
}
}
}
setState
(
ncomment
(
type
,
currNest
));
return
type
;
}
}
function
stringLiteral
(
source
,
setState
)
{
while
(
!
source
.
eol
())
{
var
ch
=
source
.
next
();
if
(
ch
==
'
"
'
)
{
setState
(
normal
());
return
"
string
"
;
}
if
(
ch
==
'
\\
'
)
{
if
(
source
.
eol
()
||
source
.
eat
(
whiteCharRE
))
{
setState
(
stringGap
);
return
"
string
"
;
}
if
(
!
source
.
eat
(
'
&
'
))
source
.
next
();
// should handle other escapes here
}
}
setState
(
normal
());
return
"
error
"
;
}
function
stringGap
(
source
,
setState
)
{
if
(
source
.
eat
(
'
\\
'
))
{
return
switchState
(
source
,
setState
,
stringLiteral
);
}
source
.
next
();
setState
(
normal
());
return
"
error
"
;
}
var
wellKnownWords
=
(
function
()
{
var
wkw
=
{};
var
keywords
=
[
"
case
"
,
"
of
"
,
"
as
"
,
"
if
"
,
"
then
"
,
"
else
"
,
"
let
"
,
"
in
"
,
"
infix
"
,
"
infixl
"
,
"
infixr
"
,
"
type
"
,
"
alias
"
,
"
input
"
,
"
output
"
,
"
foreign
"
,
"
loopback
"
,
"
module
"
,
"
where
"
,
"
import
"
,
"
exposing
"
,
"
_
"
,
"
..
"
,
"
|
"
,
"
:
"
,
"
=
"
,
"
\\
"
,
"
\"
"
,
"
->
"
,
"
<-
"
];
for
(
var
i
=
keywords
.
length
;
i
--
;)
wkw
[
keywords
[
i
]]
=
"
keyword
"
;
return
wkw
;
})();
return
{
startState
:
function
()
{
return
{
f
:
normal
()
};
},
copyState
:
function
(
s
)
{
return
{
f
:
s
.
f
};
},
token
:
function
(
stream
,
state
)
{
var
t
=
state
.
f
(
stream
,
function
(
s
)
{
state
.
f
=
s
;
});
var
w
=
stream
.
current
();
return
(
wellKnownWords
.
hasOwnProperty
(
w
))
?
wellKnownWords
[
w
]
:
t
;
}
};
});
CodeMirror
.
defineMIME
(
"
text/x-elm
"
,
"
elm
"
);
})();
This diff is collapsed.
Click to expand it.
mode/elm/index.html
0 → 100644
+
61
−
0
View file @
90bc10bf
<!doctype html>
<title>
CodeMirror: Elm mode
</title>
<meta
charset=
"utf-8"
/>
<link
rel=
stylesheet
href=
"../../doc/docs.css"
>
<link
rel=
"stylesheet"
href=
"../../lib/codemirror.css"
>
<script
src=
"../../lib/codemirror.js"
></script>
<script
src=
"elm.js"
></script>
<style
type=
"text/css"
>
.CodeMirror
{
border-top
:
1px
solid
black
;
border-bottom
:
1px
solid
black
;}
</style>
<div
id=
nav
>
<a
href=
"http://codemirror.net"
><h1>
CodeMirror
</h1><img
id=
logo
src=
"../../doc/logo.png"
></a>
<ul>
<li><a
href=
"../../index.html"
>
Home
</a>
<li><a
href=
"../../doc/manual.html"
>
Manual
</a>
<li><a
href=
"https://github.com/codemirror/codemirror"
>
Code
</a>
</ul>
<ul>
<li><a
href=
"../index.html"
>
Language modes
</a>
<li><a
class=
active
href=
"#"
>
Elm
</a>
</ul>
</div>
<article>
<h2>
Elm mode
</h2>
<div><textarea
id=
"code"
name=
"code"
>
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Time exposing (..)
main =
Signal.map clock (every second)
clock t =
collage 400 400
[ filled lightGrey (ngon 12 110)
, outlined (solid grey) (ngon 12 110)
, hand orange 100 t
, hand charcoal 100 (t/60)
, hand charcoal 60 (t/720)
]
hand clr len time =
let angle = degrees (90 - 6 * inSeconds time)
in
segment (0,0) (fromPolar (len,angle))
|> traced (solid clr)
</textarea></div>
<script>
var
editor
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"
code
"
),
{
lineNumbers
:
true
,
mode
:
"
text/x-elm
"
});
</script>
<p><strong>
MIME types defined:
</strong>
<code>
text/x-elm
</code>
.
</p>
</article>
This diff is collapsed.
Click to expand it.
mode/index.html
+
1
−
0
View file @
90bc10bf
...
...
@@ -52,6 +52,7 @@ option.</p>
<li><a
href=
"ebnf/index.html"
>
EBNF
</a></li>
<li><a
href=
"ecl/index.html"
>
ECL
</a></li>
<li><a
href=
"eiffel/index.html"
>
Eiffel
</a></li>
<li><a
href=
"elm/index.html"
>
Elm
</a></li>
<li><a
href=
"erlang/index.html"
>
Erlang
</a></li>
<li><a
href=
"forth/index.html"
>
Forth
</a></li>
<li><a
href=
"fortran/index.html"
>
Fortran
</a></li>
...
...
This diff is collapsed.
Click to expand it.
mode/meta.js
+
1
−
0
View file @
90bc10bf
...
...
@@ -38,6 +38,7 @@
{
name
:
"
EBNF
"
,
mime
:
"
text/x-ebnf
"
,
mode
:
"
ebnf
"
},
{
name
:
"
ECL
"
,
mime
:
"
text/x-ecl
"
,
mode
:
"
ecl
"
,
ext
:
[
"
ecl
"
]},
{
name
:
"
Eiffel
"
,
mime
:
"
text/x-eiffel
"
,
mode
:
"
eiffel
"
,
ext
:
[
"
e
"
]},
{
name
:
"
Elm
"
,
mime
:
"
text/x-elm
"
,
mode
:
"
elm
"
,
ext
:
[
"
elm
"
]},
{
name
:
"
Embedded Javascript
"
,
mime
:
"
application/x-ejs
"
,
mode
:
"
htmlembedded
"
,
ext
:
[
"
ejs
"
]},
{
name
:
"
Embedded Ruby
"
,
mime
:
"
application/x-erb
"
,
mode
:
"
htmlembedded
"
,
ext
:
[
"
erb
"
]},
{
name
:
"
Erlang
"
,
mime
:
"
text/x-erlang
"
,
mode
:
"
erlang
"
,
ext
:
[
"
erl
"
]},
...
...
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