packages feed

uuagc-0.9.39.0: src-ag/CodeSyntax.ag

imports
{
import Patterns
import CommonTypes
import Data.Map(Map)
import Data.Set(Set)
}

DATA  CGrammar
   |  CGrammar  typeSyns  : {TypeSyns}
                derivings : {Derivings}
                wrappers  : {Set NontermIdent}
                nonts     : CNonterminals
                pragmas   : {PragmaMap}
                paramMap  : {ParamMap}
                contextMap: {ContextMap}
                quantMap  : {QuantMap}
                aroundsMap: {Map NontermIdent (Map ConstructorIdent (Set Identifier))}
                mergeMap  : {Map NontermIdent (Map ConstructorIdent (Map Identifier (Identifier,[Identifier])))}
                multivisit : {Bool}

TYPE CNonterminals = [CNonterminal]

DATA  CNonterminal
   |  CNonterminal nt     :  NontermIdent
                   params :  {[Identifier]}
                   inh    :  Attributes
                   syn    :  Attributes
                   prods  :  CProductions
                   inter  :  CInterface

DATA  CInterface
   |  CInterface seg:CSegments

TYPE CSegments = [CSegment]

DATA  CSegment
   |  CSegment  inh  :  Attributes
                syn  :  Attributes

TYPE CProductions = [CProduction]

DATA  CProduction
   |  CProduction   con        : ConstructorIdent
                    visits     : CVisits
                    children   : {[(Identifier,Type,Maybe (Maybe Type))]}
                    terminals  : {[Identifier]}

TYPE CVisits = [CVisit]

DATA  CVisit
   |  CVisit  inh     :  Attributes
              syn     :  Attributes
              vss     :  Sequence  -- sequence of "steps", where each "step" is either an attribute definition or a child visit
              intra   :  Sequence  -- how to glue the visits together (child visits are child-intra's, attr-defs are attr-intra's)
              ordered :  Bool -- indicates that vss is ordered

TYPE Sequence = [CRule]

DATA  CRule
   |  CRule        name       :  Identifier
                   isIn       :  Bool   -- True iff there is a definition for an inherited attribute
                   hasCode    :  Bool   -- True iff there is an RHS
                   nt         :  NontermIdent
                   con        :  ConstructorIdent
                   field      :  Identifier
                   childnt    :  {Maybe NontermIdent}  -- Just n: 'field' of 'nt' and 'con' is a nonterminal 'n', Nothing: it is a terminal
                   tp         :  {Maybe Type}     -- type of the attribute
                   pattern    :  Pattern     -- only defined if 'isIn' is False
                   rhs        :  {[String]}     -- empty string if 'hasCode' is False
                   defines    :  {Map Int (Identifier,Identifier,Maybe Type)}   -- the attributes defined by this rule
                   owrt       :  {Bool}
                   origin     :  String  -- just for documentation (and maybe errors)
                   uses       :  {Set (Identifier, Identifier)}
                   explicit   :  Bool   -- True if this an explicit rule found in the source file
                   mbNamed    : {Maybe Identifier}
   |  CChildVisit  name    :  Identifier  -- corresponding to the name of the child
                   nt      :  NontermIdent
                   nr      :  Int   -- visit number
                   inh     :  Attributes
                   syn     :  Attributes
                   isLast  :  Bool  -- indicates whether this is the last visit to this child

SET AllCodeSyntax
  = CGrammar
    CNonterminal CNonterminals
    CInterface CSegments CSegment
    CProduction CProductions
    CVisits CVisit
    CRule