FreeBASIC Grammar

This page is under construction

The text on this page appearing below is not the complete FreeBASIC grammar. This page is an experimentation page to figure out what wakka lay - out works out best when publishing a grammar.

The grammar as it will evolve on this page will consist of rules that consist of a left hand side and a right hand side separated by ::= .
The grammar consists of (at least) three parts. The parts differ in what part of the FreeBASIC grammar is described and how the rhs of a rule should be interpreted.

First there is the preprocessor grammar.
Secondly there is the context free grammar. All the rules from the context free grammar together describe the context free part of the FreeBASIC grammar.
Any word appearing on the rhs of a rule in UPPERCASE refers to a rule in the lexical grammar. If the color of the text is BLACK then it is not optional (it MUST appear in source code). If the color of the text is grey then the use of the word is optional.
Any word appearing on the rhs of a rule in lowercase refers to a rule in the context free grammar. Optionality of a word in lowercase uses the same color scheme as that used for words in UPPERCASE (eg BLACK = must appear, grey = can appear).

The third and final part of the grammar is the lexical grammar. The lexical grammar is described using a parsing expression grammar. Whitespace used in the parsing expression grammmar is insignificant. An example of a rule to clarify.

DECLARE ::= D E C L A R E !id_char

The spaces between the individual characters on the rhs (eg D E C L A R E) are only there for readability purposes. The keyword D E C L A R E (with spaces between the individual characters) is not a FreeBASIC keyword (whereas DECLARE is).

Rules for optionality used in the lexical grammar are the same as those for the context free grammar (eg black = has to appear in code, grey = may appear in code).
Words in both UPPERCASE and lowercase refer to rules in the lexical grammar.
Words in lowercase refer to a rule with a rhs consisting of a pattern that goes beyond a single characterclass (eg [a-zA-Z] or [0-9b-v]), a single character or a string.
Words in UPPERCASE refer to a rule with a rhs consisting of a single characterclass (eg [A-Z] or [a-z] or [0-9] etc...), a single character or a string.

Whitespace between characters is insignificant in the lexical grammar. Spacing appearing on the rhs of a rule does not mean that the spacing should be matched in source code.


#context free grammar
function-declaration ::= DECLARE FUNCTION procedure-specifiers parameter-list AS type-name

procedure-specifiers ::= to-be-done
parameter-list ::= to-be-done
type-name ::= to-be-done

#lexical grammar
DECLARE  ::=  D E C L A R E !id-char
FUNCTION ::= F U N C T I O N !id-char
AS ::= A S !id-char
VIRTUAL  ::=   V I R T U A L !id-char

A  ::= [Aa]
B  ::= [Bb]
C  ::= [Cc]
D  ::= [Dd]
E  ::= [Ee]
F  ::= [Ff]
G  ::= [Gg]
H  ::= [Hh]
I  ::= [Ii]
J  ::= [Jj]
K  ::= [Kk]
L  ::= [Ll]
M  ::= [Mm]
N  ::= [Nn]
O  ::= [Oo]
P  ::= [Pp]
Q  ::= [Qq]
R  ::= [Rr]
S  ::= [Ss]
T  ::= [Tt]
U  ::= [Uu]
V  ::= [Vv]
W  ::= [Ww]
X  ::= [Xx]
Y  ::= [Yy]
Z  ::= [Zz]

virtual
id-char ::= [A-Z0-9_]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode