Skip to content

Commit 74b357b

Browse files
committed
Remove the continue keyword
1 parent 1a14dd7 commit 74b357b

File tree

16 files changed

+6
-922
lines changed

16 files changed

+6
-922
lines changed

ast/ast.c

-9
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,6 @@ Stmt* breakStmt(int lineno)
355355
return stmt;
356356
}
357357

358-
Stmt* continueStmt(int lineno)
359-
{
360-
ContinueStmt* continue_stmt = (struct ContinueStmt*)calloc(1, sizeof(ContinueStmt));
361-
continue_stmt->kind = ContinueStmt_kind;
362-
Stmt* stmt = buildStmt(ContinueStmt_kind, lineno);
363-
stmt->v.continue_stmt = continue_stmt;
364-
return stmt;
365-
}
366-
367358

368359
// Spec
369360

ast/ast.h

-7
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ enum StmtKind {
172172
FunctionTableStmt_kind=10,
173173
BlockStmt_kind=11,
174174
BreakStmt_kind=12,
175-
ContinueStmt_kind=13,
176175
};
177176

178177
typedef struct Stmt {
@@ -190,7 +189,6 @@ typedef struct Stmt {
190189
struct FunctionTableStmt* function_table_stmt;
191190
struct BlockStmt* block_stmt;
192191
struct BreakStmt* break_stmt;
193-
struct ContinueStmt* continue_stmt;
194192
} v;
195193
} Stmt;
196194

@@ -247,10 +245,6 @@ typedef struct BreakStmt {
247245
enum StmtKind kind;
248246
} BreakStmt;
249247

250-
typedef struct ContinueStmt {
251-
enum StmtKind kind;
252-
} ContinueStmt;
253-
254248

255249
// Spec
256250

@@ -473,7 +467,6 @@ Stmt* delStmt(Expr* ident, int lineno);
473467
Stmt* exitStmt(Expr* x, int lineno);
474468
Stmt* functionTableStmt(int lineno);
475469
Stmt* breakStmt(int lineno);
476-
Stmt* continueStmt(int lineno);
477470
Stmt* blockStmt(StmtList* stmt_list, int lineno);
478471
Spec* buildSpec(enum SpecKind kind, int lineno);
479472
Spec* typeSpec(enum Type type, Spec* sub_type_spec, int lineno);

ast/ast_print.c

-7
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,6 @@ void printASTStmt(Stmt* stmt, bool is_list, char *end)
235235
__KAOS_INDENT_CHAR__
236236
);
237237
break;
238-
case ContinueStmt_kind:
239-
printf(
240-
"%*c\"_type\": \"ContinueStmt\"\n",
241-
indent,
242-
__KAOS_INDENT_CHAR__
243-
);
244-
break;
245238
default:
246239
break;
247240
}

compiler/compiler.c

-3
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,6 @@ void compileStmt(KaosIR* program, Stmt* stmt)
432432
push_inst_(program, DYN_BREAK);
433433
break;
434434
}
435-
case ContinueStmt_kind: {
436-
break;
437-
}
438435
default:
439436
break;
440437
}

compiler/compiler_emit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ void emitBytecode(cpu *c)
401401
case DYN_GET_COMP_SIZE:
402402
sprintf(str_inst, "%s R(%d) R(%d)", "DYN_GET_COMP_SIZE", c->inst->op1->reg, c->inst->op2->reg);
403403
break;
404-
// Dynamic Loop Break/Continue
404+
// Dynamic Loop Break
405405
case DYN_BREAK:
406406
sprintf(str_inst, "%s", "DYN_BREAK");
407407
break;

interpreter/errors.c

