Jsonnet mode // C++ style comment /* C style comment */ # Hash comment local various_primitives = [ 'foo\\bar\"\u00a0', "foo\\bar\"\u00a0", @'foo\\bar''\"\u00a0', @"foo\\bar""\'\u00a0", import 'foo\\bar\"\u00a0', import "foo\\bar\"\u00a0", importstr @'foo\\bar''\"\u00a0', importstr @"foo\\bar""\'\u00a0", ||| foo\\bar\"\u00a0 bar baz function | /* still a string */ // still a string ||| didn't do anything |||, // empty file ||| |||, // blank line ||| |||, // Blank lines at beginning. ||| content |||, ||| foo ||| surprise! ||| |||, /* ||| ignore in comment ||| */ "||| ignore in string", "x\"\'x\\x\/x\bx\fx\nx\rx\tx", 'x\"\'x\\x\/x\bx\fx\nx\rx\tx', 0, 0e+0, 0e-0, 0e0, 0E+0, 0E-0, 0E0, 0.0, 0.0e+0, 0.0e-0, 0.0e0, 0.0E+0, 0.0E-0, 0.0E0, 10, 10e+0, 10e-0, 10e0, 10E+0, 10E-0, 10E0, 10.0, 10.0e+0, 10.0e-0, 10.0e0, 10.0E+0, 10.0E-0, 10.0E0, 123, 123.456, 789, 1 + 1, 1.05, 1.999e-999, false, true, null, ]; local keywords = [ import "foo", importstr "foo", import @"foo", importstr @'foo', error "foo", assert true : "bar"; "baz", { f: self, g: super.g, h: $.f }, if true then 0 else 1, { [k]: k for k in ["a", "b", "c"] }, function(x=10) x * x, std.join([], []), // Contains 'in' which should not be highlighted. ]; local myfunc(x=10) = x * x; local tail(x, c) = if x == 0 then c else tail(x - 1, c + x) tailstrict; local obj = { g: 100 } local obj_g = obj.g; local parens = (100 / (1 + 1)); local operators = [ !true, ~100, 10 - 5, 5 & 3, 4 | 3, 10 ^ 2, 1 == 3, 1 <= 3, 1 >= 3, 1 < 3, 1 > 3, 1 * 10, 1 / 3, 10 % 3, ]; // Compiler template local CCompiler = { cFlags: [], out: "a.out", local flags_str = std.join(" ", self.cFlags), local files_str = std.join(" ", self.files), cmd: "%s %s %s -o %s" % [self.compiler, flags_str, files_str, self.out], }; // GCC specialization local Gcc = CCompiler { compiler: "gcc" }; // Another specialization local Clang = CCompiler { compiler: "clang" }; // Mixins - append flags local Opt = { cFlags: super.cFlags + ["-O3", "-DNDEBUG"] }; local Dbg = { cFlags: super.cFlags + ["-g"] }; // Output: { targets: [ Gcc { files: ["a.c", "b.c"] }, Clang { files: ["test.c"], out: "test" }, Clang + Opt { files: ["test2.c"], out: "test2" }, Gcc + Opt + Dbg { files: ["foo.c", "bar.c"], out: "baz" }, ], } MIME types defined: text/jsonnet, text/x-jsonnet.