Skip to content

Commit c03d45f

Browse files
authored
Merge pull request #40 from yaacov/support-double-eq
allow == in adition to =
2 parents 277d1fc + 9afeca7 commit c03d45f

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

v6/pkg/parser/lexer.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ func (l *Lexer) scanToken() error {
156156
case '%':
157157
l.addToken(PERCENT, "%")
158158
case '=':
159-
l.addToken(EQ, "=")
159+
if l.match('=') {
160+
l.addToken(EQ, "==")
161+
} else {
162+
l.addToken(EQ, "=")
163+
}
160164
case '<':
161165
if l.match('=') {
162166
l.addToken(LE, "<=")

v6/pkg/parser/parser.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

v6/test/stability_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ echo "Starting TSL stability tests..."
8282

8383
# Basic Operators (01-10)
8484
run_test "01_op_equality" "${TSL_BIN} 'name = \"bob\"'"
85+
run_test "63_op_double_equal" "${TSL_BIN} 'name == \"bob\"'"
8586
run_test "02_op_inequality" "${TSL_BIN} 'name != \"alice\"'"
8687
run_test "03_op_greater_than" "${TSL_BIN} 'age > 25'"
8788
run_test "04_op_less_than" "${TSL_BIN} 'age < 25'"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Parsing: name == "bob"
2+
[EQ]
3+
[IDENTIFIER]: name
4+
[STRING]: bob

0 commit comments

Comments
 (0)