Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
> A pointer bug which caused the child tree to not propagate up through the tree
  • Loading branch information
nayas360 committed Mar 28, 2020
1 parent bd2b827 commit 3546df2
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions examples/algebrica/ast/expression/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,22 @@ type Operator struct {
E node.Expression
}

func (o Operator) Parse(tokens *goply.TokenStream) error {
func (o *Operator) Parse(tokens *goply.TokenStream) error {
if tokens.EOS() {
return ast.EndOfTokenStreamErr
}
var op node.Operator
if o.E != nil {
op = &Binary{Left: o.E}
o.E = &Binary{Left: o.E}
} else {
op = &Binary{}
// no left context unary operator
o.E = &Binary{}
}
err := op.Parse(tokens)
if err != nil {
return err
}
o.E = op
return nil
return o.E.Parse(tokens)
}

func (o Operator) String() string {
func (o *Operator) String() string {
return o.E.String()
}

func (o Operator) Expression() {}
func (o Operator) Operator() {}
func (o *Operator) Expression() {}
func (o *Operator) Operator() {}

0 comments on commit 3546df2

Please sign in to comment.