1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Document Syntax.

This commit is contained in:
Rob Rix 2015-11-27 09:41:43 -05:00
parent df7d79bc62
commit 05fa421642

View File

@ -2,9 +2,17 @@ module Syntax where
import Data.Map
data Syntax a f =
-- | A node in an abstract syntax tree.
data Syntax
a -- ^ The type of leaves in the syntax tree, typically String, but possibly some datatype representing different leaves more precisely.
f -- ^ The type representing another level of the tree, e.g. the children of branches. Often Cofree or Fix or similar.
=
-- | A terminal syntax node, e.g. an identifier, or atomic literal.
Leaf a
-- | An ordered branch of child nodes, expected to be variadic in the grammar, e.g. a list of statements or uncurried function parameters.
| Indexed [f]
-- | An ordered branch of child nodes, expected to be of fixed length in the grammar, e.g. a binary operator & its operands.
| Fixed [f]
-- | A branch of child nodes indexed by some String identity. This is useful for identifying e.g. methods & properties in a class scope by their names. Note that comments can generally occur in these scopes as well; one strategy for dealing with this is to identify comments by their text in the source.
| Keyed (Map String f)
deriving (Functor, Show, Eq)