CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
dts.js158 linesDownload Raw Back to languages
1/*2Language: Device Tree3Description: *.dts files used in the Linux kernel4Author: Martin Braun <martin.braun@ettus.com>, Moritz Fischer <moritz.fischer@ettus.com>5Website: https://elinux.org/Device_Tree_Reference6Category: config7*/8 9/** @type LanguageFn */10function dts(hljs) {11  const STRINGS = {12    className: 'string',13    variants: [14      hljs.inherit(hljs.QUOTE_STRING_MODE, { begin: '((u8?|U)|L)?"' }),15      {16        begin: '(u8?|U)?R"',17        end: '"',18        contains: [ hljs.BACKSLASH_ESCAPE ]19      },20      {21        begin: '\'\\\\?.',22        end: '\'',23        illegal: '.'24      }25    ]26  };27 28  const NUMBERS = {29    className: 'number',30    variants: [31      { begin: '\\b(\\d+(\\.\\d*)?|\\.\\d+)(u|U|l|L|ul|UL|f|F)' },32      { begin: hljs.C_NUMBER_RE }33    ],34    relevance: 035  };36 37  const PREPROCESSOR = {38    className: 'meta',39    begin: '#',40    end: '$',41    keywords: { keyword: 'if else elif endif define undef ifdef ifndef' },42    contains: [43      {44        begin: /\\\n/,45        relevance: 046      },47      {48        beginKeywords: 'include',49        end: '$',50        keywords: { keyword: 'include' },51        contains: [52          hljs.inherit(STRINGS, { className: 'string' }),53          {54            className: 'string',55            begin: '<',56            end: '>',57            illegal: '\\n'58          }59        ]60      },61      STRINGS,62      hljs.C_LINE_COMMENT_MODE,63      hljs.C_BLOCK_COMMENT_MODE64    ]65  };66 67  const REFERENCE = {68    className: 'variable',69    begin: /&[a-z\d_]*\b/70  };71 72  const KEYWORD = {73    className: 'keyword',74    begin: '/[a-z][a-z\\d-]*/'75  };76 77  const LABEL = {78    className: 'symbol',79    begin: '^\\s*[a-zA-Z_][a-zA-Z\\d_]*:'80  };81 82  const CELL_PROPERTY = {83    className: 'params',84    relevance: 0,85    begin: '<',86    end: '>',87    contains: [88      NUMBERS,89      REFERENCE90    ]91  };92 93  const NODE = {94    className: 'title.class',95    begin: /[a-zA-Z_][a-zA-Z\d_@-]*(?=\s\{)/,96    relevance: 0.297  };98 99  const ROOT_NODE = {100    className: 'title.class',101    begin: /^\/(?=\s*\{)/,102    relevance: 10103  };104 105  // TODO: `attribute` might be the right scope here, unsure106  // I'm not sure if all these key names have semantic meaning or not107  const ATTR_NO_VALUE = {108    match: /[a-z][a-z-,]+(?=;)/,109    relevance: 0,110    scope: "attr"111  };112  const ATTR = {113    relevance: 0,114    match: [115      /[a-z][a-z-,]+/,116      /\s*/,117      /=/118    ],119    scope: {120      1: "attr",121      3: "operator"122    }123  };124 125  const PUNC = {126    scope: "punctuation",127    relevance: 0,128    // `};` combined is just to avoid tons of useless punctuation nodes129    match: /\};|[;{}]/130  };131 132  return {133    name: 'Device Tree',134    contains: [135      ROOT_NODE,136      REFERENCE,137      KEYWORD,138      LABEL,139      NODE,140      ATTR,141      ATTR_NO_VALUE,142      CELL_PROPERTY,143      hljs.C_LINE_COMMENT_MODE,144      hljs.C_BLOCK_COMMENT_MODE,145      NUMBERS,146      STRINGS,147      PREPROCESSOR,148      PUNC,149      {150        begin: hljs.IDENT_RE + '::',151        keywords: ""152      }153    ]154  };155}156 157export { dts as default };158 
basant307/AI_Governance_Project · CoolFace