diff options
author | Jean-Nicolas Veigel <art.jnveigel@gmail.com> | 2024-03-16 03:54:38 +0100 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2024-03-26 10:31:25 +0000 |
commit | a493b21f916ebd6dad57d9cbe392a5daccab7315 (patch) | |
tree | 17bd6fc7a7fe983ad88ae021d826b73fac006b82 | |
parent | a2db58855e1102d38ae2a151cfe04141d429266c (diff) | |
download | tour-a493b21f916ebd6dad57d9cbe392a5daccab7315.tar.gz tour-a493b21f916ebd6dad57d9cbe392a5daccab7315.zip |
syntax highlight regexes
-rw-r--r-- | static/js/highlight/regexes.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/static/js/highlight/regexes.js b/static/js/highlight/regexes.js new file mode 100644 index 0000000..c59c5c8 --- /dev/null +++ b/static/js/highlight/regexes.js @@ -0,0 +1,20 @@ + +export const snakeCase = /\b(?:_)*[a-z_]+[a-z\d_]+\b/g; +export const punctuation = /[\\.,\(\):\[\]{}#]/g; +export const endParenthesis = /\(/g; +export const importModule = /(?<=import )\b(?:_)*[a-z_]+[a-z\d_]+\b/g +export const functionCall = /\b(?:_)*[a-z_]+[a-z\d_]+\b(?=\()/g; +export const functionParam = /(?<=\b(?:_)*[a-z_]+[a-z\d_]+\b\()(.|\s|\n)*(?=\))/g; +export const operator = /(<<|>>|<-|->|\|>|<>|\.\.|<=\.?|>=\.?|==\.?|!=\.?|<\.?|>\.?|&&|\|\||\+\.?|-\.?|\/\.?|\*\.?|%\.?|=)/g; +export const type = /\b[A-Z]{1}(?:[a-z]+[A-Z]{0,1})*\b/g; +export const booleanOrNil = /\b(True|False|Nil)\b/g; +export const comment = /\/\/.*/g; +export const attribute = /@[a-zA-Z0-9]+\b(?=\()/g; +export const discardName = /\b_[a-z][a-z0-9_]*\b/g; +export const number = { + binary: "\\b0[bB](?:_?[01]+)+", + octal: "\\b0[oO](?:_?[0-7]+)+", + hex: "\\b0[xX](?:_?[0-9a-fA-F]+)+", + decOrFloat: /\b\d(?:_?\d+)*(?:\.(?:\d(?:_?\d+)*)*)?/g, + scientific: /(?:(?:-\d)|\d)(?:_?\d+)*(?:\.(?:\d(?:_?\d+)*)*)?e(?:(?:-\d)|\d)(?:_?\d+)*(?:\.(?:\d(?:_?\d+)*)*)?/g +}
\ No newline at end of file |