cLanguage top-level constant

Grammar const cLanguage

C.

Implementation

const cLanguage = Grammar(
  name: 'c',
  aliases: ['h'],
  fileExtensions: ['c', 'h'],
  signatures: [
    r'^#include\s*<[\w./]+\.h>',
    r'\bint\s+main\s*\(',
    r'\b(?:printf|malloc|free|sizeof)\s*\(',
  ],
  rules: [
    ...cCommonRules,
    CommonRules.memberCall,
    CommonRules.member,
    KeywordRule(
      {
        Scopes.keyword: cKeywords,
        Scopes.typeBuiltin: cTypes,
        Scopes.literal: cLiterals,
      },
      otherwise: [CommonRules.functionCall],
    ),
    Operators('+-*/%=<>!&|^~?:'),
  ],
);