Skip to content

Commit

Permalink
Merge branch 'main' into experiment/interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Jul 30, 2024
2 parents 0d290ac + 0aebea5 commit 0ba27a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
18 changes: 6 additions & 12 deletions parser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ type SourceOverdraft struct {
Bounded *Literal
}

type SourceAllotmentValue interface{ sourceAllotmentValue() }
type AllotmentValue interface{ allotmentValue() }

func (*RemainingAllotment) sourceAllotmentValue() {}
func (*RatioLiteral) sourceAllotmentValue() {}
func (*VariableLiteral) sourceAllotmentValue() {}
func (*RemainingAllotment) allotmentValue() {}
func (*RatioLiteral) allotmentValue() {}
func (*VariableLiteral) allotmentValue() {}

type SourceAllotmentItem struct {
Range Range
Allotment SourceAllotmentValue
Allotment AllotmentValue
From Source
}

Expand All @@ -164,12 +164,6 @@ func (*DestinationAllotment) destination() {}
func (d *DestinationInorder) GetRange() Range { return d.Range }
func (d *DestinationAllotment) GetRange() Range { return d.Range }

type DestinationAllotmentValue interface{ destinationAllotmentValue() }

func (*RemainingAllotment) destinationAllotmentValue() {}
func (*RatioLiteral) destinationAllotmentValue() {}
func (*VariableLiteral) destinationAllotmentValue() {}

type DestinationInorder struct {
Range Range
Clauses []DestinationInorderClause
Expand Down Expand Up @@ -202,7 +196,7 @@ type DestinationAllotment struct {

type DestinationAllotmentItem struct {
Range Range
Allotment DestinationAllotmentValue
Allotment AllotmentValue
To KeptOrDestination
}

Expand Down
12 changes: 6 additions & 6 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func parsePercentageRatio(source string, range_ Range) *RatioLiteral {
}
}

func parseAllotment(allotmentCtx parser.IAllotmentContext) SourceAllotmentValue {
func parseAllotment(allotmentCtx parser.IAllotmentContext) AllotmentValue {
switch allotmentCtx := allotmentCtx.(type) {
case *parser.PortionedAllotmentContext:
return parsePortionSource(allotmentCtx.Portion())
Expand All @@ -290,7 +290,7 @@ func parseAllotment(allotmentCtx parser.IAllotmentContext) SourceAllotmentValue
return nil

default:
return utils.NonExhaustiveMatchPanic[SourceAllotmentValue](allotmentCtx.GetText())
return utils.NonExhaustiveMatchPanic[AllotmentValue](allotmentCtx.GetText())
}
}

Expand Down Expand Up @@ -455,7 +455,7 @@ func parseKeptOrDestination(clauseCtx parser.IKeptOrDestinationContext) KeptOrDe

}

func parseDestinationAllotment(allotmentCtx parser.IAllotmentContext) DestinationAllotmentValue {
func parseDestinationAllotment(allotmentCtx parser.IAllotmentContext) AllotmentValue {
switch allotmentCtx := allotmentCtx.(type) {
case *parser.RemainingAllotmentContext:
return &RemainingAllotment{
Expand All @@ -472,11 +472,11 @@ func parseDestinationAllotment(allotmentCtx parser.IAllotmentContext) Destinatio
return nil

default:
return utils.NonExhaustiveMatchPanic[DestinationAllotmentValue](allotmentCtx.GetText())
return utils.NonExhaustiveMatchPanic[AllotmentValue](allotmentCtx.GetText())
}
}

func parseDestinationPortion(portionCtx parser.IPortionContext) DestinationAllotmentValue {
func parseDestinationPortion(portionCtx parser.IPortionContext) AllotmentValue {
switch portionCtx.(type) {
case *parser.RatioContext:
return parseRatio(portionCtx.GetText(), ctxToRange(portionCtx))
Expand All @@ -488,7 +488,7 @@ func parseDestinationPortion(portionCtx parser.IPortionContext) DestinationAllot
return nil

default:
return utils.NonExhaustiveMatchPanic[DestinationAllotmentValue](portionCtx.GetText())
return utils.NonExhaustiveMatchPanic[AllotmentValue](portionCtx.GetText())
}
}

Expand Down

0 comments on commit 0ba27a4

Please sign in to comment.