diff --git a/Cesium.Ast/Statements.cs b/Cesium.Ast/Statements.cs index c5830225..bdc80f82 100644 --- a/Cesium.Ast/Statements.cs +++ b/Cesium.Ast/Statements.cs @@ -28,4 +28,6 @@ public record ForStatement( // 6.8.6 Jump statements public record GoToStatement(string Identifier) : Statement; +public record BreakStatement : Statement; + public record ReturnStatement(Expression Expression) : Statement; \ No newline at end of file diff --git a/Cesium.Parser/CParser.cs b/Cesium.Parser/CParser.cs index 9b121c78..25234a0b 100644 --- a/Cesium.Parser/CParser.cs +++ b/Cesium.Parser/CParser.cs @@ -697,7 +697,10 @@ private static Statement MakeGoToStatement(ICToken _, ICToken identifier, ICToke new GoToStatement(identifier.Text); // [Rule("jump_statement: 'continue' ';'")] - // [Rule("jump_statement: 'break' ';'")] + [Rule("jump_statement: 'break' ';'")] + private static Statement MakeBreakStatement(ICToken _, ICToken __) + => new BreakStatement(); + [Rule("jump_statement: 'return' expression? ';'")] private static Statement MakeReturnStatement(ICToken _, Expression expression, ICToken __) => new ReturnStatement(expression);