Added suppprt for Zig (#2019)
This adds support for the Zig language. https://ziglang.org/
This commit is contained in:
parent
d03d19b440
commit
a7cf56b7a3
File diff suppressed because one or more lines are too long
|
@ -1005,6 +1005,10 @@
|
|||
"title": "YAML",
|
||||
"alias": "yml",
|
||||
"owner": "hason"
|
||||
},
|
||||
"zig": {
|
||||
"title": "Zig",
|
||||
"owner": "RunDevelopment"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
(function (Prism) {
|
||||
|
||||
var keyword = /\b(?:align|allowzero|and|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|nakedcc|noalias|null|or|orelse|packed|promise|pub|resume|return|stdcallcc|struct|suspend|switch|test|threadlocal|try|undefined|union|unreachable|usingnamespace|var|volatile|while)\b/;
|
||||
|
||||
var IDENTIFIER = '\\b(?!' + keyword.source + ')(?!\\d)\\w+\\b';
|
||||
var ALIGN = /align\s*\((?:[^()]|\([^()]*\))*\)/.source;
|
||||
var PREFIX_TYPE_OP = /(?:\?|\bpromise->|(?:\[[^[\]]*\]|\*(?!\*)|\*\*)(?:\s*<ALIGN>|\s*const\b|\s*volatile\b|\s*allowzero\b)*)/.source.replace(/<ALIGN>/g, ALIGN);
|
||||
var SUFFIX_EXPR = /(?:\bpromise\b|(?:\berror\.)?<ID>(?:\.<ID>)*(?!\s+<ID>))/.source.replace(/<ID>/g, IDENTIFIER);
|
||||
var TYPE = '(?!\\s)(?:!?\\s*(?:' + PREFIX_TYPE_OP + '\\s*)*' + SUFFIX_EXPR + ')+';
|
||||
|
||||
/*
|
||||
* A simplified grammar for Zig compile time type literals:
|
||||
*
|
||||
* TypeExpr = ( "!"? PREFIX_TYPE_OP* SUFFIX_EXPR )+
|
||||
*
|
||||
* SUFFIX_EXPR = ( \b "promise" \b | ( \b "error" "." )? IDENTIFIER ( "." IDENTIFIER )* (?! \s+ IDENTIFIER ) )
|
||||
*
|
||||
* PREFIX_TYPE_OP = "?"
|
||||
* | \b "promise" "->"
|
||||
* | ( "[" [^\[\]]* "]" | "*" | "**" ) ( ALIGN | "const" \b | "volatile" \b | "allowzero" \b )*
|
||||
*
|
||||
* ALIGN = "align" "(" ( [^()] | "(" [^()]* ")" )* ")"
|
||||
*
|
||||
* IDENTIFIER = \b (?! KEYWORD ) [a-zA-Z_] \w* \b
|
||||
*
|
||||
*/
|
||||
|
||||
Prism.languages.zig = {
|
||||
'comment': [
|
||||
{
|
||||
pattern: /\/{3}.*/,
|
||||
alias: 'doc-comment'
|
||||
},
|
||||
/\/{2}.*/
|
||||
],
|
||||
'string': [
|
||||
{
|
||||
// "string" and c"string"
|
||||
pattern: /(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
},
|
||||
{
|
||||
// multiline strings and c-strings
|
||||
pattern: /([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
},
|
||||
{
|
||||
// characters 'a', '\n', '\xFF', '\u{10FFFF}'
|
||||
pattern: /(^|[^\\])'(?:[^'\\\r\n]|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,
|
||||
lookbehind: true,
|
||||
greedy: true
|
||||
}
|
||||
],
|
||||
'builtin': /\B@(?!\d)\w+(?=\s*\()/,
|
||||
'label': {
|
||||
pattern: /(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/,
|
||||
lookbehind: true
|
||||
},
|
||||
'class-name': [
|
||||
// const Foo = struct {};
|
||||
/\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/,
|
||||
{
|
||||
// const x: i32 = 9;
|
||||
// var x: Bar;
|
||||
// fn foo(x: bool, y: f32) void {}
|
||||
pattern: RegExp(/(:\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?[=;,)])|<TYPE>(?=\s*(?:<ALIGN>\s*)?\{)/.source.replace(/<TYPE>/g, TYPE).replace(/<ALIGN>/g, ALIGN)),
|
||||
lookbehind: true,
|
||||
inside: null // see below
|
||||
},
|
||||
{
|
||||
// extern fn foo(x: f64) f64; (optional alignment)
|
||||
pattern: RegExp(/(\)\s*)<TYPE>(?=\s*(?:<ALIGN>\s*)?;)/.source.replace(/<TYPE>/g, TYPE).replace(/<ALIGN>/g, ALIGN)),
|
||||
lookbehind: true,
|
||||
inside: null // see below
|
||||
}
|
||||
],
|
||||
'builtin-types': {
|
||||
pattern: /\b(?:anyerror|bool|c_u?(?:short|int|long|longlong)|c_longdouble|c_void|comptime_(?:float|int)|[iu](?:8|16|32|64|128|size)|f(?:16|32|64|128)|noreturn|type|void)\b/,
|
||||
alias: 'keyword'
|
||||
},
|
||||
'keyword': keyword,
|
||||
'function': /\b(?!\d)\w+(?=\s*\()/,
|
||||
'number': /\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+\.?[a-fA-F\d]*(?:[pP][+-]?[a-fA-F\d]+)?|\d+\.?\d*(?:[eE][+-]?\d+)?)\b/,
|
||||
'boolean': /\b(?:false|true)\b/,
|
||||
'operator': /\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/,
|
||||
'punctuation': /[.:,;(){}[\]]/
|
||||
};
|
||||
|
||||
Prism.languages.zig['class-name'].forEach(function (obj) {
|
||||
if (obj.inside === null) {
|
||||
obj.inside = Prism.languages.zig;
|
||||
}
|
||||
});
|
||||
|
||||
}(Prism));
|
|
@ -0,0 +1 @@
|
|||
!function(n){var e=/\b(?:align|allowzero|and|asm|async|await|break|cancel|catch|comptime|const|continue|defer|else|enum|errdefer|error|export|extern|fn|for|if|inline|linksection|nakedcc|noalias|null|or|orelse|packed|promise|pub|resume|return|stdcallcc|struct|suspend|switch|test|threadlocal|try|undefined|union|unreachable|usingnamespace|var|volatile|while)\b/,a="\\b(?!"+e.source+")(?!\\d)\\w+\\b",r="align\\s*\\((?:[^()]|\\([^()]*\\))*\\)",s="(?!\\s)(?:!?\\s*(?:"+"(?:\\?|\\bpromise->|(?:\\[[^[\\]]*\\]|\\*(?!\\*)|\\*\\*)(?:\\s*<ALIGN>|\\s*const\\b|\\s*volatile\\b|\\s*allowzero\\b)*)".replace(/<ALIGN>/g,r)+"\\s*)*"+"(?:\\bpromise\\b|(?:\\berror\\.)?<ID>(?:\\.<ID>)*(?!\\s+<ID>))".replace(/<ID>/g,a)+")+";n.languages.zig={comment:[{pattern:/\/{3}.*/,alias:"doc-comment"},/\/{2}.*/],string:[{pattern:/(^|[^\\@])c?"(?:[^"\\\r\n]|\\.)*"/,lookbehind:!0,greedy:!0},{pattern:/([\r\n])([ \t]+c?\\{2}).*(?:(?:\r\n?|\n)\2.*)*/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\])'(?:[^'\\\r\n]|\\(?:.|x[a-fA-F\d]{2}|u\{[a-fA-F\d]{1,6}\}))'/,lookbehind:!0,greedy:!0}],builtin:/\B@(?!\d)\w+(?=\s*\()/,label:{pattern:/(\b(?:break|continue)\s*:\s*)\w+\b|\b(?!\d)\w+\b(?=\s*:\s*(?:\{|while\b))/,lookbehind:!0},"class-name":[/\b(?!\d)\w+(?=\s*=\s*(?:(?:extern|packed)\s+)?(?:enum|struct|union)\s*[({])/,{pattern:RegExp("(:\\s*)<TYPE>(?=\\s*(?:<ALIGN>\\s*)?[=;,)])|<TYPE>(?=\\s*(?:<ALIGN>\\s*)?\\{)".replace(/<TYPE>/g,s).replace(/<ALIGN>/g,r)),lookbehind:!0,inside:null},{pattern:RegExp("(\\)\\s*)<TYPE>(?=\\s*(?:<ALIGN>\\s*)?;)".replace(/<TYPE>/g,s).replace(/<ALIGN>/g,r)),lookbehind:!0,inside:null}],"builtin-types":{pattern:/\b(?:anyerror|bool|c_u?(?:short|int|long|longlong)|c_longdouble|c_void|comptime_(?:float|int)|[iu](?:8|16|32|64|128|size)|f(?:16|32|64|128)|noreturn|type|void)\b/,alias:"keyword"},keyword:e,function:/\b(?!\d)\w+(?=\s*\()/,number:/\b(?:0b[01]+|0o[0-7]+|0x[a-fA-F\d]+\.?[a-fA-F\d]*(?:[pP][+-]?[a-fA-F\d]+)?|\d+\.?\d*(?:[eE][+-]?\d+)?)\b/,boolean:/\b(?:false|true)\b/,operator:/\.[*?]|\.{2,3}|[-=]>|\*\*|\+\+|\|\||(?:<<|>>|[-+*]%|[-+*/%^&|<>!=])=?|[?~]/,punctuation:/[.:,;(){}[\]]/},n.languages.zig["class-name"].forEach(function(e){null===e.inside&&(e.inside=n.languages.zig)})}(Prism);
|
|
@ -0,0 +1,46 @@
|
|||
<h2>Full example</h2>
|
||||
<pre><code>const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
// If this program is run without stdout attached, exit with an error.
|
||||
const stdout_file = try std.io.getStdOut();
|
||||
// If this program encounters pipe failure when printing to stdout, exit
|
||||
// with an error.
|
||||
try stdout_file.write("Hello, world!\n");
|
||||
}
|
||||
|
||||
const warn = @import("std").debug.warn;
|
||||
|
||||
pub fn main() void {
|
||||
warn("Hello, world!\n");
|
||||
}
|
||||
|
||||
const assert = @import("std").debug.assert;
|
||||
|
||||
test "comments" {
|
||||
// Comments in Zig start with "//" and end at the next LF byte (end of line).
|
||||
// The below line is a comment, and won't be executed.
|
||||
|
||||
//assert(false);
|
||||
|
||||
const x = true; // another comment
|
||||
assert(x);
|
||||
}
|
||||
|
||||
/// A structure for storing a timestamp, with nanosecond precision (this is a
|
||||
/// multiline doc comment).
|
||||
const Timestamp = struct {
|
||||
/// The number of seconds since the epoch (this is also a doc comment).
|
||||
seconds: i64, // signed so we can represent pre-1970 (not a doc comment)
|
||||
/// The number of nanoseconds past the second (doc comment again).
|
||||
nanos: u32,
|
||||
|
||||
/// Returns a `Timestamp` struct representing the Unix epoch; that is, the
|
||||
/// moment of 1970 Jan 1 00:00:00 UTC (this is a doc comment too).
|
||||
pub fn unixEpoch() Timestamp {
|
||||
return Timestamp{
|
||||
.seconds = 0,
|
||||
.nanos = 0,
|
||||
};
|
||||
}
|
||||
};</code></pre>
|
|
@ -0,0 +1,75 @@
|
|||
i8
|
||||
u8
|
||||
i16
|
||||
u16
|
||||
i32
|
||||
u32
|
||||
i64
|
||||
u64
|
||||
i128
|
||||
u128
|
||||
isize
|
||||
usize
|
||||
c_short
|
||||
c_ushort
|
||||
c_int
|
||||
c_uint
|
||||
c_long
|
||||
c_ulong
|
||||
c_longlong
|
||||
c_ulonglong
|
||||
c_longdouble
|
||||
c_void
|
||||
f16
|
||||
f32
|
||||
f64
|
||||
f128
|
||||
bool
|
||||
void
|
||||
noreturn
|
||||
type
|
||||
anyerror
|
||||
comptime_int
|
||||
comptime_float
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["builtin-types", "i8"],
|
||||
["builtin-types", "u8"],
|
||||
["builtin-types", "i16"],
|
||||
["builtin-types", "u16"],
|
||||
["builtin-types", "i32"],
|
||||
["builtin-types", "u32"],
|
||||
["builtin-types", "i64"],
|
||||
["builtin-types", "u64"],
|
||||
["builtin-types", "i128"],
|
||||
["builtin-types", "u128"],
|
||||
["builtin-types", "isize"],
|
||||
["builtin-types", "usize"],
|
||||
["builtin-types", "c_short"],
|
||||
["builtin-types", "c_ushort"],
|
||||
["builtin-types", "c_int"],
|
||||
["builtin-types", "c_uint"],
|
||||
["builtin-types", "c_long"],
|
||||
["builtin-types", "c_ulong"],
|
||||
["builtin-types", "c_longlong"],
|
||||
["builtin-types", "c_ulonglong"],
|
||||
["builtin-types", "c_longdouble"],
|
||||
["builtin-types", "c_void"],
|
||||
["builtin-types", "f16"],
|
||||
["builtin-types", "f32"],
|
||||
["builtin-types", "f64"],
|
||||
["builtin-types", "f128"],
|
||||
["builtin-types", "bool"],
|
||||
["builtin-types", "void"],
|
||||
["builtin-types", "noreturn"],
|
||||
["builtin-types", "type"],
|
||||
["builtin-types", "anyerror"],
|
||||
["builtin-types", "comptime_int"],
|
||||
["builtin-types", "comptime_float"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for builtin types.
|
|
@ -0,0 +1,417 @@
|
|||
@addWithOverflow()
|
||||
@alignCast()
|
||||
@alignOf()
|
||||
@ArgType()
|
||||
@atomicLoad()
|
||||
@atomicRmw()
|
||||
@bitCast()
|
||||
@bitOffsetOf()
|
||||
@boolToInt()
|
||||
@breakpoint()
|
||||
@mulAdd()
|
||||
@byteSwap()
|
||||
@bitReverse()
|
||||
@byteOffsetOf()
|
||||
@bytesToSlice()
|
||||
@cDefine()
|
||||
@cImport()
|
||||
@cInclude()
|
||||
@clz()
|
||||
@cmpxchgStrong()
|
||||
@cmpxchgWeak()
|
||||
@compileError()
|
||||
@compileLog()
|
||||
@ctz()
|
||||
@cUndef()
|
||||
@divExact()
|
||||
@divFloor()
|
||||
@divTrunc()
|
||||
@embedFile()
|
||||
@enumToInt()
|
||||
@errorName()
|
||||
@errorReturnTrace()
|
||||
@errorToInt()
|
||||
@errSetCast()
|
||||
@export()
|
||||
@fence()
|
||||
@field()
|
||||
@fieldParentPtr()
|
||||
@floatCast()
|
||||
@floatToInt()
|
||||
@frameAddress()
|
||||
@handle()
|
||||
@hasDecl()
|
||||
@hasField()
|
||||
@import()
|
||||
@inlineCall()
|
||||
@intCast()
|
||||
@intToEnum()
|
||||
@intToError()
|
||||
@intToFloat()
|
||||
@intToPtr()
|
||||
@IntType()
|
||||
@memberCount()
|
||||
@memberName()
|
||||
@memberType()
|
||||
@memcpy()
|
||||
@memset()
|
||||
@mod()
|
||||
@mulWithOverflow()
|
||||
@newStackCall()
|
||||
@noInlineCall()
|
||||
@OpaqueType()
|
||||
@panic()
|
||||
@popCount()
|
||||
@ptrCast()
|
||||
@ptrToInt()
|
||||
@rem()
|
||||
@returnAddress()
|
||||
@setAlignStack()
|
||||
@setCold()
|
||||
@setEvalBranchQuota()
|
||||
@setFloatMode()
|
||||
@setRuntimeSafety()
|
||||
@shlExact()
|
||||
@shlWithOverflow()
|
||||
@shrExact()
|
||||
@sizeOf()
|
||||
@sliceToBytes()
|
||||
@sqrt()
|
||||
@sin()
|
||||
@cos()
|
||||
@exp()
|
||||
@exp2()
|
||||
@ln()
|
||||
@log2()
|
||||
@log10()
|
||||
@fabs()
|
||||
@floor()
|
||||
@ceil()
|
||||
@trunc()
|
||||
@round()
|
||||
@subWithOverflow()
|
||||
@tagName()
|
||||
@TagType()
|
||||
@This()
|
||||
@truncate()
|
||||
@typeId()
|
||||
@typeInfo()
|
||||
@typeName()
|
||||
@typeOf()
|
||||
@unionInit()
|
||||
@Vector()
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["builtin", "@addWithOverflow"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@alignCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@alignOf"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ArgType"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@atomicLoad"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@atomicRmw"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@bitCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@bitOffsetOf"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@boolToInt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@breakpoint"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@mulAdd"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@byteSwap"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@bitReverse"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@byteOffsetOf"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@bytesToSlice"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cDefine"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cImport"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cInclude"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@clz"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cmpxchgStrong"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cmpxchgWeak"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@compileError"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@compileLog"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ctz"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cUndef"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@divExact"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@divFloor"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@divTrunc"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@embedFile"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@enumToInt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@errorName"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@errorReturnTrace"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@errorToInt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@errSetCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@export"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@fence"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@field"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@fieldParentPtr"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@floatCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@floatToInt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@frameAddress"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@handle"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@hasDecl"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@hasField"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@import"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@inlineCall"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@intCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@intToEnum"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@intToError"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@intToFloat"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@intToPtr"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@IntType"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@memberCount"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@memberName"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@memberType"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@memcpy"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@memset"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@mod"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@mulWithOverflow"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@newStackCall"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@noInlineCall"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@OpaqueType"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@panic"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@popCount"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ptrCast"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ptrToInt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@rem"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@returnAddress"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@setAlignStack"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@setCold"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@setEvalBranchQuota"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@setFloatMode"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@setRuntimeSafety"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@shlExact"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@shlWithOverflow"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@shrExact"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@sizeOf"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@sliceToBytes"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@sqrt"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@sin"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@cos"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@exp"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@exp2"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ln"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@log2"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@log10"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@fabs"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@floor"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@ceil"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@trunc"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@round"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@subWithOverflow"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@tagName"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@TagType"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@This"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@truncate"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@typeId"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@typeInfo"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@typeName"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@typeOf"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@unionInit"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["builtin", "@Vector"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for builtin functions.
|
|
@ -0,0 +1,504 @@
|
|||
const Timestamp = struct {
|
||||
seconds: i64,
|
||||
nanos: u32,
|
||||
pub fn unixEpoch() Timestamp {
|
||||
return Timestamp{
|
||||
.seconds = 0,
|
||||
.nanos = 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const one_plus_one: i32 = 1 + 1;
|
||||
var x: i32;
|
||||
const value: ?u32 = null;
|
||||
var optional_value: ?[]const u8 = null;
|
||||
var number_or_error: anyerror!i32 = error.ArgNotFound;
|
||||
const array1 = [_]u32{1,2};
|
||||
var foo: S align(4) = undefined;
|
||||
|
||||
fn add(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
extern fn foo(x: f64) f64;
|
||||
fn noop4() align(4) void {}
|
||||
fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; }
|
||||
|
||||
fn eventuallyNullSequence() ?u32 {
|
||||
return if (numbers_left == 0) null else blk: {
|
||||
numbers_left -= 1;
|
||||
break :blk numbers_left;
|
||||
};
|
||||
}
|
||||
|
||||
const message = [_]u8{ 'h', 'e', 'l', 'l', 'o' };
|
||||
|
||||
const mat4x4 = [4][4]f32{
|
||||
[_]f32{ 1.0, 0.0, 0.0, 0.0 },
|
||||
[_]f32{ 0.0, 1.0, 0.0, 1.0 },
|
||||
[_]f32{ 0.0, 0.0, 1.0, 0.0 },
|
||||
[_]f32{ 0.0, 0.0, 0.0, 1.0 },
|
||||
};
|
||||
|
||||
const Point = struct {};
|
||||
const Point2 = packed struct {};
|
||||
const Type = enum {};
|
||||
const Value = enum(u2) {};
|
||||
const Number = packed enum(u8) {};
|
||||
const Foo = extern enum { A, B, C };
|
||||
const Foo = extern enum { A, B, C };
|
||||
const Payload = union {};
|
||||
const ComplexType = union(ComplexTypeTag) {};
|
||||
|
||||
var node = ListOfInts.Node {};
|
||||
var list2 = LinkedList(i32) {};
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "const"],
|
||||
["class-name", "Timestamp"],
|
||||
["operator", "="],
|
||||
["keyword", "struct"],
|
||||
["punctuation", "{"],
|
||||
"\r\n\tseconds",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "i64"]
|
||||
]],
|
||||
["punctuation", ","],
|
||||
"\r\n\tnanos",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "u32"]
|
||||
]],
|
||||
["punctuation", ","],
|
||||
["keyword", "pub"],
|
||||
["keyword", "fn"],
|
||||
["function", "unixEpoch"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
"Timestamp"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["keyword", "return"],
|
||||
["class-name", [
|
||||
"Timestamp"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "."],
|
||||
"seconds ",
|
||||
["operator", "="],
|
||||
["number", "0"],
|
||||
["punctuation", ","],
|
||||
["punctuation", "."],
|
||||
"nanos ",
|
||||
["operator", "="],
|
||||
["number", "0"],
|
||||
["punctuation", ","],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
" one_plus_one",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["operator", "="],
|
||||
["number", "1"],
|
||||
["operator", "+"],
|
||||
["number", "1"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" x",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
" value",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["operator", "?"],
|
||||
["builtin-types", "u32"]
|
||||
]],
|
||||
["operator", "="],
|
||||
["keyword", "null"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" optional_value",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["operator", "?"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"],
|
||||
["keyword", "const"],
|
||||
["builtin-types", "u8"]
|
||||
]],
|
||||
["operator", "="],
|
||||
["keyword", "null"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" number_or_error",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "anyerror"],
|
||||
["operator", "!"],
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["operator", "="],
|
||||
["keyword", "error"],
|
||||
["punctuation", "."],
|
||||
"ArgNotFound",
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
" array1 ",
|
||||
["operator", "="],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "u32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "1"],
|
||||
["punctuation", ","],
|
||||
["number", "2"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" foo",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
"S"
|
||||
]],
|
||||
["keyword", "align"],
|
||||
["punctuation", "("],
|
||||
["number", "4"],
|
||||
["punctuation", ")"],
|
||||
["operator", "="],
|
||||
["keyword", "undefined"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "fn"],
|
||||
["function", "add"],
|
||||
["punctuation", "("],
|
||||
"a",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["punctuation", ","],
|
||||
" b",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["keyword", "return"],
|
||||
" a ",
|
||||
["operator", "+"],
|
||||
" b",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "extern"],
|
||||
["keyword", "fn"],
|
||||
["function", "foo"],
|
||||
["punctuation", "("],
|
||||
"x",
|
||||
["punctuation", ":"],
|
||||
["class-name", [
|
||||
["builtin-types", "f64"]
|
||||
]],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["builtin-types", "f64"]
|
||||
]],
|
||||
["punctuation", ";"],
|
||||
["keyword", "fn"],
|
||||
["function", "noop4"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["keyword", "align"],
|
||||
["punctuation", "("],
|
||||
["number", "4"],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["builtin-types", "void"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "fn"],
|
||||
["function", "derp"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["keyword", "align"],
|
||||
["punctuation", "("],
|
||||
["builtin", "@sizeOf"],
|
||||
["punctuation", "("],
|
||||
["builtin-types", "usize"],
|
||||
["punctuation", ")"],
|
||||
["operator", "*"],
|
||||
["number", "2"],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["builtin-types", "i32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["keyword", "return"],
|
||||
["number", "1234"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "fn"],
|
||||
["function", "eventuallyNullSequence"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["operator", "?"],
|
||||
["builtin-types", "u32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["keyword", "return"],
|
||||
["keyword", "if"],
|
||||
["punctuation", "("],
|
||||
"numbers_left ",
|
||||
["operator", "=="],
|
||||
["number", "0"],
|
||||
["punctuation", ")"],
|
||||
["keyword", "null"],
|
||||
["keyword", "else"],
|
||||
["label", "blk"],
|
||||
["punctuation", ":"],
|
||||
["punctuation", "{"],
|
||||
"\r\n\t\tnumbers_left ",
|
||||
["operator", "-="],
|
||||
["number", "1"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "break"],
|
||||
["punctuation", ":"],
|
||||
["label", "blk"],
|
||||
" numbers_left",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "const"],
|
||||
" message ",
|
||||
["operator", "="],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "u8"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["string", "'h'"],
|
||||
["punctuation", ","],
|
||||
["string", "'e'"],
|
||||
["punctuation", ","],
|
||||
["string", "'l'"],
|
||||
["punctuation", ","],
|
||||
["string", "'l'"],
|
||||
["punctuation", ","],
|
||||
["string", "'o'"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
" mat4x4 ",
|
||||
["operator", "="],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
["number", "4"],
|
||||
["punctuation", "]"],
|
||||
["punctuation", "["],
|
||||
["number", "4"],
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "f32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "f32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "1.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ","],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "f32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "1.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "1.0"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ","],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "f32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "1.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ","],
|
||||
["class-name", [
|
||||
["punctuation", "["],
|
||||
"_",
|
||||
["punctuation", "]"],
|
||||
["builtin-types", "f32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "0.0"],
|
||||
["punctuation", ","],
|
||||
["number", "1.0"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ","],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Point"],
|
||||
["operator", "="],
|
||||
["keyword", "struct"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Point2"],
|
||||
["operator", "="],
|
||||
["keyword", "packed"],
|
||||
["keyword", "struct"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Type"],
|
||||
["operator", "="],
|
||||
["keyword", "enum"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Value"],
|
||||
["operator", "="],
|
||||
["keyword", "enum"],
|
||||
["punctuation", "("],
|
||||
"u2",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Number"],
|
||||
["operator", "="],
|
||||
["keyword", "packed"],
|
||||
["keyword", "enum"],
|
||||
["punctuation", "("],
|
||||
["builtin-types", "u8"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Foo"],
|
||||
["operator", "="],
|
||||
["keyword", "extern"],
|
||||
["keyword", "enum"],
|
||||
["punctuation", "{"],
|
||||
" A",
|
||||
["punctuation", ","],
|
||||
" B",
|
||||
["punctuation", ","],
|
||||
" C ",
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Foo"],
|
||||
["operator", "="],
|
||||
["keyword", "extern"],
|
||||
["keyword", "enum"],
|
||||
["punctuation", "{"],
|
||||
" A",
|
||||
["punctuation", ","],
|
||||
" B",
|
||||
["punctuation", ","],
|
||||
" C ",
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "Payload"],
|
||||
["operator", "="],
|
||||
["keyword", "union"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "const"],
|
||||
["class-name", "ComplexType"],
|
||||
["operator", "="],
|
||||
["keyword", "union"],
|
||||
["punctuation", "("],
|
||||
"ComplexTypeTag",
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" node ",
|
||||
["operator", "="],
|
||||
["class-name", [
|
||||
"ListOfInts",
|
||||
["punctuation", "."],
|
||||
"Node"
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "var"],
|
||||
" list2 ",
|
||||
["operator", "="],
|
||||
["function", "LinkedList"],
|
||||
["punctuation", "("],
|
||||
["builtin-types", "i32"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for class names.
|
|
@ -0,0 +1,105 @@
|
|||
align
|
||||
allowzero
|
||||
and
|
||||
asm
|
||||
async
|
||||
await
|
||||
break
|
||||
cancel
|
||||
catch
|
||||
comptime
|
||||
const
|
||||
continue
|
||||
defer
|
||||
else
|
||||
enum
|
||||
errdefer
|
||||
error
|
||||
export
|
||||
extern
|
||||
fn
|
||||
for
|
||||
if
|
||||
inline
|
||||
linksection
|
||||
nakedcc
|
||||
noalias
|
||||
null
|
||||
or
|
||||
orelse
|
||||
packed
|
||||
promise
|
||||
pub
|
||||
resume
|
||||
return
|
||||
stdcallcc
|
||||
struct
|
||||
suspend
|
||||
switch
|
||||
test
|
||||
threadlocal
|
||||
try
|
||||
undefined
|
||||
union
|
||||
unreachable
|
||||
usingnamespace
|
||||
var
|
||||
volatile
|
||||
while
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["keyword", "align"],
|
||||
["keyword", "allowzero"],
|
||||
["keyword", "and"],
|
||||
["keyword", "asm"],
|
||||
["keyword", "async"],
|
||||
["keyword", "await"],
|
||||
["keyword", "break"],
|
||||
["keyword", "cancel"],
|
||||
["keyword", "catch"],
|
||||
["keyword", "comptime"],
|
||||
["keyword", "const"],
|
||||
["keyword", "continue"],
|
||||
["keyword", "defer"],
|
||||
["keyword", "else"],
|
||||
["keyword", "enum"],
|
||||
["keyword", "errdefer"],
|
||||
["keyword", "error"],
|
||||
["keyword", "export"],
|
||||
["keyword", "extern"],
|
||||
["keyword", "fn"],
|
||||
["keyword", "for"],
|
||||
["keyword", "if"],
|
||||
["keyword", "inline"],
|
||||
["keyword", "linksection"],
|
||||
["keyword", "nakedcc"],
|
||||
["keyword", "noalias"],
|
||||
["keyword", "null"],
|
||||
["keyword", "or"],
|
||||
["keyword", "orelse"],
|
||||
["keyword", "packed"],
|
||||
["keyword", "promise"],
|
||||
["keyword", "pub"],
|
||||
["keyword", "resume"],
|
||||
["keyword", "return"],
|
||||
["keyword", "stdcallcc"],
|
||||
["keyword", "struct"],
|
||||
["keyword", "suspend"],
|
||||
["keyword", "switch"],
|
||||
["keyword", "test"],
|
||||
["keyword", "threadlocal"],
|
||||
["keyword", "try"],
|
||||
["keyword", "undefined"],
|
||||
["keyword", "union"],
|
||||
["keyword", "unreachable"],
|
||||
["keyword", "usingnamespace"],
|
||||
["keyword", "var"],
|
||||
["keyword", "volatile"],
|
||||
["keyword", "while"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for keywords.
|
|
@ -0,0 +1,75 @@
|
|||
outer: while (true) {
|
||||
while (true) {
|
||||
break :outer;
|
||||
}
|
||||
}
|
||||
|
||||
fn eventuallyErrorSequence() anyerror!u32 {
|
||||
return if (numbers_left == 0) error.ReachedZero else blk: {
|
||||
numbers_left -= 1;
|
||||
break :blk numbers_left;
|
||||
};
|
||||
}
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["label", "outer"],
|
||||
["punctuation", ":"],
|
||||
["keyword", "while"],
|
||||
["punctuation", "("],
|
||||
["boolean", "true"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["keyword", "while"],
|
||||
["punctuation", "("],
|
||||
["boolean", "true"],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["keyword", "break"],
|
||||
["punctuation", ":"],
|
||||
["label", "outer"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "}"],
|
||||
["keyword", "fn"],
|
||||
["function", "eventuallyErrorSequence"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["class-name", [
|
||||
["builtin-types", "anyerror"],
|
||||
["operator", "!"],
|
||||
["builtin-types", "u32"]
|
||||
]],
|
||||
["punctuation", "{"],
|
||||
["keyword", "return"],
|
||||
["keyword", "if"],
|
||||
["punctuation", "("],
|
||||
"numbers_left ",
|
||||
["operator", "=="],
|
||||
["number", "0"],
|
||||
["punctuation", ")"],
|
||||
["keyword", "error"],
|
||||
["punctuation", "."],
|
||||
"ReachedZero ",
|
||||
["keyword", "else"],
|
||||
["label", "blk"],
|
||||
["punctuation", ":"],
|
||||
["punctuation", "{"],
|
||||
"\r\n\t\tnumbers_left ",
|
||||
["operator", "-="],
|
||||
["number", "1"],
|
||||
["punctuation", ";"],
|
||||
["keyword", "break"],
|
||||
["punctuation", ":"],
|
||||
["label", "blk"],
|
||||
" numbers_left",
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "}"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for labels.
|
|
@ -0,0 +1,22 @@
|
|||
123
|
||||
123.456e-7
|
||||
|
||||
0xBadFace
|
||||
0xBAD.FACEp+F
|
||||
|
||||
0b1001
|
||||
0o377
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["number", "123"],
|
||||
["number", "123.456e-7"],
|
||||
["number", "0xBadFace"],
|
||||
["number", "0xBAD.FACEp+F"],
|
||||
["number", "0b1001"],
|
||||
["number", "0o377"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for numbers.
|
|
@ -0,0 +1,73 @@
|
|||
+ - * / %
|
||||
+= -= *= /= %=
|
||||
|
||||
& | ^
|
||||
&= |= ^=
|
||||
|
||||
+% -% *%
|
||||
+%= -%= *%=
|
||||
|
||||
** ++
|
||||
|
||||
< > <= >= ! != == =
|
||||
~ << <<= >> >>=
|
||||
|
||||
.* .?
|
||||
.. ...
|
||||
|
||||
=> ->
|
||||
?
|
||||
||
|
||||
|
||||
----------------------------------------------------
|
||||
[
|
||||
["operator", "+"],
|
||||
["operator", "-"],
|
||||
["operator", "*"],
|
||||
["operator", "/"],
|
||||
["operator", "%"],
|
||||
["operator", "+="],
|
||||
["operator", "-="],
|
||||
["operator", "*="],
|
||||
["operator", "/="],
|
||||
["operator", "%="],
|
||||
["operator", "&"],
|
||||
["operator", "|"],
|
||||
["operator", "^"],
|
||||
["operator", "&="],
|
||||
["operator", "|="],
|
||||
["operator", "^="],
|
||||
["operator", "+%"],
|
||||
["operator", "-%"],
|
||||
["operator", "*%"],
|
||||
["operator", "+%="],
|
||||
["operator", "-%="],
|
||||
["operator", "*%="],
|
||||
["operator", "**"],
|
||||
["operator", "++"],
|
||||
["operator", "<"],
|
||||
["operator", ">"],
|
||||
["operator", "<="],
|
||||
["operator", ">="],
|
||||
["operator", "!"],
|
||||
["operator", "!="],
|
||||
["operator", "=="],
|
||||
["operator", "="],
|
||||
["operator", "~"],
|
||||
["operator", "<<"],
|
||||
["operator", "<<="],
|
||||
["operator", ">>"],
|
||||
["operator", ">>="],
|
||||
["operator", ".*"],
|
||||
["operator", ".?"],
|
||||
["operator", ".."],
|
||||
["operator", "..."],
|
||||
["operator", "=>"],
|
||||
["operator", "->"],
|
||||
["operator", "?"],
|
||||
["operator", "||"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for operators.
|
|
@ -0,0 +1,21 @@
|
|||
. : , ;
|
||||
( ) { } [ ]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["punctuation", "."],
|
||||
["punctuation", ":"],
|
||||
["punctuation", ","],
|
||||
["punctuation", ";"],
|
||||
["punctuation", "("],
|
||||
["punctuation", ")"],
|
||||
["punctuation", "{"],
|
||||
["punctuation", "}"],
|
||||
["punctuation", "["],
|
||||
["punctuation", "]"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
Checks for punctuation.
|
Loading…
Reference in New Issue