From 5ea5788f256af20fd5b6ec2fef8ece14f546b4bd Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 15 Feb 2017 21:24:42 -0500 Subject: [PATCH] Add sample syntax files --- syntax_files/c.yaml | 47 +++++++++++++++++++++++++++++++++ syntax_files/go.yaml | 51 ++++++++++++++++++++++++++++++++++++ syntax_files/java.yaml | 34 ++++++++++++++++++++++++ syntax_files/javascript.yaml | 42 +++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 syntax_files/c.yaml create mode 100644 syntax_files/go.yaml create mode 100644 syntax_files/java.yaml create mode 100644 syntax_files/javascript.yaml diff --git a/syntax_files/c.yaml b/syntax_files/c.yaml new file mode 100644 index 0000000..6f0d1d0 --- /dev/null +++ b/syntax_files/c.yaml @@ -0,0 +1,47 @@ +filetype: c + +detect: + filename: "\\.(c|C)$" + +rules: + - identifier: "\\b[A-Z_][0-9A-Z_]+\\b" + - type: "\\b(float|double|char|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\\b" + - type: "\\b((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\\b" + - statement: "\\b(typename|mutable|volatile|register|explicit)\\b" + - statement: "\\b(for|if|while|do|else|case|default|switch)\\b" + - statement: "\\b(try|throw|catch|operator|new|delete)\\b" + - statement: "\\b(goto|continue|break|return)\\b" + - preproc: "^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)" + - constant: "'([^'\\\\]|(\\\\[\"'abfnrtv\\\\]))'" + - constant: "'\\\\(([0-3]?[0-7]{1,2}))'" + - constant: "'\\\\x[0-9A-Fa-f]{1,2}'" + # GCC builtins + - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)" + - statement: "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" + # Operator Color + - statement: "([.:;,+*|=!\\%]|<|>|/|-|&)" + - constant.number: "(\\b[0-9]+\\b|\\b0x[0-9A-Fa-f]+\\b)" + - constant.number: "NULL" + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'" + end: "'" + rules: + - preproc: "..+" + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: [] + + - comment: + start: "/\\*" + end: "\\*/" + rules: [] diff --git a/syntax_files/go.yaml b/syntax_files/go.yaml new file mode 100644 index 0000000..e37b045 --- /dev/null +++ b/syntax_files/go.yaml @@ -0,0 +1,51 @@ +filetype: go + +detect: + filename: "\\.go$" + +rules: + - statement: "\\b(break|case|continue|default|else|for|go|goto|if|range|return|switch)\\b" + - statement: "\\b(package|import|const|var|type|struct|func|go|defer|iota)\\b" + - statement: "[-+/*=<>!~%&|^]|:=" + - identifier: "[a-zA-Z0-9]*\\(" + - type: "\\b(u?int(8|16|32|64)?|float(32|64)|complex(64|128))\\b" + - type: "\\b(uintptr|byte|rune|string|interface|bool|map|chan|error)\\b" + - constant: "\\b(true|false|nil)\\b" + - statement: "(\\{|\\})" + - statement: "(\\(|\\))" + - statement: "(\\[|\\])" + - statement: "!" + - statement: "," + - constant.number: "\\b([0-9]+|0x[0-9a-fA-F]*)\\b" + - constant.specialChar: "([0-7]{3|x[A-Fa-f0-9]{2}|u[A-Fa-f0-9]{4}|U[A-Fa-f0-9]{8})" + + - comment: + start: "//" + end: "$" + rules: + - todo: "(TODO|XXX|FIXME):?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: [] + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + - constant.specialChar: "%." + + - constant.string: + start: "'" + end: "'" + rules: + - preproc: "..+" + - constant.specialChar: "%." + - constant.specialChar: "\\\\." + + - constant.string: + start: "`" + end: "`" + rules: [] diff --git a/syntax_files/java.yaml b/syntax_files/java.yaml new file mode 100644 index 0000000..23798d9 --- /dev/null +++ b/syntax_files/java.yaml @@ -0,0 +1,34 @@ +filetype: java + +detect: + filename: "\\.java$" + +rules: + - type: "\\b(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\\b" + - statement: "\\b(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\\b" + - type: "\\b(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\\b" + - constant: "\\b(true|false|null)\\b" + - constant.number: "\\b[0-9]+\\b" + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'" + end: "'" + rules: + - preproc: "..+" + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: [] + + - comment: + start: "/\\*" + end: "\\*/" + rules: [] diff --git a/syntax_files/javascript.yaml b/syntax_files/javascript.yaml new file mode 100644 index 0000000..bb41762 --- /dev/null +++ b/syntax_files/javascript.yaml @@ -0,0 +1,42 @@ +filetype: javascript + +detect: + filename: "\\.js$" + +rules: + - constant.number: "\\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\\b" + - constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" + - constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" + - identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" + - statement: "\\b(break|case|catch|continue|default|delete|do|else|finally)\\b" + - statement: "\\b(for|function|get|if|in|instanceof|new|return|set|switch)\\b" + - statement: "\\b(switch|this|throw|try|typeof|var|void|while|with)\\b" + - constant: "\\b(null|undefined|NaN)\\b" + - constant: "\\b(true|false)\\b" + - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Math)\\b" + - type: "\\b(Number|Object|RegExp|String)\\b" + - statement: "[-+/*=<>!~%?:&|]" + - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*" + - constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]" + + - constant.string: + start: "\"" + end: "\"" + rules: + - constant.specialChar: "\\\\." + + - constant.string: + start: "'" + end: "'" + rules: + - constant.specialChar: "\\\\." + + - comment: + start: "//" + end: "$" + rules: [] + + - comment: + start: "/\\*" + end: "\\*/" + rules: []