[libSyntax] Fix parsing for KeyPath

This commit is contained in:
Alex Hoppen
2018-04-23 12:05:00 -07:00
parent 28973f23b6
commit 94b8a3545b
4 changed files with 22 additions and 11 deletions

View File

@@ -300,7 +300,9 @@ EXPR_NODES = [
# a.b
Node('MemberAccessExpr', kind='Expr',
children=[
Child("Base", kind='Expr'),
# The base needs to be optional to parse expressions in key paths
# like \.a
Child("Base", kind='Expr', is_optional=True),
Child("Dot", kind='PeriodToken'),
Child("Name", kind='Token'),
Child('DeclNameArguments', kind='DeclNameArguments',
@@ -496,9 +498,17 @@ EXPR_NODES = [
Node('KeyPathExpr', kind='Expr',
children=[
Child('Backslash', kind='BackslashToken'),
Child('RootExpr', kind='IdentifierExpr', is_optional=True),
Child('Expression', kind='Expr'),
]),
# The period in the key path serves as the base on which the
# right-hand-side of the key path is evaluated
Node('KeyPathBaseExpr', kind='Expr',
children=[
Child('Period', kind='PeriodToken'),
]),
# e.g. "a." or "a"
Node('ObjcNamePiece', kind='Syntax',
children=[