@@ -668,6 +668,7 @@ binary_expression: @copy_constructible <Name: String, Term> type =
668668 is_id_expression : (this) -> bool = this.n*.is_id_expression ();
669669 is_unqualified_id : (this) -> bool = this.n*.is_unqualified_id ();
670670 is_expression_list : (this) -> bool = this.n*.is_expression_list ();
671+ // is_expression : (this) -> bool = this.n*.is_expression ();
671672 is_literal : (this) -> bool = this.n*.is_literal ();
672673
673674 term_t: @copyable <T> type = {
@@ -755,8 +756,9 @@ binary_expression: @copy_constructible <Name: String, Term> type =
755756 }
756757 }
757758
758- as_expression_list: (this) -> expression_list = (this.n*.get_expression_list(), this);
759- as_literal : (this) -> std::string = this.n*.get_literal()*.to_string();
759+ as_expression_list: (this) -> expression_list = (this.n*.get_expression_list(), this);
760+ as_expression : (this) -> binary_expression = this;
761+ as_literal : (this) -> std::string = this.n*.get_literal()*.to_string();
760762
761763 // Get the postfix-expression, if that's the entire expression (not actually binary)
762764 get_if_only_a_postfix_expression: (this) -> postfix_expression = (this.n*.get_if_only_a_postfix_expression_node(), this);
@@ -1226,10 +1228,12 @@ is_as_expression: @polymorphic_base @copy_constructible type =
12261228 is_id_expression : (this) -> bool = this.n*.is_id_expression ();
12271229 is_unqualified_id : (this) -> bool = this.n*.is_unqualified_id ();
12281230 is_expression_list: (this) -> bool = this.n*.is_expression_list();
1231+ is_expression : (this) -> bool = true; // TODO: Implement this in n: this.n*.is_expression ();
12291232 is_literal : (this) -> bool = this.n*.is_literal ();
12301233
1231- as_expression_list: (this) -> expression_list = (this.n*.get_expression_list(), this);
1232- as_literal : (this) -> std::string = n*.get_literal()*.to_string();
1234+ as_expression_list: (this) -> expression_list = (this.n*.get_expression_list(), this);
1235+ as_expression : (this) -> is_as_expression = this;
1236+ as_literal : (this) -> std::string = n*.get_literal()*.to_string();
12331237
12341238 get_identifier : (this) -> std::string_view = {
12351239 ptok := this.n*.get_identifier();
@@ -3777,6 +3781,16 @@ autodiff_expression_handler: type = {
37773781
37783782 return t;
37793783 }
3784+ else if term is binary_expression {
3785+ expr := term;
3786+
3787+ t := ctx*.gen_temporary();
3788+ ad : autodiff_expression_handler = (ctx, t, ":"); // TODO: get type of expression
3789+ ad..pre_traverse(expr);
3790+ append(ad);
3791+
3792+ return t;
3793+ }
37803794 else {
37813795 term.error( "Do not know how to handle AD for: (term.to_string())$");
37823796 return "error";
0 commit comments