• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

syntax_highlight/php/Beautifier/Context.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 */
00020 
00021 class Context
00022 {
00023         function Context()
00024         {
00025         }
00026         
00027         function from_language($lang, $output)
00028         {
00029                 // Current indent level.
00030                 $this->ind              = 0;
00031                 $this->inquote          = 0;
00032                 $this->incomment        = 0;
00033                 $this->inbcomment       = 0;
00034                 $this->inwhitespace     = 1;
00035                 // Used to ensure quote matching works :-)
00036                 $this->currquotechar    = "";
00037                 $this->begseen          = 0;    
00038                 $this->newline          = 0;
00039                 $this->escaping         = 0;
00040                 // In a line select?
00041                 $this->lineselect       = 0;
00042                 $this->closingstrings   = array();
00043         
00044                 // Used by $this->munge for keyword checking - we only want to make this once.
00045                 $this->validkeys = array();
00046         
00047                 foreach(array_keys($lang->keywords) as $key)
00048                 {
00049                         if ($lang->nocase) 
00050                                 $this->validkeys[strtolower($key)] = $key;
00051                         else 
00052                                 $this->validkeys[$key] = $key;
00053                 }
00054                 $this->alldelims = array_merge($lang->delimiters, $lang->stringchars);
00055         
00056                 // Additional caching: First we want to store the strlens of the comments.
00057                 $this->lcolengths = array();
00058                 foreach($lang->linecommenton as $lco)
00059                 {
00060                         $this->lcolengths[$lco] = strlen($lco);
00061                 }
00062                 foreach($lang->blockcommenton as $bco)
00063                 {
00064                         $this->bcolengths[$bco] = strlen($bco);
00065                 }
00066                 foreach($lang->blockcommentoff as $bcf)
00067                 {
00068                         $this->bcflengths[$bcf] = strlen($bcf);
00069                 }
00070         
00071                 // Build up match arrays for bcos.
00072                 $this->bcomatches = array();
00073                 $this->startingbkonchars = array();
00074                 for($i=0; $i<sizeof($lang->blockcommenton); $i++)
00075                 {
00076                         $bco = $lang->blockcommenton[$i];
00077                         if (!isset($this->bcomatches[$bco])) $this->bcomatches[$bco] = array();
00078                         array_push($this->bcomatches[$bco], $lang->blockcommentoff[$i]);
00079                         array_push($this->startingbkonchars, $bco[0]);
00080                 
00081                 }
00082                 
00083                 
00084                 $preprolength = 0;
00085                 $this->prepro = 0;
00086                 if (isset($lang->prepro)) $this->preprolength = strlen($lang->prepro);
00087                 
00088                 // Output module handling
00089                         
00090                 $this->code_parts = explode("_WORD_", $output->code);
00091                 $this->linecomment_parts = explode("_WORD_", $output->linecomment);
00092                 $this->blockcomment_parts = explode("_WORD_", $output->blockcomment);
00093                 $this->prepro_parts = explode("_WORD_", $output->prepro);
00094                 $this->select_parts = explode("_WORD_", $output->select);
00095                 $this->quote_parts = explode("_WORD_", $output->quote);
00096                 $currcat = 1;
00097                 do
00098                 {
00099                         $varname = "category_".$currcat;
00100                         if (isset($output->{$varname}))
00101                         {
00102                                 $this->category_parts[$currcat] = explode("_WORD_", $output->{$varname});
00103                         } 
00104                         $currcat++;
00105                 } while (isset($output->{$varname}));
00106         }
00107 }
00108 ?>

Generated on Fri Dec 13 2013 09:06:39 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1