mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +03:00
Add assignment, variable declaration, identifier, and variable name
This commit is contained in:
parent
0774871fc9
commit
c2ccf00aa2
@ -31,6 +31,10 @@ type Syntax = '[
|
||||
, Syntax.Context
|
||||
, Syntax.Program
|
||||
, Syntax.Text
|
||||
, Statement.Assignment
|
||||
, Declaration.VariableDeclaration
|
||||
, Syntax.Identifier
|
||||
, Syntax.VariableName
|
||||
, [] ]
|
||||
|
||||
type Term = Term.Term (Data.Union.Union Syntax) (Record Location)
|
||||
@ -50,7 +54,51 @@ text = makeTerm <$> symbol Text <*> (Syntax.Text <$> source)
|
||||
|
||||
statement :: Assignment
|
||||
statement = handleError everything
|
||||
where everything = choice [ string ]
|
||||
where
|
||||
everything = choice [
|
||||
-- compoundStatement
|
||||
-- , namedLabelStatement
|
||||
-- , expressionStatement
|
||||
-- , selectionStatement
|
||||
-- , jumpStatement
|
||||
-- , tryStatement
|
||||
-- , declareStatement
|
||||
-- , echoStatement
|
||||
-- , constDeclaration
|
||||
-- , functionDefinition
|
||||
-- , classDeclaration
|
||||
-- , interfaceDeclaration
|
||||
-- , traitDeclaration
|
||||
-- , namespaceDefinition
|
||||
-- , namespaceUseDeclaration
|
||||
-- , globalDeclaration
|
||||
functionStaticDeclaration
|
||||
]
|
||||
|
||||
expression :: Assignment
|
||||
expression = choice [
|
||||
-- assignmentExpression,
|
||||
-- yieldExpression,
|
||||
-- unaryExpression,
|
||||
-- binaryExpression,
|
||||
-- includeExpression,
|
||||
-- includeOnceExpression,
|
||||
-- requireExpression,
|
||||
-- requireOnceExpression
|
||||
]
|
||||
|
||||
-- TODO: Does this keep the range of VariableName?
|
||||
variableName :: Assignment
|
||||
variableName = makeTerm <$> symbol VariableName <*> children (Syntax.VariableName <$> name)
|
||||
|
||||
name :: Assignment
|
||||
name = makeTerm <$> symbol Name <*> (Syntax.Identifier <$> source)
|
||||
|
||||
functionStaticDeclaration :: Assignment
|
||||
functionStaticDeclaration = makeTerm <$> symbol FunctionStaticDeclaration <*> children (Declaration.VariableDeclaration . pure <$> staticVariableDeclaration)
|
||||
|
||||
staticVariableDeclaration :: Assignment
|
||||
staticVariableDeclaration = makeTerm <$> symbol StaticVariableDeclaration <*> children (Statement.Assignment <$> pure [] <*> variableName <*> (expression <|> emptyTerm))
|
||||
|
||||
comment :: Assignment
|
||||
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
|
||||
|
@ -15,3 +15,11 @@ newtype Text a = Text ByteString
|
||||
instance Eq1 Text where liftEq = genericLiftEq
|
||||
instance Ord1 Text where liftCompare = genericLiftCompare
|
||||
instance Show1 Text where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
-- | Lookup type for a type-level key in a typescript map.
|
||||
data VariableName a = VariableName a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 VariableName where liftEq = genericLiftEq
|
||||
instance Ord1 VariableName where liftCompare = genericLiftCompare
|
||||
instance Show1 VariableName where liftShowsPrec = genericLiftShowsPrec
|
||||
|
Loading…
Reference in New Issue
Block a user