1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Assign HashBangLines in JavaScript/TypeScript

This commit is contained in:
Timothy Clem 2018-04-13 10:49:16 -07:00
parent 01d3e7d547
commit a9e5ff6a11
2 changed files with 16 additions and 0 deletions

View File

@ -303,3 +303,14 @@ instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec
-- TODO: Implement Eval instance for ScopeExit
instance Evaluatable ScopeExit
-- | HashBang line (e.g. `#!/usr/bin/env node`)
newtype HashBang a = HashBang ByteString
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1)
instance Eq1 HashBang where liftEq = genericLiftEq
instance Ord1 HashBang where liftCompare = genericLiftCompare
instance Show1 HashBang where liftShowsPrec = genericLiftShowsPrec
-- TODO: Implement Eval instance for HashBang
instance Evaluatable HashBang

View File

@ -70,6 +70,7 @@ type Syntax = '[
, Statement.Finally
, Statement.For
, Statement.ForEach
, Statement.HashBang
, Statement.If
, Statement.Match
, Statement.Pattern
@ -598,6 +599,7 @@ statement = handleError everything
, continueStatement
, returnStatement
, throwStatement
, hashBang
, emptyStatement
, labeledStatement ]
@ -625,6 +627,9 @@ returnStatement = makeTerm <$> symbol ReturnStatement <*> children (Statement.Re
throwStatement :: Assignment
throwStatement = makeTerm <$> symbol Grammar.ThrowStatement <*> children (Statement.Throw <$> term expressions)
hashBang :: Assignment
hashBang = makeTerm <$> symbol HashBangLine <*> (Statement.HashBang <$> source)
labeledStatement :: Assignment
labeledStatement = makeTerm <$> symbol Grammar.LabeledStatement <*> children (TypeScript.Syntax.LabeledStatement <$> statementIdentifier <*> term statement)