Login   Register  
PHP Classes
elePHPant
Icontem

File: example_rtf.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Richard Keizer  >  Pragmatic BNF-a-like parser  >  example_rtf.php  >  Download  
File: example_rtf.php
Role: Example script
Content type: text/plain
Description: usage example
Class: Pragmatic BNF-a-like parser
Parse language source with a BNF grammar syntax
Author: By
Last change: usage example of a rtf parser
Date: 3 years ago
Size: 1,518 bytes
 

Contents

Class file image Download
<?php
  
/**------------------------------------------------------------------------------
   * Title:        Usage example of the Pragmatic BNF-a-like parser
   * Filename:     example_rtf.php
   * Version:      0.2
   * Author:       Richard Keizer
   * Email:        ra dot keizer at gmail dot com
   *-------------------------------------------------------------------------------
   * COPYRIGHT (c) 2011 Richard Keizer
   *
   * The source code included in this package is free software; you can
   * redistribute it and/or modify it under the terms of the GNU General Public
   * License as published by the Free Software Foundation. This license can be
   * read at:
   *
   * http://www.opensource.org/licenses/gpl-license.php
   *
   * This program is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   *------------------------------------------------------------------------------
   *
   *
   */
  
  
error_reporting(E_ALL);
  
ini_set('display_errors'1);
  
  
  include_once 
'parser.class.php';
  include_once 
'RTF/RTFLexer.class.php';
  
  
$parser = new Parser(
                       new 
Grammar(file_get_contents('RTF/rtf.grammar.txt')),
                       new 
RTFLexer(file_get_contents('RTF/simple.rtf'))
                       );
  echo 
$parser->createParsetree()->saveXML();