(stream, state)
| 37 | } |
| 38 | |
| 39 | function tokenBase(stream, state) { |
| 40 | curPunc = null; |
| 41 | if (stream.sol() && stream.match("=begin") && stream.eol()) { |
| 42 | state.tokenize.push(readBlockComment); |
| 43 | return "comment"; |
| 44 | } |
| 45 | if (stream.eatSpace()) return null; |
| 46 | var ch = stream.next(), m; |
| 47 | if (ch == "`" || ch == "'" || ch == '"') { |
| 48 | return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state); |
| 49 | } else if (ch == "/") { |
| 50 | var currentIndex = stream.current().length; |
| 51 | if (stream.skipTo("/")) { |
| 52 | var search_till = stream.current().length; |
| 53 | stream.backUp(stream.current().length - currentIndex); |
| 54 | var balance = 0; // balance brackets |
| 55 | while (stream.current().length < search_till) { |
| 56 | var chchr = stream.next(); |
| 57 | if (chchr == "(") balance += 1; |
| 58 | else if (chchr == ")") balance -= 1; |
| 59 | if (balance < 0) break; |
| 60 | } |
| 61 | stream.backUp(stream.current().length - currentIndex); |
| 62 | if (balance == 0) |
| 63 | return chain(readQuoted(ch, "string-2", true), stream, state); |
| 64 | } |
| 65 | return "operator"; |
| 66 | } else if (ch == "%") { |
| 67 | var style = "string", embed = true; |
| 68 | if (stream.eat("s")) style = "atom"; |
| 69 | else if (stream.eat(/[WQ]/)) style = "string"; |
| 70 | else if (stream.eat(/[r]/)) style = "string-2"; |
| 71 | else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; } |
| 72 | var delim = stream.eat(/[^\w\s=]/); |
| 73 | if (!delim) return "operator"; |
| 74 | if (matching.propertyIsEnumerable(delim)) delim = matching[delim]; |
| 75 | return chain(readQuoted(delim, style, embed, true), stream, state); |
| 76 | } else if (ch == "#") { |
| 77 | stream.skipToEnd(); |
| 78 | return "comment"; |
| 79 | } else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) { |
| 80 | return chain(readHereDoc(m[1]), stream, state); |
| 81 | } else if (ch == "0") { |
| 82 | if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/); |
| 83 | else if (stream.eat("b")) stream.eatWhile(/[01]/); |
| 84 | else stream.eatWhile(/[0-7]/); |
| 85 | return "number"; |
| 86 | } else if (/\d/.test(ch)) { |
| 87 | stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/); |
| 88 | return "number"; |
| 89 | } else if (ch == "?") { |
| 90 | while (stream.match(/^\\[CM]-/)) {} |
| 91 | if (stream.eat("\\")) stream.eatWhile(/\w/); |
| 92 | else stream.next(); |
| 93 | return "string"; |
| 94 | } else if (ch == ":") { |
| 95 | if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state); |
| 96 | if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state); |
no test coverage detected