1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Redefine Rule to always be productive.

This commit is contained in:
Rob Rix 2017-04-05 19:46:41 -04:00
parent 315c5e6e9b
commit a9fb2b6759

View File

@ -26,14 +26,14 @@ type Syntax = Union
type Assignment symbol = Freer (AssignmentF symbol)
data AssignmentF symbol a where
Rule :: symbol -> AssignmentF symbol a
Rule :: symbol -> a -> AssignmentF symbol a
Content :: AssignmentF symbol ByteString
Children :: AssignmentF symbol [a]
Child :: AssignmentF symbol a
And :: a -> a -> AssignmentF symbol a
rule :: symbol -> Assignment symbol a
rule symbol = Rule symbol `Then` return
rule :: symbol -> Assignment symbol a -> Assignment symbol a
rule symbol = wrap . Rule symbol
content :: Assignment symbol ByteString
content = Content `Then` return
@ -55,13 +55,13 @@ data Grammar = Program | Uninterpreted | BeginBlock | EndBlock | Undef | Alias |
-- | Assignment from AST in Rubys grammar onto a program in Rubys syntax.
assignment :: Assignment Grammar (Program Syntax (Maybe ()))
assignment = foldr (>>) (pure Nothing) <$> (rule Program <> children)
assignment = foldr (>>) (pure Nothing) <$> (rule Program children)
comment :: Assignment Grammar (Program Syntax a)
comment = wrapU . Comment.Comment <$> (rule Comment <> content)
comment = wrapU . Comment.Comment <$> (rule Comment content)
if' :: Assignment Grammar (Program Syntax a)
if' = rule If <> (wrapU <$> (Statement.If <$> child <*> child <*> child))
if' = rule If (wrapU <$> (Statement.If <$> child <*> child <*> child))
instance Semigroup (Assignment symbol a) where