MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / normal

Function normal

static/js/codemirror/mode/haskell/haskell.js:19–108  ·  view source on GitHub ↗
(source, setState)

Source from the content-addressed store, hash-verified

17 var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
18
19 function normal(source, setState) {
20 if (source.eatWhile(whiteCharRE)) {
21 return null;
22 }
23
24 var ch = source.next();
25 if (specialRE.test(ch)) {
26 if (ch == '{' && source.eat('-')) {
27 var t = "comment";
28 if (source.eat('#')) {
29 t = "meta";
30 }
31 return switchState(source, setState, ncomment(t, 1));
32 }
33 return null;
34 }
35
36 if (ch == '\'') {
37 if (source.eat('\\')) {
38 source.next(); // should handle other escapes here
39 }
40 else {
41 source.next();
42 }
43 if (source.eat('\'')) {
44 return "string";
45 }
46 return "error";
47 }
48
49 if (ch == '"') {
50 return switchState(source, setState, stringLiteral);
51 }
52
53 if (largeRE.test(ch)) {
54 source.eatWhile(idRE);
55 if (source.eat('.')) {
56 return "qualifier";
57 }
58 return "variable-2";
59 }
60
61 if (smallRE.test(ch)) {
62 source.eatWhile(idRE);
63 return "variable";
64 }
65
66 if (digitRE.test(ch)) {
67 if (ch == '0') {
68 if (source.eat(/[xX]/)) {
69 source.eatWhile(hexitRE); // should require at least 1
70 return "integer";
71 }
72 if (source.eat(/[oO]/)) {
73 source.eatWhile(octitRE); // should require at least 1
74 return "number";
75 }
76 }

Callers

nothing calls this directly

Calls 4

switchStateFunction · 0.85
ncommentFunction · 0.85
nextMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected