summaryrefslogtreecommitdiff
path: root/submit/ast/BinaryOperator.java
diff options
context:
space:
mode:
authorLizzy Hunt <elizabeth.hunt@simponic.xyz>2023-04-10 09:17:11 -0600
committerLizzy Hunt <elizabeth.hunt@simponic.xyz>2023-04-10 09:17:11 -0600
commit5f28f80c4e25a56cd444914c2f0b3da5e7fdb088 (patch)
tree600ad8b1ec5aad5155baf8c0352281054a8e6366 /submit/ast/BinaryOperator.java
downloadcminus-5f28f80c4e25a56cd444914c2f0b3da5e7fdb088.tar.gz
cminus-5f28f80c4e25a56cd444914c2f0b3da5e7fdb088.zip
Initial commit - building
Diffstat (limited to 'submit/ast/BinaryOperator.java')
-rw-r--r--submit/ast/BinaryOperator.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/submit/ast/BinaryOperator.java b/submit/ast/BinaryOperator.java
new file mode 100644
index 0000000..d18766b
--- /dev/null
+++ b/submit/ast/BinaryOperator.java
@@ -0,0 +1,35 @@
+/*
+ * Code formatter project
+ * CS 4481
+ */
+package submit.ast;
+
+/**
+ *
+ * @author edwajohn
+ */
+public class BinaryOperator extends AbstractNode implements Expression {
+
+ private final Expression lhs, rhs;
+ private final BinaryOperatorType type;
+
+ public BinaryOperator(Expression lhs, BinaryOperatorType type, Expression rhs) {
+ this.lhs = lhs;
+ this.type = type;
+ this.rhs = rhs;
+ }
+
+ public BinaryOperator(Expression lhs, String type, Expression rhs) {
+ this.lhs = lhs;
+ this.type = BinaryOperatorType.fromString(type);
+ this.rhs = rhs;
+ }
+
+ @Override
+ public void toCminus(StringBuilder builder, String prefix) {
+ lhs.toCminus(builder, prefix);
+ builder.append(" ").append(type).append(" ");
+ rhs.toCminus(builder, prefix);
+ }
+
+}