diff --git a/parser/grammar.y b/parser/grammar.y index c0ab541..9e137df 100644 --- a/parser/grammar.y +++ b/parser/grammar.y @@ -1065,7 +1065,7 @@ range { if start, ok := $2.(*ast.LiteralInteger); ok { if end, ok := $4.(*ast.LiteralInteger); ok { - if (start.Value >= end.Value) { + if (start.Value > end.Value) { lexer := asLexer(yrlex) return lexer.setError( gyperror.InvalidValueError, diff --git a/tests/grammar_test.go b/tests/grammar_test.go index 8f31d8a..eb64e5f 100644 --- a/tests/grammar_test.go +++ b/tests/grammar_test.go @@ -839,6 +839,7 @@ func TestNegativeUpperRange(t *testing.T) { assert.Equal(t, "line 6: upper bound can not be negative", err.Error()) } } + func TestInvalidRange(t *testing.T) { _, err := gyp.ParseString(` rule INVALID_RANGE { @@ -852,6 +853,17 @@ func TestInvalidRange(t *testing.T) { } } +func TestEqualBoundsRange(t *testing.T) { + _, err := gyp.ParseString(` + rule EQUAL_BOUNDS_RANGE { + strings: + $a = "AXSERS" + condition: + $a in (1..1) + }`) + assert.NoError(t, err) +} + // { ~?? } is an error func TestHexNotWildcard(t *testing.T) { _, err := gyp.ParseString(`