Commit 1fa0cabf9d
Changed files (7)
doc
vim
syntax
test
doc/vim/syntax/zig.vim
@@ -1,28 +1,27 @@
" Vim syntax file
" Language: Zig
" Maintainer: Andrew Kelley
-" Latest Revision: 02 December 2015
+" Latest Revision: 28 July 2016
if exists("b:current_syntax")
finish
endif
-syn keyword zigStorage const var extern volatile export pub noalias inline
+syn keyword zigStorage const var extern export pub noalias inline noinline
syn keyword zigStructure struct enum union
syn keyword zigStatement goto break return continue asm defer
syn keyword zigConditional if else switch
syn keyword zigRepeat while for
-syn keyword zigConstant null undefined
+syn keyword zigConstant null undefined zeroes
syn keyword zigKeyword fn use
syn keyword zigType bool f32 f64 void unreachable type error
syn keyword zigType i8 u8 i16 u16 i32 u32 i64 u64 isize usize
-syn keyword zigType c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong
+syn keyword zigType c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong c_long_double
syn keyword zigBoolean true false
-syn match zigOperator display "\%(+\|-\|/\|*\|=\|\^\|&\|?\||\|!\|>\|<\|%\)=\?"
-syn match zigOperator display "&&\|||"
+syn match zigOperator display "\%(+%\?\|-%\?\|/\|*%\?\|=\|\^\|&\|?\||\|!\|>\|<\|%\|<<%\?\|>>\|&&\|||\)=\?"
syn match zigArrowCharacter display "->"
syn match zigDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\)\)\="
@@ -40,10 +39,6 @@ syn match zigShebang /\%^#![^[].*/
syn region zigCommentLine start="//" end="$" contains=zigTodo,@Spell
syn region zigCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=zigTodo,@Spell
-syn region zigCommentBlock matchgroup=zigCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=zigTodo,zigCommentBlockNest,@Spell
-syn region zigCommentBlockDoc matchgroup=zigCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=zigTodo,zigCommentBlockDocNest,@Spell
-syn region zigCommentBlockNest matchgroup=zigCommentBlock start="/\*" end="\*/" contains=zigTodo,zigCommentBlockNest,@Spell contained transparent
-syn region zigCommentBlockDocNest matchgroup=zigCommentBlockDoc start="/\*" end="\*/" contains=zigTodo,zigCommentBlockDocNest,@Spell contained transparent
syn keyword zigTodo contained TODO XXX
@@ -67,8 +62,6 @@ hi def link zigType Type
hi def link zigShebang Comment
hi def link zigCommentLine Comment
hi def link zigCommentLineDoc SpecialComment
-hi def link zigCommentBlock zigCommentLine
-hi def link zigCommentBlockDoc zigCommentLineDoc
hi def link zigTodo Todo
hi def link zigStringContinuation Special
hi def link zigString String
src/tokenizer.cpp
@@ -167,9 +167,6 @@ enum TokenizeState {
TokenizeStateSawPipe,
TokenizeStateSawPipePipe,
TokenizeStateLineComment,
- TokenizeStateMultiLineComment,
- TokenizeStateMultiLineCommentSlash,
- TokenizeStateMultiLineCommentStar,
TokenizeStateSawEq,
TokenizeStateSawBang,
TokenizeStateSawLessThan,
@@ -194,7 +191,6 @@ struct Tokenize {
int line;
int column;
Token *cur_tok;
- int multi_line_comment_count;
Tokenization *out;
int raw_string_id_start;
int raw_string_id_end;
@@ -840,11 +836,6 @@ void tokenize(Buf *buf, Tokenization *out) {
cancel_token(&t);
t.state = TokenizeStateLineComment;
break;
- case '*':
- cancel_token(&t);
- t.state = TokenizeStateMultiLineComment;
- t.multi_line_comment_count = 1;
- break;
case '=':
t.cur_tok->id = TokenIdDivEq;
end_token(&t);
@@ -867,49 +858,6 @@ void tokenize(Buf *buf, Tokenization *out) {
break;
}
break;
- case TokenizeStateMultiLineComment:
- switch (c) {
- case '*':
- t.state = TokenizeStateMultiLineCommentStar;
- break;
- case '/':
- t.state = TokenizeStateMultiLineCommentSlash;
- break;
- default:
- // do nothing
- break;
- }
- break;
- case TokenizeStateMultiLineCommentSlash:
- switch (c) {
- case '*':
- t.state = TokenizeStateMultiLineComment;
- t.multi_line_comment_count += 1;
- break;
- case '/':
- break;
- default:
- t.state = TokenizeStateMultiLineComment;
- break;
- }
- break;
- case TokenizeStateMultiLineCommentStar:
- switch (c) {
- case '/':
- t.multi_line_comment_count -= 1;
- if (t.multi_line_comment_count == 0) {
- t.state = TokenizeStateStart;
- } else {
- t.state = TokenizeStateMultiLineComment;
- }
- break;
- case '*':
- break;
- default:
- t.state = TokenizeStateMultiLineComment;
- break;
- }
- break;
case TokenizeStateSymbolFirst:
switch (c) {
case '"':
@@ -1339,11 +1287,6 @@ void tokenize(Buf *buf, Tokenization *out) {
break;
case TokenizeStateLineComment:
break;
- case TokenizeStateMultiLineComment:
- case TokenizeStateMultiLineCommentSlash:
- case TokenizeStateMultiLineCommentStar:
- tokenize_error(&t, "unterminated multi-line comment");
- break;
}
if (t.state != TokenizeStateError) {
if (t.tokens->length > 0) {
std/compiler_rt.zig
@@ -27,45 +27,41 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
var q: udwords = undefined;
var r: udwords = undefined;
var sr: c_uint = undefined;
- /* special cases, X is unknown, K != 0 */
+ // special cases, X is unknown, K != 0
if (n[high] == 0) {
if (d[high] == 0) {
- /* 0 X
- * ---
- * 0 X
- */
+ // 0 X
+ // ---
+ // 0 X
if (const rem ?= maybe_rem) {
*rem = n[low] % d[low];
}
return n[low] / d[low];
}
- /* 0 X
- * ---
- * K X
- */
+ // 0 X
+ // ---
+ // K X
if (const rem ?= maybe_rem) {
*rem = n[low];
}
return 0;
}
- /* n[high] != 0 */
+ // n[high] != 0
if (d[low] == 0) {
if (d[high] == 0) {
- /* K X
- * ---
- * 0 0
- */
+ // K X
+ // ---
+ // 0 0
if (var rem ?= maybe_rem) {
*rem = n[high] % d[low];
}
return n[high] / d[low];
}
- /* d[high] != 0 */
+ // d[high] != 0
if (n[low] == 0) {
- /* K 0
- * ---
- * K 0
- */
+ // K 0
+ // ---
+ // K 0
if (var rem ?= maybe_rem) {
r[high] = n[high] % d[high];
r[low] = 0;
@@ -73,10 +69,9 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
}
return n[high] / d[high];
}
- /* K K
- * ---
- * K 0
- */
+ // K K
+ // ---
+ // K 0
// if d is a power of 2
if ((d[high] & (d[high] - 1)) == 0) {
if (var rem ?= maybe_rem) {
@@ -86,12 +81,11 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
}
return n[high] >> @ctz(@typeof(d[high]), d[high]);
}
- /* K K
- * ---
- * K 0
- */
+ // K K
+ // ---
+ // K 0
sr = @clz(su_int, d[high]) - @clz(su_int, n[high]);
- /* 0 <= sr <= n_uword_bits - 2 or sr large */
+ // 0 <= sr <= n_uword_bits - 2 or sr large
if (sr > n_uword_bits - 2) {
if (var rem ?= maybe_rem) {
*rem = *(&du_int)(&n[0]);
@@ -99,21 +93,20 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
return 0;
}
sr += 1;
- /* 1 <= sr <= n_uword_bits - 1 */
- /* q.all = n.all << (n_udword_bits - sr); */
+ // 1 <= sr <= n_uword_bits - 1
+ // q.all = n.all << (n_udword_bits - sr);
q[low] = 0;
q[high] = n[low] << (n_uword_bits - sr);
- /* r.all = n.all >> sr; */
+ // r.all = n.all >> sr;
r[high] = n[high] >> sr;
r[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr);
} else {
- /* d[low] != 0 */
+ // d[low] != 0
if (d[high] == 0) {
- /* K X
- * ---
- * 0 K
- */
- /* if d is a power of 2 */
+ // K X
+ // ---
+ // 0 K
+ // if d is a power of 2
if ((d[low] & (d[low] - 1)) == 0) {
if (var rem ?= maybe_rem) {
*rem = n[low] & (d[low] - 1);
@@ -126,15 +119,13 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
q[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr);
return *(&du_int)(&q[0]);
}
- /* K X
- * ---
- * 0 K
- */
+ // K X
+ // ---
+ // 0 K
sr = 1 + n_uword_bits + @clz(su_int, d[low]) - @clz(su_int, n[high]);
- /* 2 <= sr <= n_udword_bits - 1
- * q.all = n.all << (n_udword_bits - sr);
- * r.all = n.all >> sr;
- */
+ // 2 <= sr <= n_udword_bits - 1
+ // q.all = n.all << (n_udword_bits - sr);
+ // r.all = n.all >> sr;
if (sr == n_uword_bits) {
q[low] = 0;
q[high] = n[low];
@@ -155,12 +146,11 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
r[low] = n[high] >> (sr - n_uword_bits);
}
} else {
- /* K X
- * ---
- * K K
- */
+ // K X
+ // ---
+ // K K
sr = @clz(su_int, d[high]) - @clz(su_int, n[high]);
- /* 0 <= sr <= n_uword_bits - 1 or sr large */
+ // 0 <= sr <= n_uword_bits - 1 or sr large
if (sr > n_uword_bits - 1) {
if (var rem ?= maybe_rem) {
*rem = *(&du_int)(&n[0]);
@@ -168,8 +158,8 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
return 0;
}
sr += 1;
- /* 1 <= sr <= n_uword_bits */
- /* q.all = n.all << (n_udword_bits - sr); */
+ // 1 <= sr <= n_uword_bits
+ // q.all = n.all << (n_udword_bits - sr);
q[low] = 0;
if (sr == n_uword_bits) {
q[high] = n[low];
@@ -182,26 +172,24 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
}
}
}
- /* Not a special case
- * q and r are initialized with:
- * q.all = n.all << (n_udword_bits - sr);
- * r.all = n.all >> sr;
- * 1 <= sr <= n_udword_bits - 1
- */
+ // Not a special case
+ // q and r are initialized with:
+ // q.all = n.all << (n_udword_bits - sr);
+ // r.all = n.all >> sr;
+ // 1 <= sr <= n_udword_bits - 1
var carry: su_int = 0;
while (sr > 0) {
- /* r:q = ((r:q) << 1) | carry */
+ // r:q = ((r:q) << 1) | carry
r[high] = (r[high] << 1) | (r[low] >> (n_uword_bits - 1));
r[low] = (r[low] << 1) | (q[high] >> (n_uword_bits - 1));
q[high] = (q[high] << 1) | (q[low] >> (n_uword_bits - 1));
q[low] = (q[low] << 1) | carry;
- /* carry = 0;
- * if (r.all >= d.all)
- * {
- * r.all -= d.all;
- * carry = 1;
- * }
- */
+ // carry = 0;
+ // if (r.all >= d.all)
+ // {
+ // r.all -= d.all;
+ // carry = 1;
+ // }
const s: di_int = (di_int)(*(&du_int)(&d[0]) - *(&du_int)(&r[0]) - 1) >> (n_udword_bits - 1);
carry = su_int(s & 1);
*(&du_int)(&r[0]) -= *(&du_int)(&d[0]) & u64(s);
std/hash_map.zig
@@ -6,11 +6,11 @@ const Allocator = mem.Allocator;
const want_modification_safety = !@compile_var("is_release");
const debug_u32 = if (want_modification_safety) u32 else void;
-/*
-pub inline fn HashMap(inline K: type, inline V: type, inline hash: fn(key: K)->u32, inline eql: fn(a: K, b: K)->bool) {
- SmallHashMap(K, V, hash, eql, 8);
+pub inline fn HashMap(inline K: type, inline V: type,
+ inline hash: fn(key: K)->u32, inline eql: fn(a: K, b: K)->bool)
+{
+ SmallHashMap(K, V, hash, eql, 8)
}
-*/
pub struct SmallHashMap(K: type, V: type, hash: fn(key: K)->u32, eql: fn(a: K, b: K)->bool, STATIC_SIZE: usize) {
entries: []Entry,
std/linux.zig
@@ -342,27 +342,27 @@ export struct iovec {
iov_len: usize,
}
-/*
-const IF_NAMESIZE = 16;
-
-export struct ifreq {
- ifrn_name: [IF_NAMESIZE]u8,
- union {
- ifru_addr: sockaddr,
- ifru_dstaddr: sockaddr,
- ifru_broadaddr: sockaddr,
- ifru_netmask: sockaddr,
- ifru_hwaddr: sockaddr,
- ifru_flags: i16,
- ifru_ivalue: i32,
- ifru_mtu: i32,
- ifru_map: ifmap,
- ifru_slave: [IF_NAMESIZE]u8,
- ifru_newname: [IF_NAMESIZE]u8,
- ifru_data: &u8,
- } ifr_ifru;
-}
-*/
+//
+//const IF_NAMESIZE = 16;
+//
+//export struct ifreq {
+// ifrn_name: [IF_NAMESIZE]u8,
+// union {
+// ifru_addr: sockaddr,
+// ifru_dstaddr: sockaddr,
+// ifru_broadaddr: sockaddr,
+// ifru_netmask: sockaddr,
+// ifru_hwaddr: sockaddr,
+// ifru_flags: i16,
+// ifru_ivalue: i32,
+// ifru_mtu: i32,
+// ifru_map: ifmap,
+// ifru_slave: [IF_NAMESIZE]u8,
+// ifru_newname: [IF_NAMESIZE]u8,
+// ifru_data: &u8,
+// } ifr_ifru;
+//}
+//
pub fn getsockname(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> usize {
arch.syscall3(arch.SYS_getsockname, usize(fd), usize(addr), usize(len))
std/net.zig
@@ -67,12 +67,12 @@ struct Address {
pub fn lookup(hostname: []const u8, out_addrs: []Address) -> %[]Address {
if (hostname.len == 0) {
-/*
- if (family != AF_INET6)
- buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
- if (family != AF_INET)
- buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
- */
+//
+// if (family != AF_INET6)
+// buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
+// if (family != AF_INET)
+// buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
+//
unreachable{} // TODO
}
@@ -248,20 +248,20 @@ fn parse_ip6(buf: []const u8) -> %Address {
return error.Incomplete;
}
- /*
- if (p) {
- if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
- else z = p-1;
- if (*z) {
- if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
- !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
- return EAI_NONAME;
- scopeid = if_nametoindex(p);
- if (!scopeid) return EAI_NONAME;
- }
- if (scopeid > UINT_MAX) return EAI_NONAME;
- }
- */
+//
+// if (p) {
+// if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
+// else z = p-1;
+// if (*z) {
+// if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
+// !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
+// return EAI_NONAME;
+// scopeid = if_nametoindex(p);
+// if (!scopeid) return EAI_NONAME;
+// }
+// if (scopeid > UINT_MAX) return EAI_NONAME;
+// }
+//
if (scope_id) {
return result;
test/self_hosted.zig
@@ -4,22 +4,11 @@ const str = std.str;
const cstr = std.cstr;
const other = @import("other.zig");
-#attribute("test")
-fn empty_function() {}
-
-
-
-/**
- * multi line doc comment
- */
+// normal comment
/// this is a documentation comment
/// doc comment line 2
#attribute("test")
-fn comments() {
- comments_f1(/* mid-line comment /* nested */ */ "OK\n");
-}
-
-fn comments_f1(s: []u8) {}
+fn empty_function_with_comments() {}
#attribute("test")