Matteo Scandolo | 46b5610 | 2015-12-16 14:23:08 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Generic language patterns |
| 3 | * |
| 4 | * @author Craig Campbell |
| 5 | * @version 1.0.9 |
| 6 | */ |
| 7 | Rainbow.extend([ |
| 8 | { |
| 9 | 'matches': { |
| 10 | 1: { |
| 11 | 'name': 'keyword.operator', |
| 12 | 'pattern': /\=/g |
| 13 | }, |
| 14 | 2: { |
| 15 | 'name': 'string', |
| 16 | 'matches': { |
| 17 | 'name': 'constant.character.escape', |
| 18 | 'pattern': /\\('|"){1}/g |
| 19 | } |
| 20 | } |
| 21 | }, |
| 22 | 'pattern': /(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm |
| 23 | }, |
| 24 | { |
| 25 | 'name': 'comment', |
| 26 | 'pattern': /\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm |
| 27 | }, |
| 28 | { |
| 29 | 'name': 'constant.numeric', |
| 30 | 'pattern': /\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi |
| 31 | }, |
| 32 | { |
| 33 | 'matches': { |
| 34 | 1: 'keyword' |
| 35 | }, |
| 36 | 'pattern': /\b(and|array|as|bool(ean)?|c(atch|har|lass|onst)|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi |
| 37 | }, |
| 38 | { |
| 39 | 'name': 'constant.language', |
| 40 | 'pattern': /true|false|null/g |
| 41 | }, |
| 42 | { |
| 43 | 'name': 'keyword.operator', |
| 44 | 'pattern': /\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g |
| 45 | }, |
| 46 | { |
| 47 | 'matches': { |
| 48 | 1: 'function.call' |
| 49 | }, |
| 50 | 'pattern': /(\w+?)(?=\()/g |
| 51 | }, |
| 52 | { |
| 53 | 'matches': { |
| 54 | 1: 'storage.function', |
| 55 | 2: 'entity.name.function' |
| 56 | }, |
| 57 | 'pattern': /(function)\s(.*?)(?=\()/g |
| 58 | } |
| 59 | ]); |