<?php
class C4Module
{ function __construct($C4,$Module,$Grammar)
  { $this->C4       = $C4;
    $this->Name     = $Module;
    $this->Grammar  = $Grammar;
  }

  function Parse()
  {
  }

  function Dispatch()
  {
  }

}

/* C4 Options
  O = [o,p,j]       // Output
      o             // Object
      p             // PHP
      j             // Javascript

  L = {s,l,o,w,e}   // Listing
      s             // Source
      l             // Line Number
      o             // Output
      w             // Warnings
      e             // Errors

  M = {a,k,l,b,sc,e,st,d,dc,c,cd,ma,ms,ol,t,ex,p }   // Modules
      a             // All
      k             // Keywords (1.1)
      l             // Lexical conventions (1.2)
      b             // Basic concepts  (1.3)
      sc            // Standard Conversions (1.4)
      e             // Expressions (1.5)
      st            // Statements (1.6)
      d             // Declarations (1.7)
      dc            // Declarators (1.8)
      c             // Classes(1.9)
      cd            // Derived classes (1.10)
      ma            // Member Access Control (1.11)
      ms            // Special member functions(1.12)
      ol            // Overloading (1.13)
      t             // Templates (1.14)
      ex            // Exception handling (1.15)
      p             // Preprocessing directives (1.16)

  LB* = {l,ll,ld,lu,ls,lo,lc,lt,la,ln,li  }   // Libraries
      l             // Library introduction (1.17)
      ll            // Language support Library (1.18)
      ld            // Diagnostics Library (1.19)
      lu            // Utilities Library (1.20)
      ls            // String Library (1.21)
      lo            // Localization Library (1.22)
      lc            // Container Library (1.23)
      lt            // Iteration Library (1.24)
      la            // Algorithms Library (1.25)
      ln            // Numerics Library (1.26)
      li            // Input Output Library (1.27)
*/

class C4
{ function __construct($Options)
  { $this->Options  = (is_null($Options))?array():$this->SetOptions($Options);
  }

  function Compile($File,$Options)
  { if ($this->Options != $Options) $this->SetOptions($Options);
    $data     = array();
    $lex      = array();
    $rules    = array();
    $tokens   = array();
    $file     = str_replace("\r\n"," ",urldecode($_POST['file']));
    $file     = preg_replace('!\s+!', ' ',$file);
    $Grammar  = Lex();
    $Text     = explode(" ",$file);
    $n        = count($Text);
    echo $n," Tokens<br>";
    for($i=0;i<$n;$i++)
    { if (!is_set($Grammar[1][$Text[$i]]))
      {
      }
      $Rules  = $Grammar[1][$i];

      echo $token,'<br>';
    }
    return;
  }

  function SetOptions($Options)
  { if (is_set($Options['M']))
    { foreach($Options['M'] as $opt)
      {
      a             // All
      k             // Keywords (1.1)
      l             // Lexical conventions (1.2)
      b             // Basic concepts  (1.3)
      sc            // Standard Conversions (1.4)
      e             // Expressions (1.5)
      st            // Statements (1.6)
      d             // Declarations (1.7)
      dc            // Declarators (1.8)
      c             // Classes(1.9)
      cd            // Derived classes (1.10)
      ma            // Member Access Control (1.11)
      ms            // Special member functions(1.12)
      ol            // Overloading (1.13)
      t             // Templates (1.14)
      ex            // Exception handling (1.15)
      p             // Preprocessing directives (1.16)
    }
  }

  function Save($File)
  {
  }

}
?>
