namespace AIStudio.Tools.CodeHighlighting.Languages; /// /// How JavaScript code looks to the tokenizer, JSX included, whose tags stay plain. /// /// /// A template literal stays one string, including the expressions within it. A regular expression /// literal stays plain: telling it from a division needs the grammar of the language. /// public static class JavaScriptCodeRules { /// /// The keywords of JavaScript, which TypeScript has, too. /// internal static readonly string[] KEYWORDS = [ "async", "await", "break", "case", "catch", "class", "const", "continue", "debugger", "default", "delete", "do", "else", "export", "extends", "finally", "for", "from", "function", "if", "import", "in", "instanceof", "let", "new", "of", "return", "static", "super", "switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "yield", ]; /// /// The words of JavaScript which stand for a value, which TypeScript has, too. /// internal static readonly string[] LITERALS = ["true", "false", "null", "undefined", "NaN", "Infinity"]; /// /// The strings of JavaScript, which TypeScript has, too. /// internal static readonly IReadOnlyList STRINGS = [ new("`", "`", IsMultiline: true), new("\"", "\""), new("'", "'"), ]; public static readonly CodeLanguageRules RULES = new() { Keywords = CodeLanguageRules.Words(KEYWORDS), Literals = CodeLanguageRules.Words(LITERALS), FunctionDeclarations = CodeLanguageRules.Words("function"), TypeDeclarations = CodeLanguageRules.Words("class"), LineComments = ["//"], BlockComments = [new("/*", "*/")], Strings = STRINGS, AnnotationPrefix = '@', WordStartCharacters = "$", WordCharacters = "$", }; }