-6
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,9 @@ void throw_error_base(
144144
case E_BREAK_CALL_OUTSIDE_LOOP:
145145
sprintf(error_msg, "Call to a function with `break` from outside a loop: %s", str1);
146146
break;
147-
case E_CONTINUE_CALL_OUTSIDE_LOOP:
148-
sprintf(error_msg, "Call to a function with `continue` from outside a loop: %s", str1);
149-
break;
150147
case E_BREAK_CALL_MULTILINE_LOOP:
151148
sprintf(error_msg, "Call to a function with `break` from a multiline loop: %s", str1);
152149
break;
153-
case E_CONTINUE_CALL_MULTILINE_LOOP:
154-
sprintf(error_msg, "Call to a function with `continue` from a multiline loop: %s", str1);
155-
break;
156150
case E_STACK_OVERFLOW:
157151
sprintf(error_msg, "Stack overflow! Report this error to https://github.com/chaos-lang/chaos/issues");
158152
break;

interpreter/errors.h

-2
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ enum ExitCode {
6666
E_INVALID_OPTION,
6767
E_NEGATIVE_ITERATION_COUNT,
6868
E_BREAK_CALL_OUTSIDE_LOOP,
69-
E_CONTINUE_CALL_OUTSIDE_LOOP,
7069
E_BREAK_CALL_MULTILINE_LOOP,
71-
E_CONTINUE_CALL_MULTILINE_LOOP,
7270
E_STACK_OVERFLOW,
7371
E_PREEMPTIVE
7472
};

lexer/lexer.l

-1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,5 @@ default:
284284
"def" {shell_indicator_block_counter++; return T_DEF;}
285285
"import" {return T_IMPORT;}
286286
"break" {return T_BREAK;}
287-
"continue" {return T_CONTINUE;}
288287
[a-zA-Z_][a-zA-Z0-9_]* {yylval.sval=strdup(yytext); return T_VAR;}
289288
%%

parser/parser.y

+2-14
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extern unsigned long long shell_indicator_block_counter;
7474
%token T_NEWLINE T_EXIT
7575
%token T_PRINT T_ECHO T_PRETTY
7676
%token T_VAR_BOOL T_VAR_NUMBER T_VAR_STRING T_VAR_LIST T_VAR_DICT T_VAR_ANY T_NULL
77-
%token T_DEL T_RETURN T_VOID T_DEFAULT T_BREAK T_CONTINUE
77+
%token T_DEL T_RETURN T_VOID T_DEFAULT T_BREAK
7878
%token T_SYMBOL_TABLE T_FUNCTION_TABLE
7979
%token T_TIMES_DO T_FOREACH T_AS T_END T_DEF T_IMPORT T_FROM T_BACKSLASH T_INFINITE
8080
%token T_EQL T_NEQ T_GTR T_LSS T_GEQ T_LEQ
@@ -91,7 +91,7 @@ extern unsigned long long shell_indicator_block_counter;
9191
%type<expr> selector_expr call_expr decision_expr default_expr
9292
%type<stmt> stmt assign_stmt print_stmt echo_stmt return_stmt expr_stmt decl_stmt del_stmt exit_stmt
9393
%type<stmt> function_table_stmt
94-
%type<stmt> block_stmt break_stmt continue_stmt
94+
%type<stmt> block_stmt break_stmt
9595
%type<spec> type_spec sub_type_spec pretty_spec import parent_dir_spec asterisk_spec
9696
%type<spec> field_spec optional_field_spec field_list_spec optional_field_list_spec
9797
%type<spec> decision_block
@@ -437,9 +437,6 @@ decision_expr:
437437
| bool_expr T_COLON break_stmt {
438438
$$ = decisionExpr($1, $3, yylineno);
439439
}
440-
| bool_expr T_COLON continue_stmt {
441-
$$ = decisionExpr($1, $3, yylineno);
442-
}
443440
;
444441

445442
default_expr:
@@ -452,9 +449,6 @@ default_expr:
452449
| T_DEFAULT T_COLON break_stmt {
453450
$$ = defaultExpr($3, yylineno);
454451
}
455-
| T_DEFAULT T_COLON continue_stmt {
456-
$$ = defaultExpr($3, yylineno);
457-
}
458452
;
459453

460454
decision_expr_list:
@@ -617,12 +611,6 @@ break_stmt:
617611
}
618612
;
619613

620-
continue_stmt:
621-
T_CONTINUE {
622-
$$ = continueStmt(yylineno);
623-
}
624-
;
625-
626614
type_spec:
627615
T_VOID {
628616
$$ = typeSpec(K_BOOL, NULL, yylineno);

0 commit comments

Comments
 (0)