~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System.Collections;
 
2
using System.Collections.Generic;
 
3
using System.Collections.Specialized;
 
4
using System.Linq;
 
5
using System.Text;
 
6
using ICSharpCode.NRefactory.Ast;
 
7
using ICSharpCode.NRefactory.Parser.VB;
 
8
using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
 
9
 
 
10
COMPILER VBNET
 
11
 
 
12
/* START AUTOGENERATED TOKENS SECTION */
 
13
TOKENS
 
14
        /* ----- terminal classes ----- */
 
15
        /* EOF is 0 */
 
16
        EOL
 
17
        ident
 
18
        LiteralString
 
19
        LiteralCharacter
 
20
        LiteralInteger
 
21
        LiteralDouble
 
22
        LiteralSingle
 
23
        LiteralDecimal
 
24
        LiteralDate
 
25
        XmlOpenTag
 
26
        XmlCloseTag
 
27
        XmlStartInlineVB
 
28
        XmlEndInlineVB
 
29
        XmlCloseTagEmptyElement
 
30
        XmlOpenEndTag
 
31
        XmlContent
 
32
        XmlComment
 
33
        XmlCData
 
34
        XmlProcessingInstruction
 
35
 
 
36
        /* ----- special character ----- */
 
37
        "="
 
38
        ":"
 
39
        ","
 
40
        "&"
 
41
        "/"
 
42
        "\\"
 
43
        "."
 
44
        "..."
 
45
        ".@"
 
46
        "!"
 
47
        "-"
 
48
        "+"
 
49
        "^"
 
50
        "?"
 
51
        "*"
 
52
        "{"
 
53
        "}"
 
54
        "("
 
55
        ")"
 
56
        ">"
 
57
        "<"
 
58
        "<>"
 
59
        ">="
 
60
        "<="
 
61
        "<<"
 
62
        ">>"
 
63
        "+="
 
64
        "^="
 
65
        "-="
 
66
        "*="
 
67
        "/="
 
68
        "\\="
 
69
        "<<="
 
70
        ">>="
 
71
        "&="
 
72
        ":="
 
73
 
 
74
        /* ----- keywords ----- */
 
75
        "AddHandler"
 
76
        "AddressOf"
 
77
        "Aggregate"
 
78
        "Alias"
 
79
        "And"
 
80
        "AndAlso"
 
81
        "Ansi"
 
82
        "As"
 
83
        "Ascending"
 
84
        "Assembly"
 
85
        "Auto"
 
86
        "Binary"
 
87
        "Boolean"
 
88
        "ByRef"
 
89
        "By"
 
90
        "Byte"
 
91
        "ByVal"
 
92
        "Call"
 
93
        "Case"
 
94
        "Catch"
 
95
        "CBool"
 
96
        "CByte"
 
97
        "CChar"
 
98
        "CDate"
 
99
        "CDbl"
 
100
        "CDec"
 
101
        "Char"
 
102
        "CInt"
 
103
        "Class"
 
104
        "CLng"
 
105
        "CObj"
 
106
        "Compare"
 
107
        "Const"
 
108
        "Continue"
 
109
        "CSByte"
 
110
        "CShort"
 
111
        "CSng"
 
112
        "CStr"
 
113
        "CType"
 
114
        "CUInt"
 
115
        "CULng"
 
116
        "CUShort"
 
117
        "Custom"
 
118
        "Date"
 
119
        "Decimal"
 
120
        "Declare"
 
121
        "Default"
 
122
        "Delegate"
 
123
        "Descending"
 
124
        "Dim"
 
125
        "DirectCast"
 
126
        "Distinct"
 
127
        "Do"
 
128
        "Double"
 
129
        "Each"
 
130
        "Else"
 
131
        "ElseIf"
 
132
        "End"
 
133
        "EndIf"
 
134
        "Enum"
 
135
        "Equals"
 
136
        "Erase"
 
137
        "Error"
 
138
        "Event"
 
139
        "Exit"
 
140
        "Explicit"
 
141
        "False"
 
142
        "Finally"
 
143
        "For"
 
144
        "Friend"
 
145
        "From"
 
146
        "Function"
 
147
        "Get"
 
148
        "GetType"
 
149
        "Global"
 
150
        "GoSub"
 
151
        "GoTo"
 
152
        "Group"
 
153
        "Handles"
 
154
        "If"
 
155
        "Implements"
 
156
        "Imports"
 
157
        "In"
 
158
        "Infer"
 
159
        "Inherits"
 
160
        "Integer"
 
161
        "Interface"
 
162
        "Into"
 
163
        "Is"
 
164
        "IsNot"
 
165
        "Join"
 
166
        "Key"
 
167
        "Let"
 
168
        "Lib"
 
169
        "Like"
 
170
        "Long"
 
171
        "Loop"
 
172
        "Me"
 
173
        "Mod"
 
174
        "Module"
 
175
        "MustInherit"
 
176
        "MustOverride"
 
177
        "MyBase"
 
178
        "MyClass"
 
179
        "Namespace"
 
180
        "Narrowing"
 
181
        "New"
 
182
        "Next"
 
183
        "Not"
 
184
        "Nothing"
 
185
        "NotInheritable"
 
186
        "NotOverridable"
 
187
        "Object"
 
188
        "Of"
 
189
        "Off"
 
190
        "On"
 
191
        "Operator"
 
192
        "Option"
 
193
        "Optional"
 
194
        "Or"
 
195
        "Order"
 
196
        "OrElse"
 
197
        "Out"
 
198
        "Overloads"
 
199
        "Overridable"
 
200
        "Overrides"
 
201
        "ParamArray"
 
202
        "Partial"
 
203
        "Preserve"
 
204
        "Private"
 
205
        "Property"
 
206
        "Protected"
 
207
        "Public"
 
208
        "RaiseEvent"
 
209
        "ReadOnly"
 
210
        "ReDim"
 
211
        "Rem"
 
212
        "RemoveHandler"
 
213
        "Resume"
 
214
        "Return"
 
215
        "SByte"
 
216
        "Select"
 
217
        "Set"
 
218
        "Shadows"
 
219
        "Shared"
 
220
        "Short"
 
221
        "Single"
 
222
        "Skip"
 
223
        "Static"
 
224
        "Step"
 
225
        "Stop"
 
226
        "Strict"
 
227
        "String"
 
228
        "Structure"
 
229
        "Sub"
 
230
        "SyncLock"
 
231
        "Take"
 
232
        "Text"
 
233
        "Then"
 
234
        "Throw"
 
235
        "To"
 
236
        "True"
 
237
        "Try"
 
238
        "TryCast"
 
239
        "TypeOf"
 
240
        "UInteger"
 
241
        "ULong"
 
242
        "Unicode"
 
243
        "Until"
 
244
        "UShort"
 
245
        "Using"
 
246
        "Variant"
 
247
        "Wend"
 
248
        "When"
 
249
        "Where"
 
250
        "While"
 
251
        "Widening"
 
252
        "With"
 
253
        "WithEvents"
 
254
        "WriteOnly"
 
255
        "Xor"
 
256
        "GetXmlNamespace"
 
257
/* END AUTOGENERATED TOKENS SECTION */
 
258
 
 
259
PRODUCTIONS
 
260
 
 
261
VBNET
 
262
        (.
 
263
                lexer.NextToken(); // get the first token
 
264
                compilationUnit = new CompilationUnit();
 
265
                BlockStart(compilationUnit);
 
266
        .)
 
267
=
 
268
        { EndOfStmt }
 
269
        { OptionStmt { EndOfStmt } }
 
270
        { ImportsStmt { EndOfStmt } }
 
271
        { IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } }
 
272
        { NamespaceMemberDecl { EndOfStmt } }
 
273
        EOF
 
274
.
 
275
 
 
276
OptionStmt (. INode node = null; bool val = true; .) =
 
277
        "Option" (. Location startPos = t.Location; .)
 
278
        (
 
279
                "Explicit" [ OptionValue<ref val> ]
 
280
                (. node = new OptionDeclaration(OptionType.Explicit, val); .)
 
281
                |
 
282
                "Strict" [ OptionValue<ref val> ]
 
283
                (. node = new OptionDeclaration(OptionType.Strict, val); .)
 
284
                |
 
285
                "Compare" ( "Binary" (. node = new OptionDeclaration(OptionType.CompareBinary, val); .)
 
286
                                  | "Text" (. node = new OptionDeclaration(OptionType.CompareText, val); .)
 
287
                                  )
 
288
                |
 
289
                "Infer" [ OptionValue<ref val> ]
 
290
                (. node = new OptionDeclaration(OptionType.Infer, val); .)
 
291
        )
 
292
        EndOfStmt
 
293
        (.
 
294
                if (node != null) {
 
295
                        node.StartLocation = startPos;
 
296
                        node.EndLocation   = t.Location;
 
297
                        AddChild(node);
 
298
                }
 
299
        .)
 
300
        .
 
301
 
 
302
OptionValue<ref bool val> =
 
303
        (
 
304
                "On" (. val = true; .)
 
305
        |
 
306
                "Off" (. val = false; .)
 
307
        )
 
308
        .
 
309
 
 
310
EndOfStmt =
 
311
        SYNC ( EOL | ":" )
 
312
.
 
313
 
 
314
ImportsStmt
 
315
        (.List<Using> usings = new List<Using>();
 
316
        .) =
 
317
        "Imports"
 
318
        (.
 
319
                Location startPos = t.Location;
 
320
                Using u;
 
321
        .)
 
322
        ImportClause<out u> (. if (u != null) { usings.Add(u); } .)
 
323
        {
 
324
                "," ImportClause<out u> (. if (u != null) { usings.Add(u); } .)
 
325
        }
 
326
        EndOfStmt
 
327
        (.
 
328
                UsingDeclaration usingDeclaration = new UsingDeclaration(usings);
 
329
                usingDeclaration.StartLocation = startPos;
 
330
                usingDeclaration.EndLocation   = t.Location;
 
331
                AddChild(usingDeclaration);
 
332
        .)
 
333
        .
 
334
 
 
335
ImportClause<out Using u>
 
336
        (.
 
337
                string qualident  = null;
 
338
                TypeReference aliasedType = null;
 
339
                u = null;
 
340
        .) =
 
341
        (
 
342
                Qualident<out qualident>
 
343
                [ "=" TypeName<out aliasedType> ]
 
344
                (.
 
345
                        if (qualident != null && qualident.Length > 0) {
 
346
                                if (aliasedType != null) {
 
347
                                        u = new Using(qualident, aliasedType);
 
348
                                } else {
 
349
                                        u = new Using(qualident);
 
350
                                }
 
351
                        }
 
352
                .)
 
353
        ) | ( (. string prefix = null; .)
 
354
                XmlOpenTag Identifier (. prefix = t.val; .) "=" LiteralString (. u = new Using(t.literalValue as string, prefix); .) XmlCloseTag
 
355
        )
 
356
        .
 
357
 
 
358
/* 6.4.2 */
 
359
NamespaceMemberDecl
 
360
        (.
 
361
                ModifierList m = new ModifierList();
 
362
                AttributeSection section;
 
363
                List<AttributeSection> attributes = new List<AttributeSection>();
 
364
                string qualident;
 
365
        .) =
 
366
        ("Namespace"
 
367
        (.
 
368
                Location startPos = t.Location;
 
369
        .)
 
370
        Qualident<out qualident>
 
371
        (.
 
372
                INode node =  new NamespaceDeclaration(qualident);
 
373
                node.StartLocation = startPos;
 
374
                AddChild(node);
 
375
                BlockStart(node);
 
376
        .)
 
377
        EndOfStmt
 
378
        NamespaceBody
 
379
        (.
 
380
                node.EndLocation = t.Location;
 
381
                BlockEnd();
 
382
        .)
 
383
        ) | (
 
384
        { AttributeSection<out section> (. attributes.Add(section); .) }
 
385
        { TypeModifier<m> } NonModuleDeclaration<m, attributes> )
 
386
        .
 
387
 
 
388
/* 4.9.1 */
 
389
TypeParameterList<List<TemplateDefinition> templates>
 
390
(.
 
391
        TemplateDefinition template;
 
392
.)
 
393
=
 
394
        [
 
395
                IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
 
396
                "(" "Of" TypeParameter<out template>
 
397
                (.
 
398
                        if (template != null) templates.Add(template);
 
399
                .)
 
400
                {
 
401
                        "," TypeParameter<out template>
 
402
                        (.
 
403
                                if (template != null) templates.Add(template);
 
404
                        .)
 
405
                }
 
406
                ")"
 
407
        ]
 
408
.
 
409
 
 
410
/* 4.9.1 */
 
411
TypeParameter<out TemplateDefinition template>
 
412
        (. VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location; .)
 
413
=
 
414
        (
 
415
                [ "In" (. modifier = VarianceModifier.Contravariant; .) | "Out" (. modifier = VarianceModifier.Covariant; .) ] Identifier (. template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; .)
 
416
                [TypeParameterConstraints<template>]
 
417
        )
 
418
        (.
 
419
                if (template != null) {
 
420
                        template.StartLocation = startLocation;
 
421
                        template.EndLocation = t.EndLocation;
 
422
                }
 
423
        .)
 
424
.
 
425
 
 
426
/* 4.9.2 */
 
427
TypeParameterConstraints<TemplateDefinition template>
 
428
(.
 
429
        TypeReference constraint;
 
430
.)
 
431
=
 
432
        "As"
 
433
        (
 
434
                "{"
 
435
                TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
 
436
                {
 
437
                        ","
 
438
                        TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
 
439
                }
 
440
                "}"
 
441
                | TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
 
442
        )
 
443
.
 
444
 
 
445
TypeParameterConstraint<out TypeReference constraint>
 
446
        (. constraint = null; Location startLocation = la.Location; .)
 
447
=
 
448
        "Class"         (. constraint = TypeReference.ClassConstraint; .)
 
449
        | "Structure"   (. constraint = TypeReference.StructConstraint; .)
 
450
        | "New"         (. constraint = TypeReference.NewConstraint; .)
 
451
        | TypeName<out constraint>
 
452
.
 
453
 
 
454
/* 6.4.2 */
 
455
NonModuleDeclaration<ModifierList m, List<AttributeSection> attributes>
 
456
                        (.
 
457
                                TypeReference typeRef = null;
 
458
                                List<TypeReference> baseInterfaces = null;
 
459
                        .) =
 
460
        (. m.Check(Modifiers.Classes); .)
 
461
        /* Spec, 7.5 */
 
462
        "Class"
 
463
                                        (. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
 
464
                                                newType.StartLocation = t.Location;
 
465
                                                AddChild(newType);
 
466
                                                BlockStart(newType);
 
467
                                                
 
468
                                                newType.Type       = ClassType.Class;
 
469
                                        .)
 
470
        Identifier                       (. newType.Name = t.val; .) 
 
471
        TypeParameterList<newType.Templates>
 
472
        EndOfStmt
 
473
        (. newType.BodyStartLocation = t.Location; .)
 
474
        [ ClassBaseType<out typeRef> (. SafeAdd(newType, newType.BaseTypes, typeRef); .) ]
 
475
        { TypeImplementsClause<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces); .) }
 
476
        ClassBody<newType>
 
477
        "End" "Class" (. newType.EndLocation = t.EndLocation; .)
 
478
        EndOfStmt
 
479
        (.
 
480
                BlockEnd();
 
481
        .)
 
482
        | "Module"
 
483
                (.
 
484
                        m.Check(Modifiers.VBModules);
 
485
                        TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
 
486
                        AddChild(newType);
 
487
                        BlockStart(newType);
 
488
                        newType.StartLocation = m.GetDeclarationLocation(t.Location);
 
489
                        newType.Type = ClassType.Module;
 
490
                .)
 
491
        Identifier                       (. newType.Name = t.val; .)
 
492
        EndOfStmt
 
493
        (. newType.BodyStartLocation = t.Location; .)
 
494
        ModuleBody<newType>
 
495
        (.
 
496
                BlockEnd();
 
497
        .)
 
498
        | "Structure"
 
499
                (.
 
500
                        m.Check(Modifiers.VBStructures);
 
501
                        TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
 
502
                        AddChild(newType);
 
503
                        BlockStart(newType);
 
504
                        newType.StartLocation = m.GetDeclarationLocation(t.Location);
 
505
                        newType.Type = ClassType.Struct;
 
506
                .)
 
507
        Identifier                       (. newType.Name = t.val; .) 
 
508
        TypeParameterList<newType.Templates>
 
509
        EndOfStmt
 
510
        (. newType.BodyStartLocation = t.Location; .)
 
511
        { TypeImplementsClause<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces);.) }
 
512
        StructureBody<newType>
 
513
        (.
 
514
                BlockEnd();
 
515
        .)
 
516
        | /* 7.4 */
 
517
        "Enum"
 
518
                (.
 
519
                        m.Check(Modifiers.VBEnums);
 
520
                        TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
 
521
                        newType.StartLocation = m.GetDeclarationLocation(t.Location);
 
522
                        AddChild(newType);
 
523
                        BlockStart(newType);
 
524
                        
 
525
                        newType.Type = ClassType.Enum;
 
526
                .)
 
527
        Identifier                       (. newType.Name = t.val; .) 
 
528
        [ "As" NonArrayTypeName<out typeRef, false> (. SafeAdd(newType, newType.BaseTypes, typeRef); .) ]
 
529
        EndOfStmt
 
530
        (. newType.BodyStartLocation = t.Location; .)
 
531
        EnumBody<newType>
 
532
        (.
 
533
                BlockEnd();
 
534
        .)
 
535
        | /* 7.8 */
 
536
        "Interface"
 
537
                (.
 
538
                        m.Check(Modifiers.VBInterfacs);
 
539
                        TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
 
540
                        newType.StartLocation = m.GetDeclarationLocation(t.Location);
 
541
                        AddChild(newType);
 
542
                        BlockStart(newType);
 
543
                        newType.Type = ClassType.Interface;
 
544
                .)
 
545
        Identifier                       (. newType.Name = t.val; .) 
 
546
        TypeParameterList<newType.Templates>
 
547
        EndOfStmt
 
548
        (. newType.BodyStartLocation = t.Location; .)
 
549
        { InterfaceBase<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces); .) }
 
550
        InterfaceBody<newType>
 
551
        (.
 
552
                BlockEnd();
 
553
        .)
 
554
        | /* 7.10 */
 
555
        "Delegate"
 
556
        (.
 
557
                m.Check(Modifiers.VBDelegates);
 
558
                DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
 
559
                delegateDeclr.ReturnType = new TypeReference("System.Void", true);
 
560
                delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
 
561
                List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
 
562
        .)
 
563
        (
 
564
                "Sub" Identifier (. delegateDeclr.Name = t.val; .)
 
565
                TypeParameterList<delegateDeclr.Templates>
 
566
                [ "(" [ FormalParameterList<p> ] ")" (. delegateDeclr.Parameters = p; .) ]
 
567
                |
 
568
                "Function" Identifier (. delegateDeclr.Name = t.val; .)
 
569
                TypeParameterList<delegateDeclr.Templates>
 
570
                [ "(" [ FormalParameterList<p> ] ")" (. delegateDeclr.Parameters = p; .) ]
 
571
                [ "As" (. TypeReference type; .) TypeName<out type> (. delegateDeclr.ReturnType = type; .)]
 
572
        )
 
573
        (.              delegateDeclr.EndLocation = t.EndLocation; .)
 
574
        EndOfStmt
 
575
        (.
 
576
                AddChild(delegateDeclr);
 
577
        .)
 
578
        .
 
579
 
 
580
NamespaceBody =
 
581
        { EndOfStmt } /* allow empty lines at begin of body */
 
582
        {
 
583
                NamespaceMemberDecl
 
584
                { EndOfStmt } /* allow empty lines in body */
 
585
        }
 
586
        "End" "Namespace"
 
587
        EndOfStmt
 
588
        .
 
589
 
 
590
ClassBody<TypeDeclaration newType>
 
591
        (. AttributeSection section; .) =
 
592
        { EndOfStmt } /* allow empty lines at begin of body */
 
593
        {
 
594
                (.List<AttributeSection> attributes = new List<AttributeSection>();
 
595
                        ModifierList m = new ModifierList();
 
596
                .)
 
597
                { AttributeSection<out section> (. attributes.Add(section); .) }
 
598
                { MemberModifier<m> }
 
599
                ClassMemberDecl<m, attributes>
 
600
                { EndOfStmt } /* allow empty lines in body */
 
601
        }
 
