mirror of
https://github.com/github/semantic.git
synced 2025-01-05 14:11:33 +03:00
Update JSX terms
This commit is contained in:
parent
9fa6d42945
commit
bbee1d839c
@ -144,6 +144,9 @@ type Syntax = '[
|
||||
, TypeScript.Syntax.JsxClosingElement
|
||||
, TypeScript.Syntax.JsxExpression
|
||||
, TypeScript.Syntax.JsxAttribute
|
||||
, TypeScript.Syntax.JsxMemberExpression
|
||||
, TypeScript.Syntax.JsxFragment
|
||||
, TypeScript.Syntax.JsxNamespaceName
|
||||
, TypeScript.Syntax.OptionalParameter
|
||||
, TypeScript.Syntax.RequiredParameter
|
||||
, TypeScript.Syntax.RestParameter
|
||||
@ -196,8 +199,8 @@ expression = handleError everything
|
||||
super,
|
||||
object,
|
||||
array,
|
||||
jsxElement,
|
||||
jsxSelfClosingElement,
|
||||
jsxElement',
|
||||
jsxFragment,
|
||||
class',
|
||||
anonymousClass,
|
||||
function,
|
||||
@ -352,26 +355,47 @@ object = makeTerm <$> (symbol Object <|> symbol ObjectPattern) <*> children (Lit
|
||||
array :: Assignment
|
||||
array = makeTerm <$> (symbol Array <|> symbol ArrayPattern) <*> children (Literal.Array <$> manyTerm (expression <|> spreadElement))
|
||||
|
||||
jsxElement' :: Assignment
|
||||
jsxElement' = choice [ jsxElement, jsxSelfClosingElement ]
|
||||
|
||||
jsxElement :: Assignment
|
||||
jsxElement = makeTerm <$> symbol Grammar.JsxElement <*> children (TypeScript.Syntax.JsxElement <$> term jsxOpeningElement' <*> manyTerm (jsxElement <|> jsxSelfClosingElement <|> jsxExpression' <|> jsxText) <*> term jsxClosingElement')
|
||||
jsxElement = makeTerm <$> symbol Grammar.JsxElement <*> children (TypeScript.Syntax.JsxElement <$> term jsxOpeningElement' <*> manyTerm jsxChild <*> term jsxClosingElement')
|
||||
|
||||
jsxFragment :: Assignment
|
||||
jsxFragment = makeTerm <$> symbol Grammar.JsxFragment <*> children (TypeScript.Syntax.JsxFragment <$> manyTerm jsxChild)
|
||||
|
||||
jsxChild :: Assignment
|
||||
jsxChild = choice [ jsxElement', jsxExpression', jsxText ]
|
||||
|
||||
jsxSelfClosingElement :: Assignment
|
||||
jsxSelfClosingElement = makeTerm <$> symbol Grammar.JsxSelfClosingElement <*> children (TypeScript.Syntax.JsxSelfClosingElement <$> term (identifier <|> nestedIdentifier) <*> manyTerm (jsxAttribute <|> jsxExpression'))
|
||||
jsxSelfClosingElement = makeTerm <$> symbol Grammar.JsxSelfClosingElement <*> children (TypeScript.Syntax.JsxSelfClosingElement <$> term jsxElementName <*> manyTerm jsxAttribute')
|
||||
|
||||
jsxAttribute' = jsxAttribute <|> jsxExpression'
|
||||
|
||||
jsxOpeningElement' :: Assignment
|
||||
jsxOpeningElement' = makeTerm <$> symbol Grammar.JsxOpeningElement <*> children (TypeScript.Syntax.JsxOpeningElement <$> term (identifier <|> nestedIdentifier) <*> manyTerm (jsxAttribute <|> jsxExpression'))
|
||||
jsxOpeningElement' = makeTerm <$> symbol Grammar.JsxOpeningElement <*> children (TypeScript.Syntax.JsxOpeningElement <$> term jsxElementName <*> manyTerm jsxAttribute')
|
||||
|
||||
jsxElementName :: Assignment
|
||||
jsxElementName = choice [ identifier, jsxMemberExpression, jsxNamespaceName ]
|
||||
|
||||
jsxNamespaceName :: Assignment
|
||||
jsxNamespaceName = makeTerm <$> symbol Grammar.JsxNamespaceName <*> children (TypeScript.Syntax.JsxNamespaceName <$> identifier <*> identifier)
|
||||
|
||||
jsxMemberExpression :: Assignment
|
||||
jsxMemberExpression = makeTerm <$> symbol Grammar.JsxMemberExpression <*> children (TypeScript.Syntax.JsxMemberExpression <$> manyTerm identifier)
|
||||
|
||||
jsxExpression' :: Assignment
|
||||
jsxExpression' = makeTerm <$> symbol Grammar.JsxExpression <*> children (TypeScript.Syntax.JsxExpression <$> term (expressions <|> spreadElement))
|
||||
jsxExpression' = makeTerm <$> symbol Grammar.JsxExpression <*> children (TypeScript.Syntax.JsxExpression <$> term (expressions <|> spreadElement <|> emptyTerm))
|
||||
|
||||
jsxText :: Assignment
|
||||
jsxText = makeTerm <$> symbol Grammar.JsxText <*> (TypeScript.Syntax.JsxText <$> source)
|
||||
|
||||
jsxClosingElement' :: Assignment
|
||||
jsxClosingElement' = makeTerm <$> symbol Grammar.JsxClosingElement <*> children (TypeScript.Syntax.JsxClosingElement <$> term (identifier <|> nestedIdentifier))
|
||||
jsxClosingElement' = makeTerm <$> symbol Grammar.JsxClosingElement <*> children (TypeScript.Syntax.JsxClosingElement <$> term jsxElementName)
|
||||
|
||||
jsxAttribute :: Assignment
|
||||
jsxAttribute = makeTerm <$> symbol Grammar.JsxAttribute <*> children (TypeScript.Syntax.JsxAttribute <$> term propertyIdentifier <*> (term (number <|> string <|> jsxExpression') <|> emptyTerm))
|
||||
jsxAttribute = makeTerm <$> symbol Grammar.JsxAttribute <*> children (TypeScript.Syntax.JsxAttribute <$> term (propertyIdentifier <|> jsxNamespaceName) <*> (term jsxAttributeValue <|> emptyTerm))
|
||||
where jsxAttributeValue = choice [ string, jsxExpression', jsxElement', jsxFragment ]
|
||||
|
||||
propertyIdentifier :: Assignment
|
||||
propertyIdentifier = makeTerm <$> symbol PropertyIdentifier <*> (Syntax.Identifier <$> source)
|
||||
|
@ -493,3 +493,24 @@ data RestParameter a = RestParameter { _restParameterContext :: ![a], _restParam
|
||||
instance Eq1 RestParameter where liftEq = genericLiftEq
|
||||
instance Ord1 RestParameter where liftCompare = genericLiftCompare
|
||||
instance Show1 RestParameter where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data JsxFragment a = JsxFragment [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 JsxFragment where liftEq = genericLiftEq
|
||||
instance Ord1 JsxFragment where liftCompare = genericLiftCompare
|
||||
instance Show1 JsxFragment where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data JsxNamespaceName a = JsxNamespaceName a a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 JsxNamespaceName where liftEq = genericLiftEq
|
||||
instance Ord1 JsxNamespaceName where liftCompare = genericLiftCompare
|
||||
instance Show1 JsxNamespaceName where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data JsxMemberExpression a = JsxMemberExpression [a]
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 JsxMemberExpression where liftEq = genericLiftEq
|
||||
instance Ord1 JsxMemberExpression where liftCompare = genericLiftCompare
|
||||
instance Show1 JsxMemberExpression where liftShowsPrec = genericLiftShowsPrec
|
||||
|
Loading…
Reference in New Issue
Block a user