Skip to content

Commit b2cd2d8

Browse files
authored
Add attributes to Algorithms and Loops (#248)
* yeah * whoops!
1 parent e417714 commit b2cd2d8

16 files changed

Lines changed: 14508 additions & 14305 deletions

File tree

meta/src/meta/grammar.y

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,11 +891,12 @@ attribute
891891
$4: Sequence[logic.Value] = $$.args
892892

893893
algorithm
894-
: "(" "algorithm" relation_id* script ")"
895-
construct: $$ = logic.Algorithm(global=$3, body=$4)
894+
: "(" "algorithm" relation_id* script attrs? ")"
895+
construct: $$ = logic.Algorithm(global=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]()))
896896
deconstruct:
897897
$3: Sequence[logic.RelationId] = $$.global
898898
$4: logic.Script = $$.body
899+
$5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None
899900

900901
script
901902
: "(" "script" construct* ")"
@@ -913,11 +914,12 @@ construct
913914
$1: logic.Instruction = $$.instruction
914915

915916
loop
916-
: "(" "loop" init script ")"
917-
construct: $$ = logic.Loop(init=$3, body=$4)
917+
: "(" "loop" init script attrs? ")"
918+
construct: $$ = logic.Loop(init=$3, body=$4, attrs=builtin.unwrap_option_or($5, list[logic.Attribute]()))
918919
deconstruct:
919920
$3: Sequence[logic.Instruction] = $$.init
920921
$4: logic.Script = $$.body
922+
$5: Optional[Sequence[logic.Attribute]] = $$.attrs if not builtin.is_empty($$.attrs) else None
921923

922924
init
923925
: "(" "init" instruction* ")"

proto/relationalai/lqp/v1/logic.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ message FunctionalDependency {
3535
message Algorithm {
3636
repeated RelationId global = 1;
3737
Script body = 2;
38+
repeated Attribute attrs = 3;
3839
}
3940

4041
message Script {
@@ -51,6 +52,7 @@ message Construct {
5152
message Loop {
5253
repeated Instruction init = 1;
5354
Script body = 2;
55+
repeated Attribute attrs = 3;
5456
}
5557

5658
message Instruction {

sdks/go/src/lqp/v1/logic.pb.go

Lines changed: 746 additions & 721 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/go/src/parser.go

Lines changed: 2774 additions & 2754 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)