PascalScript syntax

Program -> [PROGRAM Ident ';']
           [UsesClause]        
           Block '.'           

UsesClause -> USES (String/,)... ';' 

Block -> [DeclSection]...   
         CompoundStmt       

DeclSection -> ConstSection         
            -> VarSection           
            -> ProcedureDeclSection 

ConstSection -> CONST (ConstantDecl)... 

ConstantDecl -> Ident '=' Expression ';' 

VarSection -> VAR (VarList ';')...

VarList -> Ident/','... ':' TypeIdent [InitValue] 

TypeIdent -> Ident  
          -> Array  

Array -> ARRAY '[' ArrayDim/','... ']' OF Ident  

ArrayDim -> Expression..Expression  
         -> Expression              

InitValue -> '=' Expression  

Expression -> SimpleExpression [RelOp SimpleExpression]...

SimpleExpression -> ['-'] Term [AddOp Term]... 

Term -> Factor [MulOp Factor]...

Factor -> Designator                     
       -> UnsignedNumber                 
       -> String                         
       -> '(' Expression ')'             
       -> NOT Factor                     
       -> '[' SetConstructor ']'         

SetConstructor -> SetNode/','...  

SetNode -> Expression ['..' Expression]  

RelOp -> '>'   
      -> '<'   
      -> '<='  
      -> '>='  
      -> '<>'  
      -> '='   
      -> IN    
      -> IS    

AddOp -> '+'  
      -> '-'  
      -> OR   
      -> XOR  

MulOp -> '*'
      -> '/'    
      -> DIV    
      -> MOD    
      -> AND
      -> SHL    
      -> SHR    

Designator -> ['@'] Ident ['.' Ident | '[' ExprList ']' | '(' ExprList ')']...  

ExprList -> Expression/','...  

Statement -> [SimpleStatement | StructStmt]  

StmtList -> Statement/';'...  

SimpleStatement -> Designator                     
                -> Designator ':=' Expression     
                -> BREAK | CONTINUE | EXIT        

StructStmt -> CompoundStmt        
           -> ConditionalStmt     
           -> LoopStmt            
           -> TryStmt             
           -> WithStmt            

CompoundStmt -> BEGIN StmtList END   

ConditionalStmt -> IfStmt     
                -> CaseStmt   

IfStmt -> IF Expression THEN Statement [ELSE Statement]

CaseStmt -> CASE Expression OF CaseSelector/';'... [ELSE Statement] [';'] END  

CaseSelector -> SetConstructor ':' Statement

LoopStmt -> RepeatStmt  
         -> WhileStmt   
         -> ForStmt     

RepeatStmt -> REPEAT StmtList UNTIL Expression  

WhileStmt -> WHILE Expression DO Statement  

ForStmt -> FOR Ident ':=' Expression ToDownto Expression DO Statement  

ToDownto -> (TO | DOWNTO)  

TryStmt -> TRY StmtList (FINALLY | EXCEPT) StmtList END  

WithStmt -> WITH (Designator/,..) DO Statement  

ProcedureDeclSection -> ProcedureDecl  
                     -> FunctionDecl   

ProcedureDecl -> ProcedureHeading ';'  
                 Block ';'             

ProcedureHeading -> PROCEDURE Ident [FormalParameters]  

FunctionDecl -> FunctionHeading ';'  
                Block ';'

FunctionHeading -> FUNCTION Ident [FormalParameters] ':' Ident

FormalParameters -> '(' FormalParam/';'... ')'

FormalParm -> [VAR | CONST] VarList