Skip to content

Commit

Permalink
edgeql: Drop .> path operator.
Browse files Browse the repository at this point in the history
Drop the redundant `.>` path operator in favor of using only `.`.

Fixes #982.
  • Loading branch information
vpetrovykh committed Dec 17, 2019
1 parent a69e449 commit 669cce4
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 94 deletions.
2 changes: 1 addition & 1 deletion docs/edgeql/expressions/paths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The individual path components are:
:eql:synopsis:`<step-direction>`
It can be one of the following:

- ``.`` or ``.>`` for an outgoing or "forward" link reference
- ``.`` for an outgoing or "forward" link reference
- ``.<`` for an incoming or "backward" link reference
- ``@`` for a link property reference

Expand Down
34 changes: 0 additions & 34 deletions edb/edgeql/parser/grammar/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,23 +1029,6 @@ def reduce_DOT_FCONST(self, *kids):
steps=self._float_to_path(kids[1], kids[0].context),
partial=True)

@parsing.precedence(precedence.P_DOT)
def reduce_Expr_DOTFW_FCONST(self, *kids):
# this is a valid link-like syntax for accessing unnamed tuples
path = kids[0].val
if not isinstance(path, qlast.Path):
path = qlast.Path(steps=[path])

path.steps.extend(self._float_to_path(kids[2], kids[1].context))
self.val = path

@parsing.precedence(precedence.P_DOT)
def reduce_DOTFW_FCONST(self, *kids):
# this is a valid link-like syntax for accessing unnamed tuples
self.val = qlast.Path(
steps=self._float_to_path(kids[1], kids[0].context),
partial=True)

def _float_to_path(self, token, context):
from edb.schema import pointers as s_pointers

Expand Down Expand Up @@ -1095,23 +1078,6 @@ def reduce_DOT_ICONST(self, *kids):
direction=s_pointers.PointerDirection.Outbound
)

def reduce_DOTFW_ICONST(self, *kids):
# this is a valid link-like syntax for accessing unnamed tuples
from edb.schema import pointers as s_pointers

self.val = qlast.Ptr(
ptr=qlast.ObjectRef(name=kids[1].val),
direction=s_pointers.PointerDirection.Outbound
)

def reduce_DOTFW_PathStepName(self, *kids):
from edb.schema import pointers as s_pointers

self.val = qlast.Ptr(
ptr=kids[1].val,
direction=s_pointers.PointerDirection.Outbound
)

def reduce_DOTBW_PathStepName(self, *kids):
from edb.schema import pointers as s_pointers

Expand Down
4 changes: 0 additions & 4 deletions edb/edgeql/parser/grammar/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ class EdgeQLLexer(lexer.Lexer):
next_state=STATE_KEEP,
regexp=r'\.<'),

Rule(token='.>',
next_state=STATE_KEEP,
regexp=r'\.>'),

Rule(token='//',
next_state=STATE_KEEP,
regexp=r'//'),
Expand Down
2 changes: 1 addition & 1 deletion edb/edgeql/parser/grammar/precedence.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class P_PAREN(Precedence, assoc='left', tokens=('LPAREN', 'RPAREN')):
pass


class P_DOT(Precedence, assoc='left', tokens=('DOT', 'DOTFW', 'DOTBW')):
class P_DOT(Precedence, assoc='left', tokens=('DOT', 'DOTBW')):
pass


Expand Down
4 changes: 0 additions & 4 deletions edb/edgeql/parser/grammar/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class T_DOT(Token, lextoken='.'):
pass


class T_DOTFW(Token, lextoken='.>'):
pass


class T_DOTBW(Token, lextoken='.<'):
pass

Expand Down
16 changes: 0 additions & 16 deletions tests/test_edgeql_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3325,22 +3325,6 @@ async def test_edgeql_expr_tuple_18(self):
[3],
)

await self.assert_query_result(
'''
WITH TUP := (1, (2, 3))
SELECT TUP.>1.1;
''',
[3],
)

await self.assert_query_result(
'''
WITH TUP := (1, (2, 3))
SELECT TUP.>1.>1;
''',
[3],
)

async def test_edgeql_expr_tuple_indirection_01(self):
await self.assert_query_result(
r"""
Expand Down
33 changes: 0 additions & 33 deletions tests/test_edgeql_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,52 +1531,40 @@ def test_edgeql_syntax_struct_13(self):
def test_edgeql_syntax_path_01(self):
"""
SELECT Foo.bar;
SELECT Foo.>bar;
SELECT Foo.<bar;
SELECT Foo.bar@spam;
SELECT Foo.>bar@spam;
SELECT Foo.<bar@spam;
SELECT Foo.bar[IS Baz];
SELECT Foo.>bar[IS Baz];
SELECT Foo.<bar[IS Baz];
SELECT Foo.<var[IS Baz][IS Spam].bar[IS Foo];
% OK %
SELECT Foo.bar;
SELECT Foo.bar;
SELECT Foo.<bar;
SELECT Foo.bar@spam;
SELECT Foo.bar@spam;
SELECT Foo.<bar@spam;
SELECT Foo.bar[IS Baz];
SELECT Foo.bar[IS Baz];
SELECT Foo.<bar[IS Baz];
SELECT Foo.<var[IS Baz][IS Spam].bar[IS Foo];
"""

def test_edgeql_syntax_path_02(self):
"""
SELECT Foo.event;
SELECT Foo.>event;
SELECT Foo.<event;
SELECT Foo.event@action;
SELECT Foo.>event@action;
SELECT Foo.<event@action;
SELECT Foo.event[IS Action];
SELECT Foo.>event[IS Action];
SELECT Foo.<event[IS Action];
% OK %
SELECT Foo.event;
SELECT Foo.event;
SELECT Foo.<event;
SELECT Foo.event@action;
SELECT Foo.event@action;
SELECT Foo.<event@action;
SELECT Foo.event[IS Action];
SELECT Foo.event[IS Action];
SELECT Foo.<event[IS Action];
"""

Expand Down Expand Up @@ -1766,14 +1754,6 @@ def test_edgeql_syntax_path_27(self):
def test_edgeql_syntax_path_28(self):
"""
SELECT TUP.1.1;
SELECT TUP.>1.1;
SELECT TUP.>1.>1;
% OK %
SELECT TUP.1.1;
SELECT TUP.1.1;
SELECT TUP.1.1;
"""

def test_edgeql_syntax_path_29(self):
Expand All @@ -1793,19 +1773,6 @@ def test_edgeql_syntax_path_30(self):
# legal when `$0`, `$1`, `$a` and `$abc` are tuples
"""
SELECT $1.1.1;
SELECT $1.>1.1;
SELECT $1.>1.>1;
SELECT $a.1.1;
SELECT $a.>1.1;
SELECT $a.>1.>1;
% OK %
SELECT $1.1.1;
SELECT $1.1.1;
SELECT $1.1.1;
SELECT $a.1.1;
SELECT $a.1.1;
SELECT $a.1.1;
"""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_type_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_cqa_type_coverage_common_markup(self) -> None:
self.assertFunctionCoverage(EDB_DIR / "common" / "markup", 0)

def test_cqa_type_coverage_edgeql(self) -> None:
self.assertFunctionCoverage(EDB_DIR / "edgeql", 41.43)
self.assertFunctionCoverage(EDB_DIR / "edgeql", 41.58)

def test_cqa_type_coverage_edgeql_compiler(self) -> None:
self.assertFunctionCoverage(EDB_DIR / "edgeql" / "compiler", 100.00)
Expand Down

0 comments on commit 669cce4

Please sign in to comment.