Skip to content

Commit

Permalink
Revert "pipeless generator syntax"
Browse files Browse the repository at this point in the history
This reverts commit 445a1b1.
  • Loading branch information
borisbat committed Nov 2, 2024
1 parent 445a1b1 commit d0a687c
Show file tree
Hide file tree
Showing 9 changed files with 33,999 additions and 34,241 deletions.
46 changes: 0 additions & 46 deletions examples/test/misc/hello_world.das
Original file line number Diff line number Diff line change
Expand Up @@ -420,52 +420,6 @@ def test_lambda_capture ( a : int ) {
};
}

////////////
// generator

[export]
def test_generator ( a : int ) {
// passing block as argument
var g1 <- generator<int> (${
for ( x in range(1,a) ) {
yield x;
}
return false;
});
var G1 <- generator<int> capture(=a) (${
for ( x in range(1,a) ) {
yield x;
}
return false;
});
// simplified syntax
var g2 <- generator<int> {
for ( x in range(1,a) ) {
yield x;
}
return false;
};
var G2 <- generator<int> capture(=a) {
for ( x in range(1,a) ) {
yield x;
}
return false;
};
// via pipe
var g3 <- generator<int>() <| ${
for ( x in range(1,a) ) {
yield x;
}
return false;
};
var G3 <- generator<int> capture(=a) () <| ${
for ( x in range(1,a) ) {
yield x;
}
return false;
};
}

///////
// main

Expand Down
4 changes: 2 additions & 2 deletions src/ast/ast_infer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2774,10 +2774,10 @@ namespace das {
return Visitor::visit(expr);
}
if ( expr->arguments.size()!=1 ) {
error("generator can only have one argument", "", "",
error("expecting generator(closure)", "", "",
expr->at, CompilationError::invalid_argument_count);
} else if ( !expr->arguments[0]->rtti_isMakeBlock() ) {
error("expecting generator(closure), got " + string(expr->arguments[0]->__rtti) + " instead", "", "",
error("expecting generator(closure)", "", "",
expr->at, CompilationError::invalid_argument_type);
} else {
auto mkBlock = static_pointer_cast<ExprMakeBlock>(expr->arguments[0]);
Expand Down
24 changes: 0 additions & 24 deletions src/builtin/builtin.das.inc
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ static unsigned char builtin_das[] = {
0x69,0x74,0x56,0x61,0x6c,0x75,0x65,0x0a,
0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x6e,0x65,
0x77,0x53,0x69,0x7a,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x72,0x65,0x73,0x69,
0x7a,0x65,0x5f,0x6e,0x6f,0x5f,0x69,0x6e,
0x69,0x74,0x28,0x76,0x61,0x72,0x20,0x41,
Expand Down Expand Up @@ -473,10 +469,6 @@ static unsigned char builtin_das[] = {
0x6e,0x65,0x67,0x61,0x74,0x69,0x76,0x65,
0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x76,0x61,
0x6c,0x75,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x70,0x75,0x73,0x68,
0x28,0x76,0x61,0x72,0x20,0x41,0x72,0x72,
0x3a,0x61,0x72,0x72,0x61,0x79,0x3c,0x61,
Expand Down Expand Up @@ -524,10 +516,6 @@ static unsigned char builtin_das[] = {
0x6e,0x27,0x74,0x20,0x62,0x65,0x20,0x63,
0x6f,0x70,0x69,0x65,0x64,0x22,0x29,0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x76,0x61,
0x6c,0x75,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x70,0x75,0x73,0x68,
0x28,0x76,0x61,0x72,0x20,0x41,0x72,0x72,
0x3a,0x61,0x72,0x72,0x61,0x79,0x3c,0x61,
Expand Down Expand Up @@ -574,10 +562,6 @@ static unsigned char builtin_das[] = {
0x6e,0x27,0x74,0x20,0x62,0x65,0x20,0x63,
0x6f,0x70,0x69,0x65,0x64,0x22,0x29,0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x76,0x61,
0x6c,0x75,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x70,0x75,0x73,0x68,
0x28,0x76,0x61,0x72,0x20,0x41,0x72,0x72,
0x3a,0x61,0x72,0x72,0x61,0x79,0x3c,0x61,
Expand Down Expand Up @@ -628,10 +612,6 @@ static unsigned char builtin_das[] = {
0x6e,0x27,0x74,0x20,0x62,0x65,0x20,0x63,
0x6f,0x70,0x69,0x65,0x64,0x22,0x29,0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x76,0x61,
0x6c,0x75,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x70,0x75,0x73,0x68,
0x28,0x76,0x61,0x72,0x20,0x41,0x72,0x72,
0x3a,0x61,0x72,0x72,0x61,0x79,0x3c,0x61,
Expand Down Expand Up @@ -682,10 +662,6 @@ static unsigned char builtin_das[] = {
0x6e,0x27,0x74,0x20,0x62,0x65,0x20,0x63,
0x6f,0x70,0x69,0x65,0x64,0x22,0x29,0x0a,
0x0a,
0x5b,0x75,0x6e,0x75,0x73,0x65,0x64,0x5f,
0x61,0x72,0x67,0x75,0x6d,0x65,0x6e,0x74,
0x28,0x41,0x72,0x72,0x2c,0x20,0x76,0x61,
0x6c,0x75,0x65,0x29,0x5d,0x0a,
0x64,0x65,0x66,0x20,0x70,0x75,0x73,0x68,
0x28,0x76,0x61,0x72,0x20,0x41,0x72,0x72,
0x3a,0x61,0x72,0x72,0x61,0x79,0x3c,0x61,
Expand Down
5,054 changes: 2,516 additions & 2,538 deletions src/parser/ds2_parser.cpp

Large diffs are not rendered by default.

Loading

0 comments on commit d0a687c

Please sign in to comment.