mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Add variable and member access expressions
This commit is contained in:
parent
5004d661ee
commit
0f1ee09d69
@ -75,6 +75,7 @@ type Syntax = '[
|
||||
, Declaration.Function
|
||||
, Expression.New
|
||||
, Literal.Array
|
||||
, Expression.MemberAccess
|
||||
, [] ]
|
||||
|
||||
type Term = Term.Term (Data.Union.Union Syntax) (Record Location)
|
||||
@ -149,7 +150,7 @@ cloneExpression = makeTerm <$> symbol CloneExpression <*> children (Syntax.Clone
|
||||
|
||||
primaryExpression :: Assignment
|
||||
primaryExpression = choice [
|
||||
-- variable,
|
||||
variable,
|
||||
-- classConstantAccessExpression,
|
||||
qualifiedName,
|
||||
literal,
|
||||
@ -162,6 +163,32 @@ primaryExpression = choice [
|
||||
expression
|
||||
]
|
||||
|
||||
variable :: Assignment
|
||||
variable = callableVariable <|> scopedPropertyAccessExpression <|> memberAccessExpression
|
||||
|
||||
callableVariable :: Assignment
|
||||
callableVariable = simpleVariable
|
||||
-- subscriptExpression,
|
||||
-- memberCallExpression,
|
||||
-- scopedCallExpression,
|
||||
-- functionCallExpression
|
||||
|
||||
memberAccessExpression :: Assignment
|
||||
memberAccessExpression = makeTerm <$> symbol MemberAccessExpression <*> children (Expression.MemberAccess <$> dereferencableExpression <*> memberName)
|
||||
|
||||
dereferencableExpression :: Assignment
|
||||
dereferencableExpression = symbol DereferencableExpression *> children (variable <|> expression <|> arrayCreationExpression <|> string)
|
||||
|
||||
scopedPropertyAccessExpression :: Assignment
|
||||
scopedPropertyAccessExpression = makeTerm <$> symbol ScopedPropertyAccessExpression <*> children (Expression.MemberAccess <$> scopeResolutionQualifier <*> simpleVariable)
|
||||
|
||||
scopeResolutionQualifier :: Assignment
|
||||
scopeResolutionQualifier = choice [
|
||||
relativeScope,
|
||||
qualifiedName,
|
||||
dereferencableExpression
|
||||
]
|
||||
|
||||
arrayCreationExpression :: Assignment
|
||||
arrayCreationExpression = makeTerm <$> symbol ArrayCreationExpression <*> children (Literal.Array <$> manyTerm arrayElementInitializer)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user