Pragmatic BNF-a-like parser: Parse language source with a BNF grammar syntax

Recommend this page to a friend!
  Info   View files (10)   Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 547 All time: 5,447 This week: 286
Version License PHP version Categories
pragmatic-parser 0.3GNU General Publi...5.3PHP 5, Text processing, Parsers
Description Author

This package can parse source code in a given language based on the language syntax defined in the BNF format (Backus-Naur Form).

It takes a grammar with syntax rules defined in BNF format and parses the syntax to build a XML parse tree.

The main class also takes as parameter a reference to a lexer object that splits the source code text in tokens.

A SQL parser and a RTF parser are provided as examples.

Innovation Award
PHP Programming Innovation award nominee
October 2011
Number 4

Prize: One book of choice by Packt
BNF (Backus-Naur Form) defines a syntax for representing the grammar of the commands of a given programming language.

This implements a parser to process a language grammar in the BNF format, so it can be used to implement parsers and compilers for that language.

Manuel Lemos
Picture of Richard Keizer
  Performance   Level  
Name: Richard Keizer <contact>
Classes: 7 packages by
Country: The Netherlands The Netherlands
Age: 45
All time rank: 48414 in The Netherlands The Netherlands
Week rank: 762 19 in The Netherlands The Netherlands
Innovation award
Innovation award
Nominee: 5x

Winner: 1x

File Role Description
RTF (3 files)
SQL (2 files)
example_rtf.php Example usage example
example_sql.php Example usage example
howto_grammar.txt Doc. grammar basics explained
howto_lexer.txt Doc. lexer basics explained
parser.class.php Class main class(es)

  Files  /  RTF  
File Role Description
   rtf.grammar.txt Data simplified rtf grammar
   RTFLexer.class.php Class rtf lexer
   simple.rtf Data rtf file

  Files  /  SQL  
File Role Description
   sql.grammar.txt Data sql grammar
   SQLLexer.class.php Class sql lexer

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:5,447
This week:286
User Comments (1)
more docs/examples please!
8 years ago (Colin McKinnon)

For more information send a message to info at phpclasses dot org.