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
b8a38503
Commit
b8a38503
authored
11 years ago
by
mats cronqvist
Committed by
Marijn Haverbeke
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
erlang mode bug fixes
parent
3f5c8432
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/erlang/erlang.js
+30
-26
30 additions, 26 deletions
mode/erlang/erlang.js
mode/erlang/index.html
+1
-1
1 addition, 1 deletion
mode/erlang/index.html
with
31 additions
and
27 deletions
mode/erlang/erlang.js
+
30
−
26
View file @
b8a38503
...
...
@@ -11,18 +11,10 @@ CodeMirror.defineMIME("text/x-erlang", "erlang");
CodeMirror
.
defineMode
(
"
erlang
"
,
function
(
cmCfg
)
{
function
rval
(
state
,
stream
,
type
)
{
function
rval
(
state
,
_
stream
,
type
)
{
// distinguish between "." as terminator and record field operator
if
(
type
==
"
record
"
)
{
state
.
context
=
"
record
"
;
}
else
{
state
.
context
=
false
;
}
state
.
in_record
=
(
type
==
"
record
"
);
// remember last significant bit on last line for indenting
if
(
type
!=
"
whitespace
"
&&
type
!=
"
comment
"
)
{
state
.
lastToken
=
stream
.
current
();
}
// erlang -> CodeMirror tag
switch
(
type
)
{
case
"
atom
"
:
return
"
atom
"
;
...
...
@@ -133,6 +125,19 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
}
function
tokenize
(
stream
,
state
)
{
// in multi-line string
if
(
state
.
in_string
)
{
state
.
in_string
=
(
!
doubleQuote
(
stream
));
return
rval
(
state
,
stream
,
"
string
"
);
}
// in multi-line atom
if
(
state
.
in_atom
)
{
state
.
in_atom
=
(
!
singleQuote
(
stream
));
return
rval
(
state
,
stream
,
"
atom
"
);
}
// whitespace
if
(
stream
.
eatSpace
())
{
return
rval
(
state
,
stream
,
"
whitespace
"
);
}
...
...
@@ -183,20 +188,14 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
// quoted atom
if
(
ch
==
'
\'
'
)
{
if
(
singleQuote
(
stream
))
{
return
rval
(
state
,
stream
,
"
atom
"
);
}
else
{
return
rval
(
state
,
stream
,
"
error
"
);
}
state
.
in_atom
=
(
!
singleQuote
(
stream
));
return
rval
(
state
,
stream
,
"
atom
"
);
}
// string
if
(
ch
==
'
"
'
)
{
if
(
doubleQuote
(
stream
))
{
return
rval
(
state
,
stream
,
"
string
"
);
}
else
{
return
rval
(
state
,
stream
,
"
error
"
);
}
state
.
in_string
=
(
!
doubleQuote
(
stream
));
return
rval
(
state
,
stream
,
"
string
"
);
}
// variable
...
...
@@ -282,7 +281,7 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
// separators
if
(
greedy
(
stream
,
sepRE
,
separatorWords
))
{
// distinguish between "." as terminator and record field operator
if
(
state
.
context
==
false
)
{
if
(
!
state
.
in_record
)
{
pushToken
(
state
,
stream
);
}
return
rval
(
state
,
stream
,
"
separator
"
);
...
...
@@ -359,15 +358,19 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
var
token
=
(
peekToken
(
state
)).
token
;
var
wordAfter
=
takewhile
(
textAfter
,
/
[^
a-z
]
/
);
if
(
isMember
(
token
,
openParenWords
))
{
return
(
peekToken
(
state
)).
column
+
token
.
length
;
}
else
if
(
token
==
"
.
"
||
token
==
""
){
if
(
state
.
in_string
||
state
.
in_atom
)
{
return
0
;
}
else
if
(
token
==
"
.
"
||
token
==
""
)
{
return
0
;
}
else
if
(
isMember
(
token
,
openParenWords
))
{
return
(
peekToken
(
state
)).
column
+
token
.
length
;
}
else
if
(
token
==
"
->
"
)
{
if
(
wordAfter
==
"
end
"
)
{
return
peekToken
(
state
,
2
).
column
;
}
else
if
(
peekToken
(
state
,
2
).
token
==
"
fun
"
)
{
return
peekToken
(
state
,
2
).
column
+
indent
;
}
else
if
(
peekToken
(
state
,
2
).
token
==
"
.
"
)
{
return
indent
;
}
else
{
return
(
peekToken
(
state
)).
indent
+
indent
;
}
...
...
@@ -445,8 +448,9 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
startState
:
function
()
{
return
{
tokenStack
:
[],
context
:
false
,
lastToken
:
null
};
in_record
:
false
,
in_string
:
false
,
in_atom
:
false
};
},
token
:
...
...
This diff is collapsed.
Click to expand it.
mode/erlang/index.html
+
1
−
1
View file @
b8a38503
...
...
@@ -32,7 +32,7 @@
rec_info(demo) -> record_info(fields,demo).
demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
expand_recs(M,List) when is_list(List) ->
[expand_recs(M,L)||L
<-List
];
expand_recs
(
M
,
Tup
)
when
is_tuple
(
Tup
)
-
>
...
...
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