1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 05:41:54 +03:00

Produce program syntaxes (for ruby at least)

This commit is contained in:
Timothy Clem 2017-07-20 13:52:10 -07:00
parent dec0de378c
commit 9618db2cdb
2 changed files with 10 additions and 1 deletions

View File

@ -32,6 +32,12 @@ newtype Identifier a = Identifier ByteString
instance Eq1 Identifier where liftEq = genericLiftEq
instance Show1 Identifier where liftShowsPrec = genericLiftShowsPrec
newtype Program a = Program [a]
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
instance Eq1 Program where liftEq = genericLiftEq
instance Show1 Program where liftShowsPrec = genericLiftShowsPrec
-- | Empty syntax, with essentially no-op semantics.
--

View File

@ -67,6 +67,7 @@ type Syntax = '[
, Syntax.Empty
, Syntax.Error
, Syntax.Identifier
, Syntax.Program
, []
]
@ -76,7 +77,9 @@ type Assignment = HasCallStack => Assignment.Assignment (AST Grammar) Grammar Te
-- | Assignment from AST in Rubys grammar onto a program in Rubys syntax.
assignment :: Assignment
assignment = makeTerm <$> symbol Program <*> children (many statement) <|> parseError
assignment =
makeTerm <$> symbol Program <*> children (Syntax.Program <$> many statement)
<|> parseError
statement :: Assignment
statement =