Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

80 lines (74 sloc) 2.545 kB
# Coco language plugin for
# [google-code-prettify](http://code.google.com/p/google-code-prettify/).
tint = (ext, shortcuts, fallthroughs) ->
rule.splice 2 0 0 if rule.length < 4 for rule of shortcuts
PR.registerLangHandler PR.createSimpleLexer(shortcuts, fallthroughs), [ext]
ident = /(?![\d\s])[$\w\xAA-\uFFDC](?:(?!\s)[$\w\xAA-\uFFDC]|-[A-Za-z])*/$
kwend = /(?!(?!\s)[$\w\xAA-\uFFDC]|-[A-Za-z])/$
### Main
tint \co [
[\str // ^ '(?: ''[\S\s]*?'' | [^\\']*(?:\\[\S\s][^\\']*)* )' // \']
[\lang-co-qq //(^ "(?: ""[\S\s]*?"" | [^\\"]*(?:\\[\S\s][^\\"]*)* )" )// \"]
[\lang-co-qr //(^ / / [\S\s]*? / / [gimy$?]{0,4} )// \/]
[\lang-co-at //(^ @@? #ident? )// \@]
[\com /^#.*/ \#]
[\typ // ^ (?
: 0x[\da-f][\da-f_]*
| (?:[2-9]|[12]\d|3[0-6]) r [\da-z][\da-z_]*
| \d[\d_]*(?:\.\d[\d_]*)? (?:e[+-]?\d[\d_]*)? [\w$]*
) //i \0123456789]
[\lang-js /^`([^\\`]*(?:\\[\S\s][^\\`]*)*)`/ \`]
] [
[\str // ^ \\ \S [^\s,;)}\]]* //]
[\com // ^ /\* [\S\s]* \*/ //]
[\pln // ^ (?
: \.{3}
| (?: \.\s*(?:(?:[-+*/%&|^:]|>>>?|<<)?=|[~!@])?\s* | [)}\]?] | :: )
(?: #ident[?~!@]? )+
| #ident [^\n\S]* :(?![:=])
) //]
# ref. [retrie](https://github.com/satyr/retrie)
[\kwd // ^ (?
: t(?:ry|h(?:row|en)|ypeof!?)
| f(?:or(?:[^\n\S]+(?:own|ever))?|inally|unction)
| n(?:ew|ot)
| c(?:on(?:tinue|st)|a(?:se|tch)|lass)
| i(?:[fs]|n(?:stanceof)?|mp(?:ort(?:[^\n\S]+all)?|lements))
| e(?:lse|x(?:tends|port))
| d(?:e(?:fault|lete|bugger)|o)
| un(?:less|til)
| w(?:hile|ith)
| s(?:witch|uper)
| o[fr] | return | break | and | let | var
) #kwend //]
[\typ // ^ (?: true | false | null | void ) #kwend //]
[\ctx // ^ (?
: t(?:h(?:is|at)|o|il)
| f(?:rom|allthrough)
| e(?:val)?
| it | arguments | by | constructor | prototype | superclass
) #kwend //]
[\glb // ^ (?
: Array | Boolean | Date | Error | Function | JSON | Math | Number
| Object | RegExp | S(?:tring|yntaxError) | TypeError
| is(?:NaN|Finite) | parse(?:Int|Float) | (?:en|de)codeURI(?:Component)?
) #kwend //]
[\var // ^ #ident //]
[\str /^<\[[\S\s]*?]>/]
[\lang-co-r // ^ [^/] (
/ (?![\s/])
[^ [ / \n \\ ]*
(?:
(?: \\.
| \[ [^\]\n\\]*(?:\\.[^\]\n\\]*)* \]
) [^ [ / \n \\ ]*
)* / [gimy$]{0,4}
) (?!\d) //]
]
### Subrules
interps = [\lang-co // ^# ({[\S\s]*?} | #ident | [@&]) // \#]
regexes = [\lit /^[\S\s]+?/]
tint \co-qq [interps] [[\str /^[\S\s]+?/]]
tint \co-qr [interps] [[\com /^\s#(?!{).*/] regexes]
tint \co-r [] [regexes]
tint \co-at [[\ctx /^@+/ \@]] []
Jump to Line
Something went wrong with that request. Please try again.