Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Aug 18, 2024
1 parent 0f4f999 commit f53ebba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ func (interp *interpreter) evaluate(expr parser.Expression) Value {
case *parser.FunctionExpression:
closure := interp.vars[len(interp.vars)-1]
return &userFunction{"", e.Parameters, e.Ellipsis, e.Body, closure}
case *parser.SemiTag:
return nil
default:
// Parser should never give us this
panic(fmt.Sprintf("unexpected expression type %T", expr))
Expand Down
7 changes: 7 additions & 0 deletions parser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,10 @@ func (e *Variable) Position() Position { return e.pos }
func (e *Variable) String() string {
return e.Name
}

type SemiTag struct {
pos Position
}

func (e *SemiTag) expressionNode() {}
func (e *SemiTag) Position() Position { return e.pos }
21 changes: 13 additions & 8 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ func (p *parser) call() Expression {
p.error("can only have ... after last argument")
}
p.expect(RPAREN)
if p.tok == SEMI {
p.expect(SEMI)
} else {
print(p.tok)
}
//if p.tok == SEMI {
// p.expect(SEMI)
//} else {
// print(p.tok)
//}

expr = &Call{pos, expr, args, gotEllipsis}
} else if p.tok == LBRACKET {
pos := p.pos
p.next()
subscript := p.expression()
p.expect(RBRACKET)
p.expect(SEMI)
//p.expect(SEMI)
expr = &Subscript{pos, expr, subscript}
} else {
pos := p.pos
Expand Down Expand Up @@ -404,8 +404,13 @@ func (p *parser) primary() Expression {
p.next()
expr := p.expression()
p.expect(RPAREN)
p.expect(SEMI)
//p.expect(SEMI)
return expr
case SEMI:
p.next()
pos := p.pos
return &SemiTag{pos}

default:
formatter := prettyjson.NewFormatter()
output, _ := formatter.Marshal(p.val)
Expand Down Expand Up @@ -437,7 +442,7 @@ func (p *parser) list() Expression {
}
}
p.expect(RBRACKET)
p.expect(SEMI)
//p.expect(SEMI)
return &List{pos, values}
}

Expand Down
2 changes: 0 additions & 2 deletions tests/all-syntax-variations.davi
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?davi

// This is a comment

$test = "Test string";


echo("Time is:");
echo(time());

Expand Down

0 comments on commit f53ebba

Please sign in to comment.