|
|
|
Pl0 Grammar - Felix John COLIBRI.
|
- abstract : the Pl0 ebnf grammar
- key words : ebnf, iebnf, compiler, pascal
- software used : Windows XP, Delphi 6
- hardware used : Pentium 1.400Mhz, 256 M memory, 140 G hard disc
- scope : Delphi 1 to 8 for Windows, Kylix
- level : Delphi developer
- plan :
1 - Introduction
We simply provide here the pl0 language grammar. This was a small language that
Niklaus WIRTH used for buiding the compiler and interpreter example in his book
"Algorithm+ Data Structure= Programming".
Here is the grammar:
program = block '.' .
block = { declaration } statement .
declaration = constant | variable | function .
constant = CONST constant_definition { ',' constant_definition } ';' .
constant_definition = NAME '=' NUMBER .
variable = VAR NAME { ',' NAME } ';' .
function = FUNCTION NAME '(' [ NAME { ',' NAME } ] ')' block ';' .
expression = [ ( '-' | '+' ) ] term { ( '-' | '+' ) term } .
term = factor { ( '*' | '/' ) factor } .
factor = NAME '(' [ expression { ',' expression } ] ')'
| NUMBER | NAME | '(' expression ')' .
statement = [ NAME ':=' expression
| BEGIN statement { ';' statement } END
| IF condition THEN statement
| WHILE condition DO statement
| RETURN expression
| WRITE expression ] .
condition = ODD expression
| expression ( '=' | '<>' | '<' | '<=' | '>' | '>=' ) expression .
|
3 - Comments
As usual:
- please tell us at fcolibri@felix-colibri.com if you found some errors, mistakes, bugs or had
some problem downloading the file. Resulting corrections will be helpful
for other readers
- we welcome any comment, criticism, enhancement, other sources or reference
suggestion. Just send an e-mail to fcolibri@felix-colibri.com.
- or more simply, enter your (anonymous or with your e-mail if you want an
answer) comments below and clic the "send" button
- and if you liked this article, talk about this site to your fellow
developpers, add a link to your links page ou mention our articles in
your newsgroup posts when relevant. That's the way we operate: the more
traffic and Google references we get, the more articles we will write.
4 - The author
Felix John COLIBRI works at the Pascal
Institute. He programs in Pascal since 1979, and is mainly active in the area
of custom software
development and training, and is a frequent speaker at Borland
Developer Conferences. His web site features
tutorials, technical papers about programming with full downloadable source
code, and the description and calendar of forthcoming Delphi,
Interbase, Asp.Net, Ado.Net and OOP / UML training sessions.
|
|