602
        .
 
603
 
 
604
StructureBody<TypeDeclaration newType>
 
605
        (. AttributeSection section; .) =
 
606
        { EndOfStmt } /* allow empty lines at begin of body */
 
607
        {
 
608
                (.List<AttributeSection> attributes = new List<AttributeSection>();
 
609
                        ModifierList m = new ModifierList();
 
610
                .)
 
611
                { AttributeSection<out section> (. attributes.Add(section); .) }
 
612
                { MemberModifier<m> }
 
613
                StructureMemberDecl<m, attributes>
 
614
                { EndOfStmt } /* allow empty lines in body */
 
615
        }
 
616
        "End" "Structure" (. newType.EndLocation = t.EndLocation; .)
 
617
        EndOfStmt
 
618
        .
 
619
 
 
620
/* 7.7.1 */
 
621
ModuleBody<TypeDeclaration newType>
 
622
        (. AttributeSection section; .) =
 
623
        { EndOfStmt } /* allow empty lines at begin of body */
 
624
        {
 
625
                (.List<AttributeSection> attributes = new List<AttributeSection>();
 
626
                        ModifierList m = new ModifierList();
 
627
                .)
 
628
                { AttributeSection<out section> (. attributes.Add(section); .) }
 
629
                { MemberModifier<m> }
 
630
                ClassMemberDecl<m, attributes>
 
631
                { EndOfStmt } /* allow empty lines in body */
 
632
        }
 
633
        "End" "Module" (. newType.EndLocation = t.EndLocation; .)
 
634
        EndOfStmt
 
635
        .
 
636
 
 
637
EnumBody<TypeDeclaration newType>
 
638
        (. FieldDeclaration f; .) =
 
639
        { EndOfStmt } /* allow empty lines at begin of body */
 
640
        {
 
641
                EnumMemberDecl<out f>
 
642
                (.
 
643
                        AddChild(f);
 
644
                .)
 
645
                { EndOfStmt } /* allow empty lines in body */
 
646
        }
 
647
        "End" "Enum" (. newType.EndLocation = t.EndLocation; .)
 
648
        EndOfStmt
 
649
        .
 
650
 
 
651
InterfaceBody<TypeDeclaration newType> =
 
652
        { EndOfStmt } /* allow empty lines at begin of body */
 
653
        {
 
654
                InterfaceMemberDecl
 
655
                { EndOfStmt } /* allow empty lines in body */
 
656
        }
 
657
        "End" "Interface" (. newType.EndLocation = t.EndLocation; .)
 
658
        EndOfStmt
 
659
        .
 
660
 
 
661
/* The information provided in the spec about */
 
662
/* interface declarations is wrong */
 
663
InterfaceMemberDecl
 
664
        (.
 
665
                TypeReference type =null;
 
666
                List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
 
667
                List<TemplateDefinition> templates = new List<TemplateDefinition>();
 
668
                AttributeSection section, returnTypeAttributeSection = null;
 
669
                ModifierList mod = new ModifierList();
 
670
                List<AttributeSection> attributes = new List<AttributeSection>();
 
671
                string name;
 
672
        .) =
 
673
        { AttributeSection<out section>                 (. attributes.Add(section); .) }
 
674
        /* this is different to c#: not only the Shadows modifier is allowed, */
 
675
        /*  also member modifiers like overloads etc. */
 
676
        { MemberModifier<mod> }
 
677
        (
 
678
                "Event"
 
679
                (.
 
680
                        mod.Check(Modifiers.VBInterfaceEvents);
 
681
                        Location startLocation = t.Location;
 
682
                .)
 
683
                Identifier (. name = t.val; .)
 
684
                [ "(" [ FormalParameterList<p> ] ")" ]
 
685
                [ "As" TypeName<out type> ]
 
686
                EndOfStmt
 
687
                (.
 
688
                        EventDeclaration ed = new EventDeclaration {
 
689
                                Name = name, TypeReference = type, Modifier = mod.Modifier,
 
690
                                Parameters = p, Attributes = attributes,
 
691
                                StartLocation = startLocation, EndLocation = t.EndLocation
 
692
                        };
 
693
                        AddChild(ed);
 
694
                .)
 
695
                |
 
696
                "Sub"
 
697
                (.
 
698
                        Location startLocation =  t.Location;
 
699
                        mod.Check(Modifiers.VBInterfaceMethods);
 
700
                .)
 
701
                Identifier (. name = t.val; .)
 
702
                TypeParameterList<templates>
 
703
                [ "(" [ FormalParameterList<p> ] ")" ]
 
704
                EndOfStmt
 
705
                (.
 
706
                        MethodDeclaration md = new MethodDeclaration {
 
707
                                Name = name, 
 
708
                                Modifier = mod.Modifier, 
 
709
                                Parameters = p,
 
710
                                Attributes = attributes,
 
711
                                TypeReference = new TypeReference("System.Void", true),
 
712
                                StartLocation = startLocation,
 
713
                                EndLocation = t.EndLocation,
 
714
                                Templates = templates
 
715
                        };
 
716
                        AddChild(md);
 
717
                .)
 
718
                |
 
719
                "Function"
 
720
                (.
 
721
                        mod.Check(Modifiers.VBInterfaceMethods);
 
722
                        Location startLocation = t.Location;
 
723
                .)
 
724
                Identifier (. name = t.val; .)
 
725
                TypeParameterList<templates>
 
726
                [ "(" [ FormalParameterList<p> ] ")" ]
 
727
                [ "As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
 
728
                (.
 
729
                        if(type == null) {
 
730
                                type = new TypeReference("System.Object", true);
 
731
                        }
 
732
                        MethodDeclaration md = new MethodDeclaration {
 
733
                                Name = name, Modifier = mod.Modifier, 
 
734
                                TypeReference = type, Parameters = p, Attributes = attributes
 
735
                        };
 
736
                        if (returnTypeAttributeSection != null) {
 
737
                                returnTypeAttributeSection.AttributeTarget = "return";
 
738
                                md.Attributes.Add(returnTypeAttributeSection);
 
739
                        }
 
740
                        md.StartLocation = startLocation;
 
741
                        md.EndLocation = t.EndLocation;
 
742
                        md.Templates = templates;
 
743
                        AddChild(md);
 
744
                .)
 
745
                EndOfStmt
 
746
                |
 
747
                "Property"
 
748
                (.
 
749
                        Location startLocation = t.Location;
 
750
                        mod.Check(Modifiers.VBInterfaceProperties);
 
751
                .)
 
752
                Identifier      (. name = t.val;  .)
 
753
                [ "(" [ FormalParameterList<p> ] ")" ]
 
754
                [ "As" TypeName<out type> ]
 
755
                (.
 
756
                        if(type == null) {
 
757
                                type = new TypeReference("System.Object", true);
 
758
                        }
 
759
                .)
 
760
                EndOfStmt
 
761
                (.
 
762
                        PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
 
763
                        pd.Parameters = p;
 
764
                        pd.EndLocation = t.EndLocation;
 
765
                        pd.StartLocation = startLocation;
 
766
                        AddChild(pd);
 
767
                .)
 
768
        )
 
769
        | /* inner type declarations */
 
770
        NonModuleDeclaration<mod, attributes>
 
771
        .
 
772
 
 
773
/* 7.4.1 */
 
774
EnumMemberDecl<out FieldDeclaration f>
 
775
        (.
 
776
                Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
 
777
                AttributeSection section = null;
 
778
                VariableDeclaration varDecl = null;
 
779
        .) =
 
780
        { AttributeSection<out section> (. attributes.Add(section); .) }
 
781
        Identifier
 
782
        (.
 
783
                f = new FieldDeclaration(attributes);
 
784
                varDecl = new VariableDeclaration(t.val);
 
785
                f.Fields.Add(varDecl);
 
786
                f.StartLocation = varDecl.StartLocation = t.Location;
 
787
        .)
 
788
        [ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
 
789
        (. f.EndLocation = varDecl.EndLocation = t.EndLocation; .)
 
790
        EndOfStmt
 
791
.
 
792
 
 
793
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
 
794
        StructureMemberDecl<m, attributes>
 
795
        .
 
796
 
 
797
ClassBaseType<out TypeReference typeRef>
 
798
(.
 
799
        typeRef = null;
 
800
.) =
 
801
        "Inherits"
 
802
        TypeName<out typeRef>
 
803
        EndOfStmt
 
804
.
 
805
 
 
806
/* 7.6.1 */
 
807
StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
 
808
        (.
 
809
                TypeReference type = null;
 
810
                List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
 
811
                Statement stmt = null;
 
812
                List<VariableDeclaration> variableDeclarators = new List<VariableDeclaration>();
 
813
                List<TemplateDefinition> templates = new List<TemplateDefinition>();
 
814
        .)
 
815
=
 
816
        NonModuleDeclaration<m, attributes>
 
817
| /* 9.2.1 */
 
818
        "Sub"
 
819
        (.
 
820
                Location startPos = t.Location;
 
821
        .)
 
822
        (
 
823
                (.
 
824
                        string name = String.Empty;
 
825
                        MethodDeclaration methodDeclaration; List<string> handlesClause = null;
 
826
                        List<InterfaceImplementation> implementsClause = null;
 
827
                .)
 
828
                Identifier
 
829
                (.
 
830
                        name = t.val;
 
831
                        m.Check(Modifiers.VBMethods);
 
832
                .)
 
833
                TypeParameterList<templates>
 
834
                [ "(" [ FormalParameterList<p> ] ")" ]
 
835
                [
 
836
                        (
 
837
                                ImplementsClause<out implementsClause>
 
838
                                |
 
839
                                HandlesClause<out handlesClause>
 
840
                        )
 
841
                ]
 
842
                (. Location endLocation = t.EndLocation; .)
 
843
                (
 
844
                        /* abstract methods without a body */
 
845
                        IF(IsMustOverride(m))
 
846
                        EndOfStmt
 
847
                        (.
 
848
                                methodDeclaration = new MethodDeclaration {
 
849
                                        Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
 
850
                                        StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
 
851
                                        TypeReference = new TypeReference("System.Void", true),
 
852
                                        Templates = templates,
 
853
                                        HandlesClause = handlesClause,
 
854
                                        InterfaceImplementations = implementsClause
 
855
                                };
 
856
                                AddChild(methodDeclaration);
 
857
                        .)
 
858
                |
 
859
                        EOL
 
860
                        (.
 
861
                                methodDeclaration = new MethodDeclaration {
 
862
                                        Name = name, Modifier = m.Modifier, Parameters = p, Attributes = attributes,
 
863
                                        StartLocation = m.GetDeclarationLocation(startPos), EndLocation = endLocation,
 
864
                                        TypeReference = new TypeReference("System.Void", true),
 
865
                                        Templates = templates,
 
866
                                        HandlesClause = handlesClause,
 
867
                                        InterfaceImplementations = implementsClause
 
868
                                };
 
869
                                AddChild(methodDeclaration);
 
870
                        .)
 
871
                        
 
872
                        (. if (ParseMethodBodies) { .)
 
873
                                Block<out stmt>
 
874
                                "End" "Sub"
 
875
                        (. } else {
 
876
                                // don't parse method body
 
877
                                lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
 
878
                           }
 
879
                        .)
 
880
                        
 
881
                        (. methodDeclaration.Body  = (BlockStatement)stmt; .)
 
882
                        (. methodDeclaration.Body.EndLocation = t.EndLocation; .)
 
883
                        EndOfStmt
 
884
                )
 
885
                /* 9.3 */
 
886
                | "New" [ "(" [ FormalParameterList<p> ] ")" ]
 
887
                (. m.Check(Modifiers.Constructors); .)
 
888
                (. Location constructorEndLocation = t.EndLocation; .)
 
889
                EOL
 
890
                
 
891
                (. if (ParseMethodBodies) { .)
 
892
                        Block<out stmt>
 
893
                        "End" "Sub"
 
894
                (. } else {
 
895
                        // don't parse method body
 
896
                        lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
 
897
                   }
 
898
                .)
 
899
                
 
900
                (. Location endLocation = t.EndLocation; .)
 
901
                EndOfStmt
 
902
                (.
 
903
                        ConstructorDeclaration cd = new ConstructorDeclaration("New", m.Modifier, p, attributes);
 
904
                        cd.StartLocation = m.GetDeclarationLocation(startPos);
 
905
                        cd.EndLocation   = constructorEndLocation;
 
906
                        cd.Body = (BlockStatement)stmt;
 
907
                        cd.Body.EndLocation   = endLocation;
 
908
                        AddChild(cd);
 
909
                .)
 
910
        )
 
911
|
 
912
        /* 9.2.1 */
 
913
        "Function"
 
914
        (.
 
915
                m.Check(Modifiers.VBMethods);
 
916
                string name = String.Empty;
 
917
                Location startPos = t.Location;
 
918
                MethodDeclaration methodDeclaration;List<string> handlesClause = null;
 
919
                List<InterfaceImplementation> implementsClause = null;
 
920
                AttributeSection returnTypeAttributeSection = null;
 
921
        .)
 
922
        Identifier                      (. name = t.val; .)
 
923
        TypeParameterList<templates>
 
924
        [ "("   [ FormalParameterList<p> ] ")" ]
 
925
        ["As"  {
 
926
                                AttributeSection<out returnTypeAttributeSection>
 
927
                                (.
 
928
                                        if (returnTypeAttributeSection != null) {
 
929
                                                returnTypeAttributeSection.AttributeTarget = "return";
 
930
                                                attributes.Add(returnTypeAttributeSection);
 
931
                                        }
 
932
                                .)
 
933
                        }
 
934
        TypeName<out type> ]
 
935
        (.
 
936
                if(type == null) {
 
937
                        type = new TypeReference("System.Object", true);
 
938
                }
 
939
        .)
 
940
        [
 
941
                (
 
942
                        ImplementsClause<out implementsClause>
 
943
                        |
 
944
                        HandlesClause<out handlesClause>
 
945
                )
 
946
        ]
 
947
        (. Location endLocation = t.EndLocation; .)
 
948
        (
 
949
                /* abstract methods without a body */
 
950
                IF(IsMustOverride(m))
 
951
                EndOfStmt
 
952
                        (.
 
953
                                methodDeclaration = new MethodDeclaration {
 
954
                                        Name = name, Modifier = m.Modifier, TypeReference = type,
 
955
                                        Parameters = p, Attributes = attributes,
 
956
                                        StartLocation = m.GetDeclarationLocation(startPos),
 
957
                                        EndLocation   = endLocation,
 
958
                                        HandlesClause = handlesClause,
 
959
                                        Templates     = templates,
 
960
                                        InterfaceImplementations = implementsClause
 
961
                                };
 
962
                                
 
963
                                AddChild(methodDeclaration);
 
964
                        .)
 
965
                |
 
966
                        EOL
 
967
                        (.
 
968
                                methodDeclaration = new MethodDeclaration {
 
969
                                        Name = name, Modifier = m.Modifier, TypeReference = type,
 
970
                                        Parameters = p, Attributes = attributes,
 
971
                                        StartLocation = m.GetDeclarationLocation(startPos),
 
972
                                        EndLocation   = endLocation,
 
973
                                        Templates     = templates,
 
974
                                        HandlesClause = handlesClause,
 
975
                                        InterfaceImplementations = implementsClause
 
976
                                };
 
977
                                
 
978
                                AddChild(methodDeclaration);
 
979
                        
 
980
                                if (ParseMethodBodies) { .)
 
981
                                        Block<out stmt>
 
982
                                        "End" "Function"
 
983
                        (.      } else {
 
984
                                        // don't parse method body
 
985
                                        lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
 
986
                                }
 
987
                                methodDeclaration.Body = (BlockStatement)stmt;
 
988
                                methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
 
989
                                methodDeclaration.Body.EndLocation   = t.EndLocation;
 
990
                        .)
 
991
                        EndOfStmt
 
992
        )
 
993
|
 
994
        /* 9.2.2. */
 
995
        "Declare"
 
996
        (.
 
997
                m.Check(Modifiers.VBExternalMethods);
 
998
                Location startPos = t.Location;
 
999
                CharsetModifier charsetModifer = CharsetModifier.None;
 
1000
                string library = String.Empty;
 
1001
                string alias = null;
 
1002
                string name = String.Empty;
 
1003
        .)
 
1004
        [Charset<out charsetModifer> ]
 
1005
        (
 
1006
                        "Sub"
 
1007
                        Identifier                              (. name = t.val; .)
 
1008
                        "Lib" LiteralString             (. library = t.literalValue as string; .)
 
1009
                        ["Alias" LiteralString  (. alias = t.literalValue as string; .)]
 
1010
                        [ "("   [ FormalParameterList<p> ] ")" ]
 
1011
                        EndOfStmt
 
1012
                        (.
 
1013
                                DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, null, p, attributes, library, alias, charsetModifer);
 
1014
                                declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
 
1015
                                declareDeclaration.EndLocation   = t.EndLocation;
 
1016
                                AddChild(declareDeclaration);
 
1017
                        .)
 
1018
                |
 
1019
                        "Function" 
 
1020
                        Identifier                                      (. name = t.val; .)
 
1021
                        "Lib" LiteralString             (. library = t.literalValue as string; .)
 
1022
                        ["Alias" LiteralString  (. alias = t.literalValue as string; .)]
 
1023
                        [ "("   [ FormalParameterList<p> ] ")" ]
 
1024
                        ["As" TypeName<out type> ]
 
1025
                        EndOfStmt
 
1026
                        (.
 
1027
                                DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
 
1028
                                declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
 
1029
                                declareDeclaration.EndLocation   = t.EndLocation;
 
1030
                                AddChild(declareDeclaration);
 
1031
                        .)
 
1032
                )
 
1033
|
 
1034
        /* 9. 4 */
 
1035
        "Event"
 
1036
        (.
 
1037
                m.Check(Modifiers.VBEvents);
 
1038
                Location startPos = t.Location;
 
1039
                EventDeclaration eventDeclaration;
 
1040
                string name = String.Empty;
 
1041
                List<InterfaceImplementation> implementsClause = null;
 
1042
        .)
 
1043
        Identifier (. name= t.val; .)
 
1044
        (
 
1045
                "As" TypeName<out type>
 
1046
                |
 
1047
                [ "("   [ FormalParameterList<p> ] ")" ]
 
1048
        )
 
1049
        [ ImplementsClause<out implementsClause> ]
 
1050
        (.
 
1051
                eventDeclaration = new EventDeclaration {
 
1052
                        Name = name, TypeReference = type, Modifier = m.Modifier, 
 
1053
                        Parameters = p, Attributes = attributes, InterfaceImplementations = implementsClause,
 
1054
                        StartLocation = m.GetDeclarationLocation(startPos),
 
1055
                        EndLocation = t.EndLocation
 
1056
                };
 
1057
                AddChild(eventDeclaration);
 
1058
        .)
 
1059
        EndOfStmt
 
1060
| /* 9.6 */
 
1061
        (.
 
1062
                m.Check(Modifiers.Fields);
 
1063
                FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
 
1064
        .)
 
1065
        IdentifierForFieldDeclaration (. string name = t.val; .)
 
1066
        (. fd.StartLocation = m.GetDeclarationLocation(t.Location); .)
 
1067
        
 
1068
        VariableDeclaratorPartAfterIdentifier<variableDeclarators, name>
 
1069
        { "," VariableDeclarator<variableDeclarators> }
 
1070
        EndOfStmt
 
1071
        (.
 
1072
                fd.EndLocation = t.EndLocation;
 
1073
                fd.Fields = variableDeclarators;
 
1074
                AddChild(fd);
 
1075
        .)
 
1076
        | /* 9.4 */
 
1077
        (. m.Check(Modifiers.Fields); .)
 
1078
        "Const" (.  m.Add(Modifiers.Const, t.Location);  .)
 
1079
        (.
 
1080
                FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
 
1081
                fd.StartLocation = m.GetDeclarationLocation(t.Location);
 
1082
                List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
 
1083
        .)
 
1084
        ConstantDeclarator<constantDeclarators>
 
1085
        { "," ConstantDeclarator<constantDeclarators> }
 
1086
        (.
 
1087
                fd.Fields = constantDeclarators;
 
1088
                fd.EndLocation = t.Location;
 
1089
        .)
 
1090
        EndOfStmt
 
1091
        (.
 
1092
                fd.EndLocation = t.EndLocation;
 
1093
                AddChild(fd);
 
1094
        .)
 
1095
| /* 9.7 */
 
1096
        "Property"
 
1097
        (.
 
1098
                m.Check(Modifiers.VBProperties);
 
1099
                Location startPos = t.Location;
 
1100
                List<InterfaceImplementation> implementsClause = null;
 
1101
                AttributeSection returnTypeAttributeSection = null;
 
1102
                Expression initializer = null;
 
1103
        .)
 
1104
        Identifier (. string propertyName = t.val; .)
 
1105
        [ "("   [ FormalParameterList<p> ] ")" ]
 
1106
        [
 
1107
                "As" {
 
1108
                                AttributeSection<out returnTypeAttributeSection>
 
1109
                                (.
 
1110
                                        if (returnTypeAttributeSection != null) {
 
1111
                                                returnTypeAttributeSection.AttributeTarget = "return";
 
1112
                                                attributes.Add(returnTypeAttributeSection);
 
1113
                                        }
 
1114
                                .)
 
1115
                }
 
1116
                (
 
1117
                        IF (IsNewExpression()) ObjectCreateExpression<out initializer>
 
1118
                        (.
 
1119
                                if (initializer is ObjectCreateExpression) {
 
1120
                                        type = ((ObjectCreateExpression)initializer).CreateType.Clone();
 
1121
                                } else {
 
1122
                                        type = ((ArrayCreateExpression)initializer).CreateType.Clone();
 
1123
                                }
 
1124
                        .)
 
1125
                |
 
1126
                        TypeName<out type>
 
1127
                )
 
1128
        ]
 
1129
        [ "=" Expr<out initializer> ]
 
1130
        [ ImplementsClause<out implementsClause> ]
 
1131
        EndOfStmt
 
1132
        (
 
1133
        /* abstract properties without a body */
 
1134
        IF(IsMustOverride(m) || IsAutomaticProperty())
 
1135
                (.
 
1136
                        PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
 
1137
                        pDecl.StartLocation = m.GetDeclarationLocation(startPos);
 
1138
                        pDecl.EndLocation   = t.Location;
 
1139
                        pDecl.TypeReference = type;
 
1140
                        pDecl.InterfaceImplementations = implementsClause;
 
1141
                        pDecl.Parameters = p;
 
1142
                        if (initializer != null)
 
1143
                                pDecl.Initializer = initializer;
 
1144
                        AddChild(pDecl);
 
1145
                .)
 
1146
        |
 
1147
                (.
 
1148
                        PropertyDeclaration pDecl = new PropertyDeclaration(propertyName, type, m.Modifier, attributes);
 
1149
                        pDecl.StartLocation = m.GetDeclarationLocation(startPos);
 
1150
                        pDecl.EndLocation   = t.Location;
 
1151
                        pDecl.BodyStart   = t.Location;
 
1152
                        pDecl.TypeReference = type;
 
1153
                        pDecl.InterfaceImplementations = implementsClause;
 
1154
                        pDecl.Parameters = p;
 
1155
                        PropertyGetRegion getRegion;
 
1156
                        PropertySetRegion setRegion;
 
1157
                .)
 
1158
                AccessorDecls<out getRegion, out setRegion> 
 
1159
                "End" "Property"
 
1160
                EndOfStmt
 
1161
                (.
 
1162
                        pDecl.GetRegion = getRegion;
 
1163
                        pDecl.SetRegion = setRegion;
 
1164
                        pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
 
1165
                        AddChild(pDecl);
 
1166
                .)
 
1167
        )
 
1168
|
 
1169
        "Custom" (. Location startPos = t.Location; .) "Event"
 
1170
        (.
 
1171
                m.Check(Modifiers.VBCustomEvents);
 
1172
                EventAddRemoveRegion eventAccessorDeclaration;
 
1173
                EventAddRegion addHandlerAccessorDeclaration = null;
 
1174
                EventRemoveRegion removeHandlerAccessorDeclaration = null;
 
1175
                EventRaiseRegion raiseEventAccessorDeclaration = null;
 
1176
                List<InterfaceImplementation> implementsClause = null;
 
1177
        .)
 
1178
        Identifier (. string customEventName = t.val; .)
 
1179
        "As" TypeName<out type>
 
1180
        [ ImplementsClause<out implementsClause> ]
 
1181
        EndOfStmt
 
1182
        {
 
1183
                EventAccessorDeclaration<out eventAccessorDeclaration>
 
1184
                (.
 
1185
                        if(eventAccessorDeclaration is EventAddRegion)
 
1186
                        {
 
1187
                                addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
 
1188
                        }
 
1189
                        else if(eventAccessorDeclaration is EventRemoveRegion)
 
1190
                        {
 
1191
                                removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
 
1192
                        }
 
1193
                        else if(eventAccessorDeclaration is EventRaiseRegion)
 
1194
                        {
 
1195
                                raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
 
1196
                        }
 
1197
                .)
 
1198
        }
 
1199
        "End" "Event" EndOfStmt
 
1200
        (.
 
1201
                if(addHandlerAccessorDeclaration == null)
 
1202
                {
 
1203
                        Error("Need to provide AddHandler accessor.");
 
1204
                }
 
1205
                
 
1206
                if(removeHandlerAccessorDeclaration == null)
 
1207
                {
 
1208
                        Error("Need to provide RemoveHandler accessor.");
 
1209
                }
 
1210
                
 
1211
                if(raiseEventAccessorDeclaration == null)
 
1212
                {
 
1213
                        Error("Need to provide RaiseEvent accessor.");
 
1214
                }
 
1215
        
 
1216
                EventDeclaration decl = new EventDeclaration {
 
1217
                        TypeReference = type, Name = customEventName, Modifier = m.Modifier,
 
1218
                        Attributes = attributes,
 
1219
                        StartLocation = m.GetDeclarationLocation(startPos),
 
1220
                        EndLocation = t.EndLocation,
 
1221
                        AddRegion = addHandlerAccessorDeclaration,
 
1222
                        RemoveRegion = removeHandlerAccessorDeclaration,
 
1223
                        RaiseRegion = raiseEventAccessorDeclaration
 
1224
                };
 
1225
                AddChild(decl);
 
1226
        .)
 
1227
|   (. ConversionType opConversionType = ConversionType.None; .)
 
1228
        [ "Widening"            (. opConversionType = ConversionType.Implicit; .)
 
1229
        | "Narrowing"           (. opConversionType = ConversionType.Explicit;.) ]
 
1230
        "Operator"
 
1231
        (.
 
1232
                m.Check(Modifiers.VBOperators);
 
1233
                Location startPos = t.Location;
 
1234
                TypeReference returnType = NullTypeReference.Instance;
 
1235
                TypeReference operandType = NullTypeReference.Instance;
 
1236
                OverloadableOperatorType operatorType;
 
1237
                AttributeSection section;
 
1238
                ParameterDeclarationExpression param;
 
1239
                List<ParameterDeclarationExpression> parameters = new List<ParameterDeclarationExpression>();
 
1240
        .)
 
1241
        OverloadableOperator<out operatorType>
 
1242
        "("
 
1243
        FormalParameter<out param>
 
1244
        (. if (param != null) parameters.Add(param); .)
 
1245
        [
 
1246
                "," FormalParameter<out param>
 
1247
                (. if (param != null) parameters.Add(param); .)
 
1248
        ]
 
1249
        ")"
 
1250
        (. Location endPos = t.EndLocation; .)
 
1251
        [ "As" { AttributeSection<out section>
 
1252
                        (. if (section != null) {
 
1253
                                        section.AttributeTarget = "return";
 
1254
                                        attributes.Add(section);
 
1255
                  } .)
 
1256
                        } TypeName<out returnType> (. endPos = t.EndLocation; .) ]
 
1257
        EOL
 
1258
        Block<out stmt> "End" "Operator" EndOfStmt
 
1259
        (.
 
1260
                OperatorDeclaration operatorDeclaration = new OperatorDeclaration {
 
1261
                        Modifier = m.Modifier,
 
1262
                        Attributes = attributes,
 
1263
                        Parameters = parameters,
 
1264
                        TypeReference = returnType,
 
1265
                        OverloadableOperator = operatorType,
 
1266
                        ConversionType = opConversionType,
 
1267
                        Body = (BlockStatement)stmt,
 
1268
                        StartLocation = m.GetDeclarationLocation(startPos),
 
1269
                        EndLocation = endPos
 
1270
                };
 
1271
                operatorDeclaration.Body.StartLocation = startPos;
 
1272
                operatorDeclaration.Body.EndLocation = t.Location;
 
1273
                AddChild(operatorDeclaration);
 
1274
        .)
 
1275
.
 
1276
 
 
1277
OverloadableOperator<out OverloadableOperatorType operatorType>
 
1278
        (. operatorType = OverloadableOperatorType.None; .)
 
1279
        =
 
1280
        "+"                     (. operatorType = OverloadableOperatorType.Add; .)
 
1281
        |
 
1282
        "-"                     (. operatorType = OverloadableOperatorType.Subtract; .)
 
1283
        |
 
1284
        "*"                     (. operatorType = OverloadableOperatorType.Multiply; .)
 
1285
        | 
 
1286
        "/"                     (. operatorType = OverloadableOperatorType.Divide; .)
 
1287
        | 
 
1288
        "\\"            (. operatorType = OverloadableOperatorType.DivideInteger; .)
 
1289
        | 
 
1290
        "&"                     (. operatorType = OverloadableOperatorType.Concat; .)
 
1291
        | 
 
1292
        "Like"          (. operatorType = OverloadableOperatorType.Like; .)
 
1293
        | 
 
1294
        "Mod"           (. operatorType = OverloadableOperatorType.Modulus; .)
 
1295
        | 
 
1296
        "And"           (. operatorType = OverloadableOperatorType.BitwiseAnd; .)
 
1297
        |
 
1298
        "Or"            (. operatorType = OverloadableOperatorType.BitwiseOr; .)
 
1299
        |
 
1300
        "Xor"           (. operatorType = OverloadableOperatorType.ExclusiveOr; .)
 
1301
        |
 
1302
        "^"                     (. operatorType = OverloadableOperatorType.Power; .)
 
1303
        |
 
1304
        "<<"            (. operatorType = OverloadableOperatorType.ShiftLeft; .)
 
1305
        |
 
1306
        ">>"            (. operatorType = OverloadableOperatorType.ShiftRight; .)
 
1307
        |
 
1308
        "="                     (. operatorType = OverloadableOperatorType.Equality; .)
 
1309
        |
 
1310
        "<>"            (. operatorType = OverloadableOperatorType.InEquality; .)
 
1311
        |
 
1312
        "<"                     (. operatorType = OverloadableOperatorType.LessThan; .)
 
1313
        |
 
1314
        "<="            (. operatorType = OverloadableOperatorType.LessThanOrEqual; .)
 
1315
        |
 
1316
        ">"                     (. operatorType = OverloadableOperatorType.GreaterThan; .)
 
1317
        |
 
1318
        ">="            (. operatorType = OverloadableOperatorType.GreaterThanOrEqual; .)
 
1319
        |
 
1320
        "CType"         (. operatorType = OverloadableOperatorType.CType; .)
 
1321
        |
 
1322
        Identifier
 
1323
        (.
 
1324
                string opName = t.val; 
 
1325
                if (string.Equals(opName, "istrue", StringComparison.InvariantCultureIgnoreCase)) {
 
1326
                        operatorType = OverloadableOperatorType.IsTrue;
 
1327
                } else if (string.Equals(opName, "isfalse", StringComparison.InvariantCultureIgnoreCase)) {
 
1328
                        operatorType = OverloadableOperatorType.IsFalse;
 
1329
                } else {
 
1330
                        Error("Invalid operator. Possible operators are '+', '-', 'Not', 'IsTrue', 'IsFalse'.");
 
1331
                }
 
1332
        .)
 
1333
        .
 
1334
 
 
1335
EventAccessorDeclaration<out EventAddRemoveRegion eventAccessorDeclaration>
 
1336
        (.
 
1337
                Statement stmt = null;
 
1338
                List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
 
1339
                AttributeSection section;
 
1340
                List<AttributeSection> attributes = new List<AttributeSection>();
 
1341
                eventAccessorDeclaration = null;
 
1342
        .) =
 
1343
        { AttributeSection<out section> (. attributes.Add(section); .) }
 
1344
        (
 
1345
                        "AddHandler" [ "(" [ FormalParameterList<p> ] ")" ] EOL
 
1346
                        Block<out stmt> "End" "AddHandler" EndOfStmt
 
1347
                        (.
 
1348
                                eventAccessorDeclaration = new EventAddRegion(attributes);
 
1349
                                eventAccessorDeclaration.Block = (BlockStatement)stmt;
 
1350
                                eventAccessorDeclaration.Parameters = p;
 
1351
                        .)
 
1352
                |
 
1353
                        "RemoveHandler" [ "(" [ FormalParameterList<p> ] ")" ] EOL
 
1354
                        Block<out stmt> "End" "RemoveHandler" EndOfStmt
 
1355
                        (.
 
1356
                                eventAccessorDeclaration = new EventRemoveRegion(attributes);
 
1357
                                eventAccessorDeclaration.Block = (BlockStatement)stmt;
 
1358
                                eventAccessorDeclaration.Parameters = p;
 
1359
                        .)
 
1360
                |
 
1361
                        "RaiseEvent" [ "(" [ FormalParameterList<p> ] ")" ] EOL
 
1362
                        Block<out stmt> "End" "RaiseEvent" EndOfStmt
 
1363
                        (.
 
1364
                                eventAccessorDeclaration = new EventRaiseRegion(attributes);
 
1365
                                eventAccessorDeclaration.Block = (BlockStatement)stmt;
 
1366
                                eventAccessorDeclaration.Parameters = p;
 
1367
                        .)
 
1368
        )
 
1369
        .
 
1370
 
 
1371
/* 9.7 */
 
1372
AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
 
1373
        (.
 
1374
                List<AttributeSection> attributes = new List<AttributeSection>();
 
1375
                AttributeSection section;
 
1376
                getBlock = null;
 
1377
                setBlock = null; 
 
1378
        .) =
 
1379
        { AttributeSection<out section> (. attributes.Add(section); .) }
 
1380
        (
 
1381
                GetAccessorDecl<out getBlock, attributes>
 
1382
                [
 
1383
                        (. attributes = new List<AttributeSection>(); .)
 
1384
                        { AttributeSection<out section> (. attributes.Add(section); .) }
 
1385
                        SetAccessorDecl<out setBlock, attributes>
 
1386
                ]
 
1387
                |
 
1388
                SetAccessorDecl<out setBlock, attributes>
 
1389
                [
 
1390
                        (. attributes = new List<AttributeSection>(); .)
 
1391
                        { AttributeSection<out section> (. attributes.Add(section); .) }
 
1392
                        GetAccessorDecl<out getBlock, attributes>
 
1393
                ]
 
1394
        )
 
1395
        .
 
1396
 
 
1397
/* 9.7.1 */
 
1398
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes>
 
1399
        (. Statement stmt = null; Modifiers m; .)
 
1400
=
 
1401
        PropertyAccessorAccessModifier<out m>
 
1402
        "Get"
 
1403
        (. Location startLocation = t.Location; .)
 
1404
        EOL
 
1405
        Block<out stmt>
 
1406
        (. getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); .)
 
