diff --git a/src/common/filetype/c.ts b/src/common/filetype/c.ts new file mode 100644 index 0000000..b77e887 --- /dev/null +++ b/src/common/filetype/c.ts @@ -0,0 +1,154 @@ +import Option, { Some } from '../option.ts'; +import { + AbstractFileType, + defaultHighlightOptions, + FileLang, + HighlightingOptions, +} from './base.ts'; + +export class CFile extends AbstractFileType { + public readonly name: FileLang = FileLang.C; + public readonly singleLineComment = Some('//'); + public readonly multiLineCommentStart: Option = Some('/*'); + public readonly multiLineCommentEnd: Option = Some('*/'); + public readonly keywords1 = [ + 'continue', + 'register', + 'restrict', + 'volatile', + 'default', + 'typedef', + 'typedef', + 'switch', + 'return', + 'static', + 'struct', + 'extern', + 'inline', + 'return', + 'sizeof', + 'switch', + 'break', + 'const', + 'while', + 'break', + 'union', + 'class', + 'union', + 'auto', + 'case', + 'else', + 'enum', + 'case', + 'for', + 'do', + 'if', + ]; + public readonly keywords2 = [ + '#include', + 'unsigned', + 'uint32_t', + 'uint64_t', + 'uint16_t', + '#define', + '#ifndef', + 'wchar_t', + 'int32_t', + 'int64_t', + 'int16_t', + 'uint8_t', + 'double', + 'signed', + '#endif', + '#ifdef', + '#error', + '#undef', + 'int8_t', + 'time_t', + 'size_t', + 'float', + '#elif', + 'long', + 'char', + 'void', + 'int', + '#if', + ]; + public readonly operators = [ + '>>>=', + '**=', + '<<=', + '>>=', + '&&=', + '||=', + '??=', + '===', + '!==', + '>>>', + '<=>', + '<<=', + '>>=', + '+=', + '-=', + '*=', + '/=', + '%=', + '&=', + '^=', + '|=', + '==', + '!=', + '>=', + '<=', + '++', + '--', + '**', + '<<', + '>>', + '&&', + '||', + '??', + '?.', + '++', + '--', + '==', + '!=', + '>=', + '<=', + '&&', + '||', + '<<', + '>>', + '+=', + '-=', + '*=', + '/=', + '%=', + '&=', + '|=', + '^=', + '->', + '::', + '?', + ':', + '=', + '>', + '<', + '%', + '-', + '+', + '&', + '|', + '^', + '~', + '!', + '.', + ',', + ';', + ]; + public readonly hlOptions: HighlightingOptions = { + ...defaultHighlightOptions, + characters: true, + hexNumbers: true, + }; +}