Skip to content

Commit d0870cb

Browse files
committed
test: add test case for concat-expr
1 parent b76bedc commit d0870cb

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

ast.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
Plus // +
4545
Colon // :
4646
Minus // -
47-
Connect // &
47+
Concat // &
4848
Equal // =
4949
NotEqual // <>
5050
LessThan // <

lexer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func (l *lexer) next() (*Token, error) {
8484
return newToken(l.pos, l.pos, Divide, "/"), nil
8585
case '$':
8686
return l.absoluteReference()
87+
case '&':
88+
l.nextch()
89+
return newToken(l.pos, l.pos, Concat, "&"), nil
8790
case '%':
8891
l.nextch()
8992
return newToken(l.pos, l.pos, Percent, "%"), nil

parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (p *Parser) connection() (Node, error) {
8181
if p.token == nil {
8282
return left, nil // No more tokens, return the left node
8383
}
84-
for p.token != nil && p.token.Type == Connect {
84+
for p.token != nil && p.token.Type == Concat {
8585
var op = p.token
8686
if err := p.advance(); err != nil { // consume the operator token
8787
return nil, err

parser_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ func TestParse(t *testing.T) {
77
src string
88
expected string
99
}{
10+
{"=A1&B1", "BinaryExpr(Left: CellExpr(A1), Operator: &, Right: CellExpr(B1))"},
1011
{"=1<>2", "BinaryExpr(Left: LiteralExpr(Value: 1), Operator: <>, Right: LiteralExpr(Value: 2))"},
1112
{"=$A:$A", "RangeExpr(CellExpr($A):CellExpr($A))"},
1213
{"=$1:1", "RangeExpr(CellExpr($1):CellExpr(1))"},

0 commit comments

Comments
 (0)