1407
        "End" "Get"
 
1408
        (. getBlock.Modifier = m; .)
 
1409
        (. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .)
 
1410
        EndOfStmt
 
1411
        .
 
1412
 
 
1413
/* 9.7.2 */
 
1414
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes>
 
1415
        (.
 
1416
                Statement stmt = null;
 
1417
                List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
 
1418
                Modifiers m;
 
1419
        .)
 
1420
=
 
1421
        PropertyAccessorAccessModifier<out m>
 
1422
        "Set"
 
1423
        (. Location startLocation = t.Location; .)
 
1424
        [ "("   [ FormalParameterList<p> ] ")" ]
 
1425
        EOL
 
1426
        Block<out stmt>
 
1427
        (.
 
1428
                setBlock = new PropertySetRegion((BlockStatement)stmt, attributes);
 
1429
                setBlock.Modifier = m;
 
1430
                setBlock.Parameters = p;
 
1431
        .)
 
1432
        "End" "Set"
 
1433
        (. setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; .)
 
1434
        EndOfStmt
 
1435
        .
 
1436
 
 
1437
/* 9.5 */
 
1438
ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
 
1439
        (.
 
1440
                Expression expr = null;
 
1441
                TypeReference type = null;
 
1442
                string name = String.Empty;
 
1443
                Location location;
 
1444
        .) =
 
1445
        Identifier                              (. name = t.val; location = t.Location; .)
 
1446
        ["As" TypeName<out type> ]
 
1447
        "=" Expr<out expr>
 
1448
        (.
 
1449
                VariableDeclaration f = new VariableDeclaration(name, expr);
 
1450
                f.TypeReference = type;
 
1451
                f.StartLocation = location;
 
1452
                constantDeclaration.Add(f);
 
1453
        .)
 
1454
.
 
1455
 
 
1456
/* 9.6 */
 
1457
VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
 
1458
=
 
1459
        Identifier (. string name = t.val; .)
 
1460
        VariableDeclaratorPartAfterIdentifier<fieldDeclaration, name>
 
1461
.
 
1462
 
 
1463
VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration, string name>
 
1464
        (.
 
1465
                Expression expr = null;
 
1466
                TypeReference type = null;
 
1467
                ArrayList rank = null;
 
1468
                List<Expression> dimension = null;
 
1469
                Location startLocation = t.Location;
 
1470
        .) =
 
1471
        [ IF(IsSize() && !IsDims()) ArrayInitializationModifier<out dimension> ]
 
1472
        [ IF(IsDims())              ArrayNameModifier<out rank> ]
 
1473
        (
 
1474
                IF (IsObjectCreation()) "As" ObjectCreateExpression<out expr>
 
1475
                (.
 
1476
                        if (expr is ObjectCreateExpression) {
 
1477
                                type = ((ObjectCreateExpression)expr).CreateType.Clone();
 
1478
                        } else {
 
1479
                                type = ((ArrayCreateExpression)expr).CreateType.Clone();
 
1480
                        }
 
1481
                .)
 
1482
        |
 
1483
                [ "As" TypeName<out type>
 
1484
                  (.
 
1485
                        if (type != null) {
 
1486
                                for (int i = fieldDeclaration.Count - 1; i >= 0; i--) {
 
1487
                                        VariableDeclaration vd = fieldDeclaration[i];
 
1488
                                        if (vd.TypeReference.Type.Length > 0) break;
 
1489
                                        TypeReference newType = type.Clone();
 
1490
                                        newType.RankSpecifier = vd.TypeReference.RankSpecifier;
 
1491
                                        vd.TypeReference = newType;
 
1492
                                }
 
1493
                        }
 
1494
                  .)
 
1495
                ]
 
1496
                (.
 
1497
                        if (type == null && (dimension != null || rank != null)) {
 
1498
                                type = new TypeReference("");
 
1499
                        }
 
1500
                        if (dimension != null) {
 
1501
                                if(type.RankSpecifier != null) {
 
1502
                                        Error("array rank only allowed one time");
 
1503
                                } else {
 
1504
                                        if (rank == null) {
 
1505
                                                type.RankSpecifier = new int[] { dimension.Count - 1 };
 
1506
                                        } else {
 
1507
                                                rank.Insert(0, dimension.Count - 1);
 
1508
                                                type.RankSpecifier = (int[])rank.ToArray(typeof(int));
 
1509
                                        }
 
1510
                                        expr = new ArrayCreateExpression(type.Clone(), dimension);
 
1511
                                }
 
1512
                        } else if (rank != null) {
 
1513
                                if(type.RankSpecifier != null) {
 
1514
                                        Error("array rank only allowed one time");
 
1515
                                } else {
 
1516
                                        type.RankSpecifier = (int[])rank.ToArray(typeof(int));
 
1517
                                }
 
1518
                        }
 
1519
                .)
 
1520
                [ "=" Expr<out expr> ]
 
1521
        )
 
1522
        (.
 
1523
                VariableDeclaration varDecl = new VariableDeclaration(name, expr, type);
 
1524
                varDecl.StartLocation = startLocation;
 
1525
                varDecl.EndLocation = t.Location;
 
1526
                fieldDeclaration.Add(varDecl);
 
1527
        .)
 
1528
.
 
1529
 
 
1530
/* 6.8 */
 
1531
ArrayInitializationModifier<out List<Expression> arrayModifiers>
 
1532
(.
 
1533
        arrayModifiers = null;
 
1534
.) =
 
