PageRenderTime 79ms CodeModel.GetById 27ms app.highlight 43ms RepoModel.GetById 1ms app.codeStats 1ms

/src/Cxx/Basics.hs

http://github.com/Eelis/geordi
Haskell | 483 lines | 368 code | 64 blank | 51 comment | 7 complexity | 03e42bd163a4aa5f5f97639eccc91a60 MD5 | raw file
  1{-# LANGUAGE UnicodeSyntax, DeriveDataTypeable, CPP #-}
  2
  3{- Notes:
  4
  5  * While we could leave things like static_assert and the new-style casts out of the grammar and let them be parsed as ordinary function calls, we incorporate them because recognizing them lets us disambiguate types from expressions.
  6
  7  * (Either a b) is not equivalent to (Either b a) in grammar rule definitions, because we use a Parse (Either a b) instance which tries the left side first.
  8
  9  * The Eq instances are all modulo whitespace.
 10
 11  * We diverge from the grammar in the standard by "flattening" *-list and *-seq. In our parse trees, their recursion will be factored out, so that they always appear as a single node in paths, and can only be found as a whole in edit commands.
 12
 13Missing:
 14
 15  preprocessor stuff
 16  internal structure in literals
 17  alternative tokens
 18  backslash handling
 19  C++1x stuff:
 20    opaque-enum declarations
 21    range-for
 22    raw literals
 23    user-defined literals
 24    attributes
 25    variadic templates
 26    lambda expressions
 27    "->"-style declarators
 28    ellipsis in various lists
 29-}
 30
 31module Cxx.Basics where
 32
 33import Data.Generics (Data, Typeable, DataType, Constr)
 34import Util (Phantom(..), TriBool(..), NeList)
 35import Control.Arrow (second)
 36
 37relational_ops, accessSpecifiers, classKeys, basic_simple_type_specifiers, casts, storageClassSpecifiers, keywords, make_type_keywords, arithmetic_ops, ops, long_ops :: [String]
 38relational_ops = words "< > <= >= == !="
 39arithmetic_ops = concatMap (\x  [x, x ++ "="]) $ words "+ - * / << >> | & ^"
 40ops = relational_ops ++ arithmetic_ops ++ words "++ -- -> .* :: && || ! = ~ [ ] ( ) { } :"
 41long_ops = filter ((>1) . length) ops
 42
 43accessSpecifiers = words "public private protected"
 44classKeys = words "class struct union"
 45basic_simple_type_specifiers = words "short auto bool double int signed unsigned void char wchar_t char32_t float long char16_t"
 46casts = words "reinterpret_cast dynamic_cast static_cast const_cast"
 47storageClassSpecifiers = words "register static thread_local extern mutable"
 48keywords = accessSpecifiers ++ classKeys ++ basic_simple_type_specifiers ++ casts ++ storageClassSpecifiers ++ words "alignas continue friend typedef alignof decltype goto return typeid asm default if typename delete inline sizeof break do static_assert using case virtual catch else namespace enum new volatile explicit nullptr switch export operator template while this const false throw constexpr true for try define elif include defined"
 49
 50make_type_keywords = words "function functions pointer pointers reference references returning and lvalue rvalue constant chars character characters floats doubles bools booleans ints integer integers array arrays of from to noninline nonvirtual nonexplicit nonmutable nonstatic nonpure pure impure nonconst nonvolatile implicit nonlong nonshort nonsigned nonunsigned thread_local nonthread_local"
 51
 52-- Todo: The stuff above is old, and could be expressed more properly.
 53
 54data Findable = FindableDataType DataType | FindableConstr Constr | BodyOf DeclaratorId | DeclarationOf DeclaratorId | Constructor | Destructor | ConversionFunction | FindableParameterDeclaration | TemplateParameter | TemplateArgument
 55  -- Todo: ParameterDeclarationOf, TemplateParameterOf, ParameterDeclarationClauseOf, similar to BodyOf. Would be nice to do it in a generic fashion.
 56
 57data AbbreviatedMain
 58  = Print Code -- Does not include the semicolon.
 59  | Block Code -- Does not include Curlies.
 60  | Call Code -- /Does/ include Parens.
 61
 62data Chunk
 63  = CharLiteral String | StringLiteral' String | RawStringLiteral String String
 64  | SingleComment String | MultiComment String
 65  | Curlies Code | Parens Code | Squares Code
 66  | Plain String
 67  deriving Eq
 68
 69type Code = [Chunk]
 70
 71-- Misc/Util
 72
 73instance Show OperatorTok where
 74  show PlusTok = "+"; show PlusIs = "+="; show MinusTok = "-"; show MinusIs = "-="
 75  show Star = "*"; show StarIs = "*="; show Slash = "/"; show SlashIs = "/="
 76  show PlusPlus = "++"; show MinusMinus = "--"
 77  show OpenAngle = "<"; show OpenAngleIs = "<="; show CloseAngle = ">"; show CloseAngleIs = ">="
 78  show OpenTwoAngles = "<<"; show OpenTwoAnglesIs = "<<="
 79  show CloseTwoAngles = ">>"; show CloseTwoAnglesIs = ">>="
 80  show OpenCurly = "{"; show CloseCurly = "}"; show OpenSquare = "["; show CloseSquare = "]"
 81  show OpenParen = "("; show CloseParen = ")"; show Tilde = "~"
 82  show Question = "?"; show Exclamation = "!"; show ExclamationIs = "!="
 83  show Hat = "^"; show HatIs = "^="; show Percent = "%"; show PercentIs = "%="
 84  show Colon = ":"; show ColonColon = "::"; show Semicolon = ";"; show CommaTok = ","
 85  show Amper = "&"; show AmperIs = "&="; show AmperAmper = "&&"
 86  show Pipe = "|"; show PipeIs = "|="; show PipePipe = "||"
 87  show Is = "="; show IsIs = "=="; show Period = "."; show PeriodStar = ".*"
 88  show Arrow = "->"; show ArrowStar = "->*"; show Ellipsis = "..."
 89
 90operatorTokName :: OperatorTok  String
 91operatorTokName Colon = "colon"
 92operatorTokName Semicolon = "semicolon"
 93operatorTokName CommaTok = "comma"
 94operatorTokName Ellipsis = "ellipsis"
 95operatorTokName o = '"' : show o ++ "\""
 96
 97data Kwd' t = Kwd' t White deriving (Data, Typeable)
 98class SingleTokenType t where
 99  token :: t  Either String OperatorTok
100  token_class_name :: Phantom t  String
101  token_class_name = const ""
102
103#define KWD(x, n) \
104  data x = x deriving (Data, Typeable, Enum, Bounded, Eq); \
105  instance SingleTokenType x where token_class_name _ = show n; token _ = Left n
106
107KWD(KwdZero, "0")
108KWD(KwdGoto, "goto")
109KWD(KwdBreak, "break")
110KWD(KwdContinue, "continue")
111KWD(KwdIf, "if")
112KWD(KwdElse, "else")
113KWD(KwdDo, "do")
114KWD(KwdWhile, "while")
115KWD(KwdReturn, "return")
116KWD(KwdFor, "for")
117KWD(KwdTemplate, "template")
118KWD(KwdAlignof, "alignof")
119KWD(KwdAlignas, "alignas")
120KWD(KwdSwitch, "switch")
121KWD(KwdTypename, "typename")
122KWD(KwdTypeid, "typeid")
123KWD(KwdOperator, "operator")
124KWD(KwdInline, "inline")
125KWD(KwdNew, "new")
126KWD(KwdClass, "class")
127KWD(KwdEnum, "enum")
128KWD(KwdStruct, "struct")
129KWD(KwdSizeof, "sizeof")
130KWD(KwdDelete, "delete")
131KWD(KwdVirtual, "virtual")
132KWD(KwdDefault, "default")
133KWD(KwdCase, "case")
134KWD(KwdStaticAssert, "static_assert")
135KWD(KwdUsing, "using")
136KWD(KwdThis, "this")
137KWD(KwdNamespace, "namespace")
138KWD(KwdFriend, "friend")
139KWD(KwdConstexpr, "constexpr")
140KWD(KwdDecltype, "decltype")
141KWD(KwdAuto, "auto")
142KWD(KwdTypedef, "typedef")
143KWD(KwdAsm, "asm")
144KWD(KwdExtern, "extern")
145KWD(KwdExport, "export")
146KWD(KwdTry, "try")
147KWD(KwdCatch, "catch")
148KWD(KwdThrow, "throw")
149KWD(KwdMutable, "mutable")
150KWD(KwdThreadLocal, "thread_local")
151
152#undef KWD
153
154#define OP(n, t) \
155  data n = n deriving (Data, Typeable, Enum, Bounded, Eq); \
156  instance SingleTokenType n where token_class_name _ = operatorTokName t; token _ = Right t
157
158OP(OpenAngle_, OpenAngle)
159OP(OpenCurly_, OpenCurly)
160OP(OpenParen_, OpenParen)
161OP(OpenSquare_, OpenSquare)
162OP(CloseAngle_, CloseAngle)
163OP(CloseCurly_, CloseCurly)
164OP(CloseParen_, CloseParen)
165OP(CloseSquare_, CloseSquare)
166OP(ColonOp, Colon)
167OP(CommaOp, CommaTok)
168OP(ArrowOp, Arrow)
169OP(SemicolonOperator, Semicolon)
170OP(StarOperator, Star)
171OP(LeftShiftOp, OpenTwoAngles)
172OP(IsOperator, Is)
173OP(Tilde_, Tilde)
174OP(Ellipsis_, Ellipsis)
175OP(ScopeRes, ColonColon)
176OP(AmperProd, Amper)
177
178#undef OP
179
180data AndOperator = AndOperator | AltAndOperator deriving (Data, Typeable, Enum, Bounded, Eq)
181instance SingleTokenType AndOperator where
182  token_class_name _ = "and-operator"
183  token AndOperator = Right Amper
184  token AltAndOperator = Left "bitand"
185
186data LogicalOrOperator = LogicalOrOperator | AltLogicalOrOperator deriving (Data, Typeable, Enum, Bounded, Eq)
187instance SingleTokenType LogicalOrOperator where
188  token_class_name _ = "logical-or-operator"
189  token LogicalOrOperator = Right PipePipe
190  token AltLogicalOrOperator = Left "or"
191
192data InclusiveOrOperator = InclusiveOrOperator | AltInclusiveOrOperator deriving (Data, Typeable, Enum, Bounded, Eq)
193instance SingleTokenType InclusiveOrOperator where
194  token_class_name _ = "inclusive-or-operator"
195  token InclusiveOrOperator = Right Pipe
196  token AltInclusiveOrOperator = Left "bitor"
197
198data ExclusiveOrOperator = ExclusiveOrOperator | AltExclusiveOrOperator deriving (Data, Typeable, Enum, Bounded, Eq)
199instance SingleTokenType ExclusiveOrOperator where
200  token_class_name _ = "exclusive-or-operator"
201  token ExclusiveOrOperator = Right Hat
202  token AltExclusiveOrOperator = Left "xor"
203
204data LogicalAndOperator = LogicalAndOperator | AltLogicalAndOperator deriving (Data, Typeable, Enum, Bounded, Eq)
205instance SingleTokenType LogicalAndOperator where
206  token_class_name _ = "logical-and-operator"
207  token LogicalAndOperator = Right AmperAmper
208  token AltLogicalAndOperator = Left "and"
209
210data QuestionOp = QuestionOp deriving (Data, Typeable, Enum, Bounded, Eq)
211instance SingleTokenType QuestionOp where token_class_name _ = "ternary operator"; token _ = Right Question
212data IncDecOperator = IncrementOperator | DecrementOperator deriving (Data, Typeable, Enum, Bounded, Eq)
213instance SingleTokenType IncDecOperator where
214  token IncrementOperator = Right PlusPlus; token DecrementOperator = Right MinusMinus
215
216data Enclosed a = Enclosed a deriving (Typeable, Eq, Data)
217  -- Things wrapped in enclosed will not be wrapped in parentheses when shown for --precedence.
218
219data Commad a = Commad a [((CommaOp, White), a)] deriving (Data, Typeable, Eq)
220data Angled a = Angled (OpenAngle_, White) (Enclosed a) (CloseAngle_, White) deriving (Data, Typeable, Eq)
221data Squared a = Squared (OpenSquare_, White) (Enclosed a) (CloseSquare_, White) deriving (Data, Typeable, Eq)
222data Curlied a = Curlied (OpenCurly_, White) (Enclosed a) (CloseCurly_, White) deriving (Data, Typeable, Eq)
223data Parenthesized a = Parenthesized (OpenParen_, White) (Enclosed a) (CloseParen_, White) deriving (Data, Typeable, Eq)
224newtype White = White String deriving (Data, Typeable)
225instance Eq White where _ == _ = True
226
227instance Functor Commad where fmap f (Commad x l) = Commad (f x) $ map (second f) l
228
229data AnyMixOf a b = MixNone | MixA a | MixB b | MixAB a b | MixBA b a deriving (Eq, Data, Typeable)
230
231data OptQualified = OptQualified (Maybe (ScopeRes, White)) (Maybe NestedNameSpecifier) deriving (Data, Typeable, Eq)
232
233data GeordiRequestWithoutWhite = GeordiRequest_TU TranslationUnit | GeordiRequest_Print (LeftShiftOp, White) Expression (Maybe ((SemicolonOperator, White), TranslationUnit)) | GeordiRequest_Block FunctionBody TranslationUnit | GeordiRequest_Call (Parenthesized (Maybe ExpressionList)) (Maybe ((SemicolonOperator, White), TranslationUnit)) deriving (Data, Typeable)
234
235type GeordiRequest = (White, GeordiRequestWithoutWhite)
236
237data MakeSpecifier = NonStorageClassSpecifier StorageClassSpecifier | NonFunctionSpecifier FunctionSpecifier | MakeSpecifier_DeclSpecifier DeclSpecifier | NonSign Sign | NonLength LengthSpec | NonCv CvQualifier | LongLong deriving (Data, Typeable, Eq)
238data MakeDeclaration = MakeDeclaration [MakeSpecifier] (Maybe PtrAbstractDeclarator) TriBool deriving (Data, Typeable)
239  -- The tribool indicates purity.
240
241data OperatorTok =
242  PlusTok | PlusIs | MinusTok | MinusIs | PlusPlus | MinusMinus | Star | StarIs | Slash | SlashIs |
243  OpenAngle | OpenAngleIs | CloseAngle | CloseAngleIs | OpenTwoAngles | CloseTwoAngles | OpenTwoAnglesIs | CloseTwoAnglesIs | OpenCurly | CloseCurly | OpenSquare | CloseSquare | OpenParen | CloseParen | Question | Colon | ColonColon | Semicolon | Amper | AmperIs | AmperAmper | Pipe | PipeIs | PipePipe | Percent | PercentIs | Hat | HatIs | Exclamation | ExclamationIs | Is | IsIs | Tilde | Arrow | ArrowStar | Period | PeriodStar | CommaTok | Ellipsis
244 deriving (Eq, Enum, Bounded, Data, Typeable)
245
246data NewStyleCast = DynamicCast | StaticCast | ReinterpretCast | ConstCast deriving (Bounded, Enum, Data, Typeable, Eq)
247data MemberOperator = MemberPeriod | MemberArrow deriving (Enum, Bounded, Data, Typeable, Eq)
248data PmOperator = PmOperator_MemPtr | PmOperator_PtrMemPtr deriving (Enum, Bounded, Data, Typeable, Eq)
249data MultiplicativeOperator = MultiplicativeOperator_Multiply | MultiplicativeOperator_Divide | MultiplicativeOperator_Modulo deriving (Enum, Bounded, Data, Typeable, Eq)
250data AdditiveOperator = AdditiveOperator_Plus | AdditiveOperator_Minus deriving (Bounded, Enum, Data, Typeable, Eq)
251data ShiftOperator = ShiftOperator_Left | ShiftOperator_Right deriving (Bounded, Enum, Data, Typeable, Eq)
252data RelationalOperator = RelationalOperator_Less | RelationalOperator_Greater | RelationalOperator_LessEqual | RelationalOperator_GreaterEqual deriving (Bounded, Enum, Data, Typeable, Eq)
253data EqualityOperator = EqualityOperator_Equal | EqualityOperator_Unequal | EqualityOperator_AltUnequal deriving (Bounded, Enum, Data, Typeable, Eq)
254
255-- A.1 Keywords [gram.key]
256
257newtype TypedefName = TypedefName Identifier deriving (Data, Typeable, Eq)
258data NamespaceName = NamespaceName_OriginalNamespaceName OriginalNamespaceName | NamespaceName_NamespaceAlias NamespaceAlias deriving (Data, Typeable, Eq)
259newtype OriginalNamespaceName = OriginalNamespaceName Identifier deriving (Data, Typeable, Eq)
260newtype NamespaceAlias = NamespaceAlias Identifier deriving (Data, Typeable, Eq)
261data ClassName = ClassName_Identifier Identifier | ClassName_TemplateId TemplateId deriving (Data, Typeable, Eq)
262newtype EnumName = EnumName Identifier deriving (Data, Typeable, Eq)
263newtype TemplateName = TemplateName Identifier deriving (Data, Typeable, Eq)
264
265-- A.2 Lexical conventions [gram.lex]
266
267data Identifier = Identifier String White deriving (Data, Typeable, Eq)
268data Literal = Literal_IntegerLiteral IntegerLiteral White | Literal_CharacterLiteral CharacterLiteral White | Literal_FloatingLiteral FloatingLiteral White | Literal_StringLiteral StringLiteral | BooleanLiteral Bool White | PointerLiteral White deriving (Data, Typeable, Eq)
269newtype IntegerLiteral = IntegerLiteral String deriving (Data, Typeable, Eq)
270data CharacterLiteralKind = CharacterLiteral_Plain | CharacterLiteralKind_u | CharacterLiteralKind_U | CharacterLiteralKind_L deriving (Data, Typeable, Eq)
271data CharacterLiteral = CharacterLiteral CharacterLiteralKind String deriving (Data, Typeable, Eq)
272newtype FloatingLiteral = FloatingLiteral String deriving (Data, Typeable, Eq)
273data EncodingPrefix = EncodingPrefix_u8 | EncodingPrefix_u | EncodingPrefix_U | EncodingPrefix_L deriving (Data, Typeable, Eq)
274data SingleStringLiteral = SingleStringLiteral (Maybe EncodingPrefix) String deriving (Data, Typeable, Eq)
275data StringLiteral = StringLiteral (NeList (SingleStringLiteral, White)) deriving (Data, Typeable, Eq)
276
277-- A.3 Basic concepts [gram.basic]
278
279newtype TranslationUnit = TranslationUnit (Maybe DeclarationSeq) deriving (Data, Typeable)
280
281-- A.4 Expressions [gram.expr]
282
283data PrimaryExpression = PrimaryExpression_Literal Literal | PrimaryExpression_This (KwdThis, White) | PrimaryExpression_Expression (Parenthesized Expression) | PrimaryExpression_IdExpression IdExpression | PrimaryExpression_LambdaExpression LambdaExpression deriving (Data, Typeable, Eq)
284newtype IdExpression = IdExpression (Either QualifiedId UnqualifiedId) deriving (Data, Typeable, Eq)
285data UnqualifiedId = UnqualifiedId_Identifier Identifier | UnqualifiedId_OperatorFunctionId OperatorFunctionId | UnqualifiedId_ConversionFunctionId ConversionFunctionId | UnqualifiedId_Destructor (Tilde_, White) ClassName | UnqualifiedId_TemplateId TemplateId deriving (Data, Typeable, Eq)
286data QualifiedId = NestedUnqualifiedId (Maybe (ScopeRes, White)) NestedNameSpecifier (Maybe (KwdTemplate, White)) UnqualifiedId | GlobalIdentifier (ScopeRes, White) Identifier | GlobalOperatorFunctionId (ScopeRes, White) OperatorFunctionId | GlobalTemplateId (ScopeRes, White) TemplateId deriving (Data, Typeable, Eq)
287data NestedNameSpecifier = NestedNameSpecifier_TypeName TypeName (ScopeRes, White) | NestedNameSpecifier_NamespaceName NamespaceName (ScopeRes, White) | NestedNameSpecifier_Identifier NestedNameSpecifier Identifier (ScopeRes, White) | NestedNameSpecifier_SimpleTemplateId NestedNameSpecifier (Maybe White) SimpleTemplateId (ScopeRes, White) deriving (Data, Typeable, Eq)
288data LambdaExpression = LambdaExpression LambdaIntroducer (Maybe LambdaDeclarator) CompoundStatement deriving (Data, Typeable, Eq)
289newtype LambdaIntroducer = LambdaIntroducer (Squared (Maybe LambdaCapture)) deriving (Data, Typeable, Eq)
290data LambdaCapture = LambdaCapture (Maybe CaptureDefault) (Maybe (CommaOp, White)) (Maybe CaptureList) deriving (Data, Typeable, Eq)
291newtype CaptureDefault = CaptureDefault (Either (AmperProd, White) (IsOperator, White)) deriving (Data, Typeable, Eq)
292  -- Todo: Why not integrate the White's into the operator production ADTs?
293newtype CaptureList = CaptureList (Commad Capture) deriving (Data, Typeable, Eq)
294data Capture = Capture_Identifier (Maybe (AmperProd, White)) Identifier | Capture_This (KwdThis, White) deriving (Data, Typeable, Eq)
295data LambdaDeclarator = LambdaDeclarator (Parenthesized ParameterDeclarationClause) (Maybe (KwdMutable, White)) (Maybe ExceptionSpecification) (Maybe TrailingReturnType) deriving (Data, Typeable, Eq) -- Todo: attr-spec-seq
296data PostfixExpression
297  = PostfixExpression_PrimaryExpression PrimaryExpression
298  | PostfixExpression_Squared PostfixExpression (Squared (Either Expression BracedInitList))
299  | PostfixExpression_FunctionCall PostfixExpression (Parenthesized (Maybe ExpressionList))
300  | PostfixExpression_Conversion (Either SimpleTypeSpecifier TypenameSpecifier) (Either (Parenthesized (Maybe ExpressionList)) BracedInitList)
301  | PostfixExpression_Member PostfixExpression (MemberOperator, White) (Maybe (KwdTemplate, White)) IdExpression
302  | PostfixExpression_PseudoDestructor PostfixExpression (MemberOperator, White) PseudoDestructorName
303  | PostfixExpression_IncDec PostfixExpression (IncDecOperator, White)
304  | PostfixExpression_NewStyleCast (NewStyleCast, White) (Angled TypeId) (Parenthesized Expression)
305  | PostfixExpression_TypeId (KwdTypeid, White) (Parenthesized (Either Expression TypeId))
306  deriving (Data, Typeable, Eq)
307newtype ExpressionList = ExpressionList InitializerList deriving (Data, Typeable, Eq)
308data PseudoDestructorName = PseudoDestructorName_InTypeName OptQualified TypeName (ScopeRes, White) (Tilde_, White) TypeName | PseudoDestructorName_InTemplate (Maybe (ScopeRes, White)) NestedNameSpecifier (KwdTemplate, White) SimpleTemplateId (ScopeRes, White) (Tilde_, White) TypeName | PseudoDestructorName OptQualified (Tilde_, White) TypeName deriving (Data, Typeable, Eq)
309data UnaryExpression = UnaryExpression_PostfixExpression PostfixExpression | UnaryExpression (UnaryOperator, White) CastExpression | UnaryExpression_Sizeof_UnaryExpression (KwdSizeof, White) UnaryExpression | UnaryExpression_Sizeof_TypeId (KwdSizeof, White) (Parenthesized TypeId) | UnaryExpression_Sizeof_Ellipsis (KwdSizeof, White) (Ellipsis_, White) (Parenthesized Identifier) | UnaryExpression_AlignOf (KwdAlignof, White) (Parenthesized TypeId) | UnaryExpression_NewExpression NewExpression | UnaryExpression_DeleteExpression DeleteExpression deriving (Data, Typeable, Eq)
310data UnaryOperator = Dereference' | AddressOf' | Negate' | Positive' | LogicalNot' | AltLogicalNot | Complement' | AltComplement | PrefixIncrement | PrefixDecrement deriving (Bounded, Enum, Data, Typeable, Eq)
311data NewExpression = NewExpression (Maybe (ScopeRes, White)) (KwdNew, White) (Maybe NewPlacement) (Either NewTypeId (Parenthesized TypeId)) (Maybe NewInitializer) deriving (Data, Typeable, Eq)
312newtype NewPlacement = NewPlacement (Parenthesized ExpressionList) deriving (Data, Typeable, Eq)
313data NewTypeId = NewTypeId TypeSpecifierSeq (Maybe NewDeclarator) deriving (Data, Typeable, Eq)
314data NewDeclarator = NewDeclarator_PtrOperator PtrOperator (Maybe NewDeclarator) | NewDeclarator_NoptrNewDeclarator NoptrNewDeclarator deriving (Data, Typeable, Eq)
315data NoptrNewDeclarator = NoptrNewDeclarator (Squared Expression) [Squared ConstantExpression] deriving (Data, Typeable, Eq)
316data NewInitializer = NewInitializer_ExpressionList (Parenthesized (Maybe ExpressionList)) | NewInitializer_BracedInitList BracedInitList deriving (Data, Typeable, Eq)
317data DeleteExpression = DeleteExpression (Maybe (ScopeRes, White)) (KwdDelete, White) (Maybe (Squared ())) CastExpression deriving (Data, Typeable, Eq)
318data CastExpression = CastExpression_UnaryExpression UnaryExpression | CastExpression_Cast (Parenthesized TypeId) CastExpression deriving (Data, Typeable, Eq)
319data PmExpression = PmExpression_CastExpression CastExpression | PmExpression PmExpression (PmOperator, White) CastExpression deriving (Data, Typeable, Eq)
320data MultiplicativeExpression = MultiplicativeExpression_PmExpression PmExpression | MultiplicativeExpression MultiplicativeExpression (MultiplicativeOperator, White) PmExpression deriving (Data, Typeable, Eq)
321data AdditiveExpression = AdditiveExpression_MultiplicativeExpression MultiplicativeExpression | AdditiveExpression AdditiveExpression (AdditiveOperator, White) MultiplicativeExpression deriving (Data, Typeable, Eq)
322data ShiftExpression = ShiftExpression_AdditiveExpression AdditiveExpression | ShiftExpression ShiftExpression (ShiftOperator, White) AdditiveExpression deriving (Data, Typeable, Eq)
323data RelationalExpression = RelationalExpression_ShiftExpression ShiftExpression | RelationalExpression RelationalExpression (RelationalOperator, White) ShiftExpression deriving (Data, Typeable, Eq)
324data EqualityExpression = EqualityExpression_RelationalExpression RelationalExpression | EqualityExpression EqualityExpression (EqualityOperator, White) RelationalExpression deriving (Data, Typeable, Eq)
325data AndExpression = AndExpression_EqualityExpression EqualityExpression | AndExpression AndExpression (AndOperator, White) EqualityExpression deriving (Data, Typeable, Eq)
326data ExclusiveOrExpression = ExclusiveOrExpression_AndExpression AndExpression | ExclusiveOrExpression ExclusiveOrExpression (ExclusiveOrOperator, White) AndExpression deriving (Data, Typeable, Eq)
327data InclusiveOrExpression = InclusiveOrExpression_ExclusiveOrExpression ExclusiveOrExpression | InclusiveOrExpression InclusiveOrExpression (InclusiveOrOperator, White) ExclusiveOrExpression deriving (Data, Typeable, Eq)
328data LogicalAndExpression = LogicalAndExpression_InclusiveOrExpression InclusiveOrExpression | LogicalAndExpression LogicalAndExpression (LogicalAndOperator, White) InclusiveOrExpression deriving (Data, Typeable, Eq)
329data LogicalOrExpression = LogicalOrExpression_LogicalAndExpression LogicalAndExpression | LogicalOrExpression LogicalOrExpression (LogicalOrOperator, White) LogicalAndExpression deriving (Data, Typeable, Eq)
330data ConditionalExpression = ConditionalExpression_LogicalOrExpression LogicalOrExpression | ConditionalExpression LogicalOrExpression (QuestionOp, White) Expression (ColonOp, White) AssignmentExpression deriving (Data, Typeable, Eq)
331data AssignmentExpression = AssignmentExpression_ConditionalExpression ConditionalExpression | AssignmentExpression LogicalOrExpression (AssignmentOperator, White) InitializerClause | AssignmentExpression_ThrowExpression ThrowExpression deriving (Data, Typeable, Eq)
332data AssignmentOperator = AssignmentOperator_Assign | AssignmentOperator_MultiplyAssign | AssignmentOperator_DivideAssign | AssignmentOperator_PercentAssign | AssignmentOperator_PlusAssign | AssignmentOperator_MinusAssign | AssignmentOperator_RightShiftAssign | AssignmentOperator_LeftShiftAssign | AssignmentOperator_BitAndAssign | AssignmentOperator_AltBitAndAssign | AssignmentOperator_BitXorAssign | AssignmentOperator_AltBitXorAssign | AssignmentOperator_BitOrAssign | AssignmentOperator_AltBitOrAssign deriving (Bounded, Enum, Data, Typeable, Eq)
333data Expression = Expression_AssignmentExpression AssignmentExpression | Expression_Comma Expression (CommaOp, White) AssignmentExpression deriving (Data, Typeable, Eq)
334newtype ConstantExpression = ConstantExpression ConditionalExpression deriving (Data, Typeable, Eq)
335
336-- A.5 Statements [gram.stmt]
337
338data Statement = Statement_Labeled LabeledStatement | Statement_ExpressionStatement ExpressionStatement | Statement_DeclarationStatement DeclarationStatement | Statement_CompoundStatement CompoundStatement | Statement_SelectionStatement SelectionStatement | Statement_IterationStatement IterationStatement | Statement_JumpStatement JumpStatement | Statement_TryBlock TryBlock deriving (Data, Typeable, Eq)
339data Label = IdentifierLabel Identifier | CaseLabel (KwdCase, White) ConstantExpression | DefaultLabel (KwdDefault, White) deriving (Data, Typeable, Eq)
340data LabeledStatement = LabeledStatement Label (ColonOp, White) Statement deriving (Data, Typeable, Eq)
341data ExpressionStatement = ExpressionStatement (Maybe Expression) (SemicolonOperator, White) deriving (Data, Typeable, Eq)
342newtype CompoundStatement = CompoundStatement (Curlied (Maybe StatementSeq)) deriving (Data, Typeable, Eq)
343newtype StatementSeq = StatementSeq (NeList Statement) deriving (Data, Typeable, Eq)
344data SelectionStatement = IfStatement (KwdIf, White) (Parenthesized Condition) Statement (Maybe ((KwdElse, White), Statement)) | SwitchStatement (KwdSwitch, White) (Parenthesized Condition) Statement deriving (Data, Typeable, Eq)
345data Condition = Condition_Expression Expression | Condition_Declaration TypeSpecifierSeq Declarator BraceOrEqualInitializer deriving (Data, Typeable, Eq)
346  -- Why doesn't the draft use brace-or-equal-initializer here?
347data IterationStatement = WhileStatement (KwdWhile, White) (Parenthesized Condition) Statement | DoWhileStatement (KwdDo, White) Statement (KwdWhile, White) (Parenthesized Expression) (SemicolonOperator, White) | ForStatement (KwdFor, White) (Parenthesized (ForInitStatement, Maybe Condition, (SemicolonOperator, White), Maybe Expression)) Statement | RangeForStatement (KwdFor, White) (Parenthesized (ForRangeDeclaration, (ColonOp, White), ForRangeInitializer)) Statement deriving (Data, Typeable, Eq)
348data ForInitStatement = ForInitStatement_ExpressionStatement ExpressionStatement | ForInitStatement_SimpleDeclaration SimpleDeclaration deriving (Data, Typeable, Eq)
349data ForRangeDeclaration = ForRangeDeclaration DeclSpecifierSeq Declarator deriving (Data, Typeable, Eq)
350data ForRangeInitializer = ForRangeInitializer_Expression Expression | ForRangeInitializer_BracedInitList BracedInitList deriving (Data, Typeable, Eq)
351data JumpStatement = BreakStatement (KwdBreak, White) (SemicolonOperator, White) | ContinueStatement (KwdContinue, White) (SemicolonOperator, White) | ReturnStatement (KwdReturn, White) (Maybe Expression) (SemicolonOperator, White) | GotoStatement (KwdGoto, White) Identifier (SemicolonOperator, White) deriving (Data, Typeable, Eq)
352data DeclarationStatement = DeclarationStatement BlockDeclaration deriving (Data, Typeable, Eq)
353
354-- A.6 Declarations [gram.dcl]
355
356newtype DeclarationSeq = DeclarationSeq (NeList Declaration) deriving (Data, Typeable, Eq)
357data Declaration = Declaration_BlockDeclaration BlockDeclaration | Declaration_FunctionDefinition FunctionDefinition | Declaration_TemplateDeclaration TemplateDeclaration | Declaration_ExplicitInstantiation ExplicitInstantiation | Declaration_ExplicitSpecialization ExplicitSpecialization | Declaration_LinkageSpecification LinkageSpecification | Declaration_NamespaceDefinition NamespaceDefinition deriving (Data, Typeable, Eq)
358data BlockDeclaration = BlockDeclaration_SimpleDeclaration SimpleDeclaration | BlockDeclaration_AsmDefinition AsmDefinition | BlockDeclaration_NamespaceAliasDefinition NamespaceAliasDefinition | BlockDeclaration_UsingDeclaration UsingDeclaration | BlockDeclaration_UsingDirective UsingDirective | BlockDeclaration_StaticAssertDeclaration StaticAssertDeclaration | BlockDeclaration_AliasDeclaration AliasDeclaration deriving (Data, Typeable, Eq)
359data AliasDeclaration = AliasDeclaration (KwdUsing, White) Identifier (IsOperator, White) TypeId (SemicolonOperator, White) deriving (Data, Typeable, Eq)
360data SimpleDeclaration = SimpleDeclaration (Maybe DeclSpecifierSeq) (Maybe InitDeclaratorList) (SemicolonOperator, White) deriving (Data, Typeable, Eq)
361data StaticAssertDeclaration = StaticAssertDeclaration (KwdStaticAssert, White) (Parenthesized (ConstantExpression, (CommaOp, White), StringLiteral)) (SemicolonOperator, White) deriving (Data, Typeable, Eq)
362data DeclSpecifier = DeclSpecifier_StorageClassSpecifier (StorageClassSpecifier, White) | DeclSpecifier_TypeSpecifier TypeSpecifier | DeclSpecifier_FunctionSpecifier (FunctionSpecifier, White) | DeclSpecifier_Friend (KwdFriend, White) | DeclSpecifier_Typedef (KwdTypedef, White) | DeclSpecifier_ConstExpr (KwdConstexpr, White) | DeclSpecifier_AlignmentSpecifier AlignmentSpecifier deriving (Data, Typeable, Eq)
363newtype DeclSpecifierSeq = DeclSpecifierSeq (NeList DeclSpecifier) deriving (Data, Typeable, Eq)
364data StorageClassSpecifier = Register | Static | ThreadLocal | Extern | Mutable deriving (Enum, Bounded, Data, Typeable, Eq)
365data FunctionSpecifier = Inline | Virtual | Explicit deriving (Enum, Bounded, Data, Typeable, Eq)
366data Sign = Signed | Unsigned deriving (Eq, Bounded, Enum, Data, Typeable)
367data LengthSpec = ShortSpec | LongSpec deriving (Eq, Bounded, Enum, Data, Typeable)
368data BasicType = Char' | Char16 | Char32 | Wchar | Bool' | Int' | Float' | Double' | Void deriving (Enum, Bounded, Data, Typeable, Eq)
369data TypeSpecifier = TypeSpecifier_TrailingTypeSpecifier TrailingTypeSpecifier | TypeSpecifier_ClassSpecifier ClassSpecifier | TypeSpecifier_EnumSpecifier EnumSpecifier deriving (Data, Typeable, Eq)
370data TrailingTypeSpecifier = TrailingTypeSpecifier_SimpleTypeSpecifier SimpleTypeSpecifier | TrailingTypeSpecifier_ElaboratedTypeSpecifier ElaboratedTypeSpecifier | TrailingTypeSpecifier_TypenameSpecifier TypenameSpecifier | TrailingTypeSpecifier_CvQualifier (CvQualifier, White) deriving (Data, Typeable, Eq)
371newtype TypeSpecifierSeq = TypeSpecifierSeq (NeList TypeSpecifier) deriving (Data, Typeable, Eq)
372newtype TrailingTypeSpecifierSeq = TrailingTypeSpecifierSeq (NeList TrailingTypeSpecifier) deriving (Data, Typeable, Eq)
373data SimpleTypeSpecifier = SimpleTypeSpecifier_BasicType (BasicType, White) | SimpleTypeSpecifier_Auto (KwdAuto, White) | SimpleTypeSpecifier_DeclType (KwdDecltype, White) (Parenthesized Expression) | LengthSpec (LengthSpec, White) | SignSpec (Sign, White) | SimpleTypeSpecifier_TypeName OptQualified TypeName | SimpleTypeSpecifier_SimpleTemplateId (Maybe (ScopeRes, White)) NestedNameSpecifier White SimpleTemplateId deriving (Data, Typeable, Eq)
374data TypeName = TypeName_ClassName ClassName | TypeName_EnumName EnumName | TypeName_TypedefName TypedefName deriving (Data, Typeable, Eq)
375data ElaboratedTypeSpecifier = ElaboratedTypeSpecifier (ClassKey, White) OptQualified (Either (Maybe (KwdTemplate, White), SimpleTemplateId) Identifier) deriving (Data, Typeable, Eq)
376data EnumSpecifier = EnumSpecifier EnumHead (Curlied (Maybe (EnumeratorList, Maybe (CommaOp, White)))) deriving (Data, Typeable, Eq)
377data EnumHead = EnumHead EnumKey (Maybe Identifier) (Maybe EnumBase) deriving (Data, Typeable, Eq)
378data EnumKey = EnumKey (KwdEnum, White) | EnumKey_Class (KwdEnum, White) (KwdClass, White) | EnumKey_Struct (KwdEnum, White) (KwdStruct, White) deriving (Data, Typeable, Eq)
379data EnumBase = EnumBase (ColonOp, White) TypeSpecifierSeq deriving (Data, Typeable, Eq)
380  -- Todo: Make this "make"-able some day.
381newtype EnumeratorList = EnumeratorList (Commad EnumeratorDefinition) deriving (Data, Typeable, Eq)
382data EnumeratorDefinition = EnumeratorDefinition Enumerator (Maybe ((IsOperator, White), ConstantExpression)) deriving (Data, Typeable, Eq)
383newtype Enumerator = Enumerator Identifier deriving (Data, Typeable, Eq)
384data NamespaceDefinition = NamespaceDefinition (Maybe (KwdInline, White)) (KwdNamespace, White) (Maybe Identifier) (Curlied NamespaceBody) deriving (Data, Typeable, Eq)
385newtype NamespaceBody = NamespaceBody (Maybe DeclarationSeq) deriving (Data, Typeable, Eq)
386data NamespaceAliasDefinition = NamespaceAliasDefinition (KwdNamespace, White) Identifier (IsOperator, White) OptQualified NamespaceName (SemicolonOperator, White) deriving (Data, Typeable, Eq)
387data UsingDeclaration = UsingDeclaration_Nested (KwdUsing, White) (Maybe (KwdTypename, White)) (Maybe (ScopeRes, White)) NestedNameSpecifier UnqualifiedId (SemicolonOperator, White) | UsingDeclaration_NonNested (KwdUsing, White) (ScopeRes, White) UnqualifiedId (SemicolonOperator, White) deriving (Data, Typeable, Eq)
388data UsingDirective = UsingDirective (KwdUsing, White) (KwdNamespace, White) OptQualified NamespaceName (SemicolonOperator, White) deriving (Data, Typeable, Eq)
389data AsmDefinition = AsmDefinition (KwdAsm, White) (Parenthesized StringLiteral) (SemicolonOperator, White) deriving (Data, Typeable, Eq)
390data LinkageSpecification = LinkageSpecification (KwdExtern, White) StringLiteral (Either Declaration (Curlied (Maybe DeclarationSeq))) deriving (Data, Typeable, Eq)
391data AlignmentSpecifier = AlignmentSpecifier (KwdAlignas, White) (Parenthesized (Either ConstantExpression TypeId)) deriving (Data, Typeable, Eq)
392
393-- A.7 Declarators [gram.decl]
394
395newtype InitDeclaratorList = InitDeclaratorList (Commad InitDeclarator) deriving (Data, Typeable, Eq)
396data InitDeclarator = InitDeclarator Declarator (Maybe Initializer) deriving (Data, Typeable, Eq)
397data Declarator = Declarator_PtrDeclarator PtrDeclarator | Declarator_TrailingReturnType NoptrDeclarator ParametersAndQualifiers TrailingReturnType deriving (Data, Typeable, Eq)
398data PtrDeclarator = PtrDeclarator_NoptrDeclarator NoptrDeclarator | PtrDeclarator PtrOperator PtrDeclarator deriving (Data, Typeable, Eq)
399data NoptrDeclarator = NoptrDeclarator_Id DeclaratorId | NoptrDeclarator_WithParams NoptrDeclarator ParametersAndQualifiers | NoptrDeclarator_Squared NoptrDeclarator (Squared (Maybe ConstantExpression)) | NoptrDeclarator_Parenthesized (Parenthesized PtrDeclarator) deriving (Data, Typeable, Eq)
400data ParametersAndQualifiers = ParametersAndQualifiers (Parenthesized ParameterDeclarationClause) (Maybe CvQualifierSeq) (Maybe (RefQualifier, White)) (Maybe ExceptionSpecification) deriving (Data, Typeable, Eq)
401data TrailingReturnType = TrailingReturnType (ArrowOp, White) TrailingTypeSpecifierSeq (Maybe AbstractDeclarator) deriving (Data, Typeable, Eq)
402data PtrOperator = PtrOperator_Ptr (StarOperator, White) (Maybe CvQualifierSeq) | PtrOperator_Ref (RefQualifier, White) | PtrOperator_Nested (Maybe (ScopeRes, White)) NestedNameSpecifier (StarOperator, White) (Maybe CvQualifierSeq) deriving (Data, Typeable, Eq)
403newtype CvQualifierSeq = CvQualifierSeq (NeList (CvQualifier, White)) deriving (Data, Typeable, Eq)
404data CvQualifier = Const | Volatile deriving (Bounded, Enum, Data, Typeable, Eq)
405data RefQualifier = Lvalue | Rvalue deriving (Bounded, Enum, Data, Typeable, Eq)
406data DeclaratorId = DeclaratorId_IdExpression (Maybe (Ellipsis_, White)) IdExpression | DeclaratorId_Nested OptQualified ClassName deriving (Data, Typeable, Eq)
407data TypeId = TypeId TypeSpecifierSeq (Maybe AbstractDeclarator) deriving (Data, Typeable, Eq)
408data AbstractDeclarator = AbstractDeclarator_PtrAbstractDeclarator PtrAbstractDeclarator | AbstractDeclarator_Ellipsis (Ellipsis_, White) deriving (Data, Typeable, Eq)
409data PtrAbstractDeclarator = PtrAbstractDeclarator_NoptrAbstractDeclarator NoptrAbstractDeclarator | PtrAbstractDeclarator PtrOperator (Maybe PtrAbstractDeclarator) deriving (Data, Typeable, Eq)
410data NoptrAbstractDeclarator = NoptrAbstractDeclarator (Maybe NoptrAbstractDeclarator) (Either ParametersAndQualifiers (Squared (Maybe ConstantExpression))) | NoptrAbstractDeclarator_PtrAbstractDeclarator (Parenthesized PtrAbstractDeclarator) deriving (Data, Typeable, Eq)
411  -- In the latest draft, this constant expression isn't optional, which I think may be a bug. Todo: check again in the next draft.
412data ParameterDeclarationClause = ParameterDeclarationClause (Maybe ParameterDeclarationList) (Maybe (Ellipsis_, White)) | ParameterDeclarationClauseWithEllipsis ParameterDeclarationList (CommaOp, White) (Ellipsis_, White) deriving (Data, Typeable, Eq)
413newtype ParameterDeclarationList = ParameterDeclarationList (Commad ParameterDeclaration) deriving (Data, Typeable, Eq)
414data ParameterDeclaration = ParameterDeclaration DeclSpecifierSeq (Either Declarator (Maybe AbstractDeclarator)) (Maybe ((IsOperator, White), AssignmentExpression)) deriving (Data, Typeable, Eq)
415data FunctionDefinition = FunctionDefinition (Maybe DeclSpecifierSeq) Declarator FunctionBody deriving (Data, Typeable, Eq)
416data FunctionBody = FunctionBody (Maybe CtorInitializer) CompoundStatement | FunctionBody_FunctionTryBlock FunctionTryBlock | DefaultedFunctionBody (IsOperator, White) (KwdDefault, White) (SemicolonOperator, White) | DeletedFunctionBody (IsOperator, White) (KwdDelete, White) (SemicolonOperator, White) deriving (Data, Typeable, Eq)
417data Initializer = Initializer_Parenthesized (Parenthesized ExpressionList) | Initializer_BraceOrEqualInitializer BraceOrEqualInitializer deriving (Data, Typeable, Eq)
418data BraceOrEqualInitializer = EqualInitializer (IsOperator, White) InitializerClause | BraceInitializer BracedInitList deriving (Data, Typeable, Eq)
419newtype InitializerClause = InitializerClause (Either BracedInitList AssignmentExpression) deriving (Data, Typeable, Eq)
420newtype InitializerList = InitializerList (Commad InitializerClause) deriving (Data, Typeable, Eq)
421newtype BracedInitList = BracedInitList (Curlied (Maybe (InitializerList, Maybe (CommaOp, White)))) deriving (Data, Typeable, Eq)
422
423-- A.8 Classes [gram.class]
424
425data ClassSpecifier = ClassSpecifier ClassHead (Curlied MemberSpecification) deriving (Data, Typeable, Eq)
426data ClassHeadKind = ClassHeadKind_Identifier (Maybe Identifier) | ClassHeadKind_NestedIdentifier NestedNameSpecifier Identifier | ClassHeadKind_SimpleTemplateId (Maybe NestedNameSpecifier) SimpleTemplateId deriving (Data, Typeable, Eq)
427data ClassHead = ClassHead (ClassKey, White) ClassHeadKind (Maybe BaseClause) deriving (Data, Typeable, Eq)
428data ClassKey = Class | Struct | Union deriving (Enum, Bounded, Data, Typeable, Eq)
429data MemberAccessSpecifier = MemberAccessSpecifier (AccessSpecifier, White) (ColonOp, White) deriving (Data, Typeable, Eq)
430data MemberSpecification = MemberSpecification [Either MemberDeclaration MemberAccessSpecifier] deriving (Data, Typeable, Eq)
431data MemberDeclaration = MemberDeclaration (Maybe DeclSpecifierSeq) (Maybe MemberDeclaratorList) (SemicolonOperator, White) | MemberFunctionDefinition FunctionDefinition (Maybe (SemicolonOperator, White)) | MemberUsingDeclaration UsingDeclaration | MemberTemplateDeclaration TemplateDeclaration deriving (Data, Typeable, Eq)
432newtype MemberDeclaratorList = MemberDeclaratorList (Commad MemberDeclarator) deriving (Data, Typeable, Eq)
433data MemberDeclarator = MemberDeclarator Declarator (Maybe (Either PureSpecifier BraceOrEqualInitializer)) | BitField (Maybe Identifier) (ColonOp, White) ConstantExpression deriving (Data, Typeable, Eq)
434data PureSpecifier = PureSpecifier (IsOperator, White) (KwdZero, White) deriving (Data, Typeable, Eq)
435
436-- A.9 Derived classes [gram.derived]
437
438data BaseClause = BaseClause (ColonOp, White) BaseSpecifierList deriving (Data, Typeable, Eq)
439newtype BaseSpecifierList = BaseSpecifierList (Commad BaseSpecifier) deriving (Data, Typeable, Eq)
440data BaseSpecifier = BaseSpecifier (AnyMixOf (AccessSpecifier, White) (KwdVirtual, White)) OptQualified ClassName deriving (Data, Typeable, Eq)
441data AccessSpecifier = Private | Protected | Public deriving (Bounded, Enum, Data, Typeable, Eq)
442
443-- A.10 Special member functions [gram.special]
444
445data ConversionFunctionId = ConversionFunctionId (KwdOperator, White) ConversionTypeId deriving (Data, Typeable, Eq)
446data ConversionTypeId = ConversionTypeId TypeSpecifierSeq [PtrOperator] deriving (Data, Typeable, Eq)
447data CtorInitializer = CtorInitializer (ColonOp, White) MemInitializerList deriving (Data, Typeable, Eq)
448newtype MemInitializerList = MemInitializerList (Commad MemInitializer) deriving (Data, Typeable, Eq)
449data MemInitializer = MemInitializer MemInitializerId (Either (Parenthesized (Maybe ExpressionList)) BracedInitList) deriving (Data, Typeable, Eq)
450data MemInitializerId = MemInitializerId_ClassName OptQualified ClassName | MemInitializerId_Identifier Identifier deriving (Data, Typeable, Eq)
451
452-- A.11 Overloading [gram.over]
453
454data OperatorFunctionId = OperatorFunctionId (KwdOperator, White) OverloadableOperator deriving (Data, Typeable, Eq)
455data OverloadableOperator = OverloadableOperator_New (KwdNew, White) (Maybe (Squared ())) | OverloadableOperator_Delete (KwdDelete, White) (Maybe (Squared ())) | OverloadableOperator_Call (Parenthesized ()) | OverloadableOperator_Index (Squared ()) | OverloadableUnaryOperator (UnaryOperator, White) | OverloadableAssignmentOperator (AssignmentOperator, White) | OverloadableRelationalOperator (RelationalOperator, White) | OverloadableMultiplicativeOperator (MultiplicativeOperator, White) | OverloadableShiftOperator (ShiftOperator, White) | OverloadableAdditiveOperator (AdditiveOperator, White) | OverloadableEqualityOperator (EqualityOperator, White) | OverloadableBitXor (ExclusiveOrOperator, White) | OverloadableBitAnd (AndOperator, White) | OverloadableBitOr (InclusiveOrOperator, White) | OverloadableLogicalAnd (LogicalAndOperator, White) | OverloadableLogicalOr (LogicalOrOperator, White) | OverloadableComma (CommaOp, White) | OverloadablePmOperator (PmOperator, White) | OverloadableArrowOperator (ArrowOp, White) deriving (Data, Typeable, Eq)
456
457-- A.12 Templates [gram.temp]
458
459data TemplateDeclaration = TemplateDeclaration (Maybe (KwdExport, White)) (KwdTemplate, White) (Angled TemplateParameterList) Declaration deriving (Data, Typeable, Eq)
460newtype TemplateParameterList = TemplateParameterList (Commad TemplateParameter) deriving (Data, Typeable, Eq)
461data TemplateParameter = TemplateParameter_TypeParameter TypeParameter | TemplateParameter_ParameterDeclaration ParameterDeclaration deriving (Data, Typeable, Eq)
462data TypeParameter = TypeParameter_Class (Either (KwdClass, White) (KwdTypename, White)) (Maybe Identifier) (Maybe ((IsOperator, White), TypeId)) | TypeParameter_Template (KwdTemplate, White) (Angled TemplateParameterList) (KwdClass, White) (Maybe Identifier) (Maybe (White, IdExpression)) deriving (Data, Typeable, Eq)
463data TemplateArguments = TemplateArguments (Angled (Maybe TemplateArgumentList)) deriving (Data, Typeable, Eq)
464data SimpleTemplateId = SimpleTemplateId TemplateName TemplateArguments deriving (Data, Typeable, Eq)
465data TemplateId = TemplateId_SimpleTemplateId SimpleTemplateId | TemplateId_OperatorFunctionId OperatorFunctionId TemplateArguments deriving (Data, Typeable, Eq)
466newtype TemplateArgumentList = TemplateArgumentList (Commad TemplateArgument) deriving (Data, Typeable, Eq)
467data TemplateArgument = TemplateArgument_ConstantExpression ConstantExpression | TemplateArgument_TypeId TypeId | TemplateArgument_IdExpression IdExpression deriving (Data, Typeable, Eq)
468data TypenameSpecifier = TypenameSpecifier (KwdTypename, White) (Maybe (ScopeRes, White)) NestedNameSpecifier (Either Identifier (Maybe (KwdTemplate, White), SimpleTemplateId)) deriving (Data, Typeable, Eq)
469data ExplicitInstantiation = ExplicitInstantiation (Maybe (KwdExtern, White)) (KwdTemplate, White) Declaration deriving (Data, Typeable, Eq)
470data ExplicitSpecialization = ExplicitSpecialization (KwdTemplate, White) (Angled ()) Declaration deriving (Data, Typeable, Eq)
471
472-- A.13 Exception handling [gram.except]
473
474data TryBlock = TryBlock (KwdTry, White) CompoundStatement HandlerSeq deriving (Data, Typeable, Eq)
475data FunctionTryBlock = FunctionTryBlock (KwdTry, White) (Maybe CtorInitializer) CompoundStatement HandlerSeq deriving (Data, Typeable, Eq)
476newtype HandlerSeq = HandlerSeq (NeList Handler) deriving (Data, Typeable, Eq)
477data Handler = Handler (KwdCatch, White) (Parenthesized ExceptionDeclaration) CompoundStatement deriving (Data, Typeable, Eq)
478data ExceptionDeclaration = ExceptionDeclaration_Ellipsis (Ellipsis_, White) | ExceptionDeclaration TypeSpecifierSeq (Maybe (Either Declarator AbstractDeclarator)) deriving (Data, Typeable, Eq)
479data ThrowExpression = ThrowExpression (KwdThrow, White) (Maybe AssignmentExpression) deriving (Data, Typeable, Eq)
480data ExceptionSpecification = ExceptionSpecification (KwdThrow, White) (Parenthesized (Maybe TypeIdList)) deriving (Data, Typeable, Eq)
481newtype TypeIdList = TypeIdList (Commad TypeId) deriving (Data, Typeable, Eq)
482
483-- A.14 Preprocessing directives [gram.cpp]