|
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".
2 - The grammar 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, broken links 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 blog or 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. Starting with Pascal in 1979, he then became involved with Object Oriented Programming, Delphi, Sql, Tcp/Ip, Html, UML. Currently, he is mainly
active in the area of custom software development (new projects, maintenance, audits, BDE migration, Delphi
Xe_n migrations, refactoring), Delphi Consulting and Delph
training. His web site features tutorials, technical papers about programming with full downloadable source code, and the description and calendar of forthcoming Delphi, FireBird, Tcp/IP, Web Services, OOP / UML, Design Patterns, Unit Testing training sessions. |
|