1535
        "(" InitializationRankList<out arrayModifiers> ")"
 
1536
.
 
1537
 
 
1538
/* 7.5.4.3 */
 
1539
InitializationRankList<out List<Expression> rank>
 
1540
(.
 
1541
        rank = new List<Expression>();
 
1542
        Expression expr = null;
 
1543
.) =
 
1544
        Expr<out expr>
 
1545
        [       "To" (. EnsureIsZero(expr); .)
 
1546
                Expr<out expr>
 
1547
        ]
 
1548
        (. if (expr != null) { rank.Add(expr); } .)
 
1549
        {       ","
 
1550
                Expr<out expr>
 
1551
                [       "To" (. EnsureIsZero(expr); .)
 
1552
                        Expr<out expr>
 
1553
                ]
 
1554
                (. if (expr != null) { rank.Add(expr); } .)
 
1555
        }
 
1556
.
 
1557
 
 
1558
/* 9.6.3.4 */
 
1559
CollectionInitializer<out CollectionInitializerExpression outExpr>
 
1560
        (.
 
1561
                Expression expr = null;
 
1562
                CollectionInitializerExpression initializer = new CollectionInitializerExpression();
 
1563
                Location startLocation = la.Location;
 
1564
        .) =
 
1565
        "{"
 
1566
        [
 
1567
                Expr<out expr>
 
1568
                (.
 
1569
                        if (expr != null) { initializer.CreateExpressions.Add(expr); }
 
1570
                .)
 
1571
                {
 
1572
                        IF (NotFinalComma()) "," Expr<out expr>
 
1573
                        (. if (expr != null) { initializer.CreateExpressions.Add(expr); } .)
 
1574
                }
 
1575
        ]
 
1576
        "}"
 
1577
        (.
 
1578
                outExpr = initializer;
 
1579
                outExpr.StartLocation = startLocation;
 
1580
                outExpr.EndLocation = t.EndLocation;
 
1581
        .)
 
1582
.
 
1583
 
 
1584
Charset<out CharsetModifier charsetModifier>
 
1585
        (. charsetModifier = CharsetModifier.None; .) =
 
1586
        | "Ansi"                (. charsetModifier = CharsetModifier.Ansi; .)
 
1587
        | "Auto"                (. charsetModifier = CharsetModifier.Auto; .)
 
1588
        | "Unicode"             (. charsetModifier = CharsetModifier.Unicode; .)
 
1589
        .
 
1590
 
 
1591
/* 9.2.6 */
 
1592
HandlesClause<out List<string> handlesClause>
 
1593
        (.
 
1594
                handlesClause = new List<string>();
 
1595
                string name;
 
1596
        .) =
 
1597
        "Handles" EventMemberSpecifier<out name>        (. if (name != null) handlesClause.Add(name); .)
 
1598
        { "," EventMemberSpecifier<out name>            (. if (name != null) handlesClause.Add(name); .) }
 
1599
        .
 
1600
 
 
1601
/* 7.8. */
 
1602
InterfaceBase<out List<TypeReference> bases>
 
1603
        (.
 
1604
                TypeReference type;
 
1605
                bases = new List<TypeReference>();
 
1606
        .) =
 
1607
        "Inherits"
 
1608
        TypeName<out type> (. if (type != null) bases.Add(type); .)
 
1609
        {
 
1610
                ","
 
1611
                TypeName<out type> (. if (type != null) bases.Add(type); .)
 
1612
        }
 
1613
        EndOfStmt
 
1614
        .
 
1615
 
 
1616
/* 7.2 */
 
1617
TypeImplementsClause<out List<TypeReference> baseInterfaces>
 
1618
        (.
 
1619
                baseInterfaces = new List<TypeReference>();
 
1620
                TypeReference type = null;
 
1621
        .) =
 
1622
        "Implements" TypeName<out type>
 
1623
        (.
 
1624
                if (type != null) baseInterfaces.Add(type);
 
1625
        .)
 
1626
        {
 
1627
                "," TypeName<out type>
 
1628
                (. if (type != null) baseInterfaces.Add(type); .)
 
1629
        }
 
1630
        EndOfStmt
 
1631
        .
 
1632
 
 
1633
/* 9.1 */
 
1634
ImplementsClause<out List<InterfaceImplementation> baseInterfaces>
 
1635
        (.
 
1636
                baseInterfaces = new List<InterfaceImplementation>();
 
1637
                TypeReference type = null;
 
1638
                string memberName = null;
 
1639
        .) =
 
1640
        "Implements"
 
1641
        NonArrayTypeName<out type, false>
 
1642
        (. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
 
1643
        (. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
 
1644
        { ","
 
1645
                NonArrayTypeName<out type, false>
 
1646
                (. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
 
1647
                (. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
 
1648
        }
 
1649
.
 
1650
 
 
1651
EventMemberSpecifier<out string name>
 
1652
(. string eventName; .)
 
1653
=
 
1654
        ( Identifier | "MyBase" | "Me" )
 
1655
        (. name = t.val; .)
 
1656
        "."
 
1657
        IdentifierOrKeyword<out eventName>
 
1658
        (. name = name + "." + eventName; .)
 
1659
.
 
1660
 
 
1661
Expr<out Expression expr>
 
1662
        (. expr = null; Location startLocation = la.Location; .)
 
1663
        =
 
1664
        (
 
1665
                  IF ( IsQueryExpression() )
 
1666
                  QueryExpr<out expr>
 
1667
                | LambdaExpr<out expr>
 
1668
                | DisjunctionExpr<out expr>
 
1669
        )
 
1670
        (.
 
1671
                if (expr != null) {
 
1672
                        expr.StartLocation = startLocation;
 
1673
                        expr.EndLocation = t.EndLocation;
 
1674
                }
 
1675
        .)
 
1676
.
 
1677
 
 
1678
AssignmentOperator<out AssignmentOperatorType op>
 
1679
        (. op = AssignmentOperatorType.None; .) =
 
1680
        "="             (. op = AssignmentOperatorType.Assign; .)
 
1681
        | "&="  (. op = AssignmentOperatorType.ConcatString; .)
 
1682
        | "+="  (. op = AssignmentOperatorType.Add; .)
 
1683
        | "-="  (. op = AssignmentOperatorType.Subtract; .)
 
1684
        | "*="  (. op = AssignmentOperatorType.Multiply; .)
 
1685
        | "/="  (. op = AssignmentOperatorType.Divide; .)
 
1686
        | "\\=" (. op = AssignmentOperatorType.DivideInteger; .)
 
1687
        | "^="  (. op = AssignmentOperatorType.Power; .)
 
1688
        | "<<=" (. op = AssignmentOperatorType.ShiftLeft; .)
 
1689
        | ">>=" (. op = AssignmentOperatorType.ShiftRight; .)
 
1690
        .
 
1691
 
 
1692
/* 11.4 */
 
1693
SimpleExpr<out Expression pexpr>
 
1694
(. string name; Location startLocation = la.Location; .)
 
1695
=
 
1696
(
 
1697
        SimpleNonInvocationExpression<out pexpr>
 
1698
        {
 
1699
                        "." (
 
1700
                                XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag
 
1701
                                (. pexpr = new XmlMemberAccessExpression(pexpr, XmlAxisType.Element, name, true); .)
 
1702
                                | IdentifierOrKeyword<out name>
 
1703
                                (. pexpr = new MemberReferenceExpression(pexpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
 
1704
                        )
 
1705
                        [ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
 
1706
                                        "(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")"
 
1707
                        ]
 
1708
                |       "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(pexpr, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .)
 
1709
                |       (. XmlAxisType type = XmlAxisType.Attribute; bool isXmlName = false; .)
 
1710
                        ( ".@" | "..." (. type = XmlAxisType.Descendents; .) ) [ XmlOpenTag (. isXmlName = true; .) ] IdentifierOrKeyword<out name> [ XmlCloseTag ]
 
1711
                        (. pexpr = new XmlMemberAccessExpression(pexpr, type, name, isXmlName); .)
 
1712
                |       InvocationExpression<ref pexpr>
 
1713
        }
 
1714
)
 
1715
(.
 
1716
        if (pexpr != null) {
 
1717
                pexpr.StartLocation = startLocation;
 
1718
                pexpr.EndLocation = t.EndLocation;
 
1719
        }
 
1720
.)
 
1721
.
 
1722
 
 
1723
SimpleNonInvocationExpression<out Expression pexpr>
 
1724
(.
 
1725
        Expression expr;
 
1726
        CollectionInitializerExpression cie;
 
1727
        TypeReference type = null;
 
1728
        string name = String.Empty;
 
1729
        Location startLocation = la.Location;
 
1730
        pexpr = null;
 
1731
.) =
 
1732
        (
 
1733
                (
 
1734
                        /* 11.4.1 */ 
 
1735
                        LiteralString                                                   (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1736
                |       LiteralCharacter                                                (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1737
                |       LiteralSingle                                                   (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1738
                |       LiteralDouble                                                   (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1739
                |       LiteralInteger                                          (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1740
                |       LiteralDate                                                     (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1741
                |       LiteralDecimal                                          (.pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  .)
 
1742
                        /* True, False and Nothing are handled as literals in the spec */
 
1743
                |       "True"                                                                                  (.pexpr = new PrimitiveExpression(true, "true");  .)
 
1744
                |       "False"                                                                                 (.pexpr = new PrimitiveExpression(false, "false"); .)
 
1745
                |       "Nothing"                                                                                       (.pexpr = new PrimitiveExpression(null, "null");  .)
 
1746
                |       /* 11.4.2 */ "(" Expr<out expr> ")"                             (. pexpr = new ParenthesizedExpression(expr); .)
 
1747
                |       /* 11.4.4 */ Identifier
 
1748
                                (.      pexpr = new IdentifierExpression(t.val);
 
1749
                                        pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
 
1750
                                .)
 
1751
                                [ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
 
1752
                                        "(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")"
 
1753
                                ]
 
1754
                |       (. string val = String.Empty; .)
 
1755
                        ( PrimitiveTypeName<out val> | "Object" (. val = "System.Object"; .) )
 
1756
                        (. pexpr = new TypeReferenceExpression(new TypeReference(val, true)); .)
 
1757
                |       "Me"                                                    (. pexpr = new ThisReferenceExpression(); .)
 
1758
                |       (. Expression retExpr = null; .)
 
1759
                        ( "MyBase"                                                                              (. retExpr = new BaseReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
 
1760
                        | "MyClass"                                                                             (. retExpr = new ClassReferenceExpression() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
 
1761
                        )
 
1762
                        "." IdentifierOrKeyword<out name>                               (. pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
 
1763
                |       "Global" "."
 
1764
                        Identifier (. type = new TypeReference(t.val ?? ""); .)
 
1765
                        /* fallback to "" is required if the token wasn't an identifier (->parser error but no exception) */
 
1766
                        (. type.IsGlobal = true; .)
 
1767
                        (. pexpr = new TypeReferenceExpression(type); .)
 
1768
                |       ObjectCreateExpression<out expr>                                        (. pexpr = expr; .)
 
1769
                |       CollectionInitializer<out cie>                                  (. pexpr = cie; .)
 
1770
                |       /* 11.11 : Casts */
 
1771
                        (. CastType castType = CastType.Cast; .)
 
1772
                        ( "DirectCast"
 
1773
                        | "CType"   (. castType = CastType.Conversion; .)
 
1774
                        | "TryCast" (. castType = CastType.TryCast; .)
 
1775
                        )
 
1776
                        "(" Expr<out expr> "," TypeName<out type> ")"
 
1777
                        (. pexpr = new CastExpression(type, expr, castType); .)
 
1778
                |       /* 11.11 */ CastTarget<out type> "(" Expr<out expr> ")" (. pexpr = new CastExpression(type, expr, CastType.PrimitiveConversion); .)
 
1779
                |       /* 11.4.5 */ "AddressOf" Expr<out expr>                 (. pexpr = new AddressOfExpression(expr); .)
 
1780
                |       /* 11.5.1 */ "GetType" "(" GetTypeTypeName<out type> ")"        (. pexpr = new TypeOfExpression(type); .)
 
1781
                |       /* 11.5.2 */ "TypeOf" SimpleExpr<out expr> "Is" TypeName<out type> (. pexpr = new TypeOfIsExpression(expr, type); .)
 
1782
                |   /* 11.22 */ ConditionalExpression<out pexpr>
 
1783
                | XmlLiteralExpression<out pexpr>
 
1784
                )
 
1785
        |
 
1786
                (
 
1787
                        /* this form only occurs in WithStatements */
 
1788
                        "." (
 
1789
                                XmlOpenTag IdentifierOrKeyword<out name> XmlCloseTag
 
1790
                                (. pexpr = new XmlMemberAccessExpression(null, XmlAxisType.Element, name, true) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
 
1791
                                | IdentifierOrKeyword<out name>
 
1792
                                (. pexpr = new MemberReferenceExpression(null, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
 
1793
                        ) |
 
1794
                        "!" IdentifierOrKeyword<out name> (. pexpr = new BinaryOperatorExpression(null, BinaryOperatorType.DictionaryAccess, new PrimitiveExpression(name, name) { StartLocation = t.Location, EndLocation = t.EndLocation }); .)
 
1795
                        | (. XmlAxisType axisType = XmlAxisType.Element; bool isXmlIdentifier = false; .)
 
1796
                        ( "..." (. axisType = XmlAxisType.Descendents; .) | ".@" (. axisType = XmlAxisType.Attribute; .) ) (
 
1797
                                [ XmlOpenTag (. isXmlIdentifier = true; .) ] IdentifierOrKeyword<out name> [ XmlCloseTag ]
 
1798
                                (. pexpr = new XmlMemberAccessExpression(null, axisType, name, isXmlIdentifier); .)
 
1799
                        )
 
1800
                )
 
1801
        )
 
1802
(.
 
1803
        if (pexpr != null) {
 
1804
                pexpr.StartLocation = startLocation;
 
1805
                pexpr.EndLocation = t.EndLocation;
 
1806
        }
 
1807
.)
 
1808
.
 
1809
 
 
1810
XmlLiteralExpression<out Expression pexpr>
 
1811
(.
 
1812
        List<XmlExpression> exprs = new List<XmlExpression>();
 
1813
        XmlExpression currentExpression = null;
 
1814
.)
 
1815
        =
 
1816
        (
 
1817
                XmlContentExpression<exprs> { XmlContentExpression<exprs> } [ XmlElement<out currentExpression> (. exprs.Add(currentExpression); .) { XmlContentExpression<exprs> } ]
 
1818
        |
 
1819
                XmlElement<out currentExpression> (. exprs.Add(currentExpression); .) { XmlContentExpression<exprs> }
 
1820
        )
 
1821
        (.
 
1822
                if (exprs.Count > 1) {
 
1823
                        pexpr = new XmlDocumentExpression() { Expressions = exprs };
 
1824
                } else {
 
1825
                        pexpr = exprs[0];
 
1826
                }
 
1827
        .)
 
1828
.
 
1829
 
 
1830
XmlContentExpression<List<XmlExpression> exprs> =
 
1831
(. XmlContentExpression expr = null; .)
 
1832
        (
 
1833
                XmlContent (. expr = new XmlContentExpression(t.val, XmlContentType.Text); .)
 
1834
                | XmlCData (. expr = new XmlContentExpression(t.val, XmlContentType.CData); .)
 
1835
                | XmlComment (. expr = new XmlContentExpression(t.val, XmlContentType.Comment); .)
 
1836
                | XmlProcessingInstruction (. expr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction); .)
 
1837
        )
 
1838
        (.
 
1839
                expr.StartLocation = t.Location;
 
1840
                expr.EndLocation = t.EndLocation;
 
1841
                exprs.Add(expr);
 
1842
        .)
 
1843
.
 
1844
 
 
1845
XmlNestedContent<out XmlExpression expr>
 
1846
        (. XmlExpression tmpExpr = null; Location start = la.Location; .)
 
1847
=
 
1848
        (
 
1849
                XmlContent (. tmpExpr = new XmlContentExpression(t.val, XmlContentType.Text); .)
 
1850
                | XmlCData (. tmpExpr = new XmlContentExpression(t.val, XmlContentType.CData); .)
 
1851
                | XmlComment (. tmpExpr = new XmlContentExpression(t.val, XmlContentType.Comment); .)
 
1852
                | XmlProcessingInstruction (. tmpExpr = new XmlContentExpression(t.val, XmlContentType.ProcessingInstruction); .)
 
1853
                | XmlStartInlineVB (. Expression innerExpression; .) Expr<out innerExpression> XmlEndInlineVB (. tmpExpr = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression }; .)
 
1854
                | XmlElement<out tmpExpr>
 
1855
        )
 
1856
        (.
 
1857
                if (tmpExpr.StartLocation.IsEmpty)
 
1858
                        tmpExpr.StartLocation = start;
 
1859
                if (tmpExpr.EndLocation.IsEmpty)
 
1860
                        tmpExpr.EndLocation = t.EndLocation;
 
1861
                expr = tmpExpr;
 
1862
        .)
 
1863
.
 
1864
 
 
1865
XmlElement<out XmlExpression expr>
 
1866
        (. XmlElementExpression el = new XmlElementExpression(); .)
 
1867
=
 
1868
        (
 
1869
                XmlOpenTag (. el.StartLocation = t.Location; .)
 
1870
                ( XmlStartInlineVB (. Expression innerExpression; .) Expr<out innerExpression> XmlEndInlineVB
 
1871
                (. el.NameExpression = new XmlEmbeddedExpression() { InlineVBExpression = innerExpression }; .)
 
1872
                | Identifier (. el.XmlName = t.val; .) ) { XmlAttribute<el.Attributes> }
 
1873
                ( XmlCloseTagEmptyElement (. el.EndLocation = t.EndLocation; .) | XmlCloseTag { (. XmlExpression child; .) XmlNestedContent<out child> (. el.Children.Add(child); .) } XmlOpenEndTag { ANY } XmlCloseTag (. el.EndLocation = t.EndLocation; .) )
 
1874
        )
 
1875
        (. expr = el; .)
 
1876
.
 
1877
 
 
1878
XmlAttribute<List<XmlExpression> attrs>
 
1879
        (. Location start = la.Location; .)
 
1880
=
 
1881
                Identifier (. string name = t.val; .) "="
 
1882
                (. string literalValue = null; Expression expressionValue = null; bool useDoubleQuotes = false; .)
 
1883
                ( LiteralString (. literalValue = t.literalValue.ToString(); useDoubleQuotes = t.val[0] == '"'; .) | XmlStartInlineVB Expr<out expressionValue> XmlEndInlineVB )
 
1884
                (. attrs.Add(new XmlAttributeExpression() { Name = name, ExpressionValue = expressionValue, LiteralValue = literalValue, UseDoubleQuotes = useDoubleQuotes, StartLocation = start, EndLocation = t.EndLocation }); .)
 
1885
        |
 
1886
                XmlStartInlineVB (. Expression innerExpression; .) Expr<out innerExpression> XmlEndInlineVB
 
1887
                (. attrs.Add(new XmlEmbeddedExpression() { InlineVBExpression = innerExpression, StartLocation = start, EndLocation = t.EndLocation }); .)
 
1888
.
 
1889
 
 
1890
ConditionalExpression<out Expression expr>
 
1891
        (.
 
1892
                ConditionalExpression conditionalExpression = new ConditionalExpression();
 
1893
                BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression();
 
1894
                conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location;
 
1895
                
 
1896
                Expression condition = null;
 
1897
                Expression trueExpr = null;
 
1898
                Expression falseExpr = null;
 
1899
        .)
 
1900
=
 
1901
        "If" "(" Expr<out condition> "," Expr<out trueExpr> [ "," Expr<out falseExpr> ] ")"
 
1902
        (.
 
1903
                if(falseExpr != null)
 
1904
                {
 
1905
                        conditionalExpression.Condition = condition;
 
1906
                        conditionalExpression.TrueExpression = trueExpr;
 
1907
                        conditionalExpression.FalseExpression = falseExpr;
 
1908
                        conditionalExpression.EndLocation = t.EndLocation;
 
1909
                        
 
1910
                        expr = conditionalExpression;
 
1911
                }
 
1912
                else
 
1913
                {
 
1914
                        binaryOperatorExpression.Left = condition;
 
1915
                        binaryOperatorExpression.Right = trueExpr;
 
1916
                        binaryOperatorExpression.Op = BinaryOperatorType.NullCoalescing;
 
1917
                        binaryOperatorExpression.EndLocation = t.EndLocation;
 
1918
                        
 
1919
                        expr = binaryOperatorExpression;
 
1920
                }
 
1921
        .)
 
1922
.       
 
1923
 
 
1924
InvocationExpression<ref Expression pexpr>
 
1925
(. List<Expression> parameters = null; .)
 
1926
=
 
1927
        "(" (. Location start = t.Location; .)
 
1928
        ArgumentList<out parameters>
 
1929
        ")"
 
1930
        (.
 
1931
                pexpr = new InvocationExpression(pexpr, parameters);
 
1932
        .)
 
1933
        (. pexpr.StartLocation = start; pexpr.EndLocation = t.Location; .)
 
1934
.
 
1935
 
 
1936
/* 11.11 */
 
1937
 
 
1938
CastTarget<out TypeReference type>
 
1939
        (.
 
1940
                type = null;
 
1941
        .) =
 
1942
        "CBool"         (. type = new TypeReference("System.Boolean", true); .)
 
1943
        | "CByte"       (. type = new TypeReference("System.Byte", true); .)
 
1944
        | "CSByte"      (. type = new TypeReference("System.SByte", true); .)
 
1945
        | "CChar"       (. type = new TypeReference("System.Char", true); .)
 
1946
        | "CDate"       (. type = new TypeReference("System.DateTime", true); .)
 
1947
        | "CDec"        (. type = new TypeReference("System.Decimal", true); .)
 
1948
        | "CDbl"        (. type = new TypeReference("System.Double", true); .)
 
1949
        | "CShort"      (. type = new TypeReference("System.Int16", true); .)
 
1950
        | "CInt"        (. type = new TypeReference("System.Int32", true); .)
 
1951
        | "CLng"        (. type = new TypeReference("System.Int64", true); .)
 
1952
        | "CUShort"     (. type = new TypeReference("System.UInt16", true); .)
 
1953
        | "CUInt"       (. type = new TypeReference("System.UInt32", true); .)
 
1954
        | "CULng"       (. type = new TypeReference("System.UInt64", true); .)
 
1955
        | "CObj"        (. type = new TypeReference("System.Object", true); .)
 
1956
        | "CSng"        (. type = new TypeReference("System.Single", true); .)
 
1957
        | "CStr"        (. type = new TypeReference("System.String", true); .)
 
1958
        .
 
1959
 
 
1960
DisjunctionExpr<out Expression outExpr>
 
1961
(.
 
1962
        Expression expr;
 
1963
        BinaryOperatorType op = BinaryOperatorType.None;
 
1964
        Location startLocation = la.Location;
 
1965
.) =
 
1966
        ConjunctionExpr<out outExpr>
 
1967
        {
 
1968
                (
 
1969
                          "Or"     (. op = BinaryOperatorType.BitwiseOr; .)
 
1970
                        | "OrElse" (. op = BinaryOperatorType.LogicalOr; .)
 
1971
                        | "Xor"    (. op = BinaryOperatorType.ExclusiveOr; .)
 
1972
                )
 
1973
                ConjunctionExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .)
 
1974
        }
 
1975
.
 
1976
 
 
1977
ConjunctionExpr<out Expression outExpr>
 
1978
(.
 
1979
        Expression expr;
 
1980
        BinaryOperatorType op = BinaryOperatorType.None;
 
1981
        Location startLocation = la.Location;
 
1982
.) =
 
1983
        NotExpr<out outExpr>
 
1984
        {
 
1985
                (
 
1986
                          "And"     (. op = BinaryOperatorType.BitwiseAnd; .)
 
1987
                        | "AndAlso" (. op = BinaryOperatorType.LogicalAnd; .)
 
1988
                )
 
1989
                NotExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .)
 
1990
        }
 
1991
.
 
1992
 
 
1993
NotExpr<out Expression outExpr> 
 
1994
        (. UnaryOperatorType uop = UnaryOperatorType.None; .) =
 
1995
        {       "Not" (. uop = UnaryOperatorType.Not; .) }
 
1996
        ComparisonExpr<out outExpr>
 
1997
                (. if (uop != UnaryOperatorType.None)
 
1998
                           outExpr = new UnaryOperatorExpression(outExpr, uop);
 
1999
                .)
 
2000
        .
 
2001
 
 
2002
ComparisonExpr<out Expression outExpr>
 
2003
(.
 
2004
        Expression expr;
 
2005
        BinaryOperatorType op = BinaryOperatorType.None;
 
2006
        Location startLocation = la.Location;
 
2007
.) =
 
2008
        ShiftExpr<out outExpr>
 
2009
        {
 
2010
                (
 
2011
                        "<"    (. op = BinaryOperatorType.LessThan; .)
 
2012
                        | ">"  (. op = BinaryOperatorType.GreaterThan; .)
 
2013
                        | "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
 
2014
                        | ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
 
2015
                        | "<>"          (. op = BinaryOperatorType.InEquality; .)
 
2016
                        | "="           (. op = BinaryOperatorType.Equality; .)
 
2017
                        | "Like"        (. op = BinaryOperatorType.Like; .)
 
2018
                        | "Is"  (. op = BinaryOperatorType.ReferenceEquality; .)
 
2019
                        | "IsNot" (. op = BinaryOperatorType.ReferenceInequality; .)
 
2020
                )
 
2021
                (
 
2022
                        ShiftExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .)
 
2023
                | (. Location startLocation2 = la.Location; .)
 
2024
                        "Not"
 
2025
                        ShiftExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not) { StartLocation = startLocation2, EndLocation = t.EndLocation }) { StartLocation = startLocation, EndLocation = t.EndLocation };  .)
 
2026
                )
 
2027
        }
 
2028
.
 
2029
 
 
2030
ShiftExpr<out Expression outExpr>
 
2031
        (.
 
2032
                Expression expr;
 
2033
                BinaryOperatorType op = BinaryOperatorType.None;
 
2034
                Location startLocation = la.Location;
 
2035
        .) =
 
2036
        ConcatenationExpr<out outExpr> 
 
2037
        {
 
2038
                (
 
2039
                        "<<"   (. op = BinaryOperatorType.ShiftLeft; .)
 
2040
                        | ">>" (. op = BinaryOperatorType.ShiftRight; .)
 
2041
                )
 
2042
                ConcatenationExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .) 
 
2043
        }
 
2044
        .
 
2045
 
 
2046
ConcatenationExpr<out Expression outExpr>
 
2047
(. Expression expr; Location startLocation = la.Location; .)
 
2048
=
 
2049
        AdditiveExpr<out outExpr> { "&" AdditiveExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .) }
 
2050
.
 
2051
 
 
2052
AdditiveExpr<out Expression outExpr>
 
2053
(.
 
2054
        Expression expr;
 
2055
        BinaryOperatorType op = BinaryOperatorType.None;
 
2056
        Location startLocation = la.Location;
 
2057
.) =
 
2058
        ModuloExpr<out outExpr>
 
2059
        {
 
2060
                (
 
2061
                          "+"   (. op = BinaryOperatorType.Add; .)
 
2062
                        | "-" (. op = BinaryOperatorType.Subtract; .)
 
2063
                )
 
2064
                ModuloExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .)
 
2065
        }
 
2066
.
 
2067
 
 
2068
ModuloExpr<out Expression outExpr>
 
2069
(. Expression expr; Location startLocation = la.Location; .)
 
2070
 
2071
        IntegerDivisionExpr<out outExpr> { "Mod" IntegerDivisionExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .) }
 
2072
.
 
2073
 
 
2074
IntegerDivisionExpr<out Expression outExpr>
 
2075
(. Expression expr; Location startLocation = la.Location; .)
 
2076
=
 
2077
        MultiplicativeExpr<out outExpr> { "\\" MultiplicativeExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .) }
 
2078
.
 
2079
 
 
2080
MultiplicativeExpr<out Expression outExpr>
 
2081
(.
 
2082
        Expression expr;
 
2083
        BinaryOperatorType op = BinaryOperatorType.None;
 
2084
        Location startLocation = la.Location;
 
2085
.) =
 
2086
        UnaryExpr<out outExpr>
 
2087
        {
 
2088
                (
 
2089
                        "*"   (. op = BinaryOperatorType.Multiply; .)
 
2090
                        | "/" (. op = BinaryOperatorType.Divide; .)
 
2091
                ) 
 
2092
                UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) 
 
2093
        }
 
2094
.
 
2095
 
 
2096
UnaryExpr<out Expression uExpr> 
 
2097
(.
 
2098
        Expression expr;
 
2099
        UnaryOperatorType uop = UnaryOperatorType.None;
 
2100
        Location startLocation = la.Location;
 
2101
        bool isUOp = false;
 
2102
.) =
 
2103
        {       "+"             (. uop = UnaryOperatorType.Plus; isUOp = true; .)
 
2104
                | "-"           (. uop = UnaryOperatorType.Minus; isUOp = true; .)
 
2105
                | "*"           (. uop = UnaryOperatorType.Dereference;  isUOp = true;.)
 
2106
        }
 
2107
        ExponentiationExpr<out expr>
 
2108
        (.
 
2109
                if (isUOp) {
 
2110
                        uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation };
 
2111
                } else {
 
2112
                        uExpr = expr;
 
2113
                }
 
2114
        .)
 
2115
.
 
2116
 
 
2117
ExponentiationExpr<out Expression outExpr>
 
2118
(. Expression expr; Location startLocation = la.Location; .)
 
2119
=
 
2120
        SimpleExpr<out outExpr> { "^" SimpleExpr<out expr> (.  outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };  .) }
 
