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 -- TODO: Implement Eval instance for ScopeExit
instance Evaluatable 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.Finally
, Statement.For , Statement.For
, Statement.ForEach , Statement.ForEach
, Statement.HashBang
, Statement.If , Statement.If
, Statement.Match , Statement.Match
, Statement.Pattern , Statement.Pattern
@ -598,6 +599,7 @@ statement = handleError everything
, continueStatement , continueStatement
, returnStatement , returnStatement
, throwStatement , throwStatement
, hashBang
, emptyStatement , emptyStatement
, labeledStatement ] , labeledStatement ]
@ -625,6 +627,9 @@ returnStatement = makeTerm <$> symbol ReturnStatement <*> children (Statement.Re
throwStatement :: Assignment throwStatement :: Assignment
throwStatement = makeTerm <$> symbol Grammar.ThrowStatement <*> children (Statement.Throw <$> term expressions) throwStatement = makeTerm <$> symbol Grammar.ThrowStatement <*> children (Statement.Throw <$> term expressions)
hashBang :: Assignment
hashBang = makeTerm <$> symbol HashBangLine <*> (Statement.HashBang <$> source)
labeledStatement :: Assignment labeledStatement :: Assignment
labeledStatement = makeTerm <$> symbol Grammar.LabeledStatement <*> children (TypeScript.Syntax.LabeledStatement <$> statementIdentifier <*> term statement) labeledStatement = makeTerm <$> symbol Grammar.LabeledStatement <*> children (TypeScript.Syntax.LabeledStatement <$> statementIdentifier <*> term statement)