@ -20,7 +20,7 @@ TOKENS
@@ -20,7 +20,7 @@ TOKENS
LiteralSingle
LiteralDecimal
LiteralDate
XmlOpenTag
XmlOpenTag
XmlCloseTag
XmlStartInlineVB
XmlEndInlineVB
@ -285,495 +285,14 @@ TypeDeclaration =
@@ -285,495 +285,14 @@ TypeDeclaration =
InterfaceDeclaration
.
ClassOrModuleOrStructureTypeDeclaration =
( "Module" | "Class" | "Structure" ) ANY
[ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator
(. Indent(la); .)
{
( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration
| InterfaceDeclaration | MemberDeclaration )
}
(. Unindent(la); .)
"End" ( "Module" | "Class" | "Structure" ) StatementTerminator
.
DelegateTypeDeclaration = "Delegate" { ANY } StatementTerminator .
EnumTypeDeclaration =
"Enum" { ANY } StatementTerminator
(. Indent(la); .)
{ ANY [ "=" Expression ] StatementTerminator }
{ ANY } StatementTerminator
(. Unindent(la); .)
"End" "Enum" StatementTerminator
.
InterfaceDeclaration =
"Interface" ANY [ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator
(. Indent(la); .)
[ "Inherits" TypeName { "," TypeName } StatementTerminator ]
{
( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration
| InterfaceDeclaration | InterfaceMemberDeclaration ) { ANY }
}
(. Unindent(la); .)
"End" "Interface" StatementTerminator
.
InterfaceMemberDeclaration =
InterfaceEvent | InterfaceProperty | InterfaceSubOrFunction
.
InterfaceEvent =
"Event" { ANY } StatementTerminator
.
InterfaceProperty =
"Property" { ANY } StatementTerminator
.
InterfaceSubOrFunction =
("Sub" | "Function") { ANY }
{ "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" }
[ "As" TypeName ]
StatementTerminator
.
GenericConstraint =
TypeName | "New" | "Class" | "Structure"
.
GenericConstraintList =
GenericConstraint | "{" GenericConstraint { "," GenericConstraint } "}"
.
GenericTypeParameterDeclaration =
[ "Out" | "In" ] ANY [ "As" GenericConstraintList ]
{ "," [ "Out" | "In" ] ANY [ "As" GenericConstraintList ] }
.
DelegateTypeDeclaration =
"Delegate" ("Sub" | "Function") ANY
[ "(" [ ParameterList ] ")" ] [ "As" TypeName ] StatementTerminator
.
MemberDeclaration =
(
MemberVariableOrConstantDeclaration |
SubOrFunctionDeclaration |
ExternalMemberDeclaration |
EventMemberDeclaration |
CustomEventMemberDeclaration |
PropertyDeclaration |
OperatorDeclaration
)
.
SubOrFunctionDeclaration =
("Sub" | "Function")
ANY
{ "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" }
[ "As" TypeName ]
StatementTerminatorAndBlock
"End" ("Sub" | "Function") StatementTerminator
.
ExternalMemberDeclaration =
"Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) ANY
"Lib" LiteralString [ "Alias" LiteralString ] [ "(" [ ParameterList ] ")" ] [ "As" TypeName ] StatementTerminator
.
EventMemberDeclaration =
"Event" ANY ( "As" TypeName | [ "(" [ ParameterList ] ")" ] )
[ "Implements" TypeName /*"." IdentifierOrKeyword*/ { "," TypeName /*"." IdentifierOrKeyword*/ } ]
/* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammer we just leave that out */
StatementTerminator
.
CustomEventMemberDeclaration =
"Custom" EventMemberDeclaration
{
( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) "(" ParameterList ")"
StatementTerminatorAndBlock
"End" ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) StatementTerminator
}
"End" "Event" StatementTerminator
.
PropertyDeclaration =
"Property" { ANY } [ "=" Expression ] StatementTerminator
{ ANY }
[ (. Indent(la); .)
( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ]
StatementTerminatorAndBlock
"End" ( "Get" | "Set" ) StatementTerminator
[ ( "Get" | "Set" ) [ "(" [ ParameterList ] ")" ]
StatementTerminatorAndBlock
"End" ( "Get" | "Set" ) StatementTerminator ]
(. Unindent(la); .)
"End" "Property" StatementTerminator ]
.
OperatorDeclaration =
"Operator" { ANY }
StatementTerminatorAndBlock
"End" "Operator" StatementTerminator
.
MemberVariableOrConstantDeclaration =
MemberVariableOrConstantDeclarator { "," MemberVariableOrConstantDeclarator } StatementTerminator
.
MemberVariableOrConstantDeclarator =
[ "Const" ]
ANY
[ "As" ( NewExpression | TypeName ) ]
[ "=" Expression ]
.
ParameterList =
Parameter { "," Parameter }
.
Parameter =
ANY
{ ANY }
[ "As" TypeName ]
[ "=" Expression ]
.
StatementTerminatorAndBlock =
(. Indent(la); .)
StatementTerminator
{ EXPECTEDCONFLICT("End")
(
[ Statement] StatementTerminator
| "End"
( StatementTerminator /* End+StatementTerminator is end statement */
| /* End+anything else is the end of this block. */
(.
currentState = endOfStatementTerminatorAndBlock; /* leave this block */
InformToken(t); /* process End again*/
/* for processing current token (la): go to the position after processing End */
goto switchlbl;
.)
ANY /* never reached due to goto above: */
/* this ANY is just so that Coco knows this branch isn't empty */
)
)
}
(.NamedState:endOfStatementTerminatorAndBlock.)
(. Unindent(la); .)
.
Expression
(.NamedState:startOfExpression.)
= SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix } .
BinaryOperator =
"+" | "-" | "*" | "\\" | "/" | "^" | "Mod"
| "=" | "<>" | "<" | ">" | "<=" | ">="
| "Like" | "&" | "And" | "AndAlso" | "Or" | "OrElse"
| "Xor" | "<<" | ">>" | "Is" | "IsNot"
| "^=" | "*=" | "/=" | "\\=" | "+=" | "-=" | "&=" | "<<=" | ">>=" | "To" | ":="
.
UnaryOperator =
"+" | "-" | "Not" | "AddressOf"
.
SimpleExpressionWithSuffix =
{ UnaryOperator }
(
SimpleExpression { ExpressionSuffix }
| "TypeOf" SimpleExpressionWithSuffix "Is" TypeName
| NewExpression
| CollectionInitializer
)
.
SimpleExpression =
( ANY
| XmlLiteral
| LambdaExpression
| ConditionalExpression
)
.
NewExpression =
"New" (
TypeName
[
EXPECTEDCONFLICT("From")
(
"From"
(
CollectionInitializer /* From + CollectionInitializer is a NewExpression */
|
(.
currentState = endOfStatementTerminatorAndBlock; /* leave this block */
InformToken(t); /* process From again*/
/* for processing current token (la): go to the position after processing End */
goto switchlbl;
.)
ANY /* never reached due to goto above: */
/* this ANY is just so that Coco knows this branch isn't empty */
)
|
"With" ObjectInitializer
)
]
|
"With" ObjectInitializer
)
.
ObjectInitializer =
"{" [ "Key" ] "." ANY "=" Expression { "," [ "Key" ] "." ANY "=" Expression } "}"
.
CollectionInitializer =
"{" Expression { "," Expression } "}"
.
ExpressionSuffix =
"(" ( "Of" TypeName { "," TypeName } ")" | [ ArgumentList ] ")" )
| ( "." | "!" | ".@" | "..." ) [ XmlOpenTag ] ANY [ XmlCloseTag ]
.
ConditionalExpression =
"If" "(" Expression "," Expression [ "," Expression ] ")"
.
LambdaExpression =
SubLambdaExpression |
FunctionLambdaExpression
.
SubLambdaExpression =
"Sub" "(" [ ParameterList ] ")"
( GREEDY Statement | StatementTerminatorAndBlock "End" "Sub" )
.
FunctionLambdaExpression =
"Function" "(" [ ParameterList ] ")"
( GREEDY Expression | [ "As" TypeName ] StatementTerminatorAndBlock "End" "Function" )
.
/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */
XmlLiteral =
(
( XmlComment | XmlProcessingInstruction | XmlCData ) [ XmlContent ] { ( XmlComment | XmlProcessingInstruction ) [ XmlContent ] } [ XmlElement { XmlComment [ XmlContent ] } ]
|
XmlElement { XmlComment [ XmlContent ] }
)
.
XmlElement =
XmlOpenTag { ANY | XmlEmbeddedExpression } ( XmlCloseTagEmptyElement | XmlCloseTag { ANY | XmlEmbeddedExpression | XmlElement } XmlOpenEndTag { ANY | XmlEmbeddedExpression } XmlCloseTag )
.
XmlEmbeddedExpression =
XmlStartInlineVB Expression XmlEndInlineVB
.
PrimitiveTypeName =
"Byte" |
"SByte" |
"UShort" |
"Short" |
"UInteger" |
"Integer" |
"ULong" |
"Long" |
"Single" |
"Double" |
"Decimal" |
"Boolean" |
"Date" |
"Char" |
"String" |
"Object"
.
TypeName = ( "Global" | ident | PrimitiveTypeName | "?" /* used for ? = completion */ ) { TypeSuffix } { "." IdentifierOrKeyword { TypeSuffix } } .
TypeSuffix = "(" ( "Of" [ TypeName ] { "," [ TypeName ] } | [ ArgumentList ] ) ")" .
IdentifierOrKeyword = ANY .
Statement =
VariableDeclarationStatement
| WithOrLockStatement
| AddOrRemoveHandlerStatement
| RaiseEventStatement
| EXPECTEDCONFLICT("If") IfStatement /* prefer if-statement to if-expression */
| SelectStatement
| WhileStatement
| DoLoopStatement
| ForStatement
| ErrorHandlingStatement
| ThrowStatement
| TryStatement
| BranchStatement
| ReDimStatement
| EraseStatement
| UsingStatement
| InvocationStatement
.
VariableDeclarationStatement =
( "Dim" | "Static" | "Const" ) ANY [ "?" ] [ ( "(" { "," } ")" ) ]
{ "," ANY [ "?" ] [ ( "(" { "," } ")" ) ] }
[ "As" ( NewExpression | TypeName ) ]
[ "=" Expression ]
.
WithOrLockStatement =
( "With" | "SyncLock" ) Expression StatementTerminatorAndBlock "End" ( "With" | "SyncLock" )
.
AddOrRemoveHandlerStatement =
( "AddHandler" | "RemoveHandler" ) Expression "," Expression
.
RaiseEventStatement =
"RaiseEvent" IdentifierOrKeyword [ "(" [ ArgumentList ] ")" ]
.
IfStatement =
"If" Expression
( "Then"
( Statement { EXPECTEDCONFLICT(":") ":" [Statement] } [ EXPECTEDCONFLICT("Else") "Else" [Statement] { EXPECTEDCONFLICT(":") ":" [Statement] } ]
| MultilineIfRemainder
)
| MultilineIfRemainder
)
.
MultilineIfRemainder =
StatementTerminatorAndBlock
{
("Else" [ "If" Expression [ "Then" ] ]
| "ElseIf" Expression [ "Then" ]
)
StatementTerminatorAndBlock
}
"End" "If"
.
SelectStatement =
"Select" [ "Case" ] Expression StatementTerminator
{
"Case" (
"Else" |
( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression )
{ "," ( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression ) }
)
StatementTerminatorAndBlock
}
"End" "Select"
.
ComparisonOperator =
"=" | "<>" | "<" | ">" | ">=" | "<="
.
WhileStatement =
"While" Expression StatementTerminatorAndBlock "End" "While"
.
DoLoopStatement =
"Do" ( DoTopLoopStatement | DoBottomLoopStatement )
.
DoTopLoopStatement =
( "While" | "Until" ) Expression
StatementTerminatorAndBlock
"Loop"
.
DoBottomLoopStatement =
StatementTerminatorAndBlock
"Loop" [ ( "While" | "Until" ) Expression ]
.
ForStatement =
"For" ( ForLoopStatement | ForEachLoopStatement )
.
ForLoopStatement =
ForLoopVariable "=" Expression /* "To" is binary operator */ [ "Step" Expression ]
StatementTerminatorAndBlock
"Next" [ Expression { "," Expression } ]
.
ForEachLoopStatement =
"Each" ForLoopVariable "In" Expression
StatementTerminatorAndBlock
"Next" [ Expression { "," Expression } ]
.
ForLoopVariable =
SimpleExpression
[ "?" ] { ExpressionSuffix }
[ "As" TypeName ]
.
ErrorHandlingStatement =
[ "On" ] "Error" ( Expression | "GoTo" ( LiteralInteger | ident ) | "Resume" "Next" )
| "Resume" ( "Next" | LiteralInteger | ident )
.
ThrowStatement =
"Throw" [ Expression ]
.
TryStatement =
"Try"
StatementTerminatorAndBlock
{
"Catch"
[ ANY [ "As" TypeName ] ]
[ "When" Expression ]
StatementTerminatorAndBlock
}
[
"Finally"
StatementTerminatorAndBlock
]
"End" "Try"
.
BranchStatement =
"GoTo" ( ident | LiteralInteger )
| "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" )
| "Continue" ( "Do" | "For" | "While" )
| "Stop"
/*| "End" HACK End-Statements has special handling in Block */
| "Return" [ Expression ]
.
ReDimStatement =
"ReDim"
[ EXPECTEDCONFLICT("Preserve") "Preserve" ] /* Preserve is context-dependend keyword */
Expression
.
EraseStatement =
"Erase" Expression { "," Expression }
.
UsingStatement =
"Using" Expression
StatementTerminatorAndBlock
"End" "Using"
.
InvocationStatement =
[ "Call" ] Expression
.
ArgumentList =
Expression { "," [ Expression ] }
| "," [ Expression ] { "," [ Expression ] }
.
END VBIndentationStrategy.