2121
.
 
2122
        
 
2123
ObjectCreateExpression<out Expression oce>
 
2124
(.
 
2125
        TypeReference type = null;
 
2126
        CollectionInitializerExpression initializer = null;
 
2127
        List<Expression> arguments = null;
 
2128
        ArrayList dimensions = null;
 
2129
        oce = null;
 
2130
        Location startLocation = la.Location;
 
2131
        bool canBeNormal; bool canBeReDim;
 
2132
.) =
 
2133
        "New" 
 
2134
        [ NonArrayTypeName<out type, false>
 
2135
                ["(" NormalOrReDimArgumentList<out arguments, out canBeNormal, out canBeReDim> ")"
 
2136
                        [ IF (la.kind == Tokens.OpenParenthesis)
 
2137
                                ArrayTypeModifiers<out dimensions>
 
2138
                                CollectionInitializer<out initializer>
 
2139
                        |       CollectionInitializer<out initializer>
 
2140
                        ]
 
2141
                        (. if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); .)
 
2142
                ]
 
2143
        ]
 
2144
        (.
 
2145
                if (initializer == null) {
 
2146
                        oce = new ObjectCreateExpression(type, arguments);
 
2147
                } else {
 
2148
                        if (dimensions == null) dimensions = new ArrayList();
 
2149
                        dimensions.Insert(0, (arguments == null) ? 0 : Math.Max(arguments.Count - 1, 0));
 
2150
                        type.RankSpecifier = (int[])dimensions.ToArray(typeof(int));
 
2151
                        ArrayCreateExpression ace = new ArrayCreateExpression(type, initializer);
 
2152
                        ace.Arguments = arguments;
 
2153
                        oce = ace;
 
2154
                }
 
2155
        .)
 
