1
using System.Collections;
2
using System.Collections.Generic;
3
using System.Collections.Specialized;
6
using ICSharpCode.NRefactory.Ast;
7
using ICSharpCode.NRefactory.Parser.VB;
8
using ASTAttribute = ICSharpCode.NRefactory.Ast.Attribute;
12
/* START AUTOGENERATED TOKENS SECTION */
14
/* ----- terminal classes ----- */
29
XmlCloseTagEmptyElement
34
XmlProcessingInstruction
36
/* ----- special character ----- */
74
/* ----- keywords ----- */
257
/* END AUTOGENERATED TOKENS SECTION */
263
lexer.NextToken(); // get the first token
264
compilationUnit = new CompilationUnit();
265
BlockStart(compilationUnit);
269
{ OptionStmt { EndOfStmt } }
270
{ ImportsStmt { EndOfStmt } }
271
{ IF (IsGlobalAttrTarget()) GlobalAttributeSection { EndOfStmt } }
272
{ NamespaceMemberDecl { EndOfStmt } }
276
OptionStmt (. INode node = null; bool val = true; .) =
277
"Option" (. Location startPos = t.Location; .)
279
"Explicit" [ OptionValue<ref val> ]
280
(. node = new OptionDeclaration(OptionType.Explicit, val); .)
282
"Strict" [ OptionValue<ref val> ]
283
(. node = new OptionDeclaration(OptionType.Strict, val); .)
285
"Compare" ( "Binary" (. node = new OptionDeclaration(OptionType.CompareBinary, val); .)
286
| "Text" (. node = new OptionDeclaration(OptionType.CompareText, val); .)
289
"Infer" [ OptionValue<ref val> ]
290
(. node = new OptionDeclaration(OptionType.Infer, val); .)
295
node.StartLocation = startPos;
296
node.EndLocation = t.Location;
302
OptionValue<ref bool val> =
304
"On" (. val = true; .)
306
"Off" (. val = false; .)
315
(.List<Using> usings = new List<Using>();
319
Location startPos = t.Location;
322
ImportClause<out u> (. if (u != null) { usings.Add(u); } .)
324
"," ImportClause<out u> (. if (u != null) { usings.Add(u); } .)
328
UsingDeclaration usingDeclaration = new UsingDeclaration(usings);
329
usingDeclaration.StartLocation = startPos;
330
usingDeclaration.EndLocation = t.Location;
331
AddChild(usingDeclaration);
335
ImportClause<out Using u>
337
string qualident = null;
338
TypeReference aliasedType = null;
342
Qualident<out qualident>
343
[ "=" TypeName<out aliasedType> ]
345
if (qualident != null && qualident.Length > 0) {
346
if (aliasedType != null) {
347
u = new Using(qualident, aliasedType);
349
u = new Using(qualident);
353
) | ( (. string prefix = null; .)
354
XmlOpenTag Identifier (. prefix = t.val; .) "=" LiteralString (. u = new Using(t.literalValue as string, prefix); .) XmlCloseTag
361
ModifierList m = new ModifierList();
362
AttributeSection section;
363
List<AttributeSection> attributes = new List<AttributeSection>();
368
Location startPos = t.Location;
370
Qualident<out qualident>
372
INode node = new NamespaceDeclaration(qualident);
373
node.StartLocation = startPos;
380
node.EndLocation = t.Location;
384
{ AttributeSection<out section> (. attributes.Add(section); .) }
385
{ TypeModifier<m> } NonModuleDeclaration<m, attributes> )
389
TypeParameterList<List<TemplateDefinition> templates>
391
TemplateDefinition template;
395
IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
396
"(" "Of" TypeParameter<out template>
398
if (template != null) templates.Add(template);
401
"," TypeParameter<out template>
403
if (template != null) templates.Add(template);
411
TypeParameter<out TemplateDefinition template>
412
(. VarianceModifier modifier = VarianceModifier.Invariant; Location startLocation = la.Location; .)
415
[ "In" (. modifier = VarianceModifier.Contravariant; .) | "Out" (. modifier = VarianceModifier.Covariant; .) ] Identifier (. template = new TemplateDefinition(t.val, null) { VarianceModifier = modifier }; .)
416
[TypeParameterConstraints<template>]
419
if (template != null) {
420
template.StartLocation = startLocation;
421
template.EndLocation = t.EndLocation;
427
TypeParameterConstraints<TemplateDefinition template>
429
TypeReference constraint;
435
TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
438
TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
441
| TypeParameterConstraint<out constraint> (. if (constraint != null) { template.Bases.Add(constraint); } .)
445
TypeParameterConstraint<out TypeReference constraint>
446
(. constraint = null; Location startLocation = la.Location; .)
448
"Class" (. constraint = TypeReference.ClassConstraint; .)
449
| "Structure" (. constraint = TypeReference.StructConstraint; .)
450
| "New" (. constraint = TypeReference.NewConstraint; .)
451
| TypeName<out constraint>
455
NonModuleDeclaration<ModifierList m, List<AttributeSection> attributes>
457
TypeReference typeRef = null;
458
List<TypeReference> baseInterfaces = null;
460
(. m.Check(Modifiers.Classes); .)
463
(. TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
464
newType.StartLocation = t.Location;
468
newType.Type = ClassType.Class;
470
Identifier (. newType.Name = t.val; .)
471
TypeParameterList<newType.Templates>
473
(. newType.BodyStartLocation = t.Location; .)
474
[ ClassBaseType<out typeRef> (. SafeAdd(newType, newType.BaseTypes, typeRef); .) ]
475
{ TypeImplementsClause<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces); .) }
477
"End" "Class" (. newType.EndLocation = t.EndLocation; .)
484
m.Check(Modifiers.VBModules);
485
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
488
newType.StartLocation = m.GetDeclarationLocation(t.Location);
489
newType.Type = ClassType.Module;
491
Identifier (. newType.Name = t.val; .)
493
(. newType.BodyStartLocation = t.Location; .)
500
m.Check(Modifiers.VBStructures);
501
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
504
newType.StartLocation = m.GetDeclarationLocation(t.Location);
505
newType.Type = ClassType.Struct;
507
Identifier (. newType.Name = t.val; .)
508
TypeParameterList<newType.Templates>
510
(. newType.BodyStartLocation = t.Location; .)
511
{ TypeImplementsClause<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces);.) }
512
StructureBody<newType>
519
m.Check(Modifiers.VBEnums);
520
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
521
newType.StartLocation = m.GetDeclarationLocation(t.Location);
525
newType.Type = ClassType.Enum;
527
Identifier (. newType.Name = t.val; .)
528
[ "As" NonArrayTypeName<out typeRef, false> (. SafeAdd(newType, newType.BaseTypes, typeRef); .) ]
530
(. newType.BodyStartLocation = t.Location; .)
538
m.Check(Modifiers.VBInterfacs);
539
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
540
newType.StartLocation = m.GetDeclarationLocation(t.Location);
543
newType.Type = ClassType.Interface;
545
Identifier (. newType.Name = t.val; .)
546
TypeParameterList<newType.Templates>
548
(. newType.BodyStartLocation = t.Location; .)
549
{ InterfaceBase<out baseInterfaces> (. newType.BaseTypes.AddRange(baseInterfaces); .) }
550
InterfaceBody<newType>
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>();
564
"Sub" Identifier (. delegateDeclr.Name = t.val; .)
565
TypeParameterList<delegateDeclr.Templates>
566
[ "(" [ FormalParameterList<p> ] ")" (. delegateDeclr.Parameters = p; .) ]
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; .)]
573
(. delegateDeclr.EndLocation = t.EndLocation; .)
576
AddChild(delegateDeclr);
581
{ EndOfStmt } /* allow empty lines at begin of body */
584
{ EndOfStmt } /* allow empty lines in body */
590
ClassBody<TypeDeclaration newType>
591
(. AttributeSection section; .) =
592
{ EndOfStmt } /* allow empty lines at begin of body */
594
(.List<AttributeSection> attributes = new List<AttributeSection>();
595
ModifierList m = new ModifierList();
597
{ AttributeSection<out section> (. attributes.Add(section); .) }
598
{ MemberModifier<m> }
599
ClassMemberDecl<m, attributes>
600
{ EndOfStmt } /* allow empty lines in body */
604
StructureBody<TypeDeclaration newType>
605
(. AttributeSection section; .) =
606
{ EndOfStmt } /* allow empty lines at begin of body */
608
(.List<AttributeSection> attributes = new List<AttributeSection>();
609
ModifierList m = new ModifierList();
611
{ AttributeSection<out section> (. attributes.Add(section); .) }
612
{ MemberModifier<m> }
613
StructureMemberDecl<m, attributes>
614
{ EndOfStmt } /* allow empty lines in body */
616
"End" "Structure" (. newType.EndLocation = t.EndLocation; .)
621
ModuleBody<TypeDeclaration newType>
622
(. AttributeSection section; .) =
623
{ EndOfStmt } /* allow empty lines at begin of body */
625
(.List<AttributeSection> attributes = new List<AttributeSection>();
626
ModifierList m = new ModifierList();
628
{ AttributeSection<out section> (. attributes.Add(section); .) }
629
{ MemberModifier<m> }
630
ClassMemberDecl<m, attributes>
631
{ EndOfStmt } /* allow empty lines in body */
633
"End" "Module" (. newType.EndLocation = t.EndLocation; .)
637
EnumBody<TypeDeclaration newType>
638
(. FieldDeclaration f; .) =
639
{ EndOfStmt } /* allow empty lines at begin of body */
641
EnumMemberDecl<out f>
645
{ EndOfStmt } /* allow empty lines in body */
647
"End" "Enum" (. newType.EndLocation = t.EndLocation; .)
651
InterfaceBody<TypeDeclaration newType> =
652
{ EndOfStmt } /* allow empty lines at begin of body */
655
{ EndOfStmt } /* allow empty lines in body */
657
"End" "Interface" (. newType.EndLocation = t.EndLocation; .)
661
/* The information provided in the spec about */
662
/* interface declarations is wrong */
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>();
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> }
680
mod.Check(Modifiers.VBInterfaceEvents);
681
Location startLocation = t.Location;
683
Identifier (. name = t.val; .)
684
[ "(" [ FormalParameterList<p> ] ")" ]
685
[ "As" TypeName<out type> ]
688
EventDeclaration ed = new EventDeclaration {
689
Name = name, TypeReference = type, Modifier = mod.Modifier,
690
Parameters = p, Attributes = attributes,
691
StartLocation = startLocation, EndLocation = t.EndLocation
698
Location startLocation = t.Location;
699
mod.Check(Modifiers.VBInterfaceMethods);
701
Identifier (. name = t.val; .)
702
TypeParameterList<templates>
703
[ "(" [ FormalParameterList<p> ] ")" ]
706
MethodDeclaration md = new MethodDeclaration {
708
Modifier = mod.Modifier,
710
Attributes = attributes,
711
TypeReference = new TypeReference("System.Void", true),
712
StartLocation = startLocation,
713
EndLocation = t.EndLocation,
714
Templates = templates
721
mod.Check(Modifiers.VBInterfaceMethods);
722
Location startLocation = t.Location;
724
Identifier (. name = t.val; .)
725
TypeParameterList<templates>
726
[ "(" [ FormalParameterList<p> ] ")" ]
727
[ "As" { AttributeSection<out returnTypeAttributeSection> } TypeName<out type> ]
730
type = new TypeReference("System.Object", true);
732
MethodDeclaration md = new MethodDeclaration {
733
Name = name, Modifier = mod.Modifier,
734
TypeReference = type, Parameters = p, Attributes = attributes
736
if (returnTypeAttributeSection != null) {
737
returnTypeAttributeSection.AttributeTarget = "return";
738
md.Attributes.Add(returnTypeAttributeSection);
740
md.StartLocation = startLocation;
741
md.EndLocation = t.EndLocation;
742
md.Templates = templates;
749
Location startLocation = t.Location;
750
mod.Check(Modifiers.VBInterfaceProperties);
752
Identifier (. name = t.val; .)
753
[ "(" [ FormalParameterList<p> ] ")" ]
754
[ "As" TypeName<out type> ]
757
type = new TypeReference("System.Object", true);
762
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod.Modifier, attributes);
764
pd.EndLocation = t.EndLocation;
765
pd.StartLocation = startLocation;
769
| /* inner type declarations */
770
NonModuleDeclaration<mod, attributes>
774
EnumMemberDecl<out FieldDeclaration f>
776
Expression expr = null;List<AttributeSection> attributes = new List<AttributeSection>();
777
AttributeSection section = null;
778
VariableDeclaration varDecl = null;
780
{ AttributeSection<out section> (. attributes.Add(section); .) }
783
f = new FieldDeclaration(attributes);
784
varDecl = new VariableDeclaration(t.val);
785
f.Fields.Add(varDecl);
786
f.StartLocation = varDecl.StartLocation = t.Location;
788
[ "=" Expr<out expr> (. varDecl.Initializer = expr; .) ]
789
(. f.EndLocation = varDecl.EndLocation = t.EndLocation; .)
793
ClassMemberDecl<ModifierList m, List<AttributeSection> attributes> =
794
StructureMemberDecl<m, attributes>
797
ClassBaseType<out TypeReference typeRef>
802
TypeName<out typeRef>
807
StructureMemberDecl<ModifierList m, List<AttributeSection> attributes>
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>();
816
NonModuleDeclaration<m, attributes>
820
Location startPos = t.Location;
824
string name = String.Empty;
825
MethodDeclaration methodDeclaration; List<string> handlesClause = null;
826
List<InterfaceImplementation> implementsClause = null;
831
m.Check(Modifiers.VBMethods);
833
TypeParameterList<templates>
834
[ "(" [ FormalParameterList<p> ] ")" ]
837
ImplementsClause<out implementsClause>
839
HandlesClause<out handlesClause>
842
(. Location endLocation = t.EndLocation; .)
844
/* abstract methods without a body */
845
IF(IsMustOverride(m))
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
856
AddChild(methodDeclaration);
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
869
AddChild(methodDeclaration);
872
(. if (ParseMethodBodies) { .)
876
// don't parse method body
877
lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
881
(. methodDeclaration.Body = (BlockStatement)stmt; .)
882
(. methodDeclaration.Body.EndLocation = t.EndLocation; .)
886
| "New" [ "(" [ FormalParameterList<p> ] ")" ]
887
(. m.Check(Modifiers.Constructors); .)
888
(. Location constructorEndLocation = t.EndLocation; .)
891
(. if (ParseMethodBodies) { .)
895
// don't parse method body
896
lexer.SkipCurrentBlock(Tokens.Sub); stmt = new BlockStatement();
900
(. Location endLocation = t.EndLocation; .)
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;
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;
922
Identifier (. name = t.val; .)
923
TypeParameterList<templates>
924
[ "(" [ FormalParameterList<p> ] ")" ]
926
AttributeSection<out returnTypeAttributeSection>
928
if (returnTypeAttributeSection != null) {
929
returnTypeAttributeSection.AttributeTarget = "return";
930
attributes.Add(returnTypeAttributeSection);
937
type = new TypeReference("System.Object", true);
942
ImplementsClause<out implementsClause>
944
HandlesClause<out handlesClause>
947
(. Location endLocation = t.EndLocation; .)
949
/* abstract methods without a body */
950
IF(IsMustOverride(m))
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
963
AddChild(methodDeclaration);
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
978
AddChild(methodDeclaration);
980
if (ParseMethodBodies) { .)
984
// don't parse method body
985
lexer.SkipCurrentBlock(Tokens.Function); stmt = new BlockStatement();
987
methodDeclaration.Body = (BlockStatement)stmt;
988
methodDeclaration.Body.StartLocation = methodDeclaration.EndLocation;
989
methodDeclaration.Body.EndLocation = t.EndLocation;
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;
1004
[Charset<out charsetModifer> ]
1007
Identifier (. name = t.val; .)
1008
"Lib" LiteralString (. library = t.literalValue as string; .)
1009
["Alias" LiteralString (. alias = t.literalValue as string; .)]
1010
[ "(" [ FormalParameterList<p> ] ")" ]
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);
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> ]
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);
1037
m.Check(Modifiers.VBEvents);
1038
Location startPos = t.Location;
1039
EventDeclaration eventDeclaration;
1040
string name = String.Empty;
1041
List<InterfaceImplementation> implementsClause = null;
1043
Identifier (. name= t.val; .)
1045
"As" TypeName<out type>
1047
[ "(" [ FormalParameterList<p> ] ")" ]
1049
[ ImplementsClause<out implementsClause> ]
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
1057
AddChild(eventDeclaration);
1062
m.Check(Modifiers.Fields);
1063
FieldDeclaration fd = new FieldDeclaration(attributes, null, m.Modifier);
1065
IdentifierForFieldDeclaration (. string name = t.val; .)
1066
(. fd.StartLocation = m.GetDeclarationLocation(t.Location); .)
1068
VariableDeclaratorPartAfterIdentifier<variableDeclarators, name>
1069
{ "," VariableDeclarator<variableDeclarators> }
1072
fd.EndLocation = t.EndLocation;
1073
fd.Fields = variableDeclarators;
1077
(. m.Check(Modifiers.Fields); .)
1078
"Const" (. m.Add(Modifiers.Const, t.Location); .)
1080
FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
1081
fd.StartLocation = m.GetDeclarationLocation(t.Location);
1082
List<VariableDeclaration> constantDeclarators = new List<VariableDeclaration>();
1084
ConstantDeclarator<constantDeclarators>
1085
{ "," ConstantDeclarator<constantDeclarators> }
1087
fd.Fields = constantDeclarators;
1088
fd.EndLocation = t.Location;
1092
fd.EndLocation = t.EndLocation;
1098
m.Check(Modifiers.VBProperties);
1099
Location startPos = t.Location;
1100
List<InterfaceImplementation> implementsClause = null;
1101
AttributeSection returnTypeAttributeSection = null;
1102
Expression initializer = null;
1104
Identifier (. string propertyName = t.val; .)
1105
[ "(" [ FormalParameterList<p> ] ")" ]
1108
AttributeSection<out returnTypeAttributeSection>
1110
if (returnTypeAttributeSection != null) {
1111
returnTypeAttributeSection.AttributeTarget = "return";
1112
attributes.Add(returnTypeAttributeSection);
1117
IF (IsNewExpression()) ObjectCreateExpression<out initializer>
1119
if (initializer is ObjectCreateExpression) {
1120
type = ((ObjectCreateExpression)initializer).CreateType.Clone();
1122
type = ((ArrayCreateExpression)initializer).CreateType.Clone();
1129
[ "=" Expr<out initializer> ]
1130
[ ImplementsClause<out implementsClause> ]
1133
/* abstract properties without a body */
1134
IF(IsMustOverride(m) || IsAutomaticProperty())
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;
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;
1158
AccessorDecls<out getRegion, out setRegion>
1162
pDecl.GetRegion = getRegion;
1163
pDecl.SetRegion = setRegion;
1164
pDecl.BodyEnd = t.Location; // t = EndOfStmt; not "Property"
1169
"Custom" (. Location startPos = t.Location; .) "Event"
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;
1178
Identifier (. string customEventName = t.val; .)
1179
"As" TypeName<out type>
1180
[ ImplementsClause<out implementsClause> ]
1183
EventAccessorDeclaration<out eventAccessorDeclaration>
1185
if(eventAccessorDeclaration is EventAddRegion)
1187
addHandlerAccessorDeclaration = (EventAddRegion)eventAccessorDeclaration;
1189
else if(eventAccessorDeclaration is EventRemoveRegion)
1191
removeHandlerAccessorDeclaration = (EventRemoveRegion)eventAccessorDeclaration;
1193
else if(eventAccessorDeclaration is EventRaiseRegion)
1195
raiseEventAccessorDeclaration = (EventRaiseRegion)eventAccessorDeclaration;
1199
"End" "Event" EndOfStmt
1201
if(addHandlerAccessorDeclaration == null)
1203
Error("Need to provide AddHandler accessor.");
1206
if(removeHandlerAccessorDeclaration == null)
1208
Error("Need to provide RemoveHandler accessor.");
1211
if(raiseEventAccessorDeclaration == null)
1213
Error("Need to provide RaiseEvent accessor.");
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
1227
| (. ConversionType opConversionType = ConversionType.None; .)
1228
[ "Widening" (. opConversionType = ConversionType.Implicit; .)
1229
| "Narrowing" (. opConversionType = ConversionType.Explicit;.) ]
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>();
1241
OverloadableOperator<out operatorType>
1243
FormalParameter<out param>
1244
(. if (param != null) parameters.Add(param); .)
1246
"," FormalParameter<out param>
1247
(. if (param != null) parameters.Add(param); .)
1250
(. Location endPos = t.EndLocation; .)
1251
[ "As" { AttributeSection<out section>
1252
(. if (section != null) {
1253
section.AttributeTarget = "return";
1254
attributes.Add(section);
1256
} TypeName<out returnType> (. endPos = t.EndLocation; .) ]
1258
Block<out stmt> "End" "Operator" EndOfStmt
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
1271
operatorDeclaration.Body.StartLocation = startPos;
1272
operatorDeclaration.Body.EndLocation = t.Location;
1273
AddChild(operatorDeclaration);
1277
OverloadableOperator<out OverloadableOperatorType operatorType>
1278
(. operatorType = OverloadableOperatorType.None; .)
1280
"+" (. operatorType = OverloadableOperatorType.Add; .)
1282
"-" (. operatorType = OverloadableOperatorType.Subtract; .)
1284
"*" (. operatorType = OverloadableOperatorType.Multiply; .)
1286
"/" (. operatorType = OverloadableOperatorType.Divide; .)
1288
"\\" (. operatorType = OverloadableOperatorType.DivideInteger; .)
1290
"&" (. operatorType = OverloadableOperatorType.Concat; .)
1292
"Like" (. operatorType = OverloadableOperatorType.Like; .)
1294
"Mod" (. operatorType = OverloadableOperatorType.Modulus; .)
1296
"And" (. operatorType = OverloadableOperatorType.BitwiseAnd; .)
1298
"Or" (. operatorType = OverloadableOperatorType.BitwiseOr; .)
1300
"Xor" (. operatorType = OverloadableOperatorType.ExclusiveOr; .)
1302
"^" (. operatorType = OverloadableOperatorType.Power; .)
1304
"<<" (. operatorType = OverloadableOperatorType.ShiftLeft; .)
1306
">>" (. operatorType = OverloadableOperatorType.ShiftRight; .)
1308
"=" (. operatorType = OverloadableOperatorType.Equality; .)
1310
"<>" (. operatorType = OverloadableOperatorType.InEquality; .)
1312
"<" (. operatorType = OverloadableOperatorType.LessThan; .)
1314
"<=" (. operatorType = OverloadableOperatorType.LessThanOrEqual; .)
1316
">" (. operatorType = OverloadableOperatorType.GreaterThan; .)
1318
">=" (. operatorType = OverloadableOperatorType.GreaterThanOrEqual; .)
1320
"CType" (. operatorType = OverloadableOperatorType.CType; .)
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;
1330
Error("Invalid operator. Possible operators are '+', '-', 'Not', 'IsTrue', 'IsFalse'.");
1335
EventAccessorDeclaration<out EventAddRemoveRegion eventAccessorDeclaration>
1337
Statement stmt = null;
1338
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
1339
AttributeSection section;
1340
List<AttributeSection> attributes = new List<AttributeSection>();
1341
eventAccessorDeclaration = null;
1343
{ AttributeSection<out section> (. attributes.Add(section); .) }
1345
"AddHandler" [ "(" [ FormalParameterList<p> ] ")" ] EOL
1346
Block<out stmt> "End" "AddHandler" EndOfStmt
1348
eventAccessorDeclaration = new EventAddRegion(attributes);
1349
eventAccessorDeclaration.Block = (BlockStatement)stmt;
1350
eventAccessorDeclaration.Parameters = p;
1353
"RemoveHandler" [ "(" [ FormalParameterList<p> ] ")" ] EOL
1354
Block<out stmt> "End" "RemoveHandler" EndOfStmt
1356
eventAccessorDeclaration = new EventRemoveRegion(attributes);
1357
eventAccessorDeclaration.Block = (BlockStatement)stmt;
1358
eventAccessorDeclaration.Parameters = p;
1361
"RaiseEvent" [ "(" [ FormalParameterList<p> ] ")" ] EOL
1362
Block<out stmt> "End" "RaiseEvent" EndOfStmt
1364
eventAccessorDeclaration = new EventRaiseRegion(attributes);
1365
eventAccessorDeclaration.Block = (BlockStatement)stmt;
1366
eventAccessorDeclaration.Parameters = p;
1372
AccessorDecls<out PropertyGetRegion getBlock, out PropertySetRegion setBlock>
1374
List<AttributeSection> attributes = new List<AttributeSection>();
1375
AttributeSection section;
1379
{ AttributeSection<out section> (. attributes.Add(section); .) }
1381
GetAccessorDecl<out getBlock, attributes>
1383
(. attributes = new List<AttributeSection>(); .)
1384
{ AttributeSection<out section> (. attributes.Add(section); .) }
1385
SetAccessorDecl<out setBlock, attributes>
1388
SetAccessorDecl<out setBlock, attributes>
1390
(. attributes = new List<AttributeSection>(); .)
1391
{ AttributeSection<out section> (. attributes.Add(section); .) }
1392
GetAccessorDecl<out getBlock, attributes>
1398
GetAccessorDecl<out PropertyGetRegion getBlock, List<AttributeSection> attributes>
1399
(. Statement stmt = null; Modifiers m; .)
1401
PropertyAccessorAccessModifier<out m>
1403
(. Location startLocation = t.Location; .)
1406
(. getBlock = new PropertyGetRegion((BlockStatement)stmt, attributes); .)
1408
(. getBlock.Modifier = m; .)
1409
(. getBlock.StartLocation = startLocation; getBlock.EndLocation = t.EndLocation; .)
1414
SetAccessorDecl<out PropertySetRegion setBlock, List<AttributeSection> attributes>
1416
Statement stmt = null;
1417
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
1421
PropertyAccessorAccessModifier<out m>
1423
(. Location startLocation = t.Location; .)
1424
[ "(" [ FormalParameterList<p> ] ")" ]
1428
setBlock = new PropertySetRegion((BlockStatement)stmt, attributes);
1429
setBlock.Modifier = m;
1430
setBlock.Parameters = p;
1433
(. setBlock.StartLocation = startLocation; setBlock.EndLocation = t.EndLocation; .)
1438
ConstantDeclarator<List<VariableDeclaration> constantDeclaration>
1440
Expression expr = null;
1441
TypeReference type = null;
1442
string name = String.Empty;
1445
Identifier (. name = t.val; location = t.Location; .)
1446
["As" TypeName<out type> ]
1449
VariableDeclaration f = new VariableDeclaration(name, expr);
1450
f.TypeReference = type;
1451
f.StartLocation = location;
1452
constantDeclaration.Add(f);
1457
VariableDeclarator<List<VariableDeclaration> fieldDeclaration>
1459
Identifier (. string name = t.val; .)
1460
VariableDeclaratorPartAfterIdentifier<fieldDeclaration, name>
1463
VariableDeclaratorPartAfterIdentifier<List<VariableDeclaration> fieldDeclaration, string name>
1465
Expression expr = null;
1466
TypeReference type = null;
1467
ArrayList rank = null;
1468
List<Expression> dimension = null;
1469
Location startLocation = t.Location;
1471
[ IF(IsSize() && !IsDims()) ArrayInitializationModifier<out dimension> ]
1472
[ IF(IsDims()) ArrayNameModifier<out rank> ]
1474
IF (IsObjectCreation()) "As" ObjectCreateExpression<out expr>
1476
if (expr is ObjectCreateExpression) {
1477
type = ((ObjectCreateExpression)expr).CreateType.Clone();
1479
type = ((ArrayCreateExpression)expr).CreateType.Clone();
1483
[ "As" TypeName<out type>
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;
1497
if (type == null && (dimension != null || rank != null)) {
1498
type = new TypeReference("");
1500
if (dimension != null) {
1501
if(type.RankSpecifier != null) {
1502
Error("array rank only allowed one time");
1505
type.RankSpecifier = new int[] { dimension.Count - 1 };
1507
rank.Insert(0, dimension.Count - 1);
1508
type.RankSpecifier = (int[])rank.ToArray(typeof(int));
1510
expr = new ArrayCreateExpression(type.Clone(), dimension);
1512
} else if (rank != null) {
1513
if(type.RankSpecifier != null) {
1514
Error("array rank only allowed one time");
1516
type.RankSpecifier = (int[])rank.ToArray(typeof(int));
1520
[ "=" Expr<out expr> ]
1523
VariableDeclaration varDecl = new VariableDeclaration(name, expr, type);
1524
varDecl.StartLocation = startLocation;
1525
varDecl.EndLocation = t.Location;
1526
fieldDeclaration.Add(varDecl);
1531
ArrayInitializationModifier<out List<Expression> arrayModifiers>
1533
arrayModifiers = null;
1535
"(" InitializationRankList<out arrayModifiers> ")"
1539
InitializationRankList<out List<Expression> rank>
1541
rank = new List<Expression>();
1542
Expression expr = null;
1545
[ "To" (. EnsureIsZero(expr); .)
1548
(. if (expr != null) { rank.Add(expr); } .)
1551
[ "To" (. EnsureIsZero(expr); .)
1554
(. if (expr != null) { rank.Add(expr); } .)
1559
CollectionInitializer<out CollectionInitializerExpression outExpr>
1561
Expression expr = null;
1562
CollectionInitializerExpression initializer = new CollectionInitializerExpression();
1563
Location startLocation = la.Location;
1569
if (expr != null) { initializer.CreateExpressions.Add(expr); }
1572
IF (NotFinalComma()) "," Expr<out expr>
1573
(. if (expr != null) { initializer.CreateExpressions.Add(expr); } .)
1578
outExpr = initializer;
1579
outExpr.StartLocation = startLocation;
1580
outExpr.EndLocation = t.EndLocation;
1584
Charset<out CharsetModifier charsetModifier>
1585
(. charsetModifier = CharsetModifier.None; .) =
1586
| "Ansi" (. charsetModifier = CharsetModifier.Ansi; .)
1587
| "Auto" (. charsetModifier = CharsetModifier.Auto; .)
1588
| "Unicode" (. charsetModifier = CharsetModifier.Unicode; .)
1592
HandlesClause<out List<string> handlesClause>
1594
handlesClause = new List<string>();
1597
"Handles" EventMemberSpecifier<out name> (. if (name != null) handlesClause.Add(name); .)
1598
{ "," EventMemberSpecifier<out name> (. if (name != null) handlesClause.Add(name); .) }
1602
InterfaceBase<out List<TypeReference> bases>
1605
bases = new List<TypeReference>();
1608
TypeName<out type> (. if (type != null) bases.Add(type); .)
1611
TypeName<out type> (. if (type != null) bases.Add(type); .)
1617
TypeImplementsClause<out List<TypeReference> baseInterfaces>
1619
baseInterfaces = new List<TypeReference>();
1620
TypeReference type = null;
1622
"Implements" TypeName<out type>
1624
if (type != null) baseInterfaces.Add(type);
1627
"," TypeName<out type>
1628
(. if (type != null) baseInterfaces.Add(type); .)
1634
ImplementsClause<out List<InterfaceImplementation> baseInterfaces>
1636
baseInterfaces = new List<InterfaceImplementation>();
1637
TypeReference type = null;
1638
string memberName = null;
1641
NonArrayTypeName<out type, false>
1642
(. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
1643
(. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
1645
NonArrayTypeName<out type, false>
1646
(. if (type != null) memberName = TypeReference.StripLastIdentifierFromType(ref type); .)
1647
(. baseInterfaces.Add(new InterfaceImplementation(type, memberName)); .)
1651
EventMemberSpecifier<out string name>
1652
(. string eventName; .)
1654
( Identifier | "MyBase" | "Me" )
1657
IdentifierOrKeyword<out eventName>
1658
(. name = name + "." + eventName; .)
1661
Expr<out Expression expr>
1662
(. expr = null; Location startLocation = la.Location; .)
1665
IF ( IsQueryExpression() )
1667
| LambdaExpr<out expr>
1668
| DisjunctionExpr<out expr>
1672
expr.StartLocation = startLocation;
1673
expr.EndLocation = t.EndLocation;
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; .)
1693
SimpleExpr<out Expression pexpr>
1694
(. string name; Location startLocation = la.Location; .)
1697
SimpleNonInvocationExpression<out pexpr>
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 }; .)
1705
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
1706
"(" "Of" TypeArgumentList<((MemberReferenceExpression)pexpr).TypeArguments> ")"
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>
1716
if (pexpr != null) {
1717
pexpr.StartLocation = startLocation;
1718
pexpr.EndLocation = t.EndLocation;
1723
SimpleNonInvocationExpression<out Expression pexpr>
1726
CollectionInitializerExpression cie;
1727
TypeReference type = null;
1728
string name = String.Empty;
1729
Location startLocation = la.Location;
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;
1751
[ IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.Of)
1752
"(" "Of" TypeArgumentList<((IdentifierExpression)pexpr).TypeArguments> ")"
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 }; .)
1762
"." IdentifierOrKeyword<out name> (. pexpr = new MemberReferenceExpression(retExpr, name) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
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; .)
1773
| "CType" (. castType = CastType.Conversion; .)
1774
| "TryCast" (. castType = CastType.TryCast; .)
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>
1787
/* this form only occurs in WithStatements */
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 }; .)
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); .)
1803
if (pexpr != null) {
1804
pexpr.StartLocation = startLocation;
1805
pexpr.EndLocation = t.EndLocation;
1810
XmlLiteralExpression<out Expression pexpr>
1812
List<XmlExpression> exprs = new List<XmlExpression>();
1813
XmlExpression currentExpression = null;
1817
XmlContentExpression<exprs> { XmlContentExpression<exprs> } [ XmlElement<out currentExpression> (. exprs.Add(currentExpression); .) { XmlContentExpression<exprs> } ]
1819
XmlElement<out currentExpression> (. exprs.Add(currentExpression); .) { XmlContentExpression<exprs> }
1822
if (exprs.Count > 1) {
1823
pexpr = new XmlDocumentExpression() { Expressions = exprs };
1830
XmlContentExpression<List<XmlExpression> exprs> =
1831
(. XmlContentExpression expr = null; .)
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); .)
1839
expr.StartLocation = t.Location;
1840
expr.EndLocation = t.EndLocation;
1845
XmlNestedContent<out XmlExpression expr>
1846
(. XmlExpression tmpExpr = null; Location start = la.Location; .)
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>
1857
if (tmpExpr.StartLocation.IsEmpty)
1858
tmpExpr.StartLocation = start;
1859
if (tmpExpr.EndLocation.IsEmpty)
1860
tmpExpr.EndLocation = t.EndLocation;
1865
XmlElement<out XmlExpression expr>
1866
(. XmlElementExpression el = new XmlElementExpression(); .)
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; .) )
1878
XmlAttribute<List<XmlExpression> attrs>
1879
(. Location start = la.Location; .)
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 }); .)
1886
XmlStartInlineVB (. Expression innerExpression; .) Expr<out innerExpression> XmlEndInlineVB
1887
(. attrs.Add(new XmlEmbeddedExpression() { InlineVBExpression = innerExpression, StartLocation = start, EndLocation = t.EndLocation }); .)
1890
ConditionalExpression<out Expression expr>
1892
ConditionalExpression conditionalExpression = new ConditionalExpression();
1893
BinaryOperatorExpression binaryOperatorExpression = new BinaryOperatorExpression();
1894
conditionalExpression.StartLocation = binaryOperatorExpression.StartLocation = la.Location;
1896
Expression condition = null;
1897
Expression trueExpr = null;
1898
Expression falseExpr = null;
1901
"If" "(" Expr<out condition> "," Expr<out trueExpr> [ "," Expr<out falseExpr> ] ")"
1903
if(falseExpr != null)
1905
conditionalExpression.Condition = condition;
1906
conditionalExpression.TrueExpression = trueExpr;
1907
conditionalExpression.FalseExpression = falseExpr;
1908
conditionalExpression.EndLocation = t.EndLocation;
1910
expr = conditionalExpression;
1914
binaryOperatorExpression.Left = condition;
1915
binaryOperatorExpression.Right = trueExpr;
1916
binaryOperatorExpression.Op = BinaryOperatorType.NullCoalescing;
1917
binaryOperatorExpression.EndLocation = t.EndLocation;
1919
expr = binaryOperatorExpression;
1924
InvocationExpression<ref Expression pexpr>
1925
(. List<Expression> parameters = null; .)
1927
"(" (. Location start = t.Location; .)
1928
ArgumentList<out parameters>
1931
pexpr = new InvocationExpression(pexpr, parameters);
1933
(. pexpr.StartLocation = start; pexpr.EndLocation = t.Location; .)
1938
CastTarget<out TypeReference type>
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); .)
1960
DisjunctionExpr<out Expression outExpr>
1963
BinaryOperatorType op = BinaryOperatorType.None;
1964
Location startLocation = la.Location;
1966
ConjunctionExpr<out outExpr>
1969
"Or" (. op = BinaryOperatorType.BitwiseOr; .)
1970
| "OrElse" (. op = BinaryOperatorType.LogicalOr; .)
1971
| "Xor" (. op = BinaryOperatorType.ExclusiveOr; .)
1973
ConjunctionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
1977
ConjunctionExpr<out Expression outExpr>
1980
BinaryOperatorType op = BinaryOperatorType.None;
1981
Location startLocation = la.Location;
1983
NotExpr<out outExpr>
1986
"And" (. op = BinaryOperatorType.BitwiseAnd; .)
1987
| "AndAlso" (. op = BinaryOperatorType.LogicalAnd; .)
1989
NotExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
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);
2002
ComparisonExpr<out Expression outExpr>
2005
BinaryOperatorType op = BinaryOperatorType.None;
2006
Location startLocation = la.Location;
2008
ShiftExpr<out outExpr>
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; .)
2022
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
2023
| (. Location startLocation2 = la.Location; .)
2025
ShiftExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, new UnaryOperatorExpression(expr, UnaryOperatorType.Not) { StartLocation = startLocation2, EndLocation = t.EndLocation }) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
2030
ShiftExpr<out Expression outExpr>
2033
BinaryOperatorType op = BinaryOperatorType.None;
2034
Location startLocation = la.Location;
2036
ConcatenationExpr<out outExpr>
2039
"<<" (. op = BinaryOperatorType.ShiftLeft; .)
2040
| ">>" (. op = BinaryOperatorType.ShiftRight; .)
2042
ConcatenationExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
2046
ConcatenationExpr<out Expression outExpr>
2047
(. Expression expr; Location startLocation = la.Location; .)
2049
AdditiveExpr<out outExpr> { "&" AdditiveExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Concat, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
2052
AdditiveExpr<out Expression outExpr>
2055
BinaryOperatorType op = BinaryOperatorType.None;
2056
Location startLocation = la.Location;
2058
ModuloExpr<out outExpr>
2061
"+" (. op = BinaryOperatorType.Add; .)
2062
| "-" (. op = BinaryOperatorType.Subtract; .)
2064
ModuloExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
2068
ModuloExpr<out Expression outExpr>
2069
(. Expression expr; Location startLocation = la.Location; .)
2071
IntegerDivisionExpr<out outExpr> { "Mod" IntegerDivisionExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Modulus, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
2074
IntegerDivisionExpr<out Expression outExpr>
2075
(. Expression expr; Location startLocation = la.Location; .)
2077
MultiplicativeExpr<out outExpr> { "\\" MultiplicativeExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.DivideInteger, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
2080
MultiplicativeExpr<out Expression outExpr>
2083
BinaryOperatorType op = BinaryOperatorType.None;
2084
Location startLocation = la.Location;
2086
UnaryExpr<out outExpr>
2089
"*" (. op = BinaryOperatorType.Multiply; .)
2090
| "/" (. op = BinaryOperatorType.Divide; .)
2092
UnaryExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, op, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .)
2096
UnaryExpr<out Expression uExpr>
2099
UnaryOperatorType uop = UnaryOperatorType.None;
2100
Location startLocation = la.Location;
2103
{ "+" (. uop = UnaryOperatorType.Plus; isUOp = true; .)
2104
| "-" (. uop = UnaryOperatorType.Minus; isUOp = true; .)
2105
| "*" (. uop = UnaryOperatorType.Dereference; isUOp = true;.)
2107
ExponentiationExpr<out expr>
2110
uExpr = new UnaryOperatorExpression(expr, uop) { StartLocation = startLocation, EndLocation = t.EndLocation };
2117
ExponentiationExpr<out Expression outExpr>
2118
(. Expression expr; Location startLocation = la.Location; .)
2120
SimpleExpr<out outExpr> { "^" SimpleExpr<out expr> (. outExpr = new BinaryOperatorExpression(outExpr, BinaryOperatorType.Power, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }; .) }
2123
ObjectCreateExpression<out Expression oce>
2125
TypeReference type = null;
2126
CollectionInitializerExpression initializer = null;
2127
List<Expression> arguments = null;
2128
ArrayList dimensions = null;
2130
Location startLocation = la.Location;
2131
bool canBeNormal; bool canBeReDim;
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>
2141
(. if (canBeReDim && !canBeNormal && initializer == null) initializer = new CollectionInitializerExpression(); .)
2145
if (initializer == null) {
2146
oce = new ObjectCreateExpression(type, arguments);
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;
2160
MemberInitializerExpression memberInitializer = null;
2161
Expression anonymousMember = null;
2165
CollectionInitializerExpression memberInitializers = new CollectionInitializerExpression();
2166
memberInitializers.StartLocation = la.Location;
2170
MemberInitializer<out memberInitializer>
2171
(. memberInitializers.CreateExpressions.Add(memberInitializer); .)
2172
| Expr<out anonymousMember>
2173
(. memberInitializers.CreateExpressions.Add(anonymousMember); .)
2177
MemberInitializer<out memberInitializer>
2178
(. memberInitializers.CreateExpressions.Add(memberInitializer); .)
2179
| Expr<out anonymousMember>
2180
(. memberInitializers.CreateExpressions.Add(anonymousMember); .)
2185
memberInitializers.EndLocation = t.Location;
2186
if(oce is ObjectCreateExpression)
2188
((ObjectCreateExpression)oce).ObjectInitializer = memberInitializers;
2195
CollectionInitializer<out initializer>
2197
if(oce is ObjectCreateExpression)
2198
((ObjectCreateExpression)oce).ObjectInitializer = initializer;
2204
oce.StartLocation = startLocation;
2205
oce.EndLocation = t.EndLocation;
2210
LambdaExpr<out Expression expr>
2212
LambdaExpression lambda = null;
2214
( SubLambdaExpression<out lambda> |
2215
FunctionLambdaExpression<out lambda> )
2216
(. expr = lambda; .)
2219
SubLambdaExpression<out LambdaExpression lambda>
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;
2228
"Sub" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
2233
lambda.ExpressionBody = inner;
2234
lambda.EndLocation = t.EndLocation; // la.Location?
2235
lambda.ExtendedEndLocation = la.Location;
2238
EmbeddedStatement<out statement>
2240
lambda.StatementBody = statement;
2241
lambda.EndLocation = t.EndLocation;
2242
lambda.ExtendedEndLocation = la.Location;
2247
Block<out statement>
2250
lambda.StatementBody = statement;
2251
lambda.EndLocation = t.EndLocation;
2252
lambda.ExtendedEndLocation = la.Location;
2257
FunctionLambdaExpression<out LambdaExpression lambda>
2259
lambda = new LambdaExpression();
2260
TypeReference typeRef = null;
2261
Expression inner = null;
2262
Statement statement = null;
2263
lambda.StartLocation = la.Location;
2266
"Function" [ "(" [ FormalParameterList<lambda.Parameters> ] ")" ]
2267
[ "As" TypeName<out typeRef> (. lambda.ReturnType = typeRef; .) ]
2272
lambda.ExpressionBody = inner;
2273
lambda.EndLocation = t.EndLocation;
2274
lambda.ExtendedEndLocation = la.Location;
2277
EmbeddedStatement<out statement>
2279
lambda.StatementBody = statement;
2280
lambda.EndLocation = t.EndLocation;
2281
lambda.ExtendedEndLocation = la.Location;
2286
Block<out statement>
2289
lambda.StatementBody = statement;
2290
lambda.EndLocation = t.EndLocation;
2291
lambda.ExtendedEndLocation = la.Location;
2296
QueryExpr<out Expression expr>
2298
QueryExpressionVB qexpr = new QueryExpressionVB();
2299
qexpr.StartLocation = la.Location;
2302
FromOrAggregateQueryOperator<qexpr.Clauses>
2303
{ QueryOperator<qexpr.Clauses> }
2305
qexpr.EndLocation = t.EndLocation;
2309
FromOrAggregateQueryOperator<List<QueryExpressionClause> middleClauses>
2311
QueryExpressionFromClause fromClause = null;
2312
QueryExpressionAggregateClause aggregateClause = null;
2314
FromQueryOperator<out fromClause>
2315
(. middleClauses.Add(fromClause); .)
2316
| AggregateQueryOperator<out aggregateClause>
2317
(. middleClauses.Add(aggregateClause); .)
2320
QueryOperator<List<QueryExpressionClause> middleClauses>
2322
QueryExpressionJoinVBClause joinClause = null;
2323
QueryExpressionGroupVBClause groupByClause = null;
2324
QueryExpressionPartitionVBClause partitionClause = null;
2325
QueryExpressionGroupJoinVBClause groupJoinClause = null;
2326
QueryExpressionFromClause fromClause = null;
2327
QueryExpressionAggregateClause aggregateClause = null;
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); .)
2348
OrderByQueryOperator<List<QueryExpressionClause> middleClauses>
2350
QueryExpressionOrderClause orderClause = new QueryExpressionOrderClause();
2351
orderClause.StartLocation = la.Location;
2352
List<QueryExpressionOrdering> orderings = null;
2354
"Order" "By" OrderExpressionList<out orderings>
2356
orderClause.Orderings = orderings;
2357
orderClause.EndLocation = t.EndLocation;
2358
middleClauses.Add(orderClause);
2362
OrderExpressionList<out List<QueryExpressionOrdering> orderings>
2364
orderings = new List<QueryExpressionOrdering>();
2365
QueryExpressionOrdering ordering = null;
2367
OrderExpression<out ordering>
2368
(. orderings.Add(ordering); .)
2370
"," OrderExpression<out ordering>
2371
(. orderings.Add(ordering); .)
2375
OrderExpression<out QueryExpressionOrdering ordering>
2377
ordering = new QueryExpressionOrdering();
2378
ordering.StartLocation = la.Location;
2379
ordering.Direction = QueryExpressionOrderingDirection.None;
2380
Expression orderExpr = null;
2384
ordering.Criteria = orderExpr;
2387
"Ascending" (. ordering.Direction = QueryExpressionOrderingDirection.Ascending; .)
2388
| "Descending" (. ordering.Direction = QueryExpressionOrderingDirection.Descending; .)
2390
(. ordering.EndLocation = t.EndLocation; .)
2393
GroupByQueryOperator<out QueryExpressionGroupVBClause groupByClause>
2395
groupByClause = new QueryExpressionGroupVBClause();
2396
groupByClause.StartLocation = la.Location;
2398
"Group" ExpressionRangeVariableDeclarationList<groupByClause.GroupVariables>
2399
"By" ExpressionRangeVariableDeclarationList<groupByClause.ByVariables>
2400
"Into" ExpressionRangeVariableDeclarationList<groupByClause.IntoVariables>
2402
groupByClause.EndLocation = t.EndLocation;
2406
GroupJoinQueryOperator<out QueryExpressionGroupJoinVBClause groupJoinClause>
2408
groupJoinClause = new QueryExpressionGroupJoinVBClause();
2409
groupJoinClause.StartLocation = la.Location;
2410
QueryExpressionJoinVBClause joinClause = null;
2412
"Group" JoinQueryOperator<out joinClause>
2413
"Into" ExpressionRangeVariableDeclarationList<groupJoinClause.IntoVariables>
2415
groupJoinClause.JoinClause = joinClause;
2416
groupJoinClause.EndLocation = t.EndLocation;
2420
FromQueryOperator<out QueryExpressionFromClause fromClause>
2422
fromClause = new QueryExpressionFromClause();
2423
fromClause.StartLocation = la.Location;
2425
"From" CollectionRangeVariableDeclarationList<fromClause.Sources>
2427
fromClause.EndLocation = t.EndLocation;
2431
SelectQueryOperator<List<QueryExpressionClause> middleClauses>
2433
QueryExpressionSelectVBClause selectClause = new QueryExpressionSelectVBClause();
2434
selectClause.StartLocation = la.Location;
2436
"Select" ExpressionRangeVariableDeclarationList<selectClause.Variables>
2438
selectClause.EndLocation = t.Location;
2439
middleClauses.Add(selectClause);
2443
DistinctQueryOperator<List<QueryExpressionClause> middleClauses>
2445
QueryExpressionDistinctClause distinctClause = new QueryExpressionDistinctClause();
2446
distinctClause.StartLocation = la.Location;
2450
distinctClause.EndLocation = t.EndLocation;
2451
middleClauses.Add(distinctClause);
2455
WhereQueryOperator<List<QueryExpressionClause> middleClauses>
2457
QueryExpressionWhereClause whereClause = new QueryExpressionWhereClause();
2458
whereClause.StartLocation = la.Location;
2459
Expression operand = null;
2461
"Where" Expr<out operand>
2463
whereClause.Condition = operand;
2464
whereClause.EndLocation = t.EndLocation;
2466
middleClauses.Add(whereClause);
2470
PartitionQueryOperator<out QueryExpressionPartitionVBClause partitionClause>
2472
partitionClause = new QueryExpressionPartitionVBClause();
2473
partitionClause.StartLocation = la.Location;
2474
Expression expr = null;
2477
"Take" (. partitionClause.PartitionType = QueryExpressionPartitionType.Take; .)
2478
[ "While" (. partitionClause.PartitionType = QueryExpressionPartitionType.TakeWhile; .) ]
2479
| "Skip" (. partitionClause.PartitionType = QueryExpressionPartitionType.Skip; .)
2480
[ "While" (. partitionClause.PartitionType = QueryExpressionPartitionType.SkipWhile; .) ]
2484
partitionClause.Expression = expr;
2485
partitionClause.EndLocation = t.EndLocation;
2489
AggregateQueryOperator<out QueryExpressionAggregateClause aggregateClause>
2491
aggregateClause = new QueryExpressionAggregateClause();
2492
aggregateClause.IntoVariables = new List<ExpressionRangeVariable>();
2493
aggregateClause.StartLocation = la.Location;
2494
CollectionRangeVariable source;
2496
"Aggregate" CollectionRangeVariableDeclaration<out source>
2498
aggregateClause.Source = source;
2501
QueryOperator<aggregateClause.MiddleClauses>
2503
"Into" ExpressionRangeVariableDeclarationList<aggregateClause.IntoVariables>
2505
aggregateClause.EndLocation = t.EndLocation;
2509
LetQueryOperator<List<QueryExpressionClause> middleClauses>
2511
QueryExpressionLetVBClause letClause = new QueryExpressionLetVBClause();
2512
letClause.StartLocation = la.Location;
2514
"Let" ExpressionRangeVariableDeclarationList<letClause.Variables>
2516
letClause.EndLocation = t.EndLocation;
2517
middleClauses.Add(letClause);
2521
ExpressionRangeVariableDeclarationList<List<ExpressionRangeVariable> variables>
2523
ExpressionRangeVariable variable = null;
2525
ExpressionRangeVariableDeclaration<out variable>
2526
(. variables.Add(variable); .)
2527
{ "," ExpressionRangeVariableDeclaration<out variable> (. variables.Add(variable); .) }
2530
ExpressionRangeVariableDeclaration<out ExpressionRangeVariable variable>
2532
variable = new ExpressionRangeVariable();
2533
variable.StartLocation = la.Location;
2534
Expression rhs = null;
2535
TypeReference typeName = null;
2538
IF(IsIdentifiedExpressionRange()) Identifier
2539
(. variable.Identifier = t.val; .)
2541
"As" TypeName<out typeName>
2542
(. variable.Type = typeName; .)
2548
variable.Expression = rhs;
2549
variable.EndLocation = t.EndLocation;
2553
JoinQueryOperator<out QueryExpressionJoinVBClause joinClause>
2555
joinClause = new QueryExpressionJoinVBClause();
2556
joinClause.StartLocation = la.Location;
2557
CollectionRangeVariable joinVariable = null;
2558
QueryExpressionJoinVBClause subJoin = null;
2559
QueryExpressionJoinConditionVB condition = null;
2562
"Join" CollectionRangeVariableDeclaration<out joinVariable>
2563
(. joinClause.JoinVariable = joinVariable; .)
2565
JoinQueryOperator<out subJoin>
2566
(. joinClause.SubJoin = subJoin; .)
2569
JoinCondition<out condition>
2570
(. SafeAdd(joinClause, joinClause.Conditions, condition); .)
2572
"And" JoinCondition<out condition>
2573
(. SafeAdd(joinClause, joinClause.Conditions, condition); .)
2576
joinClause.EndLocation = t.EndLocation;
2580
CollectionRangeVariableDeclarationList<List<CollectionRangeVariable> rangeVariables>
2581
(. CollectionRangeVariable variableDeclaration; .)
2583
CollectionRangeVariableDeclaration<out variableDeclaration>
2584
(. rangeVariables.Add(variableDeclaration); .)
2585
{ "," CollectionRangeVariableDeclaration<out variableDeclaration> (. rangeVariables.Add(variableDeclaration); .) }
2588
CollectionRangeVariableDeclaration<out CollectionRangeVariable rangeVariable>
2590
rangeVariable = new CollectionRangeVariable();
2591
rangeVariable.StartLocation = la.Location;
2592
TypeReference typeName = null;
2593
Expression inExpr = null;
2595
Identifier (. rangeVariable.Identifier = t.val; .)
2596
[ "As" TypeName<out typeName> (. rangeVariable.Type = typeName; .) ]
2597
"In" Expr<out inExpr>
2599
rangeVariable.Expression = inExpr;
2600
rangeVariable.EndLocation = t.EndLocation;
2604
JoinCondition<out QueryExpressionJoinConditionVB condition>
2606
condition = new QueryExpressionJoinConditionVB();
2607
condition.StartLocation = la.Location;
2609
Expression lhs = null;
2610
Expression rhs = null;
2612
Expr<out lhs> "Equals" Expr<out rhs>
2614
condition.LeftSide = lhs;
2615
condition.RightSide = rhs;
2616
condition.EndLocation = t.EndLocation;
2620
MemberInitializer<out MemberInitializerExpression memberInitializer>
2622
memberInitializer = new MemberInitializerExpression();
2623
memberInitializer.StartLocation = la.Location;
2624
Expression initExpr = null;
2628
[ "Key" (. isKey = true; .) ]
2629
"." IdentifierOrKeyword<out name> "=" Expr<out initExpr>
2631
memberInitializer.Name = name;
2632
memberInitializer.Expression = initExpr;
2633
memberInitializer.IsKey = isKey;
2634
memberInitializer.EndLocation = t.EndLocation;
2639
ArgumentList<out List<Expression> arguments>
2641
arguments = new List<Expression>();
2642
Expression expr = null;
2644
[ Argument<out expr> ]
2645
{ "," (. arguments.Add(expr ?? Expression.Null); expr = null; .)
2646
[ Argument<out expr> ]
2647
(. if (expr == null) expr = Expression.Null; .)
2649
(. if (expr != null) arguments.Add(expr); .)
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>
2655
arguments = new List<Expression>();
2656
canBeNormal = true; canBeRedim = !IsNamedAssign();
2657
Expression expr = null;
2660
[ Argument<out expr>
2661
[ "To" (. EnsureIsZero(expr); canBeNormal = false; .)
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; .)
2672
(. if (expr == null) { canBeRedim = false; expr = Expression.Null; } .)
2674
(. if (expr != null) arguments.Add(expr); else canBeRedim = false; .)
2678
Argument<out Expression argumentexpr>
2681
argumentexpr = null;
2683
Location startLocation = la.Location;
2685
IF(IsNamedAssign()) Identifier (. name = t.val; .) ":=" Expr<out expr>
2687
argumentexpr = new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation };
2690
Expr<out argumentexpr>
2694
TypeName<out TypeReference typeref>
2695
(. ArrayList rank = null; Location startLocation = la.Location; .)
2697
NonArrayTypeName<out typeref, false>
2698
ArrayTypeModifiers<out rank>
2700
if (typeref != null) {
2702
typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
2704
typeref.StartLocation = startLocation;
2705
typeref.EndLocation = t.EndLocation;
2710
GetTypeTypeName<out TypeReference typeref>
2711
(. ArrayList rank = null; .)
2713
NonArrayTypeName<out typeref, true>
2714
ArrayTypeModifiers<out rank>
2715
(. if (rank != null && typeref != null) {
2716
typeref.RankSpecifier = (int[])rank.ToArray(typeof(int));
2722
NonArrayTypeName<out TypeReference typeref, bool canBeUnbound>
2726
bool isGlobal = false;
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); .)
2737
| "Object" (. typeref = new TypeReference("System.Object", true); .)
2741
List<TypeReference> typeArguments = new List<TypeReference>(1);
2742
if (typeref != null) typeArguments.Add(typeref);
2743
typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
2747
| PrimitiveTypeName<out name> (. typeref = new TypeReference(name, true); .)
2751
List<TypeReference> typeArguments = new List<TypeReference>(1);
2752
if (typeref != null) typeArguments.Add(typeref);
2753
typeref = new TypeReference("System.Nullable", typeArguments) { IsKeyword = true };
2758
QualIdentAndTypeArguments<out TypeReference typeref, bool canBeUnbound>
2759
(. string name; typeref = null; .)
2762
(. typeref = new TypeReference(name); .)
2763
[IF (la.kind == Tokens.OpenParenthesis && Peek(1).kind == Tokens.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>
2775
ArrayNameModifier<out ArrayList arrayModifiers>
2777
arrayModifiers = null;
2779
ArrayTypeModifiers<out arrayModifiers>
2784
ArrayTypeModifiers<out ArrayList arrayModifiers>
2786
arrayModifiers = new ArrayList();
2793
arrayModifiers.Add(i);
2798
if(arrayModifiers.Count == 0) {
2799
arrayModifiers = null;
2811
TypeArgumentList<List<TypeReference> typeArguments>
2813
TypeReference typeref;
2815
TypeName<out typeref> (. if (typeref != null) typeArguments.Add(typeref); .)
2818
TypeName<out typeref> (. if (typeref != null) typeArguments.Add(typeref); .)
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;
2829
":" Attribute<out attribute> (. attributes.Add(attribute); .)
2830
{ IF (NotFinalComma()) ["," ("Assembly" | "Module") ":"] Attribute<out attribute> (. attributes.Add(attribute); .)}
2835
AttributeSection section = new AttributeSection {
2836
AttributeTarget = attributeTarget,
2837
Attributes = attributes,
2838
StartLocation = startPos,
2839
EndLocation = t.EndLocation
2846
Attribute<out ASTAttribute attribute>
2849
List<Expression> positional = new List<Expression>();
2850
List<NamedArgumentExpression> named = new List<NamedArgumentExpression>();
2851
Location startLocation = la.Location;
2855
[ AttributeArguments<positional, named> ]
2857
attribute = new ASTAttribute(name, positional, named) { StartLocation = startLocation, EndLocation = t.EndLocation };
2862
AttributeArguments<List<Expression> positional, List<NamedArgumentExpression> named>
2864
bool nameFound = false;
2870
IF (IsNotClosingParenthesis()) (
2871
(. Location startLocation = la.Location; .)
2873
IF (IsNamedAssign()) (. nameFound = true; .)
2874
IdentifierOrKeyword<out name>
2879
if (string.IsNullOrEmpty(name)) { positional.Add(expr); }
2880
else { named.Add(new NamedArgumentExpression(name, expr) { StartLocation = startLocation, EndLocation = t.EndLocation }); name = ""; }
2886
IF (IsNamedAssign()) (. nameFound = true; .)
2887
IdentifierOrKeyword<out name>
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 = ""; }
2901
AttributeSection<out AttributeSection section>
2903
string attributeTarget = "";
2904
List<ASTAttribute> attributes = new List<ASTAttribute>();
2905
ASTAttribute attribute;
2906
Location startLocation = la.Location;
2909
[ IF (IsLocalAttrTarget())
2910
( "Event" (. attributeTarget = "event";.)
2911
| "Return" (. attributeTarget = "return";.)
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;
2924
Attribute<out attribute> (. attributes.Add(attribute); .)
2925
{ IF (NotFinalComma()) "," Attribute<out attribute> (. attributes.Add(attribute); .) }
2929
section = new AttributeSection {
2930
AttributeTarget = attributeTarget,
2931
Attributes = attributes,
2932
StartLocation = startLocation,
2933
EndLocation = t.EndLocation
2939
FormalParameterList<List<ParameterDeclarationExpression> parameter>
2940
(. ParameterDeclarationExpression p; .)
2942
FormalParameter<out p> (. if (p != null) parameter.Add(p); .)
2944
FormalParameter<out p> (. if (p != null) parameter.Add(p); .)
2948
FormalParameter<out ParameterDeclarationExpression p>
2950
AttributeSection section;
2951
List<AttributeSection> attributes = new List<AttributeSection>();
2952
TypeReference type = null;
2953
ParamModifierList mod = new ParamModifierList(this);
2954
Expression expr = null;
2956
ArrayList arrayModifiers = null;
2957
Location startLocation = la.Location;
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> ]
2967
if (arrayModifiers != null) {
2968
if (type.RankSpecifier != null) {
2969
Error("array rank only allowed one time");
2971
type.RankSpecifier = (int[])arrayModifiers.ToArray(typeof(int));
2976
[ "=" Expr<out expr> ]
2979
p = new ParameterDeclarationExpression(type, parameterName, mod.Modifier, expr);
2980
p.Attributes = attributes;
2981
p.StartLocation = startLocation;
2982
p.EndLocation = t.EndLocation;
2987
Block<out Statement stmt>
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);
2996
IF (IsEndStmtAhead())
2997
(. Token first = la; .)
3000
AddChild(new EndStatement() {
3001
StartLocation = first.Location,
3002
EndLocation = first.EndLocation }
3005
| Statement EndOfStmt
3006
/* IF (!LeaveBlock()) { }*/
3010
if (t != null) blockStmt.EndLocation = t.EndLocation;
3017
Statement stmt = null;
3018
Location startPos = la.Location;
3019
string label = String.Empty;
3023
| IF (IsLabel()) LabelName<out label>
3025
AddChild(new LabelStatement(t.val));
3028
| EmbeddedStatement<out stmt> (. AddChild(stmt); .)
3032
stmt.StartLocation = startPos;
3033
stmt.EndLocation = t.Location;
3039
LocalDeclarationStatement<out Statement statement>
3041
ModifierList m = new ModifierList();
3042
LocalVariableDeclaration localVariableDeclaration;
3043
bool dimfound = false;
3045
/* this differs from the spec: dim static x compiles with vbc. */
3047
"Const" (. m.Add(Modifiers.Const, t.Location); .)
3048
| "Static" (. m.Add(Modifiers.Static, t.Location); .)
3049
| "Dim" (. dimfound = true; .)
3052
if(dimfound && (m.Modifier & Modifiers.Const) != 0) {
3053
Error("Dim is not allowed on constants.");
3056
if(m.isNone && dimfound == false) {
3057
Error("Const, Dim or Static expected");
3060
localVariableDeclaration = new LocalVariableDeclaration(m.Modifier);
3061
localVariableDeclaration.StartLocation = t.Location;
3063
VariableDeclarator<localVariableDeclaration.Variables>
3064
{ "," VariableDeclarator<localVariableDeclaration.Variables> }
3066
statement = localVariableDeclaration;
3070
EmbeddedStatement<out Statement statement>
3072
Statement embeddedStatement = null;
3074
Expression expr = null;
3075
string name = String.Empty;
3076
List<Expression> p = null;
3077
Location startLocation = la.Location;
3080
"Exit" (. ExitType exitType = ExitType.None; .)
3082
"Sub" (. exitType = ExitType.Sub; .)
3084
"Function" (. exitType = ExitType.Function; .)
3086
"Property" (. exitType = ExitType.Property; .)
3088
"Do" (. exitType = ExitType.Do; .)
3090
"For" (. exitType = ExitType.For; .)
3092
"Try" (. exitType = ExitType.Try; .)
3094
"While" (. exitType = ExitType.While; .)
3096
"Select" (. exitType = ExitType.Select; .)
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); .)
3102
"Throw" [ Expr<out expr> ] (. statement = new ThrowStatement(expr); .)
3104
"Return" [ Expr<out expr> ] (. statement = new ReturnStatement(expr); .)
3106
"SyncLock" Expr<out expr> EndOfStmt Block<out embeddedStatement>
3107
"End" "SyncLock" (. statement = new LockStatement(expr, embeddedStatement); .)
3109
"RaiseEvent" Identifier (. name = t.val; .)
3110
[ "(" [ ArgumentList<out p> ] ")" ]
3112
statement = new RaiseEventStatement(name, p);
3115
WithStatement<out statement>
3117
"AddHandler" (. Expression handlerExpr = null; .)
3118
Expr<out expr> "," Expr<out handlerExpr>
3120
statement = new AddHandlerStatement(expr, handlerExpr);
3123
"RemoveHandler" (. Expression handlerExpr = null; .)
3124
Expr<out expr> "," Expr<out handlerExpr>
3126
statement = new RemoveHandlerStatement(expr, handlerExpr);
3129
"While" Expr<out expr> EndOfStmt
3130
Block<out embeddedStatement> "End" "While"
3132
statement = new DoLoopStatement(expr, embeddedStatement, ConditionType.While, ConditionPosition.Start);
3137
ConditionType conditionType = ConditionType.None;
3140
WhileOrUntil<out conditionType> Expr<out expr> EndOfStmt
3141
Block<out embeddedStatement>
3144
statement = new DoLoopStatement(expr,
3146
conditionType == ConditionType.While ? ConditionType.DoWhile : conditionType,
3147
ConditionPosition.Start);
3151
Block<out embeddedStatement>
3152
"Loop" [WhileOrUntil<out conditionType> Expr<out expr>]
3154
statement = new DoLoopStatement(expr, embeddedStatement, conditionType, ConditionPosition.End);
3159
Expression group = null;
3160
TypeReference typeReference;
3165
"Each" LoopControlVariable<out typeReference, out typeName>
3166
"In" Expr<out group> EndOfStmt
3167
Block<out embeddedStatement>
3168
"Next" [ Expr<out expr> ]
3170
statement = new ForeachStatement(typeReference,
3175
statement.StartLocation = startLocation;
3176
statement.EndLocation = t.EndLocation;
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;
3188
( IF (IsLoopVariableDeclaration())
3189
LoopControlVariable<out typeReference, out typeName>
3191
(. typeReference = null; typeName = null; .)
3192
SimpleExpr<out variableExpr>
3194
"=" Expr<out start> "To" Expr<out end> [ "Step" Expr<out step> ]
3195
EndOfStmt Block<out embeddedStatement>
3200
nextExpressions = new List<Expression>();
3201
nextExpressions.Add(nextExpr);
3203
{ "," Expr<out nextExpr> (. nextExpressions.Add(nextExpr); .) }
3206
statement = new ForNextStatement {
3207
TypeReference = typeReference,
3208
VariableName = typeName,
3209
LoopVariableExpression = variableExpr,
3213
EmbeddedStatement = embeddedStatement,
3214
NextExpressions = nextExpressions
3219
"Error" Expr<out expr> (. statement = new ErrorStatement(expr); .)
3221
"ReDim" (. bool isPreserve = false; .) [ "Preserve" (. isPreserve = true; .) ]
3222
ReDimClause<out expr>
3224
ReDimStatement reDimStatement = new ReDimStatement(isPreserve);
3225
statement = reDimStatement;
3226
SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression);
3228
{ "," ReDimClause<out expr>
3229
(. SafeAdd(reDimStatement, reDimStatement.ReDimClauses, expr as InvocationExpression); .)
3235
EraseStatement eraseStatement = new EraseStatement();
3236
if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr);}
3238
{ "," Expr<out expr> (. if (expr != null) { SafeAdd(eraseStatement, eraseStatement.Expressions, expr); }.) }
3239
(. statement = eraseStatement; .)
3241
"Stop" (. statement = new StopStatement(); .)
3243
IF (la.kind == Tokens.If)
3244
"If" (. Location ifStartLocation = t.Location; .) Expr<out expr> [ "Then" ]
3246
/* multiline if statement */
3247
EndOfStmt Block<out embeddedStatement>
3249
IfElseStatement ifStatement = new IfElseStatement(expr, embeddedStatement);
3250
ifStatement.StartLocation = ifStartLocation;
3251
Location elseIfStart;
3255
IF(IsElseIf()) "Else" (. elseIfStart = t.Location; .) "If"
3256
| "ElseIf" (. elseIfStart = t.Location; .)
3258
(. Expression condition = null; Statement block = null; .)
3259
Expr<out condition> [ "Then"] EndOfStmt
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);
3271
Block<out embeddedStatement>
3273
ifStatement.FalseStatement.Add(embeddedStatement);
3277
ifStatement.EndLocation = t.Location;
3278
statement = ifStatement;
3280
| /* singleline if statement */
3282
IfElseStatement ifStatement = new IfElseStatement(expr);
3283
ifStatement.StartLocation = ifStartLocation;
3285
SingleLineStatementList<ifStatement.TrueStatement>
3288
[ SingleLineStatementList<ifStatement.FalseStatement> ]
3290
(. ifStatement.EndLocation = t.Location; statement = ifStatement; .)
3293
"Select" [ "Case" ] Expr<out expr> EndOfStmt
3294
(.List<SwitchSection> selectSections = new List<SwitchSection>();
3295
Statement block = null;
3298
(.List<CaseLabel> caseClauses = null; Location caseLocation = la.Location; .)
3299
"Case" CaseClauses<out caseClauses> [ IF(IsNotStatementSeparator()) ":" ] EndOfStmt
3301
SwitchSection selectSection = new SwitchSection(caseClauses);
3302
selectSection.StartLocation = caseLocation;
3306
selectSection.Children = block.Children;
3307
selectSection.EndLocation = t.EndLocation;
3308
selectSections.Add(selectSection);
3312
statement = new SwitchStatement(expr, selectSections);
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 */
3323
Expression val = null;
3324
AssignmentOperatorType op;
3325
Location startLoc = la.Location;
3327
bool mustBeAssignment = la.kind == Tokens.Plus || la.kind == Tokens.Minus ||
3328
la.kind == Tokens.Not || la.kind == Tokens.Times;
3330
SimpleExpr<out expr>
3332
AssignmentOperator<out op> Expr<out val>
3334
expr = new AssignmentExpression(expr, op, val);
3335
expr.StartLocation = startLoc;
3336
expr.EndLocation = t.EndLocation;
3338
| (. if (mustBeAssignment) Error("error in assignment."); .)
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;
3349
statement = new ExpressionStatement(expr);
3351
| "Call" SimpleExpr<out expr> (. statement = new ExpressionStatement(expr); .)
3353
(. Statement block; .)
3354
( IF (Peek(1).kind == Tokens.As)
3355
(. LocalVariableDeclaration resourceAquisition = new LocalVariableDeclaration(Modifiers.None); .)
3356
VariableDeclarator<resourceAquisition.Variables>
3358
VariableDeclarator<resourceAquisition.Variables>
3362
statement = new UsingStatement(resourceAquisition, block);
3366
(. statement = new UsingStatement(new ExpressionStatement(expr), block); .)
3369
| LocalDeclarationStatement<out statement>
3372
if (statement != null) {
3373
statement.StartLocation = startLocation;
3374
statement.EndLocation = t.EndLocation;
3379
SingleLineStatementList<List<Statement> list>
3380
(. Statement embeddedStatement = null; .)
3382
( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
3383
| EmbeddedStatement<out embeddedStatement> )
3384
(. if (embeddedStatement != null) list.Add(embeddedStatement); .)
3386
( "End" (. embeddedStatement = new EndStatement() { StartLocation = t.Location, EndLocation = t.EndLocation }; .)
3387
| EmbeddedStatement<out embeddedStatement> )
3388
(. if (embeddedStatement != null) list.Add(embeddedStatement); .)
3393
LoopControlVariable<out TypeReference type, out string name>
3394
(.ArrayList arrayModifiers = null;
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."); } .) ]
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));
3413
OnErrorStatement<out OnErrorStatement stmt>
3416
Location startLocation = la.Location;
3417
GotoStatement goToStatement = null;
3422
IF(IsNegativeLabelName())"GoTo" "-" LiteralInteger
3424
long intLabel = Int64.Parse(t.val);
3426
Error("invalid label in on error statement.");
3428
stmt = new OnErrorStatement(new GotoStatement((intLabel * -1).ToString()));
3430
| GotoStatement<out goToStatement>
3432
string val = goToStatement.Label;
3434
// if value is numeric, make sure that is 0
3436
long intLabel = Int64.Parse(val);
3438
Error("invalid label in on error statement.");
3442
stmt = new OnErrorStatement(goToStatement);
3446
stmt = new OnErrorStatement(new ResumeStatement(true));
3451
stmt.StartLocation = startLocation;
3452
stmt.EndLocation = t.EndLocation;
3458
GotoStatement<out GotoStatement goToStatement>
3459
(. string label = String.Empty; Location startLocation = la.Location; .)
3461
"GoTo" LabelName<out label>
3463
goToStatement = new GotoStatement(label) {
3464
StartLocation = startLocation,
3465
EndLocation = t.EndLocation
3471
LabelName<out string name>
3473
name = String.Empty;
3475
Identifier (. name = t.val; .)
3476
| LiteralInteger (. name = t.val; .)
3480
ReDimClause<out Expression expr>
3482
SimpleNonInvocationExpression<out expr>
3483
ReDimClauseInternal<ref expr>
3486
ReDimClauseInternal<ref Expression expr>
3487
(. List<Expression> arguments; bool canBeNormal; bool canBeRedim; string name; Location startLocation = la.Location; .)
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>
3493
expr.StartLocation = startLocation;
3494
expr.EndLocation = t.EndLocation;
3498
NormalOrReDimArgumentList<out arguments, out canBeNormal, out canBeRedim>
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);
3511
ResumeStatement<out ResumeStatement resumeStatement>
3513
resumeStatement = null;
3514
string label = String.Empty;
3517
"Resume" "Next" (. resumeStatement = new ResumeStatement(true); .)
3518
| "Resume" [ LabelName<out label> ] (. resumeStatement = new ResumeStatement(label); .)
3522
CaseClauses<out List<CaseLabel> caseClauses>
3524
caseClauses = new List<CaseLabel>();
3525
CaseLabel caseClause = null;
3527
CaseClause<out caseClause> (. if (caseClause != null) { caseClauses.Add(caseClause); } .)
3528
{ "," CaseClause<out caseClause> (. if (caseClause != null) { caseClauses.Add(caseClause); } .) }
3532
CaseClause<out CaseLabel caseClause>
3534
Expression expr = null;
3535
Expression sexpr = null;
3536
BinaryOperatorType op = BinaryOperatorType.None;
3540
(. caseClause = new CaseLabel(); .)
3544
"<" (. op = BinaryOperatorType.LessThan; .)
3545
| ">" (. op = BinaryOperatorType.GreaterThan; .)
3546
| "<=" (. op = BinaryOperatorType.LessThanOrEqual; .)
3547
| ">=" (. op = BinaryOperatorType.GreaterThanOrEqual; .)
3548
| "=" (. op = BinaryOperatorType.Equality; .)
3549
| "<>" (. op = BinaryOperatorType.InEquality; .)
3553
caseClause = new CaseLabel(op, expr);
3555
| Expr<out expr> [ "To" Expr<out sexpr> ]
3557
caseClause = new CaseLabel(expr, sexpr);
3562
WhileOrUntil<out ConditionType conditionType>
3563
(. conditionType = ConditionType.None; .) =
3564
"While" (. conditionType = ConditionType.While; .)
3565
| "Until" (. conditionType = ConditionType.Until; .)
3569
WithStatement<out Statement withStatement>
3571
Statement blockStmt = null;
3572
Expression expr = null;
3574
"With" (. Location start = t.Location; .)
3575
Expr<out expr> EndOfStmt
3577
withStatement = new WithStatement(expr);
3578
withStatement.StartLocation = start;
3580
Block<out blockStmt>
3582
((WithStatement)withStatement).Body = (BlockStatement)blockStmt;
3585
(. withStatement.EndLocation = t.Location; .)
3589
TryStatement<out Statement tryStatement>
3591
Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
3594
Block<out blockStmt>
3595
[CatchClauses<out catchClauses>]
3596
["Finally" EndOfStmt Block<out finallyStmt> ]
3599
tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
3604
CatchClauses<out List<CatchClause> catchClauses>
3606
catchClauses = new List<CatchClause>();
3607
TypeReference type = null;
3608
Statement blockStmt = null;
3609
Expression expr = null;
3610
string name = String.Empty;
3614
[ Identifier (. name = t.val; .) ["As" TypeName<out type>] ]
3615
[ "When" Expr<out expr> ]
3617
Block<out blockStmt>
3618
(. catchClauses.Add(new CatchClause(type, name, blockStmt, expr)); .)
3623
Qualident<out string qualident>
3626
qualidentBuilder.Length = 0;
3629
Identifier (. qualidentBuilder.Append(t.val); .)
3630
{ IF (DotAndIdentOrKw()) "." IdentifierOrKeyword<out name> (. qualidentBuilder.Append('.'); qualidentBuilder.Append(name); .) }
3632
(. qualident = qualidentBuilder.ToString(); .)
3635
/* This production handles pseudo keywords that are needed in the grammar */
3637
IdentifierForFieldDeclaration
3641
IdentifierForFieldDeclaration =
3675
IdentifierOrKeyword<out string name>
3677
ANY (. name = t.val; .)
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"; .)
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); .)
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); .)
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);.)
3742
PropertyAccessorAccessModifier<out Modifiers m> =
3743
(. m = Modifiers.None; .)
3745
"Public" (. m |= Modifiers.Public; .)
3746
| "Protected" (. m |= Modifiers.Protected; .)
3747
| "Friend" (. m |= Modifiers.Internal; .)
3748
| "Private" (. m |= Modifiers.Private; .)