ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
Context.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 
19 */
20 
21 class Context
22 {
23  function Context()
24  {
25  }
26 
27  function from_language($lang, $output)
28  {
29  // Current indent level.
30  $this->ind = 0;
31  $this->inquote = 0;
32  $this->incomment = 0;
33  $this->inbcomment = 0;
34  $this->inwhitespace = 1;
35  // Used to ensure quote matching works :-)
36  $this->currquotechar = "";
37  $this->begseen = 0;
38  $this->newline = 0;
39  $this->escaping = 0;
40  // In a line select?
41  $this->lineselect = 0;
42  $this->closingstrings = array();
43 
44  // Used by $this->munge for keyword checking - we only want to make this once.
45  $this->validkeys = array();
46 
47  foreach(array_keys($lang->keywords) as $key)
48  {
49  if ($lang->nocase)
50  $this->validkeys[strtolower($key)] = $key;
51  else
52  $this->validkeys[$key] = $key;
53  }
54  $this->alldelims = array_merge($lang->delimiters, $lang->stringchars);
55 
56  // Additional caching: First we want to store the strlens of the comments.
57  $this->lcolengths = array();
58  foreach($lang->linecommenton as $lco)
59  {
60  $this->lcolengths[$lco] = strlen($lco);
61  }
62  foreach($lang->blockcommenton as $bco)
63  {
64  $this->bcolengths[$bco] = strlen($bco);
65  }
66  foreach($lang->blockcommentoff as $bcf)
67  {
68  $this->bcflengths[$bcf] = strlen($bcf);
69  }
70 
71  // Build up match arrays for bcos.
72  $this->bcomatches = array();
73  $this->startingbkonchars = array();
74  for($i=0; $i<sizeof($lang->blockcommenton); $i++)
75  {
76  $bco = $lang->blockcommenton[$i];
77  if (!isset($this->bcomatches[$bco])) $this->bcomatches[$bco] = array();
78  array_push($this->bcomatches[$bco], $lang->blockcommentoff[$i]);
79  array_push($this->startingbkonchars, $bco[0]);
80 
81  }
82 
83 
84  $preprolength = 0;
85  $this->prepro = 0;
86  if (isset($lang->prepro)) $this->preprolength = strlen($lang->prepro);
87 
88  // Output module handling
89 
90  $this->code_parts = explode("_WORD_", $output->code);
91  $this->linecomment_parts = explode("_WORD_", $output->linecomment);
92  $this->blockcomment_parts = explode("_WORD_", $output->blockcomment);
93  $this->prepro_parts = explode("_WORD_", $output->prepro);
94  $this->select_parts = explode("_WORD_", $output->select);
95  $this->quote_parts = explode("_WORD_", $output->quote);
96  $currcat = 1;
97  do
98  {
99  $varname = "category_".$currcat;
100  if (isset($output->{$varname}))
101  {
102  $this->category_parts[$currcat] = explode("_WORD_", $output->{$varname});
103  }
104  $currcat++;
105  } while (isset($output->{$varname}));
106  }
107 }
108 ?>