From 068704a2f69d409bf8f26b62988998a60080f3ad Mon Sep 17 00:00:00 2001 From: Golmote Date: Mon, 31 Aug 2015 09:06:27 +0200 Subject: [PATCH] Scheme: Fixes and simplifications --- components/prism-scheme.js | 17 ++++++++++------- components/prism-scheme.min.js | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/components/prism-scheme.js b/components/prism-scheme.js index 7966e543b4..9541d3cf78 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -1,22 +1,25 @@ Prism.languages.scheme = { - 'boolean' : /#(t|f){1}/, 'comment' : /;.*/, + 'string' : /"(?:[^"\\\r\n]|\\.)*?"|'[^'\s]+/, //thanks http://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks 'keyword' : { - pattern : /([(])(define(-syntax|-library|-values)?|(case-)?lambda|let(-values|(rec)?(\*)?)?|else|if|cond|begin|delay|delay-force|parameterize|guard|set!|(quasi-)?quote|syntax-rules)/, + pattern : /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-rules)/, lookbehind : true }, 'builtin' : { - pattern : /([(])(cons|car|cdr|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b/, + pattern : /(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)/, lookbehind : true }, - 'string' : /(["])(?:(?=(\\?))\2.)*?\1|'[^('|\s)]+/, //thanks http://stackoverflow.com/questions/171480/regex-grabbing-values-between-quotation-marks 'number' : { - pattern: /(\s|\))[-+]?[0-9]*\.?[0-9]+((\s*)[-+]{1}(\s*)[0-9]*\.?[0-9]+i)?/, + pattern: /(\s|\))[-+]?[0-9]*\.?[0-9]+(?:\s*[-+]\s*[0-9]*\.?[0-9]+i)?\b/, + lookbehind: true + }, + 'boolean' : /#[tf]/, + 'operator': { + pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)/, lookbehind: true }, - 'operator': /(\*|\+|\-|%|\/|<=|=>|>=|<|=|>)/, 'function' : { - pattern : /([(])[^(\s|\))]*\s/, + pattern : /(\()[^\s()]*(?=\s)/, lookbehind : true }, 'punctuation' : /[()]/ diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index 131ec36e2b..fb53cdaee7 100644 --- a/components/prism-scheme.min.js +++ b/components/prism-scheme.min.js @@ -1 +1 @@ -Prism.languages.scheme={"boolean":/#(t|f){1}/,comment:/;.*/,keyword:{pattern:/([(])(define(-syntax|-library|-values)?|(case-)?lambda|let(-values|(rec)?(\*)?)?|else|if|cond|begin|delay|delay-force|parameterize|guard|set!|(quasi-)?quote|syntax-rules)/,lookbehind:!0},builtin:{pattern:/([(])(cons|car|cdr|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b/,lookbehind:!0},string:/(["])(?:(?=(\\?))\2.)*?\1|'[^('|\s)]+/,number:{pattern:/(\s|\))[-+]?[0-9]*\.?[0-9]+((\s*)[-+]{1}(\s*)[0-9]*\.?[0-9]+i)?/,lookbehind:!0},operator:/(\*|\+|\-|%|\/|<=|=>|>=|<|=|>)/,"function":{pattern:/([(])[^(\s|\))]*\s/,lookbehind:!0},punctuation:/[()]/}; \ No newline at end of file +Prism.languages.scheme={comment:/;.*/,string:/"(?:[^"\\\r\n]|\\.)*?"|'[^'\s]+/,keyword:{pattern:/(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-rules)/,lookbehind:!0},builtin:{pattern:/(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)/,lookbehind:!0},number:{pattern:/(\s|\))[-+]?[0-9]*\.?[0-9]+(?:\s*[-+]\s*[0-9]*\.?[0-9]+i)?\b/,lookbehind:!0},"boolean":/#[tf]/,operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)/,lookbehind:!0},"function":{pattern:/(\()[^\s()]*(?=\s)/,lookbehind:!0},punctuation:/[()]/}; \ No newline at end of file