Warning, /frameworks/syntax-highlighting/autotests/input/highlight.jsonnet is written in an unsupported language. File is not indexed.
0001 local utils = import 'utils.libsonnet'; 0002 0003 /* A C-style 0004 comment. 0005 */ 0006 # A Python-style comment. 0007 0008 // Define a "local" function. 0009 // Default arguments are like Python: 0010 local my_function(x, y=10) = x + y; 0011 0012 local object = { 0013 // A method 0014 my_method(x): x * x, 0015 }; 0016 0017 local string1 = 'Farmer\'s Gin'; 0018 local string_newline1 = 'this is 0019 a valid string 0020 with newlines'; 0021 local string_newline2 = "this is 0022 also 0023 a valid string"; 0024 0025 local timcollins = ||| 0026 The Tom Collins is essentially gin and 0027 lemonade. The bitters add complexity. 0028 |||; 0029 0030 local obj = { 0031 "foo": 1, 0032 "bar": { 0033 "arr": [1, 2, 3], 0034 "number": 10 + 7, 0035 }, 0036 }; 0037 0038 // Define a local function. 0039 // Default arguments are like Python: 0040 local my_function(x, y=10) = x + y; 0041 0042 // Define a local multiline function. 0043 local multiline_function(x) = 0044 // One can nest locals. 0045 local temp = x * 2; 0046 // Every local ends with a semi-colon. 0047 [temp, temp + 1]; 0048 0049 local object = { 0050 // A method 0051 my_method(x): x * x, 0052 }; 0053 0054 local large = true; 0055 0056 { 0057 0058 // Functions are first class citizens. 0059 call_inline_function: 0060 (function(x) x * x)(5), 0061 0062 call_multiline_function: multiline_function(4), 0063 0064 // Using the variable fetches the function, 0065 // the parens call the function. 0066 call: my_function(2), 0067 0068 // Like python, parameters can be named at 0069 // call time. 0070 named_params: my_function(x=2), 0071 // This allows changing their order 0072 named_params2: my_function(y=3, x=2), 0073 0074 // object.my_method returns the function, 0075 // which is then called like any other. 0076 call_method1: object.my_method(3), 0077 0078 standard_lib: 0079 std.join(' ', std.split("foo/bar", '/')), 0080 len: [ 0081 std.length('hello'), 0082 std.length([1, 2, 3]), 0083 ], 0084 0085 cocktails: { 0086 local factor = if large then 2 else 1, 0087 0088 // Ingredient quantities are in fl oz. 0089 'Tom Collins': { 0090 ingredients: [ 0091 { kind: string1, qty: 1.5*factor }, 0092 { kind: 'Lemon', qty: 1 }, 0093 { kind: 'Simple Syrup', qty: 0.5E+1 }, 0094 { kind: 'Soda', qty: 2 }, 0095 { kind: 'Angostura', qty: 'dash' }, 0096 ], 0097 garnish: 'Maraschino Cherry', 0098 served: 'Tall', 0099 description: timcollins, 0100 }, 0101 }, 0102 }