mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Take a stab at assigning class declarations.
This commit is contained in:
parent
ecc1c075a6
commit
376de45263
@ -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 Ruby’s grammar onto a program in Ruby’s 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)
|
||||
|
Loading…
Reference in New Issue
Block a user