M lexer.c => lexer.c +12 -12
@@ 331,13 331,13 @@ lex_string(void)
static void
lexer_append(void)
{
- // If you see "handle used but not set" or some such: LEAVE IT ALONE. Not initializing handle when its value isn't actually needed, since lexer_append is VERY HOT, has a noticable performance gain, and has no real downsides aside from the need to ensure that the whitelist of internalized tags is correct
+ // If you see "handle used but not set" or some such: LEAVE IT ALONE. Not initializing handle when its value isn't actually needed, and since lexer_append is VERY HOT it has a noticable performance gain, and has no real downsides aside from the need to ensure that the whitelist of internalized tags is correct
uint32_t handle;
// if(ctx.token.tag != C3_WHILE && ctx.token.tag != C3_RBRACE && ctx.token.tag != C3_TRUE && ctx.token.tag != C3_LBRACE && ctx.token.tag != C3_LPAREN && ctx.token.tag != C3_RPAREN){
if(ctx.token.tag == C3_IDENT || ctx.token.tag == C3_LITERAL_STRING || ctx.token.tag == C3_LINT){
handle = c3intern(&ctx.tree, ctx.token.ptr, ctx.token.len);
if(handle == -1)
- FATAL("Failed to intern string", 0);
+ OOM();
}
if(!stb_sb_push_u32(&ctx.tokens.strings, handle) || !stb_sb_push_u8(&ctx.tokens.tags, ctx.token.tag))
OOM();
@@ 371,21 371,15 @@ zyg_lex(char *path)
c = ctx.file.buf[ctx.index];
if(c == 0)
break;
- if(c == '('){
+ if(is_alpha(c) || c == '_' || c == '@'){
+ lex_alpha();
+ }else if(c == '('){
ctx.token.tag = C3_LPAREN;
ctx.index += 1;
- }else if(ARG("+=", 2)){
- ctx.index += 2;
- ctx.token.tag = C3_PLUS_EQUAL;
- }else if(ARG("-=", 2)){
- ctx.index += 2;
- ctx.token.tag = C3_MINUS_EQUAL;
}else if(c == ')'){
ctx.token.tag = C3_RPAREN;
ctx.index += 1;
- }else if(is_alpha(c) || c == '_' || c == '@')
- lex_alpha();
- else if(c == '='){
+ }else if(c == '='){
ctx.token.tag = C3_EQ;
ctx.index += 1;
}else if(c == '{'){
@@ 433,6 427,12 @@ zyg_lex(char *path)
}else if(c == '-'){
ctx.token.tag = C3_MINUS;
ctx.index += 1;
+ }else if(ARG("+=", 2)){
+ ctx.index += 2;
+ ctx.token.tag = C3_PLUS_EQUAL;
+ }else if(ARG("-=", 2)){
+ ctx.index += 2;
+ ctx.token.tag = C3_MINUS_EQUAL;
}else if(c == '!'){
ctx.token.tag = C3_EXCLAIM;
ctx.index += 1;
M parser.c => parser.c +1 -1
@@ 707,7 707,7 @@ p_block(void)
return -1;
parser_advance();
}
- if(stb_sb_count(kids) > 0xFFFF){
+ if(stb_sb_count(kids) > 0xFFFFFF){
ERROR("Too many kids for block", 0);
return -1;
}
D profile => profile +0 -3
@@ 1,3 0,0 @@
-#!/bin/sh
-valgrind --tool=callgrind ./zyg --target none ./test/evil.zig -s ; gprof2dot --format=callgrind --output=tmp.dot callgrind.out*;dot -T png tmp.dot -o callgrind.png;rm tmp.dot callgrind.out.* -f ; cat callgrind.png | ssh pixelhero.dev 'cat >/var/www/https/tmp/callgrind.png' ; rm callgrind.png
-
M profile.sh => profile.sh +1 -1
@@ 1,3 1,3 @@
#!/bin/sh
-valgrind --tool=callgrind ./zyg --target none ./test/evil.zig -s -p ; gprof2dot --format=callgrind --output=tmp.dot callgrind.out*;dot -T png tmp.dot -o callgrind.png;rm tmp.dot callgrind.out.* -f ; cat callgrind.png | ssh pixelhero.dev 'cat >/var/www/https/tmp/callgrind.png' ; rm callgrind.png
+valgrind --tool=callgrind ./zyg --target none ./test/evil.zig -s ; gprof2dot --format=callgrind --output=tmp.dot callgrind.out*;dot -T png tmp.dot -o callgrind.png;rm tmp.dot callgrind.out.* -f ; cat callgrind.png | ssh pixelhero.dev 'cat >/var/www/https/tmp/callgrind.png' ; rm callgrind.png
M test/evil.zig => test/evil.zig +1 -5
@@ 1,4 1,4 @@
-const a = fn() void{
+export const main = fn() void {
while(true){}
while(true){}
while(true){}
@@ 44443,10 44443,6 @@ const a = fn() void{
while(true){}
while(true){}
while(true){}
-};
-
-export const main = fn() void {
- a();
while(true){}
while(true){}
while(true){}