1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Add method definitions

This commit is contained in:
joshvera 2016-07-29 23:41:21 -04:00
parent eb3df7db6a
commit d3df14cafd
3 changed files with 5 additions and 1 deletions

View File

@ -79,6 +79,8 @@ data Category
| Return
-- | A class declaration.
| Class
-- | A class method declaration.
| Method
-- | A non-standard category, which can be used for comparability.
| Other Text
deriving (Eq, Generic, Ord, Show)

View File

@ -101,6 +101,8 @@ termConstructor source sourceSpan info = cofree . construct
withDefaultInfo $ S.While expr body
construct children | DoWhile == (category info), [expr, body] <- children =
withDefaultInfo $ S.DoWhile expr body
construct children | Method == category info, [identifier, params, definitions] <- children =
withDefaultInfo $ S.Method identifier params definitions
construct children | Class == category info = case children of
[identifier, superclass, classBody] | S.Indexed definitions <- unwrap classBody ->
withDefaultInfo $ S.Class identifier (Just superclass) definitions

View File

@ -63,7 +63,7 @@ data Syntax
-- | A class with an identifier, superclass, and a list of definitions.
| Class f (Maybe f) [f]
-- | A method definition with an identifier, params, and a list of expressions.
| MethodDefinition f [f] [f]
| Method f [f] [f]
deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable)