Syntax

Top  Next

 

Below is the correct syntax for programming with the script language.

 

SCRIPT = BLOCKLIST

 

BLOCKLIST =[ BLOCK { ";" BLOCK } [";"] ]

 

BLOCK =        "begin" BLOCKLIST "end" |

 INSTR

 

INSTR =        

 "if" EXPR "then" BLOCK |

 "if" EXPR "then" BLOCK "else" BLOCK |

 "for" VAR ":=" EXPR "to" EXPR "do" BLOCK |

 "for" VAR ":=" EXPR "down to" EXPR "do" BLOCK |

 "while" EXPR "do" BLOCK |

 "repeat" BLOCKLIST "until" EXPR |

 VAR ":=" EXPR |

 FUNC |

 CONSTDECL

 

CONSTDECL ="const" "=" CONST ";"

 

FUNC =NAME [ "(" [EXPR {, EXPR}] ")" ]

 

EXPR =EXPRADD [ "=" EXPRADD]

 

EXPRADD = EXPRMUL [ "+" | "-" | "or" ]EXPRADD

 

EXPRMUL = TERM [ "*" | "/" | "and" | "mod" | "div"] EXPRMUL

 

TERM =        

 "+" TERM |

 "-" TERM |

 "not" TERM |

 CONST |

 VAR |

 FUNC |

 "(" EXPR ")"

         

CONST =        

 INT |

 HEXINT |

 FLOAT |

 STRING |

 CHAR |

 "True" |

 "False"

 

VAR=        NAME |

 NAME "[" INT "]"

 

NAME = LIT {LIT | "0".."9" | "_"}

                                                   

LIT ="A".."Z", "a".."z"

 

STRING = CHAR |" ' " {STRINGCHAR} " ' " [ STRING ]

 

STRINGCHAR =ASCII(0)..ASCII(255) - " ' " - ASCII(13) | " '' "

 

CHAR ="#" INT | "#" HEXINT

 

HEXINT =        "$" HEXNUM {HEXNUM}

 

HEXNUM = NUM | "A".."F" | "a".."f"

 

FLOAT =        INT [ "." INT ] [ "e" | "E" [ "+" "-" ] INT ]

 

INT =        NUM {NUM}

 

NUM =        "0".."9"

 

The error can be manage by exception. When an error during processing occurs, an exception is shown. The exception is a object having error information.

The exceptions are managed by try...Except as show following

try
 Code
Except
 Exception
End;