menu
  Home  ==>  papers  ==>  compilers  ==>  pl0_grammar   

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
    Name :
    E-mail :
    Comments * :
     

  • 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.
Created: nov-04. Last updated: jul-15 - 98 articles, 131 .ZIP sources, 1012 figures
Copyright © Felix J. Colibri   http://www.felix-colibri.com 2004 - 2015. All rigths reserved
Back:    Home  Papers  Training  Delphi developments  Links  Download
the Pascal Institute

Felix J COLIBRI

+ Home
  + articles_with_sources
    + database
    + web_internet_sockets
    + oop_components
    + uml_design_patterns
    + debug_and_test
    + graphic
    + controls
    + colibri_utilities
    + colibri_helpers
    + delphi
    + firemonkey
    + compilers
      – pl0_grammar
      – pascal_s_grammar
      – pascal_grammar
      – delphi_5_grammar
  + delphi_training
  + delphi_developments
  + sweet_home
  – download_zip_sources
  + links
Contacts
Site Map
– search :

RSS feed  
Blog