Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions com.minres.coredsl/src/com/minres/coredsl/CoreDsl.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ ReturnStatement: {ReturnStatement} t_return='return' value=ConditionalExpression
LoopStatement: WhileLoop | ForLoop | DoLoop;

WhileLoop:
'while' '(' condition=Expression ')' body=Statement;
'while' '(' condition=Expression ')' attributes+=Attribute* body=Statement;

ForLoop:
'for' '('
(startDeclaration=MultiInitDeclaration | startExpression=AssignmentExpression?) ';'
(condition=Expression?) ';'
(loopExpressions+=AssignmentExpression (',' loopExpressions+=AssignmentExpression)*)?
')' body=Statement;
')' attributes+=Attribute* body=Statement;

DoLoop:
'do' body=Statement 'while' '(' condition=Expression ')' ';';
'do' body=Statement 'while' '(' condition=Expression ')' attributes+=Attribute* ';';

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Declarations ////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class AttributeRegistry {
instruction,
function,
declarator,
alwaysBlock
alwaysBlock,
loop
}

static final class AttributeInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ class CoreDslAnalyzer {
* 2. [Warning] The condition should not be an assignment. <i>(LikelyAccidentalAssignment)</i>
*/
def static dispatch void analyzeStatement(AnalysisContext ctx, WhileLoop statement) {

analyzeAttributes(ctx, statement.attributes, AttributeRegistry.AttributeUsage.loop);

val conditionType = analyzeExpression(ctx, statement.condition);

checkAccidentalAssignment(ctx, statement.condition);
Expand All @@ -601,6 +604,8 @@ class CoreDslAnalyzer {
*/
def static dispatch void analyzeStatement(AnalysisContext ctx, ForLoop statement) {

analyzeAttributes(ctx, statement.attributes, AttributeRegistry.AttributeUsage.loop);

if (statement.startDeclaration !== null) {
analyzeDeclaration(ctx, statement.startDeclaration, false);
}
Expand Down Expand Up @@ -641,6 +646,9 @@ class CoreDslAnalyzer {
* 2. [Warning] The condition should not be an assignment. <i>(LikelyAccidentalAssignment)</i>
*/
def static dispatch void analyzeStatement(AnalysisContext ctx, DoLoop statement) {

analyzeAttributes(ctx, statement.attributes, AttributeRegistry.AttributeUsage.loop);

val conditionType = analyzeExpression(ctx, statement.condition);

checkAccidentalAssignment(ctx, statement.condition);
Expand Down
Loading