-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] #677 Ternary Expression Implementation #794
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,29 @@ func (n *NilExpression) String() string { | |
return "nil" | ||
} | ||
|
||
type TernaryExpression struct { | ||
st0012 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*BaseNode | ||
Condition Expression | ||
Consequence Expression | ||
Alternative Expression | ||
} | ||
|
||
func (te *TernaryExpression) expressionNode() {} | ||
func (te *TernaryExpression) TokenLiteral() string { | ||
st0012 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exported method TernaryExpression.TokenLiteral should have comment or be unexported |
||
return te.Token.Literal | ||
} | ||
func (te *TernaryExpression) String() string { | ||
var out bytes.Buffer | ||
|
||
out.WriteString(te.Condition.String()) | ||
out.WriteString(" ? ") | ||
out.WriteString(te.Consequence.String()) | ||
out.WriteString(" : ") | ||
out.WriteString(te.Alternative.String()) | ||
|
||
return out.String() | ||
} | ||
|
||
type IfExpression struct { | ||
*BaseNode | ||
Conditionals []*ConditionalExpression | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,6 +165,14 @@ func (ti *TestableIdentifier) ShouldHaveName(expectedName string) { | |
} | ||
} | ||
|
||
// TestableTernaryExpression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment on exported type TestableTernaryExpression should be of the form "TestableTernaryExpression ..." (with optional leading article) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment on exported type TestableTernaryExpression should be of the form "TestableTernaryExpression ..." (with optional leading article) |
||
type TestableTernaryExpression struct { | ||
*TernaryExpression | ||
t *testing.T | ||
} | ||
|
||
// TODO: Test helpers | ||
|
||
// TestableIfExpression | ||
type TestableIfExpression struct { | ||
*IfExpression | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported type TernaryExpression should have comment or be unexported