MCPcopy Create free account
hub / github.com/TruthHun/BookStack / normal

Function normal

static/editor.md/lib/codemirror/mode/haskell/haskell.js:32–123  ·  view source on GitHub ↗
(source, setState)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

switchStateFunction · 0.85
ncommentFunction · 0.85

Tested by

no test coverage detected