2156
        
 
2157
        [
 
2158
                (
 
2159
                        (.
 
2160
                                MemberInitializerExpression memberInitializer = null;
 
2161
                                Expression anonymousMember = null;
 
2162
                        .)
 
2163
                        "With"
 
2164
                        (.
 
2165
                                CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
 
2166
                                memberInitializers.StartLocation = la.Location;
 
2167
                        .)
 
2168
                        "{"
 
2169
                                (
 
2170
                                        MemberInitializer<out memberInitializer>
 
2171
                                                (. memberInitializers.CreateExpressions.Add(memberInitializer); .)
 
2172
                                        | Expr<out anonymousMember>
 
2173
                                                (. memberInitializers.CreateExpressions.Add(anonymousMember); .)
 
2174
                                )
 
2175
                                { ","
 
2176
                                        (
 
2177
                                                MemberInitializer<out memberInitializer>
 
2178
                                                        (. memberInitializers.CreateExpressions.Add(memberInitializer); .)
 
2179
                                                | Expr<out anonymousMember>
 
2180
                                                        (. memberInitializers.CreateExpressions.Add(anonymousMember); .)
 
2181
                                        )
 
2182
                                }
 
2183
                        "}"
 
2184
                        (.
 
2185
                                memberInitializers.EndLocation = t.Location;
 
2186
                                if(oce is ObjectCreateExpression)
 
2187
                                {
 
2188
                                        ((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
 
2189
                                }
 
2190
                        .)
 
2191
                )
 
2192
        |
 
2193
                (
 
2194
                        "From"
 
2195
                        CollectionInitializer<out initializer>
 
2196
                        (.
 
2197
                                if(oce is ObjectCreateExpression)
 
2198
                                        ((ObjectCreateExpression)oce).ObjectInitializer = initializer;
 
2199
                        .)
 
2200
                )
 
2201
        ]
 
2202
        (.
 
2203
                if (oce != null) {
 
2204
                        oce.StartLocation = startLocation;
 
2205
                        oce.EndLocation = t.EndLocation;
 
2206
                }
 
2207
        .)
 
2208
.
 
2209
 
 
2210
LambdaExpr<out Expression expr>
 
2211
        (.
 
2212
                LambdaExpression lambda = null;
 
2213
        .) =
 
2214
        ( SubLambdaExpression<out lambda> |
 
2215
        FunctionLambdaExpression<out lambda> )
 
2216
        (. expr = lambda; .)
 
2217
.
 
2218
 
 
2219
SubLambdaExpression<out LambdaExpression lambda>
 
2220
        (.
 
2221
                lambda = new LambdaExpression();
 
2222
                lambda.ReturnType = new TypeReference("System.Void", true);
 
2223
                Expression inner = null;
 
2224
                Statement statement = null;
 
2225
                lambda.StartLocation = la.Location;
 
2226
        .)
 
2227
=
 
2228
        "Sub" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
 
2229
        (
 
2230
                (
 
2231
                        Expr<out inner>
 
2232
                        (.
 
2233
                                lambda.ExpressionBody = inner;
 
2234
                                lambda.EndLocation = t.EndLocation; // la.Location?
 
2235
                                lambda.ExtendedEndLocation = la.Location;
 
2236
                        .)
 
2237
                |
 
2238
                        EmbeddedStatement<out statement>
 
2239
                        (.
 
2240
                                lambda.StatementBody = statement;
 
2241
                                lambda.EndLocation = t.EndLocation;
 
2242
                                lambda.ExtendedEndLocation = la.Location;
 
2243
                        .)
 
2244
                )
 
2245
        |
 
2246
                EOL
 
2247
                Block<out statement>
 
2248
                "End" "Sub"
 
2249
                (.
 
2250
                        lambda.StatementBody = statement;
 
2251
                        lambda.EndLocation = t.EndLocation;
 
2252
                        lambda.ExtendedEndLocation = la.Location;
 
2253
                .)
 
2254
        )
 
2255
.
 
2256
 
 
2257
FunctionLambdaExpression<out LambdaExpression lambda>
 
2258
        (.
 
2259
                lambda = new LambdaExpression();
 
2260
                TypeReference typeRef = null;
 
2261
                Expression inner = null;
 
2262
                Statement statement = null;
 
2263
                lambda.StartLocation = la.Location;
 
2264
        .)
 
2265
=
 
2266
        "Function" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
 
2267
        [ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ]
 
2268
        (
 
2269
                (
 
2270
                        Expr<out inner>
 
2271
                        (.
 
2272
                                lambda.ExpressionBody = inner;
 
2273
                                lambda.EndLocation = t.EndLocation;
 
2274
                                lambda.ExtendedEndLocation = la.Location;
 
2275
                        .)
 
2276
                |
 
2277
                        EmbeddedStatement<out statement>
 
2278
                        (.
 
2279
                                lambda.StatementBody = statement;
 
2280
                                lambda.EndLocation = t.EndLocation;
 
2281
                                lambda.ExtendedEndLocation = la.Location;
 
2282
                        .)
 
2283
                )
 
2284
        |
 
2285
                EOL
 
2286
                Block<out statement>
 
2287
                "End" "Function"
 
2288
                (.
 
2289
                        lambda.StatementBody = statement;
 
2290
                        lambda.EndLocation = t.EndLocation;
 
2291
                        lambda.ExtendedEndLocation = la.Location;
 
2292
                .)
 
2293
        )
 
2294
.
 
2295
 
 
2296
QueryExpr<out Expression expr>
 
2297
        (.
 
2298
                QueryExpressionVB qexpr = new QueryExpressionVB();
 
2299
                qexpr.StartLocation = la.Location;
 
2300
                expr = qexpr;
 
2301
        .) =
 
2302
        FromOrAggregateQueryOperator<qexpr.Clauses>
 
2303
        { QueryOperator<qexpr.Clauses> }
 
2304
        (.
 
2305
                qexpr.EndLocation = t.EndLocation;
 
2306
        .)
 
2307
.
 
2308
 
 
2309
FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
 
2310
        (.
 
2311
                QueryExpressionFromClause fromClause = null;
 
2312
                QueryExpressionAggregateClause aggregateClause = null;
 
2313
        .) =
 
2314
           FromQueryOperator<out fromClause>
 
2315
           (. middleClauses.Add(fromClause); .)
 
2316
        |  AggregateQueryOperator<out aggregateClause>
 
2317
           (. middleClauses.Add(aggregateClause); .)
 
2318
.
 
2319
 
 
2320
QueryOperator<List<QueryExpressionClause> middleClauses>
 
2321
        (.
 
2322
                QueryExpressionJoinVBClause joinClause = null;
 
2323
                QueryExpressionGroupVBClause groupByClause = null;
 
2324
                QueryExpressionPartitionVBClause partitionClause = null;
 
2325
                QueryExpressionGroupJoinVBClause groupJoinClause = null;
 
2326
                QueryExpressionFromClause fromClause = null;
 
2327
                QueryExpressionAggregateClause aggregateClause = null;
 
2328
        .) =
 
2329
           FromQueryOperator<out fromClause>
 
2330
           (. middleClauses.Add(fromClause); .)
 
2331
        |  AggregateQueryOperator<out aggregateClause>
 
2332
           (. middleClauses.Add(aggregateClause); .)
 
2333
    | SelectQueryOperator<middleClauses>
 
2334
        | DistinctQueryOperator<middleClauses>
 
2335
        | WhereQueryOperator<middleClauses>
 
2336
        | OrderByQueryOperator<middleClauses>
 
2337
        | PartitionQueryOperator<out partitionClause>
 
2338
          (. middleClauses.Add(partitionClause); .)
 
2339
        | LetQueryOperator<middleClauses>
 
2340
        | JoinQueryOperator<out joinClause>
 
2341
          (. middleClauses.Add(joinClause); .)
 
2342
        | IF(la.kind == Tokens.Group && Peek(1).kind == Tokens.Join) GroupJoinQueryOperator<out groupJoinClause>
 
2343
          (. middleClauses.Add(groupJoinClause); .)
 
2344
        | GroupByQueryOperator<out groupByClause>
 
2345
          (. middleClauses.Add(groupByClause); .)
 
2346
.       
 
2347
 
 
2348
OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
 
2349
        (.
 
2350
                QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause();
 
2351
                orderClause.StartLocation = la.Location;
 
2352
                List<QueryExpressionOrdering> orderings = null;
 
2353
        .) =
 
2354
        "Order" "By" OrderExpressionList<out orderings>
 
2355
        (.
 
2356
                orderClause.Orderings = orderings;
 
2357
                orderClause.EndLocation = t.EndLocation;
 
2358
                middleClauses.Add(orderClause);
 
2359
        .)
 
2360
.
 
2361
 
 
2362
OrderExpressionList<out List<QueryExpressionOrdering> orderings>
 
2363
        (.
 
2364
                orderings = new List<QueryExpressionOrdering>();
 
2365
                QueryExpressionOrdering ordering = null;
 
2366
        .) =
 
2367
        OrderExpression<out ordering>
 
2368
        (. orderings.Add(ordering); .)
 
2369
        {
 
2370
                "," OrderExpression<out ordering>
 
2371
                (. orderings.Add(ordering); .)
 
2372
        }
 
2373
.
 
2374
 
 
2375
OrderExpression<out QueryExpressionOrdering ordering>
 
2376
        (.
 
2377
                ordering = new QueryExpressionOrdering();
 
2378
                ordering.StartLocation = la.Location;
 
2379
                ordering.Direction = QueryExpressionOrderingDirection.None;
 
2380
                Expression orderExpr = null;
 
2381
        .) =
 
2382
        Expr<out orderExpr>
 
2383
        (.
 
2384
                ordering.Criteria = orderExpr;
 
2385
        .)
 
2386
        [
 
2387
                  "Ascending"   (. ordering.Direction = QueryExpressionOrderingDirection.Ascending; .)
 
2388
                | "Descending"  (. ordering.Direction = QueryExpressionOrderingDirection.Descending; .)
 
2389
        ]
 
2390
        (. ordering.EndLocation = t.EndLocation; .)
 
2391
.
 
2392
 
 
2393
GroupByQueryOperator<out QueryExpressionGroupVBClause groupByClause>
 
2394
        (.
 
2395
                groupByClause = new QueryExpressionGroupVBClause();
 
2396
                groupByClause.StartLocation = la.Location;
 
2397
        .) =
 
2398
        "Group" ExpressionRangeVariableDeclarationList<groupByClause.GroupVariables>
 
2399
        "By" ExpressionRangeVariableDeclarationList<groupByClause.ByVariables>
 
2400
        "Into" ExpressionRangeVariableDeclarationList<groupByClause.IntoVariables>
 
2401
        (.
 
2402
                groupByClause.EndLocation = t.EndLocation;
 
2403
        .)
 
2404
.
 
2405
 
 
2406
GroupJoinQueryOperator<out QueryExpressionGroupJoinVBClause groupJoinClause>
 
2407
        (.
 
2408
                groupJoinClause = new QueryExpressionGroupJoinVBClause();
 
2409
                groupJoinClause.StartLocation = la.Location;
 
2410
                QueryExpressionJoinVBClause joinClause = null;
 
2411
        .) =
 
2412
        "Group" JoinQueryOperator<out joinClause>
 
2413
        "Into"  ExpressionRangeVariableDeclarationList<groupJoinClause.IntoVariables>
 
2414
        (.
 
2415
                groupJoinClause.JoinClause = joinClause;
 
2416
                groupJoinClause.EndLocation = t.EndLocation;
 
2417
        .)
 
2418
.
 
2419
 
 
2420
FromQueryOperator<out QueryExpressionFromClause fromClause>
 
2421
        (.
 
2422
            fromClause = new QueryExpressionFromClause();
 
2423
            fromClause.StartLocation = la.Location;
 
2424
        .) =
 
2425
        "From" CollectionRangeVariableDeclarationList<fromClause.Sources>
 
2426
        (.
 
2427
           fromClause.EndLocation = t.EndLocation;
 
2428
        .)
 
2429
.
 
2430
 
 
2431
SelectQueryOperator<List<QueryExpressionClause> middleClauses>
 
2432
        (.
 
2433
                QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause();
 
2434
                selectClause.StartLocation = la.Location;
 
2435
        .) =
 
2436
        "Select" ExpressionRangeVariableDeclarationList<selectClause.Variables>
 
2437
        (.
 
2438
                selectClause.EndLocation = t.Location;
 
2439
                middleClauses.Add(selectClause);
 
2440
        .)
 
2441
.
 
2442
 
 
2443
DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
 
2444
        (.
 
2445
                QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause();
 
2446
                distinctClause.StartLocation = la.Location;
 
2447
        .) =
 
2448
        "Distinct"
 
2449
        (.
 
2450
                distinctClause.EndLocation = t.EndLocation;
 
2451
                middleClauses.Add(distinctClause);
 
2452
        .)
 
2453
.
 
2454
 
 
2455
WhereQueryOperator<List<QueryExpressionClause> middleClauses>
 
2456
        (.
 
2457
                QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause();
 
2458
                whereClause.StartLocation = la.Location;
 
2459
                Expression operand = null;
 
2460
        .) =
 
2461
        "Where" Expr<out operand>
 
2462
        (.
 
2463
                whereClause.Condition = operand;
 
2464
                whereClause.EndLocation = t.EndLocation;
 
2465
                
 
2466
                middleClauses.Add(whereClause);
 
2467
        .)
 
2468
.
 
2469
 
 
2470
PartitionQueryOperator<out QueryExpressionPartitionVBClause partitionClause>
 
2471
        (.
 
2472
                partitionClause = new QueryExpressionPartitionVBClause();
 
2473
                partitionClause.StartLocation = la.Location;
 
2474
                Expression expr = null;
 
2475
        .) =
 
2476
          (
 
2477
           "Take" (. partitionClause.PartitionType = QueryExpressionPartitionType.Take; .)
 
2478
          [ "While" (. partitionClause.PartitionType = QueryExpressionPartitionType.TakeWhile; .) ]
 
2479
        | "Skip" (. partitionClause.PartitionType = QueryExpressionPartitionType.Skip; .)
 
2480
      [ "While" (. partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile; .) ]
 
2481
      )
 
2482
          Expr<out expr>
 
2483
        (.
 
2484
                partitionClause.Expression = expr;
 
2485
                partitionClause.EndLocation = t.EndLocation;
 
2486
        .)
 
2487
.
 
2488
 
 
2489
AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause>
 
2490
        (.
 
2491
                aggregateClause = new QueryExpressionAggregateClause();
 
2492
                aggregateClause.IntoVariables = new List<ExpressionRangeVariable>();
 
2493
                aggregateClause.StartLocation = la.Location;
 
2494
                CollectionRangeVariable source;
 
2495
        .) =
 
2496
        "Aggregate" CollectionRangeVariableDeclaration<out source>
 
2497
        (.
 
2498
                aggregateClause.Source = source;
 
2499
        .)
 
2500
        {
 
2501
                QueryOperator<aggregateClause.MiddleClauses>
 
2502
        }
 
2503
        "Into" ExpressionRangeVariableDeclarationList<aggregateClause.IntoVariables>
 
2504
        (.
 
2505
                aggregateClause.EndLocation = t.EndLocation;
 
2506
        .)
 
2507
.
 
2508
 
 
2509
LetQueryOperator<List<QueryExpressionClause> middleClauses>
 
2510
        (.
 
2511
                QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause();
 
2512
                letClause.StartLocation = la.Location;
 
2513
        .) =
 
2514
        "Let" ExpressionRangeVariableDeclarationList<letClause.Variables>
 
2515
        (.
 
2516
                letClause.EndLocation = t.EndLocation;
 
2517
                middleClauses.Add(letClause);
 
2518
        .)
 
2519
.       
 
2520
 
 
2521
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables>
 
2522
        (.
 
2523
                ExpressionRangeVariable variable = null;
 
2524
        .) =
 
2525
        ExpressionRangeVariableDeclaration<out variable>
 
2526
        (. variables.Add(variable); .)
 
2527
        { "," ExpressionRangeVariableDeclaration<out variable> (. variables.Add(variable); .) }
 
2528
.
 
2529
 
 
2530
ExpressionRangeVariableDeclaration<out ExpressionRangeVariable variable>
 
2531
        (.
 
2532
                variable = new ExpressionRangeVariable();
 
2533
                variable.StartLocation = la.Location;
 
2534
                Expression rhs = null;
 
2535
                TypeReference typeName = null;
 
2536
        .) =
 
2537
        [
 
2538
                IF(IsIdentifiedExpressionRange()) Identifier
 
2539
                (. variable.Identifier = t.val; .)
 
2540
                [
 
2541
                        "As" TypeName<out typeName>
 
2542
                        (. variable.Type = typeName; .)
 
2543
                ]
 
2544
                "="
 
2545
        ]
 
2546
        Expr<out rhs>
 
2547
        (.
 
2548
                variable.Expression = rhs;
 
2549
                variable.EndLocation = t.EndLocation;
 
2550
        .)
 
2551
.
 
2552
 
 
2553
JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
 
2554
        (.
 
2555
                joinClause = new QueryExpressionJoinVBClause();
 
2556
                joinClause.StartLocation = la.Location;
 
2557
                CollectionRangeVariable joinVariable = null;
 
2558
                QueryExpressionJoinVBClause subJoin = null;
 
2559
                QueryExpressionJoinConditionVB condition = null;
 
2560
                
 
2561
        .) =
 
2562
        "Join" CollectionRangeVariableDeclaration<out joinVariable> 
 
2563
        (. joinClause.JoinVariable = joinVariable; .)
 
2564
        [
 
2565
                JoinQueryOperator<out subJoin>
 
2566
                (. joinClause.SubJoin = subJoin; .)
 
2567
        ]
 
2568
        "On"
 
2569
        JoinCondition<out condition>
 
2570
        (. SafeAdd(joinClause, joinClause.Conditions, condition); .)
 
2571
        {
 
2572
                "And" JoinCondition<out condition>
 
2573
                (. SafeAdd(joinClause, joinClause.Conditions, condition); .)
 
2574
        }
 
2575
        (.
 
2576
                joinClause.EndLocation = t.EndLocation;
 
2577
        .)
 
2578
.
 
2579
 
 
2580
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables>
 
2581
(. CollectionRangeVariable variableDeclaration; .)
 
2582
  =
 
2583
        CollectionRangeVariableDeclaration<out variableDeclaration>
 
2584
        (. rangeVariables.Add(variableDeclaration); .)
 
2585
        { "," CollectionRangeVariableDeclaration<out variableDeclaration> (. rangeVariables.Add(variableDeclaration); .) }
 
2586
.
 
2587
 
 
2588
CollectionRangeVariableDeclaration<out CollectionRangeVariable rangeVariable>
 
2589
        (.
 
2590
                rangeVariable = new CollectionRangeVariable();
 
2591
                rangeVariable.StartLocation = la.Location;
 
2592
                TypeReference typeName = null;
 
2593
                Expression inExpr = null;
 
2594
        .) =
 
2595
        Identifier (. rangeVariable.Identifier = t.val; .)
 
2596
        [ "As" TypeName<out typeName> (. rangeVariable.Type = typeName; .) ] 
 
2597
        "In" Expr<out inExpr>
 
2598
        (.
 
2599
                rangeVariable.Expression = inExpr;
 
2600
                rangeVariable.EndLocation = t.EndLocation;
 
2601
        .)
 
2602
.
 
2603
 
 
2604
JoinCondition<out QueryExpressionJoinConditionVB condition>
 
2605
        (.
 
2606
                condition = new QueryExpressionJoinConditionVB();
 
2607
                condition.StartLocation = la.Location;
 
2608
                
 
2609
                Expression lhs = null;
 
2610
                Expression rhs = null;
 
2611
        .) =
 
2612
        Expr<out lhs> "Equals" Expr<out rhs>
 
2613
        (.
 
2614
                condition.LeftSide = lhs;
 
2615
                condition.RightSide = rhs;
 
2616
                condition.EndLocation = t.EndLocation;
 
2617
        .)
 
2618
.
 
2619
 
 
2620
MemberInitializer<out MemberInitializerExpression memberInitializer>
 
2621
        (.
 
2622
                memberInitializer = new MemberInitializerExpression();
 
2623
                memberInitializer.StartLocation = la.Location;
 
2624
                Expression initExpr = null;
 
2625
                bool isKey = false;
 
2626
                string name = null;
 
2627
        .) =
 
2628
        [ "Key" (. isKey = true; .) ]
 
2629
        "." IdentifierOrKeyword<out name> "=" Expr<out initExpr>
 
2630
        (.
 
2631
                memberInitializer.Name = name;
 
2632
                memberInitializer.Expression = initExpr;
 
2633
                memberInitializer.IsKey = isKey;
 
2634
                memberInitializer.EndLocation = t.EndLocation;
 
2635
        .)
 
2636
.
 
2637
 
 
2638
/* 9.3.2 */
 
2639
ArgumentList<out List<Expression> arguments>
 
2640
        (.
 
2641
                arguments = new List<Expression>();
 
2642
                Expression expr = null;
 
2643
        .) =
 
2644
        [ Argument<out expr> ]
 
2645
        { "," (. arguments.Add(expr ?? Expression.Null); expr = null; .)
 
2646
                [ Argument<out expr> ]
 
2647
                (. if (expr == null) expr = Expression.Null; .)
 
2648
        }
 
2649
        (. if (expr != null) arguments.Add(expr); .)
 
2650
.
 
2651
 
 
2652
/* argument list that hasn't decided if it is method call or array initialisation */
 
2653
NormalOrReDimArgumentList<out List<Expression> arguments, out bool canBeNormal, out bool canBeRedim>
 
2654
        (.
 
2655
                arguments = new List<Expression>();
 
2656
                canBeNormal = true; canBeRedim = !IsNamedAssign();
 
2657
                Expression expr = null;
 
2658
        .)
 
2659
=
 
2660
        [ Argument<out expr>
 
2661
          [ "To" (. EnsureIsZero(expr); canBeNormal = false; .)
 
2662
            Expr<out expr>
 
2663
        ] ]
 
2664
        { ","
 
2665
                (. if (expr == null) canBeRedim = false; .)
 
2666
                (. arguments.Add(expr ?? Expression.Null); expr = null; .)
 
2667
                (. canBeRedim &= !IsNamedAssign(); .)
 
2668
                [ Argument<out expr>
 
2669
                  [ "To" (. EnsureIsZero(expr); canBeNormal = false; .)
 
2670
                    Expr<out expr>
 
2671
                ] ]
 
2672
                (. if (expr == null) { canBeRedim = false; expr = Expression.Null; } .)
 
2673
        }
 
2674
        (. if (expr != null) arguments.Add(expr); else canBeRedim = false; .)
 
2675
.
 
2676
 
 
2677
/* Spec, 11.8 */
 
2678
Argument<out Expression argumentexpr>
 
2679
        (.
 
2680
                Expression expr;
 
2681
                argumentexpr = null;
 
2682
                string name;
 
2683
                Location startLocation = la.Location;
 
2684
        .) =
 
2685
        IF(IsNamedAssign()) Identifier (. name = t.val;  .) ":=" Expr<out expr>
 
2686
        (.
 
2687
                argumentexpr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
 
2688
        .)
 
2689
        |
 
2690
        Expr<out argumentexpr>
 
2691
.
 
2692
 
 
2693
/* 7.1. */
 
2694
TypeName<out TypeReference typeref>
 
2695
(. ArrayList rank = null; Location startLocation = la.Location; .)
 
2696
=
 
2697
        NonArrayTypeName<out typeref, false>
 
2698
        ArrayTypeModifiers<out rank>
 
2699
        (.
 
2700
                if (typeref != null) {
 
2701
                        if (rank != null) {
 
2702
                                typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
 
2703
                        }
 
2704
                        typeref.StartLocation = startLocation;
 
2705
                        typeref.EndLocation = t.EndLocation;
 
2706
                }
 
2707
        .)
 
2708
.
 
2709
 
 
2710
GetTypeTypeName<out TypeReference typeref>
 
2711
(. ArrayList rank = null; .)
 
2712
=
 
2713
        NonArrayTypeName<out typeref, true>
 
2714
        ArrayTypeModifiers<out rank>
 
2715
        (.      if (rank != null && typeref != null) {
 
2716
                        typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
 
2717
                }
 
2718
        .)
 
2719
.
 
2720
 
 
2721
/* 7.1 */
 
2722
NonArrayTypeName<out TypeReference typeref, bool canBeUnbound>
 
2723
(.
 
2724
        string name;
 
2725
        typeref = null;
 
2726
        bool isGlobal = false;
 
2727
.) =
 
2728
        (
 
2729
                [ "Global" "." (. isGlobal = true; .) ]
 
2730
                QualIdentAndTypeArguments<out typeref, canBeUnbound>
 
2731
                (. typeref.IsGlobal = isGlobal; .)
 
2732
                { "." (. TypeReference nestedTypeRef; .)
 
2733
                        QualIdentAndTypeArguments<out nestedTypeRef, canBeUnbound>
 
2734
                        (. typeref = new InnerClassTypeReference(typeref, nestedTypeRef.Type, nestedTypeRef.GenericTypes); .)
 
2735
                }
 
2736
        )
 
2737
        | "Object" (. typeref = new TypeReference("System.Object", true); .)
 
2738
                [
 
2739
                "?"
 
2740
                (.
 
2741
                        List<TypeReference> typeArguments = new List<TypeReference>(1);
 
2742
                        if (typeref != null) typeArguments.Add(typeref);
 
2743
                        typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
 
2744
                .)                      
 
2745
          ]
 
2746
        
 
2747
        | PrimitiveTypeName<out name> (. typeref = new TypeReference(name, true); .)
 
2748
          [
 
2749
                "?"
 
2750
                (.
 
2751
                        List<TypeReference> typeArguments = new List<TypeReference>(1);
 
2752
                        if (typeref != null) typeArguments.Add(typeref);
 
2753
                        typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
 
2754
                .)                      
 
2755
          ]
 
2756
.
 
2757
 
 
2758
QualIdentAndTypeArguments<out TypeReference typeref, bool canBeUnbound>
 
2759
(. string name; typeref = null; .)
 
2760
=
 
2761
        Qualident<out name>
 
2762
        (. typeref = new TypeReference(name); .)
 
2763
        [IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
 
2764
                "(" "Of"
 
2765
                ( IF (canBeUnbound && (la.kind == Tokens.CloseParenthesis || la.kind == Tokens.Comma))
 
2766
                        (. typeref.GenericTypes.Add(NullTypeReference.Instance); .)
 
2767
                        { "," (. typeref.GenericTypes.Add(NullTypeReference.Instance); .) }
 
2768
                  | TypeArgumentList<typeref.GenericTypes>
 
2769
                )
 
2770
                ")"
 
2771
        ]
 
2772
.
 
2773
 
 
2774
/* 7.9 */
 
2775
ArrayNameModifier<out ArrayList arrayModifiers>
 
2776
(.
 
2777
        arrayModifiers = null;
 
2778
.) =
 
2779
        ArrayTypeModifiers<out arrayModifiers>
 
2780
.
 
2781
 
 
2782
 
 
2783
/* 7.9 */
 
2784
ArrayTypeModifiers<out ArrayList arrayModifiers>
 
2785
(.
 
2786
        arrayModifiers = new ArrayList();
 
2787
        int i = 0;
 
2788
.) =
 
2789
        {       IF (IsDims())
 
2790
                "("
 
2791
                [ RankList<out i>]
 
2792
                (.
 
2793
                        arrayModifiers.Add(i);
 
2794
                .)
 
2795
                ")"
 
2796
        }
 
2797
        (.
 
2798
                if(arrayModifiers.Count == 0) {
 
2799
                         arrayModifiers = null;
 
2800
                }
 
2801
        .)
 
2802
.
 
2803
 
 
2804
/* 7.9 */
 
2805
RankList<out int i>
 
2806
(. i = 0; .) =
 
2807
        { "," (. ++i; .) }
 
2808
.
 
2809
 
 
2810
/* 7.12 */
 
2811
TypeArgumentList<List<TypeReference> typeArguments>
 
2812
(.
 
2813
        TypeReference typeref;
 
2814
.) =
 
2815
        TypeName<out typeref> (. if (typeref != null) typeArguments.Add(typeref); .)
 
2816
        {
 
2817
                ","
 
2818
                TypeName<out typeref> (. if (typeref != null) typeArguments.Add(typeref); .)
 
2819
        }
 
2820
.
 
2821
 
 
2822
GlobalAttributeSection =
 
2823
        "<" (. Location startPos = t.Location; .)
 
2824
        ("Assembly" | "Module")
 
2825
                (.  string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
 
2826
                        List<ASTAttribute> attributes = new List<ASTAttribute>();
 
2827
                        ASTAttribute attribute;
 
2828
                .)
 
2829
        ":" Attribute<out attribute> (. attributes.Add(attribute); .)
 
2830
        { IF (NotFinalComma()) ["," ("Assembly" | "Module") ":"] Attribute<out attribute> (. attributes.Add(attribute); .)}
 
2831
        [ "," ]
 
2832
        ">"
 
2833
        EndOfStmt
 
2834
                (.
 
2835
                        AttributeSection section = new AttributeSection {
 
2836
                                AttributeTarget = attributeTarget,
 
2837
                                Attributes = attributes,
 
2838
                                StartLocation = startPos,
 
2839
                                EndLocation = t.EndLocation
 
2840
                        };
 
2841
                        AddChild(section);
 
2842
                .)
 
2843
        .
 
2844
 
 
2845
/* Spec, 5. */
 
2846
Attribute<out ASTAttribute attribute>
 
2847
(.
 
2848
        string name;
 
2849
        List<Expression> positional = new List<Expression>();
 
2850
        List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
 
2851
        Location startLocation = la.Location;
 
2852
.) =
 
2853
        [ "Global" "." ]
 
2854
        Qualident<out name>
 
2855
        [ AttributeArguments<positional, named> ]
 
2856
        (.
 
2857
                attribute  = new ASTAttribute(name, positional, named) { StartLocation = startLocation, EndLocation = t.EndLocation };
 
2858
        .)
 
2859
.
 
2860
 
 
2861
/* Spec, 5.2.2 */
 
2862
AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> named>
 
2863
        (.
 
2864
                bool nameFound = false;
 
2865
                string name = "";
 
2866
                Expression expr;
 
2867
        .) =
 
2868
        "("
 
2869
        [
 
2870
                IF (IsNotClosingParenthesis()) (
 
2871
                        (. Location startLocation = la.Location; .)
 
2872
                        [
 
2873
                                IF (IsNamedAssign()) (. nameFound = true; .)
 
2874
                                IdentifierOrKeyword<out name>
 
2875
                                ( ":=" | "=" )
 
2876
                        ] Expr<out expr>
 
2877
                                (.
 
2878
                                        if (expr != null) {
 
2879
                                                if (string.IsNullOrEmpty(name)) { positional.Add(expr); }
 
2880
                                                else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
 
2881
                                        }
 
2882
                                .)
 
2883
                        {
 
2884
                                ","
 
2885
                                        (
 
2886
                                                IF (IsNamedAssign())    (. nameFound = true; .)
 
2887
                                                IdentifierOrKeyword<out name>
 
2888
                                                ( ":=" | "=" )
 
2889
                                                | (. if (nameFound) Error("no positional argument after named argument"); .)
 
2890
                                        ) Expr<out expr>        (.      if (expr != null) { if(name == "") positional.Add(expr);
 
2891
                                                                                        else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
 
2892
                                                                                        }
 
2893
                                                                                .)
 
2894
                        }
 
2895
                )
 
2896
        ]
 
2897
        ")"
 
2898
        .
 
2899
 
 
2900
/* Spec, 5. */
 
2901
AttributeSection<out AttributeSection section>
 
2902
        (.
 
2903
                string attributeTarget = "";
 
2904
                List<ASTAttribute> attributes = new List<ASTAttribute>();
 
2905
                ASTAttribute attribute;
 
2906
                Location startLocation = la.Location;
 
2907
        .) =
 
2908
        "<"
 
2909
        [ IF (IsLocalAttrTarget())
 
2910
                ( "Event"               (. attributeTarget = "event";.)
 
2911
                | "Return"              (. attributeTarget = "return";.)
 
2912
                | Identifier
 
2913
                        (.
 
2914
                                string val = t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture);
 
2915
                                if (val != "field"      || val != "method" ||
 
2916
                                        val != "module" || val != "param"  ||
 
2917
                                        val != "property" || val != "type")
 
2918
                                Error("attribute target specifier (event, return, field," +
 
2919
                                                "method, module, param, property, or type) expected");
 
2920
                                attributeTarget = t.val;
 
2921
                        .)
 
2922
                ) ":" 
 
2923
        ]
 
2924
        Attribute<out attribute>        (. attributes.Add(attribute); .)
 
2925
        { IF (NotFinalComma()) "," Attribute<out attribute> (. attributes.Add(attribute); .) }
 
2926
        [ "," ]
 
2927
        ">"
 
2928
                (.
 
2929
                        section = new AttributeSection {
 
2930
                                AttributeTarget = attributeTarget,
 
2931
                                Attributes = attributes,
 
2932
                                StartLocation = startLocation,
 
2933
                                EndLocation = t.EndLocation
 
2934
                        };
 
2935
                .)
 
2936
        .
 
2937
 
 
2938
/* 9.2.5 */
 
2939
FormalParameterList<List<ParameterDeclarationExpression> parameter>
 
2940
(. ParameterDeclarationExpression p; .)
 
2941
=
 
2942
        FormalParameter<out p>  (. if (p != null) parameter.Add(p); .)
 
2943
        {       ","
 
2944
                FormalParameter<out p>  (. if (p != null) parameter.Add(p); .)
 
2945
        }
 
2946
.
 
2947
/* 9.2.5 */
 
2948
FormalParameter<out ParameterDeclarationExpression p>
 
2949
(.
 
2950
        AttributeSection section;
 
2951
        List<AttributeSection> attributes = new List<AttributeSection>();
 
2952
        TypeReference type = null;
 
2953
        ParamModifierList mod = new ParamModifierList(this);
 
2954
        Expression expr = null;
 
2955
        p = null;
 
2956
        ArrayList arrayModifiers = null;
 
2957
        Location startLocation = la.Location;
 
2958
.)
 
2959
=
 
2960
        { AttributeSection<out section> (. attributes.Add(section); .) }
 
2961
        { ParameterModifier<mod> }
 
2962
        Identifier (. string parameterName = t.val; .)
 
2963
        [ IF(IsDims()) ArrayTypeModifiers<out arrayModifiers> ]
 
2964
        [ "As" TypeName<out type> ]
 
2965
        (.
 
2966
                if(type != null) {
 
2967
                        if (arrayModifiers != null) {
 
2968
                                if (type.RankSpecifier != null) {
 
2969
                                        Error("array rank only allowed one time");
 
2970
                                } else {
 
2971
                                        type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int));
 
2972
                                }
 
2973
                        }
 
2974
                }
 
