Syntax of HBasic language

This document should give you a description of the currently implemented HBasic language in a style similar to BNF (Backus Nauer Form). This is a short syntax notation that may not be helpfull for everybody. I therefore try to add some text in between to explain parts of the syntax.

Links to example programs will be marked with the following icon . You will normally find the source_code for the examples in the code_examples folder of the HBasic distribution.


HBasic program

In every HBasic project there is only one BASIC program. The sourcecode of the program may be distributed to different global modules and source code parts connected to form definitions but all of this source code sections will be treated by the parser as one big program. The program is simply a list of statements which will be explained below.

<HBasic-program> ::= <Statement-list>

<Statement-list> ::= { <Statement> }

<Statement> ::=
    <Dim-statement> |
    <Assign-statement> |
    <Structure-definition> |
    <Control-statement> |
    <Subroutine-declaration> |
    <Subroutine-call> |
    <Class-declaration> |
    <Exit-statement> |
    <Raise-statement> |
    <Try-statement> |
    <Component-access> |
    <Class-access> |
    <Return-statement>

Statement types
Dim statement
Used to define variable names and types
Assign statement
Assign values to variables
Structure definition
Declare user defined structures
Control statement
Statements that control the program flow
Subroutine declaration
Declare subroutines
Subroutine call
Call a subroutine with parameters
Class declaration
Declare classes for object oriented programming
Exit statement
Abort program execution
Raise statement
Raise event (may only be used within class bodies)
Try statement
Execute code section and catch runtime errors if they occure
Component access
Access components that have been loaded with packages or Qt-C support
Class access
Access the substructures of your class definitions
Return statement
Return value for class properties

Additional contents:

The following sections are important to understand the HBasic language but cannot be handled in the simple syntax description. They will be listed as references to special docu sections here.