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

Take a stab at assigning class declarations.

This commit is contained in:
Rob Rix 2017-04-06 09:40:47 -04:00
parent ecc1c075a6
commit 376de45263

View File

@ -52,13 +52,15 @@ type Program = Freer
-- | Statically-known rules corresponding to symbols in the grammar.
data Grammar = Program | Uninterpreted | BeginBlock | EndBlock | Undef | Alias | Comment | True' | False' | Return | Yield | Break | Next | Redo | Retry | IfModifier | UnlessModifier | WhileModifier | UntilModifier | RescueModifier | While | Until | For | Do | Case | When | Pattern | If | Unless | Elsif | Else | Begin | Ensure | Rescue | Exceptions | ExceptionVariable | ElementReference | ScopeResolution | Call | MethodCall | ArgumentList | ArgumentListWithParens | SplatArgument | HashSplatArgument | BlockArgument | Class
data Grammar = Program | Uninterpreted | BeginBlock | EndBlock | Undef | Alias | Comment | True' | False' | Return | Yield | Break | Next | Redo | Retry | IfModifier | UnlessModifier | WhileModifier | UntilModifier | RescueModifier | While | Until | For | Do | Case | When | Pattern | If | Unless | Elsif | Else | Begin | Ensure | Rescue | Exceptions | ExceptionVariable | ElementReference | ScopeResolution | Call | MethodCall | ArgumentList | ArgumentListWithParens | SplatArgument | HashSplatArgument | BlockArgument | Class | Constant
deriving (Enum, Eq, Ord, Show)
-- | Assignment from AST in Rubys grammar onto a program in Rubys syntax.
assignment :: Assignment Grammar (Program Syntax (Maybe a))
assignment = foldr (>>) (pure Nothing) <$> rule Program (children declaration)
where declaration = comment
where declaration = comment <|> class'
class' = rule Class (wrapU <$> (Declaration.Class <$> constant <*> pure [] <*> declaration))
constant = rule Constant (wrapU <$> (Syntax.Identifier <$> content))
comment :: Assignment Grammar (Program Syntax a)
comment = wrapU . Comment.Comment <$> (rule Comment content)