2975
        .)
 
2976
        [ "=" Expr<out expr> ]
 
2977
        (.
 
2978
                mod.Check();
 
2979
                p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr);
 
2980
                p.Attributes = attributes;
 
2981
                p.StartLocation = startLocation;
 
2982
                p.EndLocation = t.EndLocation;
 
2983
        .)
 
2984
.
 
2985
 
 
2986
/* 10.1 */
 
2987
Block<out Statement stmt>
 
2988
        =
 
2989
        (.
 
2990
                BlockStatement blockStmt = new BlockStatement();
 
2991
                /* in snippet parsing mode, t might be null */
 
2992
                if (t != null) blockStmt.StartLocation = t.EndLocation;
 
2993
                BlockStart(blockStmt);
 
2994
        .)
 
2995
        {       
 
2996
                        IF (IsEndStmtAhead())
 
2997
                                (. Token first = la; .)
 
2998
                                "End" EndOfStmt
 
2999
                                (.
 
3000
                                        AddChild(new EndStatement() {
 
3001
                                                StartLocation = first.Location,
 
3002
                                                EndLocation = first.EndLocation }
 
3003
                                        );
 
3004
                                .)
 
3005
                        | Statement EndOfStmt
 
3006
/*              IF (!LeaveBlock()) { }*/
 
3007
        }
 
3008
        (.
 
3009
                stmt = blockStmt;
 
3010
                if (t != null) blockStmt.EndLocation = t.EndLocation;
 
3011
                BlockEnd();
 
3012
        .)
 
3013
.
 
3014
 
 
3015
Statement
 
3016
        (.
 
3017
                Statement stmt = null;
 
3018
                Location startPos = la.Location;
 
3019
                string label = String.Empty;
 
3020
                
 
3021
        .) =
 
3022
        (
 
3023
                | IF (IsLabel()) LabelName<out label>
 
3024
                (.
 
3025
                        AddChild(new LabelStatement(t.val));
 
3026
                .)
 
3027
                ":" Statement
 
3028
                | EmbeddedStatement<out stmt>                   (. AddChild(stmt); .)
 
3029
        )
 
3030
        (.
 
3031
                if (stmt != null) {
 
3032
                        stmt.StartLocation = startPos;
 
3033
                        stmt.EndLocation = t.Location;
 
3034
                }
 
3035
        .)
 
3036
.
 
3037
 
 
3038
/* 10.2 */
 
3039
LocalDeclarationStatement<out Statement statement>
 
3040
        (.
 
3041
                ModifierList m = new ModifierList();
 
3042
                LocalVariableDeclaration localVariableDeclaration;
 
3043
                bool dimfound = false;
 
3044
        .) =
 
3045
        /* this differs from the spec: dim static x     compiles with vbc. */
 
3046
        {
 
3047
                "Const"         (. m.Add(Modifiers.Const, t.Location); .)
 
3048
                | "Static"      (. m.Add(Modifiers.Static, t.Location); .)
 
3049
                | "Dim"         (. dimfound = true; .)
 
3050
        }
 
3051
        (.
 
3052
                if(dimfound && (m.Modifier & Modifiers.Const) != 0) {
 
3053
                        Error("Dim is not allowed on constants.");
 
3054
                }
 
3055
                
 
3056
                if(m.isNone && dimfound == false) {
 
3057
                        Error("Const, Dim or Static expected");
 
3058
                }
 
3059
                
 
3060
                localVariableDeclaration = new LocalVariableDeclaration(m.Modifier);
 
3061
                localVariableDeclaration.StartLocation = t.Location;
 
3062
        .)
 
3063
        VariableDeclarator<localVariableDeclaration.Variables>
 
3064
        { "," VariableDeclarator<localVariableDeclaration.Variables> }
 
3065
        (.
 
3066
                statement = localVariableDeclaration;
 
3067
        .)
 
3068
.
 
3069
 
 
3070
EmbeddedStatement<out Statement statement>
 
3071
        (.
 
3072
                Statement embeddedStatement = null;
 
3073
                statement = null;
 
3074
                Expression expr = null;
 
3075
                string name = String.Empty;
 
3076
                List<Expression> p = null;
 
3077
                Location startLocation = la.Location;
 
3078
        .) =
 
3079
        (
 
3080
                "Exit"                          (. ExitType exitType = ExitType.None; .)
 
3081
                (
 
3082
                "Sub"                           (. exitType = ExitType.Sub; .)
 
3083
                |
 
3084
                "Function"                      (. exitType = ExitType.Function; .)
 
3085
                |
 
3086
                "Property"                      (. exitType = ExitType.Property; .)
 
3087
                |
 
3088
                "Do"                            (. exitType = ExitType.Do; .)
 
3089
                |
 
3090
                "For"                           (. exitType = ExitType.For; .)
 
3091
                |
 
3092
                "Try"                           (. exitType = ExitType.Try; .)
 
3093
                |
 
3094
                "While"                         (. exitType = ExitType.While; .)
 
3095
                |
 
3096
                "Select"                        (. exitType = ExitType.Select; .)
 
3097
                )
 
3098
        (. statement = new ExitStatement(exitType); .)
 
3099
        | TryStatement<out statement>
 
3100
        | "Continue" (. ContinueType continueType = ContinueType.None; .) [ "Do" (. continueType = ContinueType.Do; .) | "For" (. continueType = ContinueType.For; .) | "While" (. continueType = ContinueType.While; .)] (. statement = new ContinueStatement(continueType); .)
 
3101
        | /* 10.10.1.3 */
 
3102
        "Throw" [ Expr<out expr> ]                              (. statement = new ThrowStatement(expr); .)
 
3103
        | /* 10.11 */
 
3104
        "Return" [ Expr<out expr> ]                     (. statement = new ReturnStatement(expr); .)
 
3105
        | /* 10.4 */
 
3106
        "SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement>
 
3107
        "End" "SyncLock"                                                (. statement = new LockStatement(expr, embeddedStatement); .)
 
3108
        | /* 10.5.1 */
 
3109
        "RaiseEvent" Identifier (. name = t.val; .)
 
3110
        [ "(" [ ArgumentList<out p> ] ")" ]
 
3111
        (.
 
3112
                statement = new RaiseEventStatement(name, p);
 
3113
        .)
 
3114
        | /* 10.3 */
 
3115
        WithStatement<out statement>
 
3116
        | /* 10.5.2 */
 
3117
        "AddHandler" (. Expression handlerExpr = null; .)
 
3118
        Expr<out expr> "," Expr<out handlerExpr>
 
3119
        (.
 
3120
                statement = new AddHandlerStatement(expr, handlerExpr);
 
3121
        .)
 
3122
        | /* 10.5.2 */
 
3123
        "RemoveHandler" (. Expression handlerExpr = null; .)
 
3124
        Expr<out expr> "," Expr<out handlerExpr>
 
3125
        (.
 
3126
                statement = new RemoveHandlerStatement(expr, handlerExpr);
 
3127
        .)
 
3128
        | /* 10.9.1 */
 
3129
        "While" Expr<out expr> EndOfStmt
 
3130
        Block<out embeddedStatement> "End" "While"
 
3131
        (.
 
3132
                statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
 
3133
        .)
 
3134
        | /* 10.9.1 */
 
3135
        "Do"
 
3136
        (.
 
3137
                ConditionType conditionType = ConditionType.None;
 
3138
        .)
 
3139
        (
 
3140
                WhileOrUntil<out conditionType> Expr<out expr> EndOfStmt
 
3141
                Block<out embeddedStatement>
 
3142
                "Loop"
 
3143
                (.
 
3144
                        statement = new DoLoopStatement(expr, 
 
3145
                                                        embeddedStatement, 
 
3146
                                                        conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType, 
 
3147
                                                        ConditionPosition.Start);
 
3148
                .)
 
3149
                |
 
3150
                EndOfStmt
 
3151
                Block<out embeddedStatement>
 
3152
                "Loop" [WhileOrUntil<out conditionType> Expr<out expr>]
 
3153
                (.
 
3154
                        statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
 
3155
                .)
 
3156
        )
 
3157
        | "For"
 
3158
        (.
 
3159
                        Expression group = null;
 
3160
                        TypeReference typeReference;
 
3161
                        string        typeName;
 
3162
        .)
 
3163
        (
 
3164
                /* 10.9.3  */
 
3165
                "Each" LoopControlVariable<out typeReference, out typeName>
 
3166
                "In" Expr<out group> EndOfStmt
 
3167
                Block<out embeddedStatement>
 
3168
                "Next" [ Expr<out expr> ]
 
3169
                (.
 
3170
                        statement = new ForeachStatement(typeReference, 
 
3171
                                                         typeName,
 
3172
                                                         group, 
 
3173
                                                         embeddedStatement, 
 
3174
                                                         expr);
 
3175
                        statement.StartLocation = startLocation;
 
3176
                        statement.EndLocation   = t.EndLocation;
 
3177
                        
 
3178
                .)
 
3179
                | /* 10.9.2 */
 
3180
                (.
 
3181
                        Expression start = null;
 
3182
                        Expression end = null;
 
3183
                        Expression step = null;
 
3184
                        Expression variableExpr = null;
 
3185
                        Expression nextExpr = null;
 
3186
                        List<Expression> nextExpressions = null;
 
3187
                .)
 
3188
                (       IF (IsLoopVariableDeclaration())
 
3189
                        LoopControlVariable<out typeReference, out typeName>
 
3190
                |
 
3191
                        (. typeReference = null; typeName = null; .)
 
3192
                        SimpleExpr<out variableExpr>
 
3193
                )
 
3194
                "=" Expr<out start> "To" Expr<out end> [ "Step" Expr<out step> ]
 
3195
                EndOfStmt Block<out embeddedStatement>
 
3196
                "Next"
 
3197
                [
 
3198
                        Expr<out nextExpr>
 
3199
                        (.
 
3200
                                nextExpressions = new List<Expression>();
 
3201
                                nextExpressions.Add(nextExpr);
 
3202
                        .)
 
3203
                        { "," Expr<out nextExpr> (. nextExpressions.Add(nextExpr); .) }
 
3204
                ]
 
3205
                (.
 
3206
                        statement = new ForNextStatement {
 
3207
                                TypeReference = typeReference,
 
3208
                                VariableName = typeName, 
 
3209
                                LoopVariableExpression = variableExpr,
 
3210
                                Start = start, 
 
3211
                                End = end, 
 
3212
                                Step = step, 
 
3213
                                EmbeddedStatement = embeddedStatement, 
 
3214
                                NextExpressions = nextExpressions
 
3215
                        };
 
3216
                .)
 
3217
        )
 
3218
        | /* 10.10.2.1 */
 
3219
        "Error" Expr<out expr>                          (. statement = new ErrorStatement(expr); .)
 
3220
        | /* 10.12.1 */
 
3221
        "ReDim" (. bool isPreserve = false; .) [ "Preserve" (. isPreserve = true; .) ]
 
3222
        ReDimClause<out expr>
 
3223
        (.
 
3224
                ReDimStatement reDimStatement = new ReDimStatement(isPreserve);
 
3225
                statement = reDimStatement;
 
3226
                SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression);
 
3227
        .)
 
3228
        { "," ReDimClause<out expr>
 
3229
                (. SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); .)
 
3230
        }
 
3231
        | /* 10.12.2 */
 
3232
        "Erase"
 
3233
        Expr<out expr>
 
3234
        (.
 
3235
                EraseStatement eraseStatement = new EraseStatement();
 
3236
                if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr);}
 
3237
        .)
 
3238
        { "," Expr<out expr> (. if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); }.) }
 
3239
        (. statement = eraseStatement; .)
 
3240
        | /* 10.11 */
 
3241
        "Stop" (. statement = new StopStatement(); .)
 
3242
        | /* 10.8.1 */
 
3243
        IF (la.kind == Tokens.If) 
 
3244
        "If" (. Location ifStartLocation = t.Location; .) Expr<out expr> [ "Then" ] 
 
3245
        (       
 
3246
                /* multiline if statement */
 
3247
                EndOfStmt Block<out embeddedStatement>
 
3248
                (.
 
3249
                        IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement);
 
3250
                        ifStatement.StartLocation = ifStartLocation;
 
3251
                        Location elseIfStart;
 
3252
                .)
 
3253
                {
 
3254
                        (
 
3255
                                IF(IsElseIf()) "Else" (. elseIfStart = t.Location; .)  "If"
 
3256
                                | "ElseIf" (. elseIfStart = t.Location; .)
 
3257
                        )
 
3258
                        (. Expression condition = null; Statement block = null; .)
 
3259
                        Expr<out condition> [ "Then"] EndOfStmt
 
3260
                        Block<out block>
 
3261
                        (.
 
3262
                                ElseIfSection elseIfSection = new ElseIfSection(condition, block);
 
3263
                                elseIfSection.StartLocation = elseIfStart;
 
3264
                                elseIfSection.EndLocation = t.Location;
 
3265
                                elseIfSection.Parent = ifStatement;
 
3266
                                ifStatement.ElseIfSections.Add(elseIfSection);
 
3267
                        .)
 
3268
                }
 
3269
                [
 
3270
                        "Else" [EndOfStmt]
 
3271
                        Block<out embeddedStatement>
 
3272
                        (.
 
3273
                                ifStatement.FalseStatement.Add(embeddedStatement);
 
3274
                        .)
 
3275
                ] "End" "If"
 
3276
                (.
 
3277
                        ifStatement.EndLocation = t.Location;
 
3278
                        statement = ifStatement;
 
3279
                .)
 
3280
        |       /* singleline if statement */
 
3281
                (.
 
3282
                        IfElseStatement ifStatement = new IfElseStatement(expr);
 
3283
                        ifStatement.StartLocation = ifStartLocation;
 
3284
                .)
 
3285
                SingleLineStatementList<ifStatement.TrueStatement>
 
3286
                [
 
3287
                        "Else"
 
3288
                        [ SingleLineStatementList<ifStatement.FalseStatement> ]
 
3289
                ]
 
3290
                (. ifStatement.EndLocation = t.Location; statement = ifStatement; .)
 
3291
        )
 
3292
        | /* 10.8.2 */
 
3293
        "Select" [ "Case" ] Expr<out expr> EndOfStmt
 
3294
        (.List<SwitchSection> selectSections = new List<SwitchSection>();
 
3295
                Statement block = null;
 
3296
        .)
 
3297
        {
 
3298
                (.List<CaseLabel> caseClauses = null; Location caseLocation = la.Location; .)
 
3299
                "Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
 
3300
                (.
 
3301
                        SwitchSection selectSection = new SwitchSection(caseClauses);
 
3302
                        selectSection.StartLocation = caseLocation;
 
3303
                .)
 
3304
                Block<out block>
 
3305
                (.
 
3306
                        selectSection.Children = block.Children;
 
3307
                        selectSection.EndLocation = t.EndLocation;
 
3308
                        selectSections.Add(selectSection);
 
3309
                .)
 
3310
        }
 
3311
        (.
 
3312
                statement = new SwitchStatement(expr, selectSections);
 
3313
        .)
 
3314
        "End" "Select"
 
3315
        | (. OnErrorStatement onErrorStatement = null; .)
 
3316
        OnErrorStatement<out onErrorStatement> (. statement = onErrorStatement; .)
 
3317
        | (. GotoStatement goToStatement = null; .)
 
3318
        GotoStatement<out goToStatement> (. statement = goToStatement; .)
 
3319
        | (. ResumeStatement resumeStatement = null; .)
 
3320
        ResumeStatement<out resumeStatement> (. statement = resumeStatement; .)
 
3321
        |/* Statement expression (invocation and assignment) 10.6.1, 10.6.2, 10.6.3 */
 
3322
        (.
 
3323
                Expression val = null;
 
3324
                AssignmentOperatorType op;
 
3325
                Location startLoc = la.Location;
 
3326
                
 
3327
                bool mustBeAssignment = la.kind == Tokens.Plus  || la.kind == Tokens.Minus ||
 
3328
                                        la.kind == Tokens.Not   || la.kind == Tokens.Times;
 
3329
        .)
 
3330
        SimpleExpr<out expr>
 
3331
                (
 
3332
                AssignmentOperator<out op> Expr<out val>
 
3333
                (.
 
3334
                        expr = new AssignmentExpression(expr, op, val);
 
3335
                        expr.StartLocation = startLoc;
 
3336
                        expr.EndLocation = t.EndLocation;
 
3337
                .)
 
3338
                | (. if (mustBeAssignment) Error("error in assignment."); .)
 
3339
                )
 
3340
                (.
 
3341
                        // a field reference expression that stands alone is a
 
3342
                        // invocation expression without parantheses and arguments
 
3343
                        if(expr is MemberReferenceExpression || expr is IdentifierExpression) {
 
3344
                                Location endLocation = expr.EndLocation;
 
3345
                                expr = new InvocationExpression(expr);
 
3346
                                expr.StartLocation = startLoc;
 
3347
                                expr.EndLocation = endLocation;
 
3348
                        }
 
3349
                        statement = new ExpressionStatement(expr);
 
3350
                .)
 
3351
        | "Call" SimpleExpr<out expr> (. statement = new ExpressionStatement(expr); .)
 
3352
        | "Using"
 
3353
                (. Statement block;  .)
 
3354
                ( IF (Peek(1).kind == Tokens.As)
 
3355
                        (. LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); .)
 
3356
                        VariableDeclarator<resourceAquisition.Variables>
 
3357
                        { ","
 
3358
                          VariableDeclarator<resourceAquisition.Variables>
 
3359
                        }
 
3360
                        Block<out block>
 
3361
                        (.
 
3362
                                statement = new UsingStatement(resourceAquisition, block);
 
3363
                        .)
 
3364
                |       Expr<out expr>
 
3365
                        Block<out block>
 
3366
                        (. statement = new UsingStatement(new ExpressionStatement(expr), block); .)
 
3367
                )
 
3368
                "End" "Using"
 
3369
        | LocalDeclarationStatement<out statement>
 
3370
)
 
3371
(.
 
3372
        if (statement != null) {
 
3373
                statement.StartLocation = startLocation;
 
3374
                statement.EndLocation = t.EndLocation;
 
3375
        }
 
3376
.)
 
3377
.
 
3378
 
 
3379
SingleLineStatementList<List<Statement> list>
 
3380
(. Statement embeddedStatement = null; .)
 
3381
=
 
3382
        ( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
 
3383
        | EmbeddedStatement<out embeddedStatement> )
 
3384
        (. if (embeddedStatement != null) list.Add(embeddedStatement); .)
 
3385
        {       ":" { ":" }
 
3386
                ( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
 
3387
                | EmbeddedStatement<out embeddedStatement> )
 
3388
                (. if (embeddedStatement != null) list.Add(embeddedStatement); .)
 
3389
        }
 
3390
.
 
3391
 
 
3392
/* 10.9.2 */
 
3393
LoopControlVariable<out TypeReference type, out string name>
 
3394
(.ArrayList arrayModifiers = null;
 
3395
        type = null;
 
3396
.)
 
3397
=
 
3398
        Qualident<out name>
 
3399
        [ IF(IsDims()) ArrayTypeModifiers<out arrayModifiers> ]
 
3400
        [ "As" TypeName<out type> (. if (name.IndexOf('.') > 0) { Error("No type def for 'for each' member indexer allowed."); } .) ]
 
3401
        (.
 
3402
                if (type != null) {
 
3403
                        if(type.RankSpecifier != null && arrayModifiers != null) {
 
3404
                                Error("array rank only allowed one time");
 
3405
                        } else if (arrayModifiers != null) {
 
3406
                                type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int));
 
3407
                        }
 
3408
                }
 
3409
        .)
 
3410
.
 
3411
 
 
3412
/* 10.2.2 */
 
3413
OnErrorStatement<out OnErrorStatement stmt>
 
3414
        (.
 
3415
                stmt = null;
 
3416
                Location startLocation = la.Location;
 
3417
                GotoStatement goToStatement = null;
 
3418
        .)
 
3419
        =
 
3420
        "On" "Error"
 
3421
        (
 
3422
                IF(IsNegativeLabelName())"GoTo" "-" LiteralInteger
 
3423
                (.
 
3424
                        long intLabel = Int64.Parse(t.val);
 
3425
                        if(intLabel != 1) {
 
3426
                                Error("invalid label in on error statement.");
 
3427
                        }
 
3428
                        stmt = new OnErrorStatement(new GotoStatement((intLabel * -1).ToString()));
 
3429
                .)
 
3430
                | GotoStatement<out goToStatement>
 
3431
                (.
 
3432
                        string val = goToStatement.Label;
 
3433
                        
 
3434
                        // if value is numeric, make sure that is 0
 
3435
                        try {
 
3436
                                long intLabel = Int64.Parse(val);
 
3437
                                if(intLabel != 0) {
 
3438
                                        Error("invalid label in on error statement.");
 
3439
                                }
 
3440
                        } catch {
 
3441
                        }
 
3442
                        stmt = new OnErrorStatement(goToStatement);
 
3443
                .)
 
3444
                | "Resume" "Next"
 
3445
                (.
 
3446
                        stmt = new OnErrorStatement(new ResumeStatement(true));
 
3447
                .)
 
3448
        )
 
3449
        (.
 
3450
                if (stmt != null) {
 
3451
                        stmt.StartLocation = startLocation;
 
3452
                        stmt.EndLocation = t.EndLocation;
 
3453
                }
 
3454
        .)
 
3455
        .
 
3456
 
 
3457
/* 10.11 */
 
3458
GotoStatement<out GotoStatement goToStatement>
 
3459
        (. string label = String.Empty; Location startLocation = la.Location; .)
 
3460
        =
 
3461
        "GoTo" LabelName<out label>
 
3462
        (.
 
3463
                goToStatement = new GotoStatement(label) {
 
3464
                        StartLocation = startLocation,
 
3465
                        EndLocation = t.EndLocation
 
3466
                };
 
3467
        .)
 
3468
.
 
3469
 
 
3470
/* 10.1 */
 
3471
LabelName<out string name>
 
3472
        (.
 
3473
                name = String.Empty;
 
3474
        .) =
 
3475
        Identifier                              (. name = t.val; .)
 
3476
        | LiteralInteger        (. name = t.val; .)
 
3477
        .
 
3478
 
 
3479
/* 12.12.1 */
 
3480
ReDimClause<out Expression expr>
 
3481
=
 
3482
        SimpleNonInvocationExpression<out expr>
 
3483
        ReDimClauseInternal<ref expr>
 
3484
.
 
3485
 
 
3486
ReDimClauseInternal<ref Expression expr>
 
3487
(. List<Expression> arguments; bool canBeNormal; bool canBeRedim; string name; Location startLocation = la.Location; .)
 
3488
=
 
3489
        { "." IdentifierOrKeyword<out name> (. expr = new MemberReferenceExpression(expr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
 
3490
        |  IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
 
3491
                InvocationExpression<ref expr>
 
3492
                (.
 
3493
                        expr.StartLocation = startLocation;
 
3494
                        expr.EndLocation = t.EndLocation;
 
3495
                .)
 
3496
        }
 
3497
        "("
 
3498
        NormalOrReDimArgumentList<out arguments, out canBeNormal, out canBeRedim>
 
3499
        ")"
 
3500
        (.      expr = new InvocationExpression(expr, arguments);
 
3501
                if (canBeRedim == false || canBeNormal && (la.kind == Tokens.Dot || la.kind == Tokens.OpenParenthesis)) {
 
3502
                        if (this.Errors.Count == 0) {
 
3503
                                // don't recurse on parse errors - could result in endless recursion
 
3504
                                ReDimClauseInternal(ref expr);
 
3505
                        }
 
3506
                }
 
3507
        .)
 
3508
.
 
3509
 
 
3510
/* 10.10.2.3 */
 
3511
ResumeStatement<out ResumeStatement resumeStatement>
 
3512
        (.
 
3513
                resumeStatement = null;
 
3514
                string label = String.Empty;
 
3515
        .) =
 
3516
        IF(IsResumeNext())
 
3517
        "Resume" "Next"                                         (. resumeStatement = new ResumeStatement(true); .)
 
3518
        | "Resume" [ LabelName<out label> ]     (. resumeStatement = new ResumeStatement(label); .)
 
3519
        .
 
3520
 
 
3521
/* 18.8.2 */
 
3522
CaseClauses<out List<CaseLabel> caseClauses>
 
3523
        (.
 
3524
                caseClauses = new List<CaseLabel>();
 
3525
                CaseLabel caseClause = null;
 
3526
        .) =
 
3527
        CaseClause<out caseClause> (. if (caseClause != null) { caseClauses.Add(caseClause); } .)
 
3528
        { "," CaseClause<out caseClause> (. if (caseClause != null) { caseClauses.Add(caseClause); } .) }
 
3529
        .
 
3530
 
 
3531
/* 19.8.2 */
 
3532
CaseClause<out CaseLabel caseClause>
 
3533
        (.
 
3534
                Expression expr = null;
 
3535
                Expression sexpr = null;
 
3536
                BinaryOperatorType op = BinaryOperatorType.None;
 
3537
                caseClause = null;
 
3538
        .) =
 
3539
        "Else"
 
3540
        (. caseClause = new CaseLabel(); .)
 
3541
        |
 
3542
        [ "Is" ] 
 
3543
        (
 
3544
                "<"             (. op = BinaryOperatorType.LessThan; .)
 
3545
                | ">"   (. op = BinaryOperatorType.GreaterThan; .)
 
3546
                | "<="  (. op = BinaryOperatorType.LessThanOrEqual; .)
 
3547
                | ">="  (. op = BinaryOperatorType.GreaterThanOrEqual; .)
 
3548
                | "="   (. op = BinaryOperatorType.Equality; .)
 
3549
                | "<>"  (. op = BinaryOperatorType.InEquality; .)
 
3550
        )
 
3551
        Expr<out expr>
 
3552
        (.
 
3553
                caseClause = new CaseLabel(op, expr);
 
3554
        .)
 
3555
        | Expr<out expr> [ "To" Expr<out sexpr> ]
 
3556
        (.
 
3557
                caseClause = new CaseLabel(expr, sexpr);
 
3558
        .)
 
3559
        .
 
3560
 
 
3561
/* 10.9.1 */
 
3562
WhileOrUntil<out ConditionType conditionType>
 
3563
        (. conditionType = ConditionType.None; .) =
 
3564
        "While"         (. conditionType = ConditionType.While; .)
 
3565
        | "Until"       (. conditionType = ConditionType.Until; .)
 
3566
        .
 
3567
 
 
3568
/* 10.3 */
 
3569
WithStatement<out Statement withStatement>
 
3570
        (.
 
3571
                Statement blockStmt = null;
 
3572
                Expression expr = null;
 
3573
        .) =
 
3574
        "With" (. Location start = t.Location; .)
 
3575
        Expr<out expr> EndOfStmt
 
3576
        (.
 
3577
                withStatement = new WithStatement(expr);
 
3578
                withStatement.StartLocation = start;
 
3579
        .)
 
3580
        Block<out blockStmt>
 
3581
        (.
 
3582
                ((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
 
3583
        .)
 
3584
        "End" "With"
 
3585
        (. withStatement.EndLocation = t.Location; .)
 
3586
        .
 
3587
        
 
3588
/* 10.10.1 */
 
3589
TryStatement<out Statement tryStatement>
 
3590
        (.
 
3591
                Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
 
3592
        .) =
 
3593
        "Try" EndOfStmt
 
3594
        Block<out blockStmt>
 
3595
        [CatchClauses<out catchClauses>]
 
3596
        ["Finally" EndOfStmt Block<out finallyStmt> ]
 
3597
        "End" "Try"
 
3598
        (.
 
3599
                tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
 
3600
        .)
 
3601
        .
 
3602
 
 
3603
/* 10.10.1.2 */
 
3604
CatchClauses<out List<CatchClause> catchClauses>
 
3605
        (.
 
3606
                catchClauses = new List<CatchClause>();
 
3607
                TypeReference type = null;
 
3608
                Statement blockStmt = null;
 
3609
                Expression expr = null;
 
3610
                string name = String.Empty;
 
3611
        .) =
 
3612
        {
 
3613
                "Catch"
 
3614
                [ Identifier (. name = t.val; .) ["As" TypeName<out type>] ]
 
3615
                [ "When" Expr<out expr> ]
 
3616
                EndOfStmt
 
3617
                Block<out blockStmt>
 
3618
                (. catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); .)
 
3619
        }
 
3620
        .
 
3621
 
 
3622
/* 4.7 */
 
3623
Qualident<out string qualident>
 
3624
(. 
 
3625
        string name;
 
3626
        qualidentBuilder.Length = 0; 
 
3627
.)
 
3628
=
 
3629
        Identifier      (. qualidentBuilder.Append(t.val); .)
 
3630
        { IF (DotAndIdentOrKw()) "." IdentifierOrKeyword<out name> (. qualidentBuilder.Append('.'); qualidentBuilder.Append(name); .) }
 
3631
        
 
3632
        (. qualident = qualidentBuilder.ToString(); .)
 
3633
.
 
3634
 
 
3635
/* This production handles pseudo keywords that are needed in the grammar */
 
3636
Identifier      =
 
3637
        IdentifierForFieldDeclaration
 
3638
        | "Custom" 
 
3639
.
 
3640
 
 
3641
IdentifierForFieldDeclaration =
 
3642
        ident
 
3643
        | "Aggregate"
 
3644
        | "Ansi"
 
3645
        | "Ascending"
 
3646
        | "Assembly"
 
3647
        | "Auto"
 
3648
        | "Binary"
 
3649
        | "By"
 
3650
        | "Compare"
 
3651
        | "Descending"
 
3652
        | "Distinct"
 
3653
        | "Equals"
 
3654
        | "Explicit"
 
3655
        | "From"
 
3656
        | "Group"
 
3657
        | "Infer"
 
3658
        | "Into"
 
3659
        | "Join"
 
3660
        | "Key"
 
3661
        | "Off"
 
3662
        | "Order"
 
3663
        | "Out"
 
3664
        | "Preserve"
 
3665
        | "Skip"
 
3666
        | "Take"
 
3667
        | "Text"
 
3668
        | "Unicode"
 
3669
        | "Until"
 
3670
        | "Where"
 
3671
.
 
3672
 
 
3673
/* 2.2 */
 
3674
 
 
3675
IdentifierOrKeyword<out string name>
 
3676
=
 
3677
        ANY (. name = t.val;  .)
 
3678
.
 
3679
 
 
3680
 
 
3681
/* 7.3 */
 
3682
PrimitiveTypeName<out string type>
 
3683
        (. type = String.Empty; .) =
 
3684
        "Boolean"               (. type = "System.Boolean"; .)
 
3685
        | "Date"                (. type = "System.DateTime"; .)
 
3686
        | "Char"                (. type = "System.Char"; .)
 
3687
        | "String"              (. type = "System.String"; .)
 
3688
        | "Decimal"             (. type = "System.Decimal"; .)
 
3689
        | "Byte"                (. type = "System.Byte"; .)
 
3690
        | "Short"               (. type = "System.Int16"; .)
 
3691
        | "Integer"             (. type = "System.Int32"; .)
 
3692
        | "Long"                (. type = "System.Int64"; .)
 
3693
        | "Single"              (. type = "System.Single"; .)
 
3694
        | "Double"              (. type = "System.Double"; .)
 
3695
        | "UInteger"    (. type = "System.UInt32"; .)
 
3696
        | "ULong"               (. type = "System.UInt64"; .)
 
3697
        | "UShort"              (. type = "System.UInt16"; .)
 
3698
        | "SByte"               (. type = "System.SByte"; .)
 
3699
        .
 
3700
 
 
3701
ParameterModifier<ParamModifierList m>
 
3702
        = "ByVal"                       (. m.Add(ParameterModifiers.In); .)
 
3703
        | "ByRef"                       (. m.Add(ParameterModifiers.Ref); .)
 
3704
        | "Optional"            (. m.Add(ParameterModifiers.Optional); .)
 
3705
        | "ParamArray"          (. m.Add(ParameterModifiers.Params); .)
 
3706
        .
 
3707
 
 
3708
TypeModifier<ModifierList m>
 
3709
=         "Public"                      (. m.Add(Modifiers.Public, t.Location); .)
 
3710
        | "Protected"           (. m.Add(Modifiers.Protected, t.Location); .)
 
3711
        | "Friend"                      (. m.Add(Modifiers.Internal, t.Location); .)
 
3712
        | "Private"                     (. m.Add(Modifiers.Private, t.Location); .)
 
3713
        | "Shared"                      (. m.Add(Modifiers.Static, t.Location); .)
 
3714
        | "Shadows"                     (. m.Add(Modifiers.New, t.Location); .)
 
3715
        | "MustInherit"         (. m.Add(Modifiers.Abstract, t.Location); .)
 
3716
        | "NotInheritable"      (. m.Add(Modifiers.Sealed, t.Location); .)
 
3717
        | "Partial"                     (. m.Add(Modifiers.Partial, t.Location); .)
 
3718
.
 
3719
 
 
3720
MemberModifier<ModifierList m> =
 
3721
          "MustInherit"         (.m.Add(Modifiers.Abstract, t.Location);.)
 
3722
        | "Default"                     (.m.Add(Modifiers.Default, t.Location);.)
 
3723
        | "Friend"                      (.m.Add(Modifiers.Internal, t.Location);.)
 
3724
        | "Shadows"                     (.m.Add(Modifiers.New, t.Location);.)
 
3725
        | "Overrides"           (.m.Add(Modifiers.Override, t.Location);.)
 
3726
        | "MustOverride"        (.m.Add(Modifiers.Abstract, t.Location);.)
 
3727
        | "Private"                     (.m.Add(Modifiers.Private, t.Location);.)
 
3728
        | "Protected"           (.m.Add(Modifiers.Protected, t.Location);.)
 
3729
        | "Public"                      (.m.Add(Modifiers.Public, t.Location);.)
 
3730
        | "NotInheritable"      (.m.Add(Modifiers.Sealed, t.Location);.)
 
3731
        | "NotOverridable"      (.m.Add(Modifiers.Sealed, t.Location);.)
 
3732
        | "Shared"                      (.m.Add(Modifiers.Static, t.Location);.)
 
3733
        | "Overridable"         (.m.Add(Modifiers.Virtual, t.Location);.)
 
3734
        | "Overloads"           (.m.Add(Modifiers.Overloads, t.Location);.)
 
3735
        | "ReadOnly"            (.m.Add(Modifiers.ReadOnly, t.Location);.)
 
3736
        | "WriteOnly"           (.m.Add(Modifiers.WriteOnly, t.Location);.)
 
3737
        | "WithEvents"          (.m.Add(Modifiers.WithEvents, t.Location);.)
 
3738
        | "Dim"                         (.m.Add(Modifiers.Dim, t.Location);.)
 
3739
        | "Partial"                     (.m.Add(Modifiers.Partial, t.Location);.)
 
3740
.
 
3741
 
 
3742
PropertyAccessorAccessModifier<out Modifiers m> =
 
3743
        (. m = Modifiers.None; .)
 
3744
        {(
 
3745
                "Public"    (. m |= Modifiers.Public; .)
 
3746
         |  "Protected" (. m |= Modifiers.Protected; .)
 
3747
         |  "Friend"    (. m |= Modifiers.Internal; .)
 
3748
         |  "Private"   (. m |= Modifiers.Private; .)
 
3749
        )}
 
3750
.
 
3751
 
 
3752
END VBNET.