Program -> Statements
Statements -> (EOL | StatementList EOL)...
StatementList -> Statement/':'...
ImportStmt -> IMPORTS (String/,)...
DimStmt -> DIM (VarDecl/',')...
VarDecl -> Ident [Array] [AsClause] [InitValue]
AsClause -> AS Ident
Array -> '[' ArrayDim/','... ']'
ArrayDim -> Expression
InitValue -> '=' Expression
Expression -> SimpleExpression [RelOp SimpleExpression]...
SimpleExpression -> ['-'] Term [AddOp Term]...
Term -> Factor [MulOp Factor]...
Factor -> Designator -> UnsignedNumber -> String -> '(' Expression ')' -> NOT Factor -> NewOperator -> '<' FRString '>'
SetConstructor -> SetNode/','...
SetNode -> Expression ['..' Expression]
NewOperator -> NEW Designator
RelOp -> '>' -> '<' -> '<=' -> '>=' -> '<>' -> '=' -> IN -> IS
AddOp -> '+' -> '-' -> '&' -> OR -> XOR
MulOp -> '*' -> '/' -> '\' -> MOD -> AND
Designator -> [ADDRESSOF] Ident ['.' Ident | '[' ExprList ']' | '(' [ExprList] ')']...
ExprList -> Expression/','...
Statement -> BreakStmt -> CaseStmt -> ContinueStmt -> DeleteStmt -> DimStmt -> DoStmt -> ExitStmt -> ForStmt -> FuncStmt -> IfStmt -> ImportStmt -> ProcStmt -> ReturnStmt -> SetStmt -> TryStmt -> WhileStmt -> WithStmt -> AssignStmt -> CallStmt
BreakStmt -> BREAK
ContinueStmt -> CONTINUE
ExitStmt -> EXIT
DeleteStmt -> DELETE Designator
SetStmt -> SET AssignStmt
AssignStmt -> Designator ['+'|'-'|'*'|'/']'=' Expression
CallStmt -> Designator ['+''+'|'-''-']
ReturnStmt -> RETURN [Expression]
IfStmt -> IF Expression THEN ThenStmt
ThenStmt -> EOL [Statements] [ElseIfStmt | ElseStmt] END IF -> StatementList
ElseIfStmt -> ELSEIF Expression THEN (EOL [Statements] [ElseIfStmt | ElseStmt] | Statement)
ElseStmt -> ELSE (EOL [Statements] | Statement)
CaseStmt -> SELECT CASE Expression EOL (CaseSelector...) [CASE ELSE ':' Statements] END SELECT
CaseSelector -> CASE SetConstructor ':' Statements
DoStmt -> DO [Statements] LOOP (UNTIL | WHILE) Expression
WhileStmt -> WHILE Expression [Statements] WEND
ForStmt -> FOR Ident '=' Expression TO Expression [STEP Expression] EOL [Statements] NEXT
TryStmt -> TRY Statements (FINALLY | CATCH) [Statements] END TRY
WithStmt -> WITH Designator EOL Statements END WITH
ProcStmt -> SUB Ident [FormalParameters] EOL [Statements] END SUB
FuncStmt -> FUNCTION Ident [FormalParameters] [AsClause] EOL [Statements] END FUNCTION
FormalParameters -> '(' (FormalParam/',')... ')'
FormalParm -> [BYREF | BYVAL] VarList |
#language BasicScript // this is optional imports "unit1.vb", "unit2.vb" // imports section - must be before any other sections
dim i, j = 0 // var section
function f1() // procedures and function end function //
sub p1() end sub // main procedure that will be executed. for i = 0 to 10 p1() next |
BasicScript may have types (for example, dim i as Integer), or may have no types and even no variable declaration. In this case a variable will have Variant type. Note: Not all of these types can be assign-compatible. Like in Object Pascal, you can't assign Extended or String to an Integer. Only one type - the Variant - can be assigned to all the types and can get value from any type. |