mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 17:23:39 +01:00
Add support for Zig
Adds syntax support for source code for the Zig programming language. https://ziglang.org/
This commit is contained in:
parent
8c0dcf3b57
commit
c76e27851c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -210,3 +210,6 @@
|
||||
[submodule "assets/syntaxes/02_Extra/Lean"]
|
||||
path = assets/syntaxes/02_Extra/Lean
|
||||
url = https://github.com/leanprover/vscode-lean.git
|
||||
[submodule "assets/syntaxes/02_Extra/Zig"]
|
||||
path = assets/syntaxes/02_Extra/Zig
|
||||
url = https://github.com/ziglang/sublime-zig-language.git
|
||||
|
1
assets/syntaxes/02_Extra/Zig
vendored
Submodule
1
assets/syntaxes/02_Extra/Zig
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 87ecbcae6fb5718369ce3bb3472ca0b2634e78e6
|
265
assets/syntaxes/02_Extra/Zig.sublime-syntax
vendored
Normal file
265
assets/syntaxes/02_Extra/Zig.sublime-syntax
vendored
Normal file
@ -0,0 +1,265 @@
|
||||
%YAML 1.2
|
||||
---
|
||||
# http://www.sublimetext.com/docs/3/syntax.html
|
||||
name: Zig
|
||||
file_extensions:
|
||||
- zig
|
||||
scope: source.zig
|
||||
contexts:
|
||||
main:
|
||||
- include: dummy_main
|
||||
block:
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(\{)'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: punctuation.section.braces.begin.zig
|
||||
push:
|
||||
- match: '(\})'
|
||||
captures:
|
||||
1: punctuation.section.braces.end.zig
|
||||
pop: true
|
||||
- include: dummy_main
|
||||
character_escapes:
|
||||
- match: \\n
|
||||
scope: constant.character.escape.newline.zig
|
||||
- match: \\r
|
||||
scope: constant.character.escape.carrigereturn.zig
|
||||
- match: \\t
|
||||
scope: constant.character.escape.tabulator.zig
|
||||
- match: \\\\
|
||||
scope: constant.character.escape.backslash.zig
|
||||
- match: \\'
|
||||
scope: constant.character.escape.single-quote.zig
|
||||
- match: \\\"
|
||||
scope: constant.character.escape.double-quote.zig
|
||||
- match: '\\x[a-fA-F\d]{2}'
|
||||
scope: constant.character.escape.hexidecimal.zig
|
||||
- match: '\\u\{[a-fA-F\d]{1,6}\}'
|
||||
scope: constant.character.escape.hexidecimal.zig
|
||||
comments:
|
||||
- match: ///
|
||||
push:
|
||||
- meta_scope: comment.line.documentation.zig
|
||||
- match: $\n?
|
||||
pop: true
|
||||
- match: '//[^/]\s*TODO'
|
||||
push:
|
||||
- meta_scope: comment.line.todo.zig
|
||||
- match: $\n?
|
||||
pop: true
|
||||
- match: "//[^/]*"
|
||||
push:
|
||||
- meta_scope: comment.line.zig
|
||||
- match: $\n?
|
||||
pop: true
|
||||
constants:
|
||||
- match: \b(null|undefined|true|false)\b
|
||||
scope: constant.language.zig
|
||||
- match: '\b(?<!\.)(-?[\d_]+)(?!\.)\b'
|
||||
scope: constant.numeric.integer.zig
|
||||
- match: '\b(?<!\.)(0x[a-fA-F\d_]+)(?!\.)\b'
|
||||
scope: constant.numeric.integer.hexadecimal.zig
|
||||
- match: '\b(?<!\.)(0o[0-7_]+)(?!\.)\b'
|
||||
scope: constant.numeric.integer.octal.zig
|
||||
- match: '\b(?<!\.)(0b[01_]+)(?!\.)\b'
|
||||
scope: constant.numeric.integer.binary.zig
|
||||
- match: '(?<!\.)(-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?)(?!\.)\b'
|
||||
scope: constant.numeric.float.zig
|
||||
- match: '(?<!\.)(-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?)(?!\.)\b'
|
||||
scope: constant.numeric.float.hexadecimal.zig
|
||||
container_decl:
|
||||
- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{])'
|
||||
scope: entity.name.union.zig
|
||||
- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{])'
|
||||
scope: entity.name.struct.zig
|
||||
- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{])'
|
||||
scope: entity.name.enum.zig
|
||||
- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{])'
|
||||
scope: entity.name.error.zig
|
||||
- match: '\b(error)(\.)([a-zA-Z_]\w*|@\".+\")'
|
||||
captures:
|
||||
1: storage.type.error.zig
|
||||
2: punctuation.accessor.zig
|
||||
3: entity.name.error.zig
|
||||
dummy_main:
|
||||
- include: label
|
||||
- include: function_type
|
||||
- include: punctuation
|
||||
- include: storage_modifier
|
||||
- include: container_decl
|
||||
- include: constants
|
||||
- include: comments
|
||||
- include: strings
|
||||
- include: storage
|
||||
- include: keywords
|
||||
- include: operators
|
||||
- include: support
|
||||
- include: field_decl
|
||||
- include: block
|
||||
- include: function_def
|
||||
- include: function_call
|
||||
- include: enum_literal
|
||||
enum_literal:
|
||||
- match: '(?<!\w|\)|\?|\}|\]|\*)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>])'
|
||||
scope: constant.language.enum
|
||||
field_decl:
|
||||
- match: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
|
||||
captures:
|
||||
1: variable.other.member.zig
|
||||
2: punctuation.separator.zig
|
||||
push:
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$)'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: punctuation.separator.zig
|
||||
3: keyword.operator.assignment.zig
|
||||
pop: true
|
||||
- include: dummy_main
|
||||
function_call:
|
||||
- match: '(?<!fn)\b([a-zA-Z_]\w*|@\".+\")(?=\s*\()'
|
||||
scope: variable.function.zig
|
||||
function_def:
|
||||
- match: '(?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\()'
|
||||
captures:
|
||||
1: entity.name.function
|
||||
2: punctuation.section.parens.begin.zig
|
||||
push:
|
||||
- match: '(?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: keyword.operator.zig
|
||||
3: storage.type.zig
|
||||
pop: true
|
||||
- include: label
|
||||
- include: param_list
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")'
|
||||
scope: storage.type.zig
|
||||
- include: dummy_main
|
||||
function_type:
|
||||
- match: \b(fn)\s*(\()
|
||||
captures:
|
||||
1: storage.type.function.zig
|
||||
2: punctuation.section.parens.begin.zig
|
||||
push:
|
||||
- meta_content_scope: meta.function.parameters.zig
|
||||
- match: '(?<=\)|\})\s*([a-zA-Z_][\w.]*|@\".+\")?\s*(!)?\s*([a-zA-Z_][\w.]*|@\".+\")'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: keyword.operator.zig
|
||||
3: storage.type.zig
|
||||
pop: true
|
||||
- include: label
|
||||
- include: param_list
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")'
|
||||
scope: storage.type.zig
|
||||
- include: dummy_main
|
||||
keywords:
|
||||
- match: \b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\b
|
||||
scope: keyword.control.zig
|
||||
- match: \b(async|await|suspend|nosuspend|resume)\b
|
||||
scope: keyword.control.async.zig
|
||||
- match: \b(if|else|switch|try|catch|orelse)\b
|
||||
scope: keyword.control.conditional.zig
|
||||
- match: (?<!\w)(@import|@cImport|@cInclude)\b
|
||||
scope: keyword.control.import.zig
|
||||
- match: \b(usingnamespace)\b
|
||||
scope: keyword.other.usingnamespace.zig
|
||||
label:
|
||||
- match: '\b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b))'
|
||||
captures:
|
||||
1: keyword.control.zig
|
||||
2: entity.name.label.zig
|
||||
3: entity.name.label.zig
|
||||
operators:
|
||||
- match: \b!\b
|
||||
scope: keyword.operator.zig
|
||||
- match: (==|(?:!|>|<)=?)
|
||||
scope: keyword.operator.logical.zig
|
||||
- match: \b(and|or)\b
|
||||
scope: keyword.operator.word.zig
|
||||
- match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=)'
|
||||
scope: keyword.operator.assignment.zig
|
||||
- match: ((?:\+|-|\*)\%?|/(?!/)|%)
|
||||
scope: keyword.operator.arithmetic.zig
|
||||
- match: '(<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~)'
|
||||
scope: keyword.operator.bitwise.zig
|
||||
- match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3})'
|
||||
scope: keyword.operator.other.zig
|
||||
param_list:
|
||||
- match: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
|
||||
captures:
|
||||
1: variable.parameter.zig
|
||||
2: punctuation.separator.zig
|
||||
push:
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\)))'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: punctuation.separator.zig
|
||||
3: punctuation.section.parens.end.zig
|
||||
pop: true
|
||||
- include: dummy_main
|
||||
- match: '([a-zA-Z_][\w.]*|@\".+\")'
|
||||
scope: storage.type.zig
|
||||
punctuation:
|
||||
- match: ","
|
||||
scope: punctuation.separator.zig
|
||||
- match: ;
|
||||
scope: punctuation.terminator.zig
|
||||
- match: (\()
|
||||
scope: punctuation.section.parens.begin.zig
|
||||
- match: (\))
|
||||
scope: punctuation.section.parens.end.zig
|
||||
storage:
|
||||
- match: \b(bool|void|noreturn|type|anyerror|anytype)\b
|
||||
scope: storage.type.zig
|
||||
- match: '\b(?<!\.)([iu]\d+|[iu]size|comptime_int)\b'
|
||||
scope: storage.type.integer.zig
|
||||
- match: \b(f16|f32|f64|f128|comptime_float)\b
|
||||
scope: storage.type.float.zig
|
||||
- match: \b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b
|
||||
scope: storage.type.c_compat.zig
|
||||
- match: '\b(anyframe)\b\s*(->)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
|
||||
captures:
|
||||
1: storage.type.zig
|
||||
2: keyword.operator.zig
|
||||
3: storage.type.zig
|
||||
- match: \bfn\b
|
||||
scope: storage.type.function.zig
|
||||
- match: \btest\b
|
||||
scope: storage.type.test.zig
|
||||
- match: \bstruct\b
|
||||
scope: storage.type.struct.zig
|
||||
- match: \benum\b
|
||||
scope: storage.type.enum.zig
|
||||
- match: \bunion\b
|
||||
scope: storage.type.union.zig
|
||||
- match: \berror\b
|
||||
scope: storage.type.error.zig
|
||||
storage_modifier:
|
||||
- match: \b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b
|
||||
scope: storage.modifier.zig
|
||||
strings:
|
||||
- match: \'
|
||||
push:
|
||||
- meta_scope: string.quoted.single.zig
|
||||
- match: \'
|
||||
pop: true
|
||||
- include: character_escapes
|
||||
- match: '\\[^\''][^\'']*?'
|
||||
scope: invalid.illegal.character.zig
|
||||
- match: c?\"
|
||||
push:
|
||||
- meta_scope: string.quoted.double.zig
|
||||
- match: \"
|
||||
pop: true
|
||||
- include: character_escapes
|
||||
- match: '\\[^\''][^\'']*?'
|
||||
scope: invalid.illegal.character.zig
|
||||
- match: c?\\\\
|
||||
push:
|
||||
- meta_scope: string.quoted.other.zig
|
||||
- match: $\n?
|
||||
pop: true
|
||||
support:
|
||||
- match: '(?<!\w)@[^\"\d][a-zA-Z_]\w*\b'
|
||||
scope: support.function.zig
|
107
tests/syntax-tests/highlighted/Zig/example.zig
Normal file
107
tests/syntax-tests/highlighted/Zig/example.zig
Normal file
@ -0,0 +1,107 @@
|
||||
[38;2;248;248;242m//! this is a top level doc, starts with "//!"[0m
|
||||
|
||||
[38;2;248;248;242mconst std = @import("std");[0m
|
||||
|
||||
[38;2;248;248;242mpub fn main() anyerror!void {[0m
|
||||
[38;2;248;248;242m const stdout = std.io.getStdOut().writer();[0m
|
||||
[38;2;248;248;242m try stdout.print("Hello, {}!\n", .{"world"});[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242mconst expect = std.testing.expect;[0m
|
||||
|
||||
[38;2;248;248;242mtest "comments" {[0m
|
||||
[38;2;248;248;242m // comments start with "//" until newline[0m
|
||||
[38;2;248;248;242m // foo bar baz[0m
|
||||
[38;2;248;248;242m const x = true; // another comment[0m
|
||||
[38;2;248;248;242m expect(x);[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m/// a doc comment starts with "///"[0m
|
||||
[38;2;248;248;242m/// multiple lines are merged together[0m
|
||||
[38;2;248;248;242mconst Timestamp = struct {[0m
|
||||
[38;2;248;248;242m /// number of seconds since epoch[0m
|
||||
[38;2;248;248;242m seconds: i64,[0m
|
||||
|
||||
[38;2;248;248;242m /// number of nanoseconds past the second[0m
|
||||
[38;2;248;248;242m nano: u32,[0m
|
||||
|
||||
[38;2;248;248;242m const Self = @This();[0m
|
||||
|
||||
[38;2;248;248;242m pub fn unixEpoch() Self {[0m
|
||||
[38;2;248;248;242m return Self{[0m
|
||||
[38;2;248;248;242m .seconds = 0,[0m
|
||||
[38;2;248;248;242m .nanos = 0,[0m
|
||||
[38;2;248;248;242m };[0m
|
||||
[38;2;248;248;242m }[0m
|
||||
[38;2;248;248;242m};[0m
|
||||
|
||||
[38;2;248;248;242mconst my_val = switch (std.Target.current.os.tag) {[0m
|
||||
[38;2;248;248;242m .linux => "Linux",[0m
|
||||
[38;2;248;248;242m else => "not Linux",[0m
|
||||
[38;2;248;248;242m};[0m
|
||||
|
||||
[38;2;248;248;242mconst Book = enum {[0m
|
||||
[38;2;248;248;242m paperback,[0m
|
||||
[38;2;248;248;242m hardcover,[0m
|
||||
[38;2;248;248;242m ebook,[0m
|
||||
[38;2;248;248;242m pdf,[0m
|
||||
[38;2;248;248;242m};[0m
|
||||
|
||||
[38;2;248;248;242mconst TokenType = union(enum) {[0m
|
||||
[38;2;248;248;242m int: isize,[0m
|
||||
[38;2;248;248;242m float: f64,[0m
|
||||
[38;2;248;248;242m string: []const u8,[0m
|
||||
[38;2;248;248;242m};[0m
|
||||
|
||||
[38;2;248;248;242mconst array_lit: [4]u8 = .{ 11, 22, 33, 44 };[0m
|
||||
[38;2;248;248;242mconst sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };[0m
|
||||
|
||||
[38;2;248;248;242mtest "address of syntax" {[0m
|
||||
[38;2;248;248;242m // Get the address of a variable:[0m
|
||||
[38;2;248;248;242m const x: i32 = 1234;[0m
|
||||
[38;2;248;248;242m const x_ptr = &x;[0m
|
||||
|
||||
[38;2;248;248;242m // Dereference a pointer:[0m
|
||||
[38;2;248;248;242m expect(x_ptr.* == 1234);[0m
|
||||
|
||||
[38;2;248;248;242m // When you get the address of a const variable, you get a const pointer to a single item.[0m
|
||||
[38;2;248;248;242m expect(@TypeOf(x_ptr) == *const i32);[0m
|
||||
|
||||
[38;2;248;248;242m // If you want to mutate the value, you'd need an address of a mutable variable:[0m
|
||||
[38;2;248;248;242m var y: i32 = 5678;[0m
|
||||
[38;2;248;248;242m const y_ptr = &y;[0m
|
||||
[38;2;248;248;242m expect(@TypeOf(y_ptr) == *i32);[0m
|
||||
[38;2;248;248;242m y_ptr.* += 1;[0m
|
||||
[38;2;248;248;242m expect(y_ptr.* == 5679);[0m
|
||||
[38;2;248;248;242m}[0m
|
||||
|
||||
[38;2;248;248;242m// integer literals[0m
|
||||
[38;2;248;248;242mconst decimal_int = 98222;[0m
|
||||
[38;2;248;248;242mconst hex_int = 0xff;[0m
|
||||
[38;2;248;248;242mconst another_hex_int = 0xFF;[0m
|
||||
[38;2;248;248;242mconst octal_int = 0o755;[0m
|
||||
[38;2;248;248;242mconst binary_int = 0b11110000;[0m
|
||||
|
||||
[38;2;248;248;242m// underscores may be placed between two digits as a visual separator[0m
|
||||
[38;2;248;248;242mconst one_billion = 1_000_000_000;[0m
|
||||
[38;2;248;248;242mconst binary_mask = 0b1_1111_1111;[0m
|
||||
[38;2;248;248;242mconst permissions = 0o7_5_5;[0m
|
||||
[38;2;248;248;242mconst big_address = 0xFF80_0000_0000_0000;[0m
|
||||
|
||||
[38;2;248;248;242m// float literals[0m
|
||||
[38;2;248;248;242mconst floating_point = 123.0E+77;[0m
|
||||
[38;2;248;248;242mconst another_float = 123.0;[0m
|
||||
[38;2;248;248;242mconst yet_another = 123.0e+77;[0m
|
||||
|
||||
[38;2;248;248;242mconst hex_floating_point = 0x103.70p-5;[0m
|
||||
[38;2;248;248;242mconst another_hex_float = 0x103.70;[0m
|
||||
[38;2;248;248;242mconst yet_another_hex_float = 0x103.70P-5;[0m
|
||||
|
||||
[38;2;248;248;242m// underscores may be placed between two digits as a visual separator[0m
|
||||
[38;2;248;248;242mconst lightspeed = 299_792_458.000_000;[0m
|
||||
[38;2;248;248;242mconst nanosecond = 0.000_000_001;[0m
|
||||
[38;2;248;248;242mconst more_hex = 0x1234_5678.9ABC_CDEFp-10;[0m
|
||||
|
||||
[38;2;248;248;242mfn max(comptime T: type, a: T, b: T) T {[0m
|
||||
[38;2;248;248;242m return if (a > b) a else b;[0m
|
||||
[38;2;248;248;242m}[0m
|
107
tests/syntax-tests/source/Zig/example.zig
Normal file
107
tests/syntax-tests/source/Zig/example.zig
Normal file
@ -0,0 +1,107 @@
|
||||
//! this is a top level doc, starts with "//!"
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
try stdout.print("Hello, {}!\n", .{"world"});
|
||||
}
|
||||
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "comments" {
|
||||
// comments start with "//" until newline
|
||||
// foo bar baz
|
||||
const x = true; // another comment
|
||||
expect(x);
|
||||
}
|
||||
|
||||
/// a doc comment starts with "///"
|
||||
/// multiple lines are merged together
|
||||
const Timestamp = struct {
|
||||
/// number of seconds since epoch
|
||||
seconds: i64,
|
||||
|
||||
/// number of nanoseconds past the second
|
||||
nano: u32,
|
||||
|
||||
const Self = @This();
|
||||
|
||||
pub fn unixEpoch() Self {
|
||||
return Self{
|
||||
.seconds = 0,
|
||||
.nanos = 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const my_val = switch (std.Target.current.os.tag) {
|
||||
.linux => "Linux",
|
||||
else => "not Linux",
|
||||
};
|
||||
|
||||
const Book = enum {
|
||||
paperback,
|
||||
hardcover,
|
||||
ebook,
|
||||
pdf,
|
||||
};
|
||||
|
||||
const TokenType = union(enum) {
|
||||
int: isize,
|
||||
float: f64,
|
||||
string: []const u8,
|
||||
};
|
||||
|
||||
const array_lit: [4]u8 = .{ 11, 22, 33, 44 };
|
||||
const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };
|
||||
|
||||
test "address of syntax" {
|
||||
// Get the address of a variable:
|
||||
const x: i32 = 1234;
|
||||
const x_ptr = &x;
|
||||
|
||||
// Dereference a pointer:
|
||||
expect(x_ptr.* == 1234);
|
||||
|
||||
// When you get the address of a const variable, you get a const pointer to a single item.
|
||||
expect(@TypeOf(x_ptr) == *const i32);
|
||||
|
||||
// If you want to mutate the value, you'd need an address of a mutable variable:
|
||||
var y: i32 = 5678;
|
||||
const y_ptr = &y;
|
||||
expect(@TypeOf(y_ptr) == *i32);
|
||||
y_ptr.* += 1;
|
||||
expect(y_ptr.* == 5679);
|
||||
}
|
||||
|
||||
// integer literals
|
||||
const decimal_int = 98222;
|
||||
const hex_int = 0xff;
|
||||
const another_hex_int = 0xFF;
|
||||
const octal_int = 0o755;
|
||||
const binary_int = 0b11110000;
|
||||
|
||||
// underscores may be placed between two digits as a visual separator
|
||||
const one_billion = 1_000_000_000;
|
||||
const binary_mask = 0b1_1111_1111;
|
||||
const permissions = 0o7_5_5;
|
||||
const big_address = 0xFF80_0000_0000_0000;
|
||||
|
||||
// float literals
|
||||
const floating_point = 123.0E+77;
|
||||
const another_float = 123.0;
|
||||
const yet_another = 123.0e+77;
|
||||
|
||||
const hex_floating_point = 0x103.70p-5;
|
||||
const another_hex_float = 0x103.70;
|
||||
const yet_another_hex_float = 0x103.70P-5;
|
||||
|
||||
// underscores may be placed between two digits as a visual separator
|
||||
const lightspeed = 299_792_458.000_000;
|
||||
const nanosecond = 0.000_000_001;
|
||||
const more_hex = 0x1234_5678.9ABC_CDEFp-10;
|
||||
|
||||
fn max(comptime T: type, a: T, b: T) T {
|
||||
return if (a > b) a else b;
|
||||
}
|
Loading…
Reference in New Issue
Block a user