Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Basic Elements
Divider

QDL programs are made up of a series of these three basic syntax elements:

Comments

Everything after a comment is initiated is completely ignored by the compiler, except the character(s) that mark the end of the comment. Comments cannot be nested. There are two kinds of comments:

Comments may be found within other syntax elements (statements and blocks), with the exception of string literals.

Examples:

// This is a single-line comment
/* This is a free-form comment.  It starts with /* and
   doesn't end until the following characters are reached: */

Blocks

A block is a series of statements delimited by either:

Except for certain restrictions that vary according to the purpose of the block, blocks can be nested to arbitrary depths.

The following example is of a block that contains one sub-statement and one (empty) sub-block:

If True Then {	                  // { marks the beginning of the block
	StdOut.Print "Hello";     // This is a statement inside the block
	While False Do {  }            // Blocks can be nested.
}                                      // This is the end of the block.

A block is always part of a statement, known as a complex statement; that statement is never terminated before the block ends.

Note: Unlike C/C++, QDL does not support anonymous blocks. You can't simply start a block out of the blue in a function, like you can in C.

Some segments of code delimited by { and } are not called blocks, but rather pseudo-blocks, because they do not contain other statements. The contents of pseudo-blocks are part of the enclosing statement and have special syntax specific to that statement; statements that use pseudo-blocks are not classified as complex statements. The statements that use pseudo-blocks are:

C programmers will demand to know why there are two different syntaxes for making blocks.  There is just one reason, and it has to do with code scanners.  It is important that a good programmer's editor be able to parse code as it is typed, and be able to know the structure of the entire program, regardless of whether the code is in a compilable state or not.  The problem with using a single brace type is that there is practically no way for an editor to know what a closing brace is supposed to be ending, when the braces do not match up (especially considering some programmers' disgusting indentation practices!)  As the programmer puts in a new opening brace for some statement, the meaning of all the closing braces that follow changes instantly.  As long as the brace ratio (opening:closing) is not 1:1, the scanner will have a hard time knowing what the program was supposed to mean.  The code scanner either has to be very complex or burn lots of cycles trying to figure out what the code means.  Since the programmer is constantly typing opening braces and closing braces, the code scanner must constantly reevaluate the code.

I realize that VC++ 6.0 has worked around these problems (albeit with some small bugs).  However, neither I nor ACD has a million bucks with which to make a feeble attempt to do the same with QDL.  The fact that we had to wait for version 6.0 to come along to get these features is a clue that they weren't very easy to do.

In QDL, three important types of complex statements use the End-terminated block: Functions (which includes Casts and Operators), Classes, and Implement. By using this kind of block for these statements, mismatched braces in functions cease to be a problem.  The end-spec marks the end of the Function, Class or Implement statement no matter what. The mismatched brace problem is then localized to the Class, Function or Implement statement in which it occurs.

The End part of the statement has the following syntax:

end-spec: End [end-what];
end-what: Class | Implement | Function | Cast | Operator

end-what specifies what statement type is ending, with the following allowances:

Statements

There are two basic categories of language constructs referred to as statements in QDL.

Non-complex statements can be subcategorized into two types:

Complex statements can be categorized by the type of block they contain:

QDL supports several preprocessor statements from C.  These preprocessor statements do not fit into the categories listed above, but do have equivalent QDL-style statements that do map to the categories above.

Some statements can be either primitive or complex depending on their usage.

Note that, in some cases, a semicolon or colon does not mark the end of the statement or (in the case of the colon) the beginning of a block.  An individual statement may have a syntax that specifies the use of : or ; for another purpose; the For loop is an example.  Ultimately the For statement does end with a semicolon or block, but there can be an intermediate colon used in specifying a label, and two intermediate semicolons that mark the end of the first two clauses. 

Some statements are executable, and some are not.

Examples:

#define NUMBERTEN 10
X: Integer(3);
Uses "filename";
If X == 3 Then 
	StdOut.Print "It's 3!\n";
Else {
	StdOut.Print "Fatal Error: It's Not 3!\n";
	Return;
}

The last example is considered, as a whole, to be just one statement, yet it contains three other sub-statements, two of which are in one sub-block.

Table of Contents Qwertie's Site/Mirror
Next
Previous