awk.js (1290B)
1 /* 2 Language: Awk 3 Author: Matthew Daly <matthewbdaly@gmail.com> 4 Website: https://www.gnu.org/software/gawk/manual/gawk.html 5 Description: language definition for Awk scripts 6 */ 7 8 /** @type LanguageFn */ 9 function awk(hljs) { 10 var VARIABLE = { 11 className: 'variable', 12 variants: [ 13 {begin: /\$[\w\d#@][\w\d_]*/}, 14 {begin: /\$\{(.*?)}/} 15 ] 16 }; 17 var KEYWORDS = 'BEGIN END if else while do for in break continue delete next nextfile function func exit|10'; 18 var STRING = { 19 className: 'string', 20 contains: [hljs.BACKSLASH_ESCAPE], 21 variants: [ 22 { 23 begin: /(u|b)?r?'''/, end: /'''/, 24 relevance: 10 25 }, 26 { 27 begin: /(u|b)?r?"""/, end: /"""/, 28 relevance: 10 29 }, 30 { 31 begin: /(u|r|ur)'/, end: /'/, 32 relevance: 10 33 }, 34 { 35 begin: /(u|r|ur)"/, end: /"/, 36 relevance: 10 37 }, 38 { 39 begin: /(b|br)'/, end: /'/ 40 }, 41 { 42 begin: /(b|br)"/, end: /"/ 43 }, 44 hljs.APOS_STRING_MODE, 45 hljs.QUOTE_STRING_MODE 46 ] 47 }; 48 return { 49 name: 'Awk', 50 keywords: { 51 keyword: KEYWORDS 52 }, 53 contains: [ 54 VARIABLE, 55 STRING, 56 hljs.REGEXP_MODE, 57 hljs.HASH_COMMENT_MODE, 58 hljs.NUMBER_MODE 59 ] 60 } 61 } 62 63 module.exports = awk;