mirror of
https://github.com/sigmasternchen/macrofuck
synced 2025-03-15 07:08:56 +00:00
feat: Add rmap - reverse map builtin
This commit is contained in:
parent
963e57c995
commit
5346b91cc2
15 changed files with 133 additions and 7 deletions
|
@ -79,7 +79,7 @@ struct statement* while_statement_new(struct expression* condition, struct block
|
|||
return stat;
|
||||
}
|
||||
|
||||
struct statement* map_statement_new(char* index_id, char* ref_id, char* list_id, struct block* block) {
|
||||
struct statement* map_statement_new(char* index_id, char* ref_id, char* list_id, struct block* block, bool reverse) {
|
||||
_new(stat, statement);
|
||||
stat->kind = MAP_STATEMENT;
|
||||
stat->map_loop = (struct map_statement) {
|
||||
|
@ -87,6 +87,7 @@ struct statement* map_statement_new(char* index_id, char* ref_id, char* list_id,
|
|||
.ref_id = ref_id,
|
||||
.list_id = list_id,
|
||||
.block = block,
|
||||
.reverse = reverse,
|
||||
};
|
||||
return stat;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ struct map_statement {
|
|||
char* ref_id;
|
||||
char* list_id;
|
||||
struct block* block;
|
||||
bool reverse;
|
||||
};
|
||||
|
||||
struct expr_statement {
|
||||
|
@ -153,7 +154,7 @@ struct statement* assignment_statement_new(struct expression*, struct expression
|
|||
struct statement* expr_statement_new(struct expression*);
|
||||
struct statement* if_statement_new(struct expression*, struct block*, struct block*);
|
||||
struct statement* while_statement_new(struct expression*, struct block*);
|
||||
struct statement* map_statement_new(char*, char*, char*, struct block*);
|
||||
struct statement* map_statement_new(char*, char*, char*, struct block*, bool);
|
||||
|
||||
struct expression* literal_expression_char_new(char);
|
||||
struct expression* literal_expression_str_new(char*);
|
||||
|
|
|
@ -164,10 +164,22 @@ static void codegen_map_statement(FILE* out, scope_t* scope, struct map_statemen
|
|||
region_t* value = scope_add_ref(local_scope, list, 0, 1);
|
||||
scope_existing(local_scope, value, statement.ref_id);
|
||||
|
||||
for (size_t i = 0; i < list->size; i++) {
|
||||
codegen_block(out, local_scope, statement.block);
|
||||
value->start++;
|
||||
move_to(index); inc();
|
||||
if (statement.reverse) {
|
||||
move_to(index); add(list->size - 1);
|
||||
value->start += list->size - 1;
|
||||
for (long long i = list->size - 1; i >= 0; i--) {
|
||||
codegen_block(out, local_scope, statement.block);
|
||||
value->start--;
|
||||
move_to(index);
|
||||
dec();
|
||||
}
|
||||
} else {
|
||||
for (size_t i = 0; i < list->size; i++) {
|
||||
codegen_block(out, local_scope, statement.block);
|
||||
value->start++;
|
||||
move_to(index);
|
||||
inc();
|
||||
}
|
||||
}
|
||||
|
||||
scope_free(local_scope);
|
||||
|
|
|
@ -10,6 +10,7 @@ if "if"
|
|||
else "else"
|
||||
while "while"
|
||||
map "map"
|
||||
rmap "rmap"
|
||||
in "in"
|
||||
|
||||
char "'"([^\\]|[\\]n|[\\]t|[\\]{2})"'"
|
||||
|
@ -82,6 +83,7 @@ strbuf_t strbuf = NULL;
|
|||
<INITIAL>{else} { return ELSE; }
|
||||
<INITIAL>{while} { return WHILE; }
|
||||
<INITIAL>{map} { return MAP; }
|
||||
<INITIAL>{rmap} { return RMAP; }
|
||||
<INITIAL>{in} { return IN; }
|
||||
|
||||
<INITIAL>"=" { return ASSIGNMENT; }
|
||||
|
|
|
@ -73,6 +73,7 @@ extern struct block* program;
|
|||
%token ELSE
|
||||
%token WHILE
|
||||
%token MAP
|
||||
%token RMAP
|
||||
%token IN
|
||||
|
||||
%start file
|
||||
|
@ -145,7 +146,11 @@ while: WHILE expr block
|
|||
|
||||
map: MAP OPENING_BRACKETS ID COMMA ID IN ID CLOSING_BRACKETS block
|
||||
{
|
||||
$$ = map_statement_new($3, $5, $7, $9);
|
||||
$$ = map_statement_new($3, $5, $7, $9, false);
|
||||
}
|
||||
| RMAP OPENING_BRACKETS ID COMMA ID IN ID CLOSING_BRACKETS block
|
||||
{
|
||||
$$ = map_statement_new($3, $5, $7, $9, true);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
6
compiler/test/cases/023a-rmap-array-print.in
Normal file
6
compiler/test/cases/023a-rmap-array-print.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
var list = []{'f', 'o', 'o', 'b', 'a', 'r'};
|
||||
|
||||
rmap(_, value in list) {
|
||||
print(value);
|
||||
print('\n');
|
||||
}
|
14
compiler/test/cases/023a-rmap-array-print.out
Normal file
14
compiler/test/cases/023a-rmap-array-print.out
Normal file
|
@ -0,0 +1,14 @@
|
|||
>>>>>>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<<<<+>>>>>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<<<+>>>>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<<+>>>>>+<]>[-<+>]<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<+>>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<+>>>+<]>[-<+>]<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<+>>+<]>[-<+>]
|
||||
<[-]+++++<.
|
||||
>>[-]++++++++++.
|
||||
<-<<.
|
||||
>>>[-]++++++++++.
|
||||
<-<<<.
|
||||
>>>>[-]++++++++++.
|
||||
<-<<<<.
|
||||
>>>>>[-]++++++++++.
|
||||
<-<<<<<.
|
||||
>>>>>>[-]++++++++++.
|
||||
<-<<<<<<.
|
||||
>>>>>>>[-]++++++++++.
|
||||
<-
|
5
compiler/test/cases/023b-rmap-array-index-print.in
Normal file
5
compiler/test/cases/023b-rmap-array-index-print.in
Normal file
|
@ -0,0 +1,5 @@
|
|||
var list = []{0, 0, 0, 0};
|
||||
|
||||
rmap(index, _ in list) {
|
||||
print(to_str(index), '\n');
|
||||
}
|
6
compiler/test/cases/023b-rmap-array-index-print.out
Normal file
6
compiler/test/cases/023b-rmap-array-index-print.out
Normal file
|
@ -0,0 +1,6 @@
|
|||
>>>>[-]>[-]<[-<<<<+>>>>>+<]>[-<+>]<[-]>[-]<[-<<<+>>>>+<]>[-<+>]<[-]>[-]<[-<<+>>>+<]>[-<+>]<[-]>[-]<[-<+>>+<]>[-<+>]
|
||||
<[-]+++>[-]>[-]>[-]>[-]>[-]++++++++++>[-]>[-]<<<<<<<[->>>>>>+<<+<+<[-]<[-]>>>>-[-<<<<+>+>>>]<<<[>>>>[-]<<<<[-]]<[->>>>+<<<<]>>>>>[>+<<<<[-]>>++++++++++>[-]]<<<<<<]>>>>[-<<<<+>>>>]>[-]++++++++++>>[-<[-]+<<<<+>>[-]>>>>[-]<<<-[-<+>>>>+<<<]>>>[<<[-]>>[-]]<<<<[->+<]>>[<++++++++++<<<<+>[-]>>>>[-]]>]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++<<<.>.>.>.
|
||||
<<<<->[-]>[-]>[-]>[-]>[-]++++++++++>[-]>[-]<<<<<<<[->>>>>>+<<+<+<[-]<[-]>>>>-[-<<<<+>+>>>]<<<[>>>>[-]<<<<[-]]<[->>>>+<<<<]>>>>>[>+<<<<[-]>>++++++++++>[-]]<<<<<<]>>>>[-<<<<+>>>>]>[-]++++++++++>>[-<[-]+<<<<+>>[-]>>>>[-]<<<-[-<+>>>>+<<<]>>>[<<[-]>>[-]]<<<<[->+<]>>[<++++++++++<<<<+>[-]>>>>[-]]>]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++<<<.>.>.>.
|
||||
<<<<->[-]>[-]>[-]>[-]>[-]++++++++++>[-]>[-]<<<<<<<[->>>>>>+<<+<+<[-]<[-]>>>>-[-<<<<+>+>>>]<<<[>>>>[-]<<<<[-]]<[->>>>+<<<<]>>>>>[>+<<<<[-]>>++++++++++>[-]]<<<<<<]>>>>[-<<<<+>>>>]>[-]++++++++++>>[-<[-]+<<<<+>>[-]>>>>[-]<<<-[-<+>>>>+<<<]>>>[<<[-]>>[-]]<<<<[->+<]>>[<++++++++++<<<<+>[-]>>>>[-]]>]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++<<<.>.>.>.
|
||||
<<<<->[-]>[-]>[-]>[-]>[-]++++++++++>[-]>[-]<<<<<<<[->>>>>>+<<+<+<[-]<[-]>>>>-[-<<<<+>+>>>]<<<[>>>>[-]<<<<[-]]<[->>>>+<<<<]>>>>>[>+<<<<[-]>>++++++++++>[-]]<<<<<<]>>>>[-<<<<+>>>>]>[-]++++++++++>>[-<[-]+<<<<+>>[-]>>>>[-]<<<-[-<+>>>>+<<<]>>>[<<[-]>>[-]]<<<<[->+<]>>[<++++++++++<<<<+>[-]>>>>[-]]>]<<<<<<++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++<<<.>.>.>.
|
||||
<<<<-
|
7
compiler/test/cases/023c-rmap-array-modify-ref.in
Normal file
7
compiler/test/cases/023c-rmap-array-modify-ref.in
Normal file
|
@ -0,0 +1,7 @@
|
|||
var list = []{'e', 'n', 'n'};
|
||||
|
||||
rmap(_, value in list) {
|
||||
value = (value + 1);
|
||||
}
|
||||
|
||||
print(list, '\n');
|
6
compiler/test/cases/023c-rmap-array-modify-ref.out
Normal file
6
compiler/test/cases/023c-rmap-array-modify-ref.out
Normal file
|
@ -0,0 +1,6 @@
|
|||
>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<+>>>>+<]>[-<+>]<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<+>>>+<]>[-<+>]<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<+>>+<]>[-<+>]
|
||||
<[-]++>[-]+>[-]>[-]<<<<[->>>+>+<<<<]>>>>[-<<<<+>>>>]<[-<+>]<<<[-]>>>[-]<[-<<+>>>+<]>[-<+>]
|
||||
<<->[-]+>[-]>[-]<<<<<[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>]<[-<+>]<<<<[-]>>>>[-]<[-<<<+>>>>+<]>[-<+>]
|
||||
<<->[-]+>[-]>[-]<<<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<[-<+>]<<<<<[-]>>>>>[-]<[-<<<<+>>>>>+<]>[-<+>]
|
||||
<<-
|
||||
[-]++++++++++<<<.>.>.>.
|
9
compiler/test/cases/023d-rmap-str-print.in
Normal file
9
compiler/test/cases/023d-rmap-str-print.in
Normal file
|
@ -0,0 +1,9 @@
|
|||
var s = "hello, world!\n";
|
||||
|
||||
rmap(_, c in s) {
|
||||
if ((c >= 'a') && (c <= 'z')) {
|
||||
c = ((c - 'a') + 'A');
|
||||
}
|
||||
}
|
||||
|
||||
print(s);
|
31
compiler/test/cases/023d-rmap-str-print.out
Normal file
31
compiler/test/cases/023d-rmap-str-print.out
Normal file
|
@ -0,0 +1,31 @@
|
|||
[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]+++++++++++++++++++++++++++++++++>[-]++++++++++
|
||||
>[-]+++++++++++++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<[->>>+>+<<<<]>>>>[-<<<<+>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<[->>>+>>+<<<<<]>>>>>[-<<<<<+>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<[-]>>>[-]>[-<<<<+>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<[->>>>+>+<<<<<]>>>>>[-<<<<<+>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<[->>>>+>>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<[-]>>>>[-]>[-<<<<<+>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<[->>>>>+>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<[->>>>>+>>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<[->>>>>>+>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<[-]>>>>>[-]>[-<<<<<<+>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<[->>>>>>+>+<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<[->>>>>>+>>+<<<<<<<<]>>>>>>>>[-<<<<<<<<+>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<[->>>>>>>+>+<<<<<<<<]>>>>>>>>[-<<<<<<<<+>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<[-]>>>>>>[-]>[-<<<<<<<+>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<[->>>>>>>+>+<<<<<<<<]>>>>>>>>[-<<<<<<<<+>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<[->>>>>>>+>>+<<<<<<<<<]>>>>>>>>>[-<<<<<<<<<+>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<[->>>>>>>>+>+<<<<<<<<<]>>>>>>>>>[-<<<<<<<<<+>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<[-]>>>>>>>[-]>[-<<<<<<<<+>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<[->>>>>>>>+>+<<<<<<<<<]>>>>>>>>>[-<<<<<<<<<+>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<[->>>>>>>>+>>+<<<<<<<<<<]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<[->>>>>>>>>+>+<<<<<<<<<<]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<[-]>>>>>>>>[-]>[-<<<<<<<<<+>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<[->>>>>>>>>+>+<<<<<<<<<<]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<[->>>>>>>>>+>>+<<<<<<<<<<<]>>>>>>>>>>>[-<<<<<<<<<<<+>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<[->>>>>>>>>>+>+<<<<<<<<<<<]>>>>>>>>>>>[-<<<<<<<<<<<+>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<[-]>>>>>>>>>[-]>[-<<<<<<<<<<+>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<[->>>>>>>>>>+>+<<<<<<<<<<<]>>>>>>>>>>>[-<<<<<<<<<<<+>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<[->>>>>>>>>>+>>+<<<<<<<<<<<<]>>>>>>>>>>>>[-<<<<<<<<<<<<+>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<[->>>>>>>>>>>+>+<<<<<<<<<<<<]>>>>>>>>>>>>[-<<<<<<<<<<<<+>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<[-]>>>>>>>>>>[-]>[-<<<<<<<<<<<+>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<[->>>>>>>>>>>+>+<<<<<<<<<<<<]>>>>>>>>>>>>[-<<<<<<<<<<<<+>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<[->>>>>>>>>>>+>>+<<<<<<<<<<<<<]>>>>>>>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<[->>>>>>>>>>>>+>+<<<<<<<<<<<<<]>>>>>>>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<[-]>>>>>>>>>>>[-]>[-<<<<<<<<<<<<+>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<[->>>>>>>>>>>>+>+<<<<<<<<<<<<<]>>>>>>>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<<[->>>>>>>>>>>>+>>+<<<<<<<<<<<<<<]>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<+>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<[->>>>>>>>>>>>>+>+<<<<<<<<<<<<<<]>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<+>>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<<[-]>>>>>>>>>>>>[-]>[-<<<<<<<<<<<<<+>>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<[->>>>>>>>>>>>>+>+<<<<<<<<<<<<<<]>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<+>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<<<[->>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<<<[-]>>>>>>>>>>>>>[-]>[-<<<<<<<<<<<<<<+>>>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>[-]>[-<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>>[-]>[-<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<->[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<[>>+>[-]<<<-]>>[<<+>>-]<<->>>[<<[-]<<[-]>>>>-]<<<<][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>[-]<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>][-]+<<[->>>>[-]+<[-]<<<<[>>>>+>[-]<<<<<-]>>>>[<<<<+>>>>-]<<<<->>>>>[<<[-]<<[-]>>>>-]<<<<]<[-]>>[>[<<<+>>>[-]]<[-]]<<[>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>[-]<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>]<<[->-<][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[->+<]<<<<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>>>[-]>[-<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>+>]<[->+<]
|
||||
<[-]]
|
||||
<-
|
||||
<<<<<<<<<<<<<<.>.>.>.>.>.>.>.>.>.>.>.>.>.
|
11
compiler/test/cases/023e-rmap-extract-value.in
Normal file
11
compiler/test/cases/023e-rmap-extract-value.in
Normal file
|
@ -0,0 +1,11 @@
|
|||
var a = []{'a', 'b', 'c'};
|
||||
|
||||
var extract = 0;
|
||||
|
||||
rmap(i, v in a) {
|
||||
if (i == 1) {
|
||||
extract = v;
|
||||
}
|
||||
}
|
||||
|
||||
print(extract, '\n');
|
10
compiler/test/cases/023e-rmap-extract-value.out
Normal file
10
compiler/test/cases/023e-rmap-extract-value.out
Normal file
|
@ -0,0 +1,10 @@
|
|||
>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<<+>>>>+<]>[-<+>]<[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<<+>>>+<]>[-<+>]<[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]<[-<+>>+<]>[-<+>]
|
||||
<[-]
|
||||
>[-]++>[-]+>[-]>[-]<<<[->>+>+<<<]>>>[-<<<+>>>]<<[->-<]+>[<->[-]]<[<<[-]>>>[-]<<<<[->+>>>+<<<<]>>>>[-<<<<+>>>>]
|
||||
<[-]]
|
||||
<->[-]+>[-]>[-]<<<[->>+>+<<<]>>>[-<<<+>>>]<<[->-<]+>[<->[-]]<[<<[-]>>>[-]<<<<<[->>+>>>+<<<<<]>>>>>[-<<<<<+>>>>>]
|
||||
<[-]]
|
||||
<->[-]+>[-]>[-]<<<[->>+>+<<<]>>>[-<<<+>>>]<<[->-<]+>[<->[-]]<[<<[-]>>>[-]<<<<<<[->>>+>>>+<<<<<<]>>>>>>[-<<<<<<+>>>>>>]
|
||||
<[-]]
|
||||
<-
|
||||
[-]++++++++++<.>.
|
Loading…
Reference in a new issue