ze
Loading...
Searching...
No Matches
Macros | Functions | Variables
syntax.c File Reference

Syntax highlighting engine implementation. More...

#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "ze.h"
Include dependency graph for syntax.c:

Macros

#define HLDB_ENTRIES   (sizeof(HLDB) / sizeof(HLDB[0]))
 

Functions

int is_separator (int c)
 Determine whether a byte is a token separator for highlighting.
 
void editorUpdateSyntax (erow *row)
 Compute highlighting for a row based on current filetype.
 
int editorSyntaxToColor (int hl)
 Map a highlight class to an ANSI color code.
 
void editorSelectSyntaxHighlight (void)
 Select appropriate language rules based on E.filename.
 

Variables

struct editorConfig E
 
char * C_HL_extensions [] = {".c", ".h", ".cpp", NULL}
 
char * Python_HL_extensions [] = {".py", NULL}
 
char * Ruby_HL_extensions [] = {".rb", ".erb", NULL}
 
char * PHP_HL_extensions [] = {".php", NULL}
 
char * Rust_HL_extensions [] = {".rs", NULL}
 
char * APL_HL_extensions [] = {".apl", NULL}
 
char * Swift_HL_extensions [] = {".swift", NULL}
 
char * TypeScript_HL_extensions [] = {".ts", ".tsx", NULL}
 
char * C_HL_keywords []
 
char * Python_HL_keywords []
 
char * Ruby_HL_keywords []
 
char * PHP_HL_keywords []
 
char * Rust_HL_keywords []
 
char * APL_HL_keywords []
 
char * Swift_HL_keywords []
 
char * TypeScript_HL_keywords []
 
struct editorSyntax HLDB []
 

Detailed Description

Syntax highlighting engine implementation.

Macro Definition Documentation

◆ HLDB_ENTRIES

#define HLDB_ENTRIES   (sizeof(HLDB) / sizeof(HLDB[0]))

Variable Documentation

◆ APL_HL_extensions

char* APL_HL_extensions[] = {".apl", NULL}

◆ APL_HL_keywords

char* APL_HL_keywords[]
Initial value:
= {
"Public", "Shared",
":Class|", ":Access|", ":For|", ":In|", ":EndFor|", ":If|", ":AndIf|", ":EndIf|",
":EndClass|", NULL
}

◆ C_HL_extensions

char* C_HL_extensions[] = {".c", ".h", ".cpp", NULL}

◆ C_HL_keywords

char* C_HL_keywords[]
Initial value:
= {
"switch", "if", "while", "for", "break", "continue", "return", "else",
"struct", "union", "typedef", "static", "enum", "class", "case", "NULL",
"int|", "long|", "double|", "float|", "char|", "unsigned|", "signed|",
"void|", "#define|", "#include|", NULL
}

◆ HLDB

struct editorSyntax HLDB[]
Initial value:
= {
{ "c", C_HL_extensions, C_HL_keywords, "//", "/*", "*/",
{ "python", Python_HL_extensions, Python_HL_keywords, "#", "'''", "'''",
{ "ruby", Ruby_HL_extensions, Ruby_HL_keywords, "#", "=begin", "=end",
{ "PHP", PHP_HL_extensions, PHP_HL_keywords, "//", "/*", "*/",
{ "Rust", Rust_HL_extensions, Rust_HL_keywords, "//", "/*", "*/",
{ "APL", APL_HL_extensions, APL_HL_keywords, "⍝", "⍝", "⍝",
{ "Swift", Swift_HL_extensions, Swift_HL_keywords, "//", "/*", "*/",
{ "TypeScript", TypeScript_HL_extensions, TypeScript_HL_keywords, "//", "/*", "*/",
}
#define HL_HIGHLIGHT_NUMBERS
Definition ze.h:56
#define HL_HIGHLIGHT_STRINGS
Definition ze.h:58
char * Ruby_HL_keywords[]
Definition syntax.c:36
char * Ruby_HL_extensions[]
Definition syntax.c:16
char * Swift_HL_keywords[]
Definition syntax.c:70
char * Swift_HL_extensions[]
Definition syntax.c:20
char * TypeScript_HL_extensions[]
Definition syntax.c:21
char * PHP_HL_keywords[]
Definition syntax.c:43
char * TypeScript_HL_keywords[]
Definition syntax.c:84
char * C_HL_keywords[]
Definition syntax.c:23
char * C_HL_extensions[]
Definition syntax.c:14
char * PHP_HL_extensions[]
Definition syntax.c:17
char * Python_HL_extensions[]
Definition syntax.c:15
char * Rust_HL_extensions[]
Definition syntax.c:18
char * Python_HL_keywords[]
Definition syntax.c:29
char * APL_HL_keywords[]
Definition syntax.c:65
char * Rust_HL_keywords[]
Definition syntax.c:56
char * APL_HL_extensions[]
Definition syntax.c:19

◆ PHP_HL_extensions

char* PHP_HL_extensions[] = {".php", NULL}

◆ PHP_HL_keywords

char* PHP_HL_keywords[]
Initial value:
= {
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable",
"case", "catch", "class", "clone", "const", "continue", "declare", "default",
"die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor",
"endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends",
"final", "for", "foreach", "function", "global", "goto", "if", "implements",
"include", "include_once", "instanceof", "insteadof", "interface", "isset",
"list", "namespace", "new", "or", "print", "private", "protected", "public",
"require", "require_once", "return", "static", "switch", "throw", "trait",
"try", "unset", "use", "var", "while", "xor",
"__CLASS__|", "__DIR__|", "__FILE__|", "__FUNCTION__|", "__LINE__|",
"__METHOD__|", "__NAMESPACE__|", "__TRAIT__|", NULL
}

◆ Python_HL_extensions

char* Python_HL_extensions[] = {".py", NULL}

◆ Python_HL_keywords

char* Python_HL_keywords[]
Initial value:
= {
"and", "as", "assert", "break", "class", "continue", "def", "del", "elif",
"else", "except", "finally", "for", "from", "global", "if", "import", "in",
"is", "lambda", "nonlocal", "not", "or", "pass", "raise", "return", "try",
"while", "with", "yield",
"False|", "None|", "True|", NULL
}

◆ Ruby_HL_extensions

char* Ruby_HL_extensions[] = {".rb", ".erb", NULL}

◆ Ruby_HL_keywords

char* Ruby_HL_keywords[]
Initial value:
= {
"alias", "and", "begin", "break", "case", "class", "def", "defined?", "do",
"else", "elsif", "end", "ensure", "false", "for", "if", "in", "module", "next",
"nil", "not", "or", "redo", "rescue", "retry", "return", "self", "super", "then",
"true", "undef", "unless", "until", "when", "while", "yield",
"__ENCODING__|", "__LINE__|", "__FILE__|", "BEGIN|", "END|", NULL
}

◆ Rust_HL_extensions

char* Rust_HL_extensions[] = {".rs", NULL}

◆ Rust_HL_keywords

char* Rust_HL_keywords[]
Initial value:
= {
"_", "abstract", "alignof", "as", "become", "box", "break", "const", "continue",
"crate", "do", "else", "enum", "extern", "false", "final", "fn", "for", "if",
"impl", "in", "let", "loop", "macro", "match", "mod", "move", "mut", "offset",
"override", "priv", "proc", "pub", "pure", "ref", "return", "Self", "self",
"sizeof", "static", "struct", "super", "trait", "true", "type", "typeof", "unsafe",
"unsized", "use", "virtual", "where", "while", "yield",
"derive|", "println!|", "Some|", "unwrap()|", "value_of()|", "next()|", "to_string()|", NULL
}

◆ Swift_HL_extensions

char* Swift_HL_extensions[] = {".swift", NULL}

◆ Swift_HL_keywords

char* Swift_HL_keywords[]
Initial value:
= {
"associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func", "import",
"init", "inout", "internal", "let", "open", "operator", "private", "protocol", "public",
"static", "struct", "subscript", "typealias", "var","break", "case", "continue", "default",
"defer", "do", "else", "fallthrough", "for", "guard", "if", "in", "repeat", "return",
"switch", "where", "while,as", "Any", "catch", "false", "is", "nil", "rethrows", "super",
"self", "Self", "throw", "throws", "true", "try",
"#available|", "#colorLiteral|", "#column|", "#else|", "#elseif|", "#endif|", "#file|",
"#fileLiteral|", "#function|", "#if|", "#imageLiteral|", "#line|", "#selector|",
"#sourceLocation|", "associativity|", "convenience|", "dynamic|", "didSet|", "final|",
"get|", "infix|", "indirect|", "lazy|", "left|", "mutating|", "none|", "nonmutating|",
"optional|", "override|", "postfix|", "precedence|", "prefix|", "Protocol|", "required|",
"right|", "set|", "Type|", "unowned|", "weak|", "willSet|", NULL
}

◆ TypeScript_HL_extensions

char* TypeScript_HL_extensions[] = {".ts", ".tsx", NULL}

◆ TypeScript_HL_keywords

char* TypeScript_HL_keywords[]
Initial value:
= {
"abstract", "any", "as", "async", "await", "boolean", "break", "case", "catch", "class",
"const", "constructor", "continue", "debugger", "declare", "default", "delete", "do",
"else", "enum", "export", "extends", "false", "finally", "for", "from", "function",
"get", "if", "implements", "import", "in", "instanceof", "interface", "let", "module",
"namespace", "new", "null", "number", "of", "package", "private", "protected", "public",
"return", "set", "static", "string", "super", "switch", "symbol", "this", "throw",
"true", "try", "type", "typeof", "undefined", "var", "void", "while", "with", "yield",
"Array|", "Boolean|", "Date|", "Error|", "Function|", "JSON|", "Math|", "Number|",
"Object|", "Promise|", "Proxy|", "RegExp|", "Set|", "String|", "Symbol|", "TypeError|",
"URIError|", "WeakMap|", "WeakSet|", "console|", "document|", "window|", "global|",
"process|", "require|", "module|", "exports|", "__dirname|", "__filename|", NULL
}