Skip to content

Instantly share code, notes, and snippets.

/vba grammar.txt Secret

Created Dec 29, 2014
Embed
What would you like to do?
vba grammar
SECTION 3
---------
module-body-physical-structure = *source-line [non-terminated-line]
source-line = *non-line-termination-character line-terminator
non-terminated-line = *non-line-termination-character
line-terminator = (%x000D %x000A) / %x000D / %x000A / %x2028 / %x2029
non-line-termination-character = <any character other than %x000D / %x000A / %x2028 / %x2029>
module-body-logical-structure = *extended-line
extended-line = *(line-continuation / non-line-termination-character) line-terminator
line-continuation = *WSC underscore *WSC line-terminator
WSC = (tab-character / eom-character /space-character / DBCS-whitespace / most-Unicode-class-Zs)
tab-character = %x0009
eom-character = %x0019
space-character = %x0020
underscore = %x005F
DBCS-whitespace = %x3000
most-Unicode-class-Zs = <all members of Unicode class Zs which are not CP2-characters>
module-body-lines = *logical-line
logical-line = LINE-START *extended-line LINE-END
WS = 1*(WSC / line-continuation)
special-token = "," / "." / "!" / "#" / "&" / "(" / ")" / "*" / "+" / "-" / "/" / ":" / ";" / "<" / "=" / ">" / "?" / "\" / "^"
NO-WS = <no whitespace characters allowed here>
NO-LINE-CONTINUATION = <a line-continuation is not allowed here>
EOL = [WS] LINE-END / single-quote comment-body
EOS = *(EOL / ":") ;End Of Statement
single-quote = %x0027 ; '
comment-body = *(line-continuation / non-line-termination-character) LINE-END
INTEGER = integer-literal ["%" / "&" / "^"]
integer-literal = decimal-literal / octal-literal / hex-literal
decimal-literal = 1*decimal-digit
octal-literal = "&" [%x004F / %x006F] 1*octal-digit ; & or &o or &O
hex-literal = "&" (%x0048 / %x0068) 1*hex-digit ; &h or &H
octal-digit = "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"
decimal-digit = octal-digit / "8" / "9"
hex-digit = decimal-digit / %x0041-0046 / %x0061-0066 ;A-F / a-f
FLOAT = (floating-point-literal [floating-point-type-suffix] ) / (decimal-literal floating-point-type-suffix)
floating-point-literal = (integer-digits exponent) / (integer-digits "." [fractional-digits] [exponent]) / ( "." fractional-digits [exponent])
integer-digits = decimal-literal
fractional-digits = decimal-literal
exponent = exponent-letter [sign] decimal-literal
exponent-letter = %x0044 / %x0045 / %x0064 / %x0065 ; D / E / d / e
sign = "+" / "-"
floating-point-type-suffix = "!" / "#" / "@"
DATE = "#" *WSC [date-or-time *WSC] "#"
date-or-time = (date-value 1*WSC time-value) / date-value / time-value
date-value = left-date-value date-separator middle-date-value [date-separator right-date-value]
left-date-value = decimal-literal / month-name
middle-date-value = decimal-literal / month-name
right-date-value = decimal-literal / month-name
date-separator = 1*WSC / (*WSC ("/" / "-" / ",") *WSC)
month-name = English-month-name / English-month-abbreviation
English-month-name = "january" / "february" / "march" / "april" / "may" / "june" / "august" / "september" / "october" / "november" / "december"
English-month-abbreviation = "jan" / "feb" / "mar" / "apr" / "jun" / "jul" / "aug" / "sep" / "oct" / "nov" / "dec"
time-value = (hour-value ampm) / (hour-value time-separator minute-value [time-separator second-value] [ampm])
hour-value = decimal-literal
minute-value = decimal-literal
second-value = decimal-literal
time-separator = *WSC (":" / ".") *WSC
ampm = *WSC ("am" / "pm" / "a" / "p")
STRING = double-quote *string-character (double-quote / line-continuation / LINE-END)
double-quote = %x0022 ; "
string-character = NO-LINE-CONTINUATION ((double-quote double-quote) / non-line-termination-character)
lex-identifier = Latin-identifier / codepage-identifier / Japanese-identifier / Korean-identifier / simplified-Chinese-identifier / traditional-Chinese-identifier
Latin-identifier = first-Latin-identifier-character *subsequent-Latin-identifier-character
first-Latin-identifier-character = (%x0041-005A / %x0061-007A) ; A-Z / a-z
subsequent-Latin-identifier-character = first-Latin-identifier-character / DIGIT / %x5F ; underscore
Japanese-identifier = first-Japanese-identifier-character *subsequent-Japanese-identifier-character
first-Japanese-identifier-character = (first-Latin-identifier-character / CP932-initial-character)
subsequent-Japanese-identifier-character = (subsequent-Latin-identifier-character / CP932-subsequent-character)
CP932-initial-character = < character ranges specified in section 3.3.5.1.1>
CP932-subsequent-character = < character ranges specified in section 3.3.5.1.1>
Korean-identifier = first-Korean-identifier-character *subsequent Korean -identifier-character
first-Korean-identifier-character = (first-Latin-identifier-character / CP949-initial-character )
subsequent-Korean-identifier-character = (subsequent-Latin-identifier-character / CP949-subsequent-character)
CP949-initial-character = < character ranges specified in section 3.3.5.1.2>
CP949-subsequent-character = < character ranges specified in section 3.3.5.1.2>
simplified-Chinese-identifier = first-sChinese-identifier-character *subsequent-sChinese-identifier-character
first-sChinese-identifier-character = (first-Latin-identifier-character / CP936-initial-character)
subsequent-sChinese-identifier-character = (subsequent-Latin-identifier-character / CP936-subsequent-character)
CP936-initial-character = < character ranges specified in section 3.3.5.1.3>
CP936-subsequent-character = < character ranges specified in section 3.3.5.1.3>
traditional-Chinese-identifier = first-tChinese-identifier-character *subsequent-tChinese-identifier-character
first-tChinese-identifier-character = (first-Latin-identifier-character / CP950-initial-character)
subsequent-tChinese-identifier-character = (subsequent-Latin-identifier-character / CP950-subsequent-character)
CP950-initial-character = < character ranges specified in section 3.3.5.1.4>
CP950-subsequent-character = < character ranges specified in section 3.3.5.1.4>
codepage-identifier = (first-Latin-identifier-character / CP2-character) *(subsequent-Latin-identifier-character / CP2-character)
CP2-character = <any Unicode character that has a mapping to the character range %x80-FF in a Microsoft Windows supported code page>
reserved-identifier = Statement-keyword / marker-keyword / operator-identifier / special-form / reserved-name / literal-identifier / rem-keyword / reserved-for-implementation-use / future-reserved
IDENTIFIER = <any lex-identifier that is not a reserved-identifier>
Statement-keyword = "Call" / "Case" /"Close" / "Const"/ "Declare" / "DefBool" / "DefByte" / "DefCur" / "DefDate" / "DefDbl" / "DefInt" / "DefLng" / "DefLngLng" / "DefLngPtr" / "DefObj" / "DefSng" / "DefStr" / "DefVar" / "Dim" / "Do" / "Else" / "ElseIf" / "End" / "EndIf" / "Enum" / "Erase" / "Event" / "Exit" / "For" / "Friend" / "Function" / "Get" / "Global" / "GoSub" / "GoTo" / "If" / "Implements"/ "Input" / "Let" / "Lock" / "Loop" / "LSet" / "Next" / "On" / "Open" / "Option" / "Print" / "Private" / "Public" / "Put" / "RaiseEvent" / "ReDim" / "Resume" / "Return" / "RSet" / "Seek" / "Select" / "Set" / "Static" / "Stop" / "Sub" / "Type" / "Unlock" / "Wend" / "While" / "With" / "Write"
rem-keyword = "Rem"
marker-keyword = "Any" / "As"/ "ByRef" / "ByVal "/"Case" / "Each" / "Else" /"In"/ "New" / "Shared" / "Until" / "WithEvents" / "Write" / "Optional" / "ParamArray" / "Preserve" / "Spc" / "Tab" / "Then" / "To"
operator-identifier = "AddressOf" / "And" / "Eqv" / "Imp" / "Is" / "Like" / "New" / "Mod" / "Not" / "Or" / "TypeOf" / "Xor"
reserved-name = "Abs" / "CBool" / "CByte" / "CCur" / "CDate" / "CDbl" / "CDec" / "CInt" / "CLng" / "CLngLng" / "CLngPtr" / "CSng" / "CStr" / "CVar" / "CVErr" / "Date" / "Debug" / "DoEvents" / "Fix" / "Int" / "Len" / "LenB" / "Me" / "PSet" / "Scale" / "Sgn" / "String"
special-form = "Array" / "Circle" / "Input" / "InputB" / "LBound" / "Scale" / "UBound"
reserved-type-identifier = "Boolean" / "Byte" / "Currency" / "Date" / "Double" / "Integer" / "Long" / "LongLong" / "LongPtr" / "Single" / "String" / "Variant"
literal-identifier = boolean-literal-identifier / object-literal-identifier / variant-literal-identifier
boolean-literal-identifier = "true" / "false"
object-literal-identifier = "nothing"
variant-literal-identifier = "empty" / "null"
reserved-for-implementation-use = "Attribute" / "LINEINPUT" / "VB_Base" / "VB_Control" / "VB_Creatable" / "VB_Customizable" / "VB_Description" / "VB_Exposed" / "VB_Ext_KEY " / "VB_GlobalNameSpace" / "VB_HelpID" / "VB_Invoke_Func" / "VB_Invoke_Property " / "VB_Invoke_PropertyPut" / "VB_Invoke_PropertyPutRefVB_MemberFlags" / "VB_Name" / "VB_PredeclaredId" / "VB_ProcData" / "VB_TemplateDerived" / "VB_UserMemId" / "VB_VarDescription" / "VB_VarHelpID" / "VB_VarMemberFlags" / "VB_VarProcData " / "VB_VarUserMemId"
future-reserved = "CDecl" / "Decimal" / "DefDec"
FOREIGN-NAME = "[" foreign-identifier "]"
foreign-identifier = 1*non-line-termination-character
BUILTIN-TYPE = reserved-type-identifier / ("[" reserved-type-identifier "]") / "object" / "[object]"
TYPED-NAME = IDENTIFIER type-suffix
type-suffix = "%" / "&" / "^" / "!" / "#" / "@" / "$"
conditional-module-body = cc-block
cc-block = *(cc-const / cc-if-block / logical-line)
cc-const = LINE-START "#" "const" cc-var-lhs "=" cc-expression cc-eol
cc-var-lhs = name
cc-eol = [single-quote *non-line-termination-character] LINE-END
cc-if-block = cc-if cc-block *cc-elseif-block [cc-else-block] cc-endif
cc-if = LINE-START "#" "if" cc-expression "then" cc-eol
cc-elseif-block = cc-elseif cc-block
cc-elseif = LINE-START "#" "elseif" cc-expression "then" cc-eol
cc-else-block = cc-else cc-block
cc-else = LINE-START "#" "else" cc-eol
cc-endif = LINE-START "#" ("endif" / ("end" "if")) cc-eol
SECTION 4-5
-----------
procedural-module = LINE-START procedural-module-header EOS LINE-START procedural-module-body
class-module = LINE-START class-module-header LINE-START class-module-body
procedural-module-header = attribute "VB_Name" attr-eq quoted-identifier attr-end
class-module-header = 1*class-attr
class-attr = attribute "VB_Name" attr-eq quoted-identifier attr-end / attribute "VB_GlobalNameSpace" attr-eq "False" attr-end / attribute "VB_Creatable" attr-eq "False" attr-end / attribute "VB_PredeclaredId" attr-eq boolean-literal-identifier attr-end / attribute "VB_Exposed" attr-eq boolean-literal-identifier attr-end / attribute "VB_Customizable" attr-eq boolean-literal-identifier attr-end
attribute = LINE-START "Attribute"
attr-eq = "="
attr-end = LINE-END
quoted-identifier = double-quote NO-WS IDENTIFIER NO-WS double-quote
procedural-module-body = LINE-START procedural-module-declaration-section LINE-START procedural-module-code-section
class-module-body = LINE-START class-module-declaration-section LINE-START class-module-code-section
unrestricted-name = name / reserved-identifier
name = untyped-name / TYPED-NAME
untyped-name = IDENTIFIER / FOREIGN-NAME
procedural-module-declaration-section = [*(procedural-module-directive-element EOS) def-directive] *( procedural-module-declaration-element EOS)
class-module-declaration-section = [*(class-module-directive-element EOS) def-directive] *(class-module-declaration-element EOS)
procedural-module-directive-element = common-option-directive / option-private-directive / def-directive
procedural-module-declaration-element = common-module-declaration-element / global-variable-declaration / public-const-declaration / public-type-declaration / public-externalprocedure-declaration / global-enum-declaration / common-optiondirective / option-private-directive
class-module-directive-element = common-option-directive / def-directive / implements-directive
class-module-declaration-element = common-module-declaration-element / event-declaration / commonoption-directive / implements-directive
common-option-directive = option-compare-directive / option-base-directive / option-explicit-directive / rem-statement
option-compare-directive = "Option" "Compare" ( "Binary" / "Text")
option-base-directive = "Option" "Base" INTEGER
option-explicit-directive = "Option" "Explicit"
option-private-directive = "Option" "Private" "Module"
def-directive = def-type letter-spec *( "," letter-spec)
letter-spec = single-letter / universal-letter-range / letter-range
single-letter = IDENTIFIER ; %x0041-005A / %x0061-007A
universal-letter-range = upper-case-A "-"upper-case-Z
upper-case-A = IDENTIFIER
upper-case-Z = IDENTIFIER
letter-range = first-letter "-" last-letter
first-letter = IDENTIFIER
last-letter = IDENTIFIER
def-type = "DefBool" / "DefByte" / "DefCur" / "DefDate" / "DefDbl" / "DefInt" / "DefLng" / "DefLngLng" / "DefLngPtr" / "DefObj" / "DefSng" / "DefStr" / "DefVar"
common-module-declaration-element = module-variable-declaration
common-module-declaration-element =/ private-const-declaration
common-module-declaration-element =/ private-type-declaration
common-module-declaration-element =/ enum-declaration
common-module-declaration-element =/ private-external-procedure-declaration
module-variable-declaration = public-variable-declaration / private-variable-declaration
global-variable-declaration = "Global" variable-declaration-list
public-variable-declaration = "Public" ["Shared"] module-variable-declaration-list
private-variable-declaration = ("Private" / "Dim") [ "Shared"] module-variable-declaration-list
module-variable-declaration-list = (withevents-variable-dcl / variable-dcl) *( "," (withevents-variable-dcl / variable-dcl) )
variable-declaration-list = variable-dcl *( "," variable-dcl )
variable-dcl = typed-variable-dcl / untyped-variable-dcl
typed-variable-dcl = TYPED-NAME [array-dim]
untyped-variable-dcl = IDENTIFIER [array-clause / as-clause]
array-clause = array-dim [as-clause]
as-clause = as-auto-object / as-type
withevents-variable-dcl = "withevents" IDENTIFIER "as" class-type-name
class-type-name = defined-type-expression
array-dim = "(" [bounds-list] ")"
bounds-list = dim-spec *("," dim-spec)
dim-spec = [lower-bound] upper-bound
lower-bound = constant-expression "to"
upper-bound = constant-expression
as-auto-object = "as" "new" class-type-name
as-type = "as" type-spec
type-spec = fixed-length-string-spec / type-expression
fixed-length-string-spec = "string" "*" string-length
string-length = constant-name / INTEGER
constant-name = simple-name-expression
public-const-declaration = ("Global" / "Public") module-const-declaration
private-const-declaration = ["Private"] module-const-declaration
module-const-declaration = const-declaration
const-declaration = "Const" const-item-list
const-item-list = const-item *[ "," const-item]
const-item = typed-name-const-item / untyped-name-const-item
typed-name-const-item = TYPED-NAME "=" constant-expression
untyped-name-const-item = IDENTIFIER [const-as-clause] "=" constant-expression
const-as-clause = "as" BUILTIN-TYPE
public-type-declaration = ["global" / "public"] udt-declaration
private-type-declaration = "private" udt-declaration
udt-declaration = "type" untyped-name EOS udt-member-list EOS "end" "type"
udt-member-list = udt-element *[EOS udt-element]
udt-element = rem-statement / udt-member
udt-member = reserved-name-member-dcl / untyped-name-member-dcl
untyped-name-member-dcl = IDENTIFIER optional-array-clause
reserved-name-member-dcl = reserved-member-name as-clause
optional-array-clause = [array-dim] as-clause
reserved-member-name = statement-keyword / marker-keyword / operator-identifier / special-form / reserved-name / literal-identifier / reserved-for-implementation-use / future-reserved
enum-declaration = public-enum-declaration / private-enum-declaration
global-enum-declaration = "global" enum-declaration
public-enum-declaration = ["public"] enum-declaration
private-enum-declaration = "private" enum-declaration
enum-declaration = "enum" untyped-name EOS member-list EOS "end" "enum"
member-list = enum-element *[EOS enum-element]
enum-element = rem-statement / enum-member
enum-member = untyped-name [ "=" constant-expression]
public-external-procedure-declaration = ["public"] external-proc-dcl
private-external-procedure-declaration = "private" external-proc-dcl
external-proc-dcl = "declare" ["ptrsafe"] (external-sub / external-function)
external-sub = "sub" subroutine-name lib-info [procedure-parameters]
external-function = "function" function-name lib-info [procedure-parameters] [function-type]
lib-info = lib-clause [alias-clause]
lib-clause = "lib" STRING
alias-clause = "alias" STRING
implements-directive = "Implements" class-type-name
event-declaration = ["Public"] "Event" IDENTIFIER [event-parameter-list]
event-parameter-list = "(" [positional-parameters] ")"
procedural-module-code-section = *( LINE-START procedural-module-code-element LINE-END)
class-module-code-section = *( LINE-START class-module-code-element LINE-END)
procedural-module-code-element = common-module-code-element
class-module-code-element = common-module-code-element / implements-directive
common-module-code-element = rem-statement / procedure-declaration
procedure-declaration = subroutine-declaration / function-declaration / property-get-declaration / property-LHS-declaration
subroutine-declaration = procedure-scope [initial-static] "sub" subroutine-name [procedure-parameters] [trailing-static] EOS [procedure-body EOS] [end-label] "end" "sub" procedure-tail
function-declaration = procedure-scope [initial-static] "function" function-name [procedure-parameters] [function-type] [trailing-static] EOS [procedure-body EOS] [end-label] "end" "function" procedure-tail
property-get-declaration = procedure-scope [initial-static] "Property" "Get" function-name [procedure-parameters] [function-type] [trailing-static] EOS [procedure-body EOS] [end-label] "end" "property" procedure-tail
property-lhs-declaration = procedure-scope [initial-static] "Property" ("Let" / "Set") subroutine-name property-parameters [trailing-static] EOS [procedure-body EOS] [end-label] "end" "property" procedure-tail
end-label = statement-label-definition
procedure-tail = [WS] LINE-END / single-quote comment-body / ":" rem-statement
procedure-scope = ["global" / "public" / "private" / "friend"]
initial-static = "static"
trailing-static = "static"
subroutine-name = IDENTIFIER / prefixed-name
function-name = TYPED-NAME / subroutine-name
prefixed-name = event-handler-name / implemented-name / lifecycle-handler-name
function-type = "as" type-expression [array-designator]
array-designator = "(" ")"
procedure-parameters = "(" [parameter-list] ")"
property-parameters = "(" [parameter-list ","] value-param ")"
parameter-list = (positional-parameters "," optional-parameters ) / (positional-parameters ["," param-array]) / optional-parameters / param-array
positional-parameters = positional-param *("," positional-param)
optional-parameters = optional-param *("," optional-param)
value-param = positional-param
positional-param = [parameter-mechanism] param-dcl
optional-param = optional-prefix param-dcl [default-value]
param-array = "paramarray" IDENTIFIER "(" ")" ["as" ("variant" / "[variant]")]
param-dcl = untyped-name-param-dcl / typed-name-param-dcl
untyped-name-param-dcl = IDENTIFIER [parameter-type]
typed-name-param-dcl = TYPED-NAME [array-designator]
optional-prefix = ("optional" [parameter-mechanism]) / ([parameter-mechanism] ("optional"))
parameter-mechanism = "byval" / " byref"
parameter-type = [array-designator] "as" (type-expression / "Any")
default-value = "=" constant-expression
event-handler-name = IDENTIFIER
implemented-name = IDENTIFIER
lifecycle-handler-name = "Class_Initialize" / "Class_Terminate"
procedure-body = statement-block
statement-block = *(block-statement EOS)
block-statement = statement-label-definition / rem-statement / statement
statement = control-statement / data-manipulation-statement / error-handling-statement / filestatement
statement-label-definition = LINE-START ((identifier-statement-label ":") / (line-number-label [":"] ))
statement-label = identifier-statement-label / line-number-label
statement-label-list = statement-label ["," statement-label]
identifier-statement-label = IDENTIFIER
line-number-label = INTEGER
rem-statement = "Rem" comment-body
control-statement = if-statement / control-statement-except-multiline-if
control-statement-except-multiline-if = call-statement / while-statement / for-statement / exit-for-statement / do-statement / exit-do-statement / single-line-if-statement / select-case-statement /stop-statement / goto-statement / on-goto-statement / gosub-statement / return-statement / on-gosub-statement /for-each-statement / exit-sub-statement / exit-function-statement / exit-property-statement / raiseevent-statement / with-statement
call-statement = "Call" (simple-name-expression / member-access-expression / index-expression / with-expression)
call-statement =/ (simple-name-expression / member-access-expression / with-expression) argument-list
while-statement = "While" boolean-expression EOS statement-block "Wend"
for-statement = simple-for-statement / explicit-for-statement
simple-for-statement = for-clause EOS statement-block "Next"
explicit-for-statement = for-clause EOS statement-block ("Next" / (nested-for-statement ",")) bound-variable-expression
nested-for-statement = explicit-for-statement / explicit-for-each-statement
for-clause = "For" bound-variable-expression "=" start-value "To" end-value [stepclause]
start-value = expression
end-value = expression
step-clause = Step" step-increment
step-increment = expression
for-each-statement = simple-for-each-statement / explicit-for-each-statement
simple-for-each-statement = for-each-clause EOS statement-block "Next"
explicit-for-each-statement = for-each-clause EOS statement-block ("Next" / (nested-for-statement ",")) bound-variable-expression
for-each-clause = "For" "Each" bound-variable-expression "In" collection
collection = expression
exit-for-statement = "Exit" "For"
do-statement = "Do" [condition-clause] EOS statement-block "Loop" [condition-clause]
condition-clause = while-clause / until-clause
while-clause = "While" boolean-expression
until-clause = "Until" boolean-expression
exit-do-statement = "Exit" "Do"
if-statement = LINE-START "If" boolean-expression "Then" EOL statement-block *[else-if-block] [else-block] LINE-START (("End" "If") / "EndIf")
else-if-block = LINE-START "ElseIf" boolean-expression "Then" EOL LINE-START statement-block
else-if-block =/ "ElseIf" boolean-expression "Then" statement-block
else-block = LINE-START "Else" statement-block
single-line-if-statement = if-with-non-empty-then / if-with-empty-then
if-with-non-empty-then = "If" boolean-expression "Then" list-or-label [single-line-else-clause]
if-with-empty-then = "If" boolean-expression "Then" single-line-else-clause
single-line-else-clause = "Else" [list-or-label]
list-or-label = (statement-label *[":" [same-line-statement]]) / ([":"] same-line-statement *[":" [same-line-statement]])
same-line-statement = file-statement / error-handling-statement / data-manipulation-statement / control-statement-except-multiline-if
select-case-statement = "Select" "Case" WS select-expression EOS *[case-clause] [case-else-clause] "End" "Select"
case-clause = "Case" range-clause ["," range-clause] EOS statement-block
case-else-clause = "Case" "Else" EOS statement-block
range-clause = expression
range-clause =/ start-value "To" end-value
range-clause =/ ["Is"] comparison-operator expression
start-value = expression
end-value = expression
select-expression = expression
comparison-operator = "=" / ("<" ">" ) / (">" "<") / "<" / ">" / (">" "=") / ("=" ">") / ("<" "=") / ("=" "<")
stop-statement = "Stop"
goto-statement = (("Go" "To") / "GoTo") statement-label
on-goto-statement = "On" expression "GoTo" statement-label-list
gosub-statement = (("Go" "Sub") / "GoSub") statement-label
return-statement = "Return"
on-gosub-statement = "On" expression "GoSub" statement-label-list
exit-sub-statement = "Exit" "Sub"
exit-function-statement = "Exit" "Function"
exit-property-statement = "Exit" "Property"
raiseevent-statement = "RaiseEvent" IDENTIFIER ["(" event-argument-list ")"]
event-argument-list = [event-argument *("," event-argument)]
event-argument = expression
with-statement = "With" expression EOS statement-block "End" "With"
Data-manipulation-statement = local-variable-declaration / static-variable-declaration / local-const-declaration / redim-statement / mid-statement /rset-statement / lset-statement / let-statement / set-statement
local-variable-declaration = ("Dim" ["Shared"] variable-declaration-list)
static-variable-declaration = "Static" variable-declaration-list
local-const-declaration = const-declaration
redim-statement = "Redim" ["Preserve"] redim-declaration-list
redim-declaration-list = redim-variable-dcl *("," redim-variable-dcl)
redim-variable-dcl = redim-typed-variable-dcl / redim-untyped-dcl
redim-typed-variable-dcl = TYPED-NAME dynamic-array-dim
redim-untyped-dcl = untyped-name dynamic-array-clause
dynamic-array-dim = "(" dynamic-bounds-list ")"
dynamic-bounds-list = dynamic-dim-spec *[ "," dynamic-dim-spec ]
dynamic-dim-spec = [dynamic-lower-bound] dynamic-upper-bound
dynamic-lower-bound = integer-expression "to"
dynamic-upper-bound = integer-expression
dynamic-array-clause = dynamic-array-dim [as-clause]
erase-statement = "Erase" erase-list
erase-list = erase-element *[ "," erase-element]
erase-element = l-expression
mid-statement = mode-specifier "(" string-argument "," start ["," length] ")" "=" expression
mode-specifier = ("Mid" / "MidB" / "Mid$" / "MidB$")
string-argument = bound-variable-expression
start = integer-expression
length = integer-expression
lset-statement = "LSet" bound-variable-expression "=" expression
rset-statement = "RSet" bound-variable-expression "=" expression
let-statement = ["Let"] l-expression "=" expression
set-statement = "Set" l-expression "=" expression
error-handling-statement = on-error-statement / resume-statement / error-statement
on-error-statement = "On" "Error" error-behavior
error-behavior = ("Resume" "Next") / ("Goto" statement-label)
resume-statement = "Resume" [("Next" / statement-label)]
Error-statement = "Error" error-number
error-number = integer-expression
file-statement = open-statement / close-statement / seek-statement / lock-statement / unlock-statement / line-input-statement / width-statement / write-statement / input-statement / put-statement / get-statement
open-statement = "Open" path-name [mode-clause] [access-clause] [lock] "As" file-number [len-clause]
path-name = expression
mode-clause = "For" mode
mode = "Append" / "Binary" / "Input" / "Output" / "Random"
access-clause = "Access" access
access = "Read" / "Write" / ("Read" "Write")
lock = "Shared" / ("Lock" "Read") / ("Lock" "Write") / ("Lock" "Read" "Write")
len-clause = "Len" "=" rec-length
rec-length = expression
file-number = marked-file-number / unmarked-file-number
marked-file-number = "#" expression
unmarked-file-number = expression
close-statement = "Reset" / ("Close" [file-number-list])
file-number-list = file-number *[ "," file-number]
seek-statement = "Seek" file-number "," position
position = expression
lock-statement = "Lock" file-number [ "," record-range]
record-range = start-record-number / ([start-record-number] "To" end-record-number)
start-record-number = expression
end-record-number = expression
unlock-statement = "Unlock" file-number [ "," record-range]
line-input-statement = "Line" "Input" marked-file-number "," variable-name
variable-name = variable-expression
width-statement = "Width" marked-file-number "," line-width
line-width = expression
print-statement = "Print" marked-file-number "," [output-list]
output-list = *output-item
output-item = [output-clause] [char-position]
output-clause = (spc-clause / tab-clause / output-expression)
char-position = ( ";" / ",")
output-expression = expression
spc-clause = "Spc" "(" spc-number ")"
spc-number = expression
tab-clause = "Tab" [tab-number-clause]
tab-number-clause = "(" tab-number ")"
tab-number = expression
write-statement = "Write" marked-file-number "," [output-list]
input-statement = "Input" marked-file-number "," input-list
input-list = input-variable *[ "," input-variable]
input-variable = bound-variable-expression
put-statement = "Put" file-number ","[record-number] "," data
record-number = expression
data = expression
get-statement = "Get" file-number "," [record-number] "," variable
variable = variable-expression
numeric-coercion-string = [WS] [sign [WS]] regionalnumber-string [exponentclause] [WS]
exponent-clause = ["e" / "d"] [sign] integer-literal
sign = "+" / "-"
regional-number-string = <unsigned number or currency value interpreted according to the active host-defined regional settings>
expression = value-expression / l-expression
value-expression = literal-expression / parenthesized-expression / typeof-is-expression / new-expression / operator-expression
l-expression = simple-name-expression / instance-expression / member-access-expression / index-expression / dictionary-access-expression / with-expression
literal-expression = INTEGER / FLOAT / DATE / STRING / (literal-identifier [type-suffix])
parenthesized-expression = "(" expression ")"
typeof-is-expression = "typeof" expression "is" type-expression
new-expression = "New" type-expression
operator-expression = arithmetic-operator / concatenation-operator / relational-operator / like-operator / is-operator / logical-operator
arithmetic-operator = unary-minus-operator / addition-operator / subtraction-operator / multiplication-operator / division-operator / integer-division-operator / modulo-operator / exponentiation-operator
unary-minus-operator = "-" expression
addition-operator = expression "+" expression
subtraction-operator = expression "-" expression
multiplication-operator = expression "*" expression
division-operator = expression "/" expression
integer-division-operator = expression "\" expression
modulo-operator = expression "mod" expression
exponentiation-operator = expression "^" expression
concatenation-operator = expression "&" expression
relational-operator = equality-operator / inequality-operator / less-than-operator / greaterthan-operator / less-than-equal-operator / greater-than-equal-operator
equality-operator = expression "=" expression
inequality-operator = expression ( "<"">" / ">""<" ) expression
less-than-operator = expression "<" expression
greater-than-operator = expression ">" expression
less-than-equal-operator = expression ( "<""=" / "=""<" ) expression
greater-than-equal-operator = expression ( ">""=" / "="">" ) expression
like-operator = expression "like" like-pattern-expression
like-pattern-expression = expression
like-pattern-string = *like-pattern-element
like-pattern-element = like-pattern-char / "?" / "#" / "*" / like-pattern-charlist
like-pattern-char = <Any character except "?", "#", "*" and "[" >
like-pattern-charlist = "[" ["!"] ["-"] *like-pattern-charlist-element ["-"] "]"
like-pattern-charlist-element = like-pattern-charlist-char / like-pattern-charlist-range
like-pattern-charlist-range = like-pattern-charlist-char "-" like-pattern-charlist-char
like-pattern-charlist-char = <Any character except "-" and "]">
is-operator = expression "is" expression
logical-operator = not-operator / and-operator / or-operator / xor-operator / impoperator / eqv-operator
not-operator = "not" expression
and-operator = expression "and" expression
or-operator = expression "or" expression
xor-operator = expression "xor" expression
eqv-operator = expression "eqv" expression
imp-operator = expression "imp" expression
simple-name-expression = name
instance-expression = "me"
member-access-expression = l-expression NO-WS "." unrestricted-name
member-access-expression =/ l-expression LINE-CONTINUATION "." unrestricted-name
index-expression = l-expression "(" argument-list ")"
argument-list = [positional-or-named-argument-list]
positional-or-named-argument-list = *(positional-argument ",") required-positional-argument
positional-or-named-argument-list =/ *(positional-argument ",") named-argument-list
positional-argument = [argument-expression]
required-positional-argument = argument-expression
named-argument-list = named-argument *("," named-argument)
named-argument = unrestricted-name ":""=" argument-expression
argument-expression = ["byval"] expression
argument-expression =/ addressof-expression
dictionary-access-expression = l-expression NO-WS "!" NO-WS unrestricted-name
dictionary-access-expression =/ l-expression LINE-CONTINUATION "!" NO-WS unrestricted-name
dictionary-access-expression =/ l-expression LINE-CONTINUATION "!" LINE-CONTINUATION unrestricted-name
with-expression = with-member-access-expression / with-dictionary-access-expression
with-member-access-expression = "." unrestricted-name
with-dictionary-access-expression = "!" unrestricted-name
constant-expression = expression
cc-expression = expression
boolean-expression = expression
integer-expression = expression
variable-expression = l-expression
bound-variable-expression = l-expression
type-expression = BUILTIN-TYPE / defined-type-expression
defined-type-expression = simple-name-expression / member-access-expression
addressof-expression = "addressof" procedure-pointer-expression
procedure-pointer-expression = simple-name-expression / member-access-expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.