authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-07-27 23:26:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-07-27 23:26:12-07:00
log1fa0cabf9dd0c2016a60c23bb616f0f39daf1dfd
treeed50dd2790c0e12cad2b20071766089b18f386cc
parent8552d7fd19836f3350b7303f9bd897708b966805

remove multiline comments

closes #161

7 files changed, 106 insertions(+), 193 deletions(-)

doc/vim/syntax/zig.vim+5-12
......@@ -1,28 +1,27 @@
11" Vim syntax file
22" Language: Zig
33" Maintainer: Andrew Kelley
4" Latest Revision: 02 December 2015
4" Latest Revision: 28 July 2016
55
66if exists("b:current_syntax")
77 finish
88endif
99
10syn keyword zigStorage const var extern volatile export pub noalias inline
10syn keyword zigStorage const var extern export pub noalias inline noinline
1111syn keyword zigStructure struct enum union
1212syn keyword zigStatement goto break return continue asm defer
1313syn keyword zigConditional if else switch
1414syn keyword zigRepeat while for
1515
16syn keyword zigConstant null undefined
16syn keyword zigConstant null undefined zeroes
1717syn keyword zigKeyword fn use
1818syn keyword zigType bool f32 f64 void unreachable type error
1919syn keyword zigType i8 u8 i16 u16 i32 u32 i64 u64 isize usize
20syn keyword zigType c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong
20syn keyword zigType c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong c_long_double
2121
2222syn keyword zigBoolean true false
2323
24syn match zigOperator display "\%(+\|-\|/\|*\|=\|\^\|&\|?\||\|!\|>\|<\|%\)=\?"
25syn match zigOperator display "&&\|||"
24syn match zigOperator display "\%(+%\?\|-%\?\|/\|*%\?\|=\|\^\|&\|?\||\|!\|>\|<\|%\|<<%\?\|>>\|&&\|||\)=\?"
2625syn match zigArrowCharacter display "->"
2726
2827syn match zigDecNumber display "\<[0-9][0-9_]*\%([iu]\%(size\|8\|16\|32\|64\)\)\="
......@@ -40,10 +39,6 @@ syn match zigShebang /\%^#![^[].*/
4039
4140syn region zigCommentLine start="//" end="$" contains=zigTodo,@Spell
4241syn region zigCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=zigTodo,@Spell
43syn region zigCommentBlock matchgroup=zigCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=zigTodo,zigCommentBlockNest,@Spell
44syn region zigCommentBlockDoc matchgroup=zigCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=zigTodo,zigCommentBlockDocNest,@Spell
45syn region zigCommentBlockNest matchgroup=zigCommentBlock start="/\*" end="\*/" contains=zigTodo,zigCommentBlockNest,@Spell contained transparent
46syn region zigCommentBlockDocNest matchgroup=zigCommentBlockDoc start="/\*" end="\*/" contains=zigTodo,zigCommentBlockDocNest,@Spell contained transparent
4742
4843syn keyword zigTodo contained TODO XXX
4944
......@@ -67,8 +62,6 @@ hi def link zigType Type
6762hi def link zigShebang Comment
6863hi def link zigCommentLine Comment
6964hi def link zigCommentLineDoc SpecialComment
70hi def link zigCommentBlock zigCommentLine
71hi def link zigCommentBlockDoc zigCommentLineDoc
7265hi def link zigTodo Todo
7366hi def link zigStringContinuation Special
7467hi def link zigString String
src/tokenizer.cpp-57
......@@ -167,9 +167,6 @@ enum TokenizeState {
167167 TokenizeStateSawPipe,
168168 TokenizeStateSawPipePipe,
169169 TokenizeStateLineComment,
170 TokenizeStateMultiLineComment,
171 TokenizeStateMultiLineCommentSlash,
172 TokenizeStateMultiLineCommentStar,
173170 TokenizeStateSawEq,
174171 TokenizeStateSawBang,
175172 TokenizeStateSawLessThan,
......@@ -194,7 +191,6 @@ struct Tokenize {
194191 int line;
195192 int column;
196193 Token *cur_tok;
197 int multi_line_comment_count;
198194 Tokenization *out;
199195 int raw_string_id_start;
200196 int raw_string_id_end;
......@@ -840,11 +836,6 @@ void tokenize(Buf *buf, Tokenization *out) {
840836 cancel_token(&t);
841837 t.state = TokenizeStateLineComment;
842838 break;
843 case '*':
844 cancel_token(&t);
845 t.state = TokenizeStateMultiLineComment;
846 t.multi_line_comment_count = 1;
847 break;
848839 case '=':
849840 t.cur_tok->id = TokenIdDivEq;
850841 end_token(&t);
......@@ -867,49 +858,6 @@ void tokenize(Buf *buf, Tokenization *out) {
867858 break;
868859 }
869860 break;
870 case TokenizeStateMultiLineComment:
871 switch (c) {
872 case '*':
873 t.state = TokenizeStateMultiLineCommentStar;
874 break;
875 case '/':
876 t.state = TokenizeStateMultiLineCommentSlash;
877 break;
878 default:
879 // do nothing
880 break;
881 }
882 break;
883 case TokenizeStateMultiLineCommentSlash:
884 switch (c) {
885 case '*':
886 t.state = TokenizeStateMultiLineComment;
887 t.multi_line_comment_count += 1;
888 break;
889 case '/':
890 break;
891 default:
892 t.state = TokenizeStateMultiLineComment;
893 break;
894 }
895 break;
896 case TokenizeStateMultiLineCommentStar:
897 switch (c) {
898 case '/':
899 t.multi_line_comment_count -= 1;
900 if (t.multi_line_comment_count == 0) {
901 t.state = TokenizeStateStart;
902 } else {
903 t.state = TokenizeStateMultiLineComment;
904 }
905 break;
906 case '*':
907 break;
908 default:
909 t.state = TokenizeStateMultiLineComment;
910 break;
911 }
912 break;
913861 case TokenizeStateSymbolFirst:
914862 switch (c) {
915863 case '"':
......@@ -1339,11 +1287,6 @@ void tokenize(Buf *buf, Tokenization *out) {
13391287 break;
13401288 case TokenizeStateLineComment:
13411289 break;
1342 case TokenizeStateMultiLineComment:
1343 case TokenizeStateMultiLineCommentSlash:
1344 case TokenizeStateMultiLineCommentStar:
1345 tokenize_error(&t, "unterminated multi-line comment");
1346 break;
13471290 }
13481291 if (t.state != TokenizeStateError) {
13491292 if (t.tokens->length > 0) {
std/compiler_rt.zig+54-66
......@@ -27,45 +27,41 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
2727 var q: udwords = undefined;
2828 var r: udwords = undefined;
2929 var sr: c_uint = undefined;
30 /* special cases, X is unknown, K != 0 */
30 // special cases, X is unknown, K != 0
3131 if (n[high] == 0) {
3232 if (d[high] == 0) {
33 /* 0 X
34 * ---
35 * 0 X
36 */
33 // 0 X
34 // ---
35 // 0 X
3736 if (const rem ?= maybe_rem) {
3837 *rem = n[low] % d[low];
3938 }
4039 return n[low] / d[low];
4140 }
42 /* 0 X
43 * ---
44 * K X
45 */
41 // 0 X
42 // ---
43 // K X
4644 if (const rem ?= maybe_rem) {
4745 *rem = n[low];
4846 }
4947 return 0;
5048 }
51 /* n[high] != 0 */
49 // n[high] != 0
5250 if (d[low] == 0) {
5351 if (d[high] == 0) {
54 /* K X
55 * ---
56 * 0 0
57 */
52 // K X
53 // ---
54 // 0 0
5855 if (var rem ?= maybe_rem) {
5956 *rem = n[high] % d[low];
6057 }
6158 return n[high] / d[low];
6259 }
63 /* d[high] != 0 */
60 // d[high] != 0
6461 if (n[low] == 0) {
65 /* K 0
66 * ---
67 * K 0
68 */
62 // K 0
63 // ---
64 // K 0
6965 if (var rem ?= maybe_rem) {
7066 r[high] = n[high] % d[high];
7167 r[low] = 0;
......@@ -73,10 +69,9 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
7369 }
7470 return n[high] / d[high];
7571 }
76 /* K K
77 * ---
78 * K 0
79 */
72 // K K
73 // ---
74 // K 0
8075 // if d is a power of 2
8176 if ((d[high] & (d[high] - 1)) == 0) {
8277 if (var rem ?= maybe_rem) {
......@@ -86,12 +81,11 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
8681 }
8782 return n[high] >> @ctz(@typeof(d[high]), d[high]);
8883 }
89 /* K K
90 * ---
91 * K 0
92 */
84 // K K
85 // ---
86 // K 0
9387 sr = @clz(su_int, d[high]) - @clz(su_int, n[high]);
94 /* 0 <= sr <= n_uword_bits - 2 or sr large */
88 // 0 <= sr <= n_uword_bits - 2 or sr large
9589 if (sr > n_uword_bits - 2) {
9690 if (var rem ?= maybe_rem) {
9791 *rem = *(&du_int)(&n[0]);
......@@ -99,21 +93,20 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
9993 return 0;
10094 }
10195 sr += 1;
102 /* 1 <= sr <= n_uword_bits - 1 */
103 /* q.all = n.all << (n_udword_bits - sr); */
96 // 1 <= sr <= n_uword_bits - 1
97 // q.all = n.all << (n_udword_bits - sr);
10498 q[low] = 0;
10599 q[high] = n[low] << (n_uword_bits - sr);
106 /* r.all = n.all >> sr; */
100 // r.all = n.all >> sr;
107101 r[high] = n[high] >> sr;
108102 r[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr);
109103 } else {
110 /* d[low] != 0 */
104 // d[low] != 0
111105 if (d[high] == 0) {
112 /* K X
113 * ---
114 * 0 K
115 */
116 /* if d is a power of 2 */
106 // K X
107 // ---
108 // 0 K
109 // if d is a power of 2
117110 if ((d[low] & (d[low] - 1)) == 0) {
118111 if (var rem ?= maybe_rem) {
119112 *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 {
126119 q[low] = (n[high] << (n_uword_bits - sr)) | (n[low] >> sr);
127120 return *(&du_int)(&q[0]);
128121 }
129 /* K X
130 * ---
131 * 0 K
132 */
122 // K X
123 // ---
124 // 0 K
133125 sr = 1 + n_uword_bits + @clz(su_int, d[low]) - @clz(su_int, n[high]);
134 /* 2 <= sr <= n_udword_bits - 1
135 * q.all = n.all << (n_udword_bits - sr);
136 * r.all = n.all >> sr;
137 */
126 // 2 <= sr <= n_udword_bits - 1
127 // q.all = n.all << (n_udword_bits - sr);
128 // r.all = n.all >> sr;
138129 if (sr == n_uword_bits) {
139130 q[low] = 0;
140131 q[high] = n[low];
......@@ -155,12 +146,11 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
155146 r[low] = n[high] >> (sr - n_uword_bits);
156147 }
157148 } else {
158 /* K X
159 * ---
160 * K K
161 */
149 // K X
150 // ---
151 // K K
162152 sr = @clz(su_int, d[high]) - @clz(su_int, n[high]);
163 /* 0 <= sr <= n_uword_bits - 1 or sr large */
153 // 0 <= sr <= n_uword_bits - 1 or sr large
164154 if (sr > n_uword_bits - 1) {
165155 if (var rem ?= maybe_rem) {
166156 *rem = *(&du_int)(&n[0]);
......@@ -168,8 +158,8 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
168158 return 0;
169159 }
170160 sr += 1;
171 /* 1 <= sr <= n_uword_bits */
172 /* q.all = n.all << (n_udword_bits - sr); */
161 // 1 <= sr <= n_uword_bits
162 // q.all = n.all << (n_udword_bits - sr);
173163 q[low] = 0;
174164 if (sr == n_uword_bits) {
175165 q[high] = n[low];
......@@ -182,26 +172,24 @@ export fn __udivmoddi4(a: du_int, b: du_int, maybe_rem: ?&du_int) -> du_int {
182172 }
183173 }
184174 }
185 /* Not a special case
186 * q and r are initialized with:
187 * q.all = n.all << (n_udword_bits - sr);
188 * r.all = n.all >> sr;
189 * 1 <= sr <= n_udword_bits - 1
190 */
175 // Not a special case
176 // q and r are initialized with:
177 // q.all = n.all << (n_udword_bits - sr);
178 // r.all = n.all >> sr;
179 // 1 <= sr <= n_udword_bits - 1
191180 var carry: su_int = 0;
192181 while (sr > 0) {
193 /* r:q = ((r:q) << 1) | carry */
182 // r:q = ((r:q) << 1) | carry
194183 r[high] = (r[high] << 1) | (r[low] >> (n_uword_bits - 1));
195184 r[low] = (r[low] << 1) | (q[high] >> (n_uword_bits - 1));
196185 q[high] = (q[high] << 1) | (q[low] >> (n_uword_bits - 1));
197186 q[low] = (q[low] << 1) | carry;
198 /* carry = 0;
199 * if (r.all >= d.all)
200 * {
201 * r.all -= d.all;
202 * carry = 1;
203 * }
204 */
187 // carry = 0;
188 // if (r.all >= d.all)
189 // {
190 // r.all -= d.all;
191 // carry = 1;
192 // }
205193 const s: di_int = (di_int)(*(&du_int)(&d[0]) - *(&du_int)(&r[0]) - 1) >> (n_udword_bits - 1);
206194 carry = su_int(s & 1);
207195 *(&du_int)(&r[0]) -= *(&du_int)(&d[0]) & u64(s);
std/hash_map.zig+4-4
......@@ -6,11 +6,11 @@ const Allocator = mem.Allocator;
66const want_modification_safety = !@compile_var("is_release");
77const debug_u32 = if (want_modification_safety) u32 else void;
88
9/*
10pub inline fn HashMap(inline K: type, inline V: type, inline hash: fn(key: K)->u32, inline eql: fn(a: K, b: K)->bool) {
11 SmallHashMap(K, V, hash, eql, 8);
9pub inline fn HashMap(inline K: type, inline V: type,
10 inline hash: fn(key: K)->u32, inline eql: fn(a: K, b: K)->bool)
11{
12 SmallHashMap(K, V, hash, eql, 8)
1213}
13*/
1414
1515pub struct SmallHashMap(K: type, V: type, hash: fn(key: K)->u32, eql: fn(a: K, b: K)->bool, STATIC_SIZE: usize) {
1616 entries: []Entry,
std/linux.zig+21-21
......@@ -342,27 +342,27 @@ export struct iovec {
342342 iov_len: usize,
343343}
344344
345/*
346const IF_NAMESIZE = 16;
347
348export struct ifreq {
349 ifrn_name: [IF_NAMESIZE]u8,
350 union {
351 ifru_addr: sockaddr,
352 ifru_dstaddr: sockaddr,
353 ifru_broadaddr: sockaddr,
354 ifru_netmask: sockaddr,
355 ifru_hwaddr: sockaddr,
356 ifru_flags: i16,
357 ifru_ivalue: i32,
358 ifru_mtu: i32,
359 ifru_map: ifmap,
360 ifru_slave: [IF_NAMESIZE]u8,
361 ifru_newname: [IF_NAMESIZE]u8,
362 ifru_data: &u8,
363 } ifr_ifru;
364}
365*/
345//
346//const IF_NAMESIZE = 16;
347//
348//export struct ifreq {
349// ifrn_name: [IF_NAMESIZE]u8,
350// union {
351// ifru_addr: sockaddr,
352// ifru_dstaddr: sockaddr,
353// ifru_broadaddr: sockaddr,
354// ifru_netmask: sockaddr,
355// ifru_hwaddr: sockaddr,
356// ifru_flags: i16,
357// ifru_ivalue: i32,
358// ifru_mtu: i32,
359// ifru_map: ifmap,
360// ifru_slave: [IF_NAMESIZE]u8,
361// ifru_newname: [IF_NAMESIZE]u8,
362// ifru_data: &u8,
363// } ifr_ifru;
364//}
365//
366366
367367pub fn getsockname(fd: i32, noalias addr: &sockaddr, noalias len: &socklen_t) -> usize {
368368 arch.syscall3(arch.SYS_getsockname, usize(fd), usize(addr), usize(len))
std/net.zig+20-20
......@@ -67,12 +67,12 @@ struct Address {
6767pub fn lookup(hostname: []const u8, out_addrs: []Address) -> %[]Address {
6868 if (hostname.len == 0) {
6969
70/*
71 if (family != AF_INET6)
72 buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
73 if (family != AF_INET)
74 buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
75 */
70//
71// if (family != AF_INET6)
72// buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
73// if (family != AF_INET)
74// buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
75//
7676 unreachable{} // TODO
7777 }
7878
......@@ -248,20 +248,20 @@ fn parse_ip6(buf: []const u8) -> %Address {
248248 return error.Incomplete;
249249 }
250250
251 /*
252 if (p) {
253 if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
254 else z = p-1;
255 if (*z) {
256 if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
257 !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
258 return EAI_NONAME;
259 scopeid = if_nametoindex(p);
260 if (!scopeid) return EAI_NONAME;
261 }
262 if (scopeid > UINT_MAX) return EAI_NONAME;
263 }
264 */
251//
252// if (p) {
253// if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
254// else z = p-1;
255// if (*z) {
256// if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
257// !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
258// return EAI_NONAME;
259// scopeid = if_nametoindex(p);
260// if (!scopeid) return EAI_NONAME;
261// }
262// if (scopeid > UINT_MAX) return EAI_NONAME;
263// }
264//
265265
266266 if (scope_id) {
267267 return result;
test/self_hosted.zig+2-13
......@@ -4,22 +4,11 @@ const str = std.str;
44const cstr = std.cstr;
55const other = @import("other.zig");
66
7#attribute("test")
8fn empty_function() {}
9
10
11
12/**
13 * multi line doc comment
14 */
7// normal comment
158/// this is a documentation comment
169/// doc comment line 2
1710#attribute("test")
18fn comments() {
19 comments_f1(/* mid-line comment /* nested */ */ "OK\n");
20}
21
22fn comments_f1(s: []u8) {}
11fn empty_function_with_comments() {}
2312
2413
2514#attribute("test")