ASP to PHP Schema. Version 44. 
==============================

Copyright (C) 2003 Pharmease, Inc.
Author: Konstantin Kirillov.
      
   
RISKY OPTIONS PRESET IN THIS SCHEMA
===================================
   The only risky options (1) and (2) are preset in this schema.
   Look for marks      '*1      and     '*2     to find them in html_schema.txt.
   To disable (1) and (2), put apostrophe at the
   beginning of lines (1) and (2).


MORE DETAILS ...
================

   ... can be found in comments in in this schema,
   ... in schema_readme.txt
   ... in readme.
  
\\


'add this global variables:
'if the source project already has
'   one of this names, 
'   this name confilct must be corrected:
'   details are in replacers.inc
|=variables."err_number_c_\l\F
             err_description_c_\l\F
             err_display_c_\l\F
             err_notify_c_\l\F
             err_helpcontext_c_\l"

|read$custom."php_equivalents\\custom.inc"
|read$replacers."php_equivalents\\replacers.inc"
|include."html_schema.txt"


'**********************************************************************************
'      THE REST OF THIS SCHEMA COVERS EVENTS ONLY FROM VB-SCRIPT - NO HTML
'==================================================================================

|include."transition_between_html_and_vb_modes.txt"


' There are three important "streams" of names to schema at this point:
'     .id  - identificatiors
'     .n   - numbers
'     .str - strings
'            identificators usually handled in 
'
'                wrapping.txt  section
'                              this section provides custom programming
'                              which intercepts and converts .id stream to
'                                       .idf, .idv "streams" or even
'                                       completes states ws or we.
'


|include."wrapping.txt"

' this instruction can be considered as a part of wrapping:
'              it allows compound object name: name.name to
'              let conversion continue when programmer missed
'              to wrap object in wrapping.txt section:
f_period       .id  .&  <               


'//////////////////////////////////////////////////////////////////////////////////
'              R E C O N G I N T I O N   T E R M S:   
'              FUNCTIONS, ARRAYS, VARIABLES, STRINGS, CONSTANTS 
'==================================================================================

'========================================================
'              This is mixed part. 
'              Number and object syntax recognition 
'              and arithmetics.
'--------------------------------------------------------

               'Event "." declared perhaps only in this section,
               '          for function, and in wrapper.

we             .n         >number               ..=number
               "."        >we_period
we_period      .n         =numberp
               .          "!!."                 <   +    'UNKNOWN CONSTRUCT:
                                                         'not_a_number.not_a_number
number         "."        ..=number."$number ." ..=numberp
               .          "$number"             <e  +
numberp        .n         "$number $"           <e  
               .          "$number"             <e  +         
e              "."        "!!."                 =we :
                          ..=ws."\l\l//!!THIS IS UNWRAPPED OBJECT with format:\l//\F
                                <expression>.<text> $warn_forgiven" :
                          "\l$ws".~ "$ws" 
'========================================================

'==================================================================================
'              DIM-STATEMENT
'- - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
ws             dim.k                                           >dim          
dim            .id        .=dd        ..~variables                    
               ,          
               .t         <2                                                    
               ' *d disables output:
               (          .i           .*d    "\$$dd =array("  >we    
dim,we         )          );           .-d    .i               <      ' dim ar()
dim,e          )          );           .-d    .i               <      ' dim ar(4,x)
               ,          ,                                    =we          
'- - -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
'              now, variable "variables" can be used as a list of variable names
'----------------------------------------------------------------------------------


'-----------------------------------------------------------------------------------
'              NAME RECOGNITION AT FUNCTION HEADER AND FOR CONSTANT
'- - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - 
'              "header" means function header parsing. 
'              All names are interpreted here as local parameter names  
'                        and do not need recognition.
header,we      .id      ..~variables     $    .&    =e                 
               ByVal.k                                    'ignored
               ByRef.k                                    'ignored
header,e       (        =f,we                             'to allow 
                                                          '   function(array(), ...
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
'              Statements like: Const x=2. No $ at constants.
'              This line must be before the main recongintion.
const          .id ..~constants   """"  .&  """" =const2   'REC
'-----------------------------------------------------------------------------------


'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
'              CORE-TERM
'======================================================================================
'              SPLIT .id STREAMS 
'--------------------------------------------------------------------------------------
-              variables.l      +"\$$ ".idv         'variables including arrays
               gloVars.l        ..~global :         '$global collects global vars which
                                +"\$$ ".idv         '  really used in procedure;
               constants.l      +.idv               'constants;
              .id               +.idf               'functions;
'======================================================================================



'======================================================================================
'          PRINTING TERM'S NAME 
'              at this point, there are 
'                 .n
'                 .str
'                 .idf
'                 .idv
'              streams are coming
'              and none of them is printed yet;
'--------------------------------------------------------------------------------------

          'preparing for a statement:
ws        .idf    .&    >f    'can become a function;
          .idv    .&    >e    'can become an array; 

          'preparing for an expression:
we        .idf    .&    =f
          .idv    .&    =e
          .n      .&    =e

          'the first uncommented .str event string has precedence and will be in effect:
          '.str   ..~warn_str   .=."\\\\"."/"   .=.".asp".".php"  .&  =e  '*  do both replacers
          '.str   ..~warn_str   .=."\\\\"."/"                     .&  =e  '*  more risky:    \ --> /   in any string
          '.str   ..~warn_str                   .=.".asp".".php"  .&  =e  '*  assuming that .asp is a file extension
          '"""\\\\""".str  ..~warn_str   """/""".=                .&  =e  '*  assuming that "\" is a folder dividor
          .str    .&  =e  '   can be commented out if one of '* above is used

'======================================================================================


'ssssssssssssssssssssssssssssssssssssssssss
'         TO COVER STANDARD-STATEMENTS
'------------------------------------------
ws,e      =       "="   >=,we              
          .t      ;     <2     +.tfull     
ws,e,=,e  .t      ;     <4     +.tfull
'ssssssssssssssssssssssssssssssssssssssssss
'         TO COVER EMTPY STATEMENTS
'         AND EMPTY LINES
'------------------------------------------
'         .tempty reports to upper states:
ws        .t      <     +.tempty           
'ssssssssssssssssssssssssssssssssssssssssss




'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
'	     TRANSFORM FUNCTION NAME TO FUNCTION OR EXPRESSION
'--------------------------------------------------------------------------------------
f          (            (          >we          'opening list of function parameters; 
                                                'statements like object(x).print x 
                                                'are still forbidden.
           "."          "!!."      >f_period    'add "." to the function name; 
                                                'to continue when
                                                'object is missed by schema programmer;

ws,f       
           'to cover procedure-call-statements:
           " "..l       >f_space   
           "\009"..l    >f_space   
          
           'to cover STANDARD-STATEMENTS:
           '    let conversion continue when 
           '    variable f declaration is below
           '    at first round;
           =            =e         +             
           .t     ()    =e         +

           'kk.deferred: won't work: inconsistance in schema design:
           '   raw level event .10 will be intercepted here:
           '   .10 may requered to be parsed below because
           '   if-control structure needs it:
           '.      +"!! 1 Syntax: incorrect separator `$ ` after the name.".exc

f_space    'to cover STANDARD-STATEMENTS
           '   as in case ws,f above:
           =            <e         +      
           .t     ()    <e         +
          
           'ignore spacers:
           " "..l          
           "\009"..l                             

           '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           ' to cover procedure-call-statements:
           '    print x,y 
           '    print (x)
           ' note that statements 
           '    sin(x) y 
           '    sin * 
           '    sin )
           '    are still forbidden
           '    extra syntax:  object .method --->
           '                     object(.method());
             .  <    +(    +           
           '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


           '-----------------------------------------
           '  This is a final instruction which
           '  covers all still uncaught events 
           '  for transition:
           '    f --> e
           '  This instruction allows conversion:
           '    rnd/3   ---> rand() / 3
           '
           '  This instruction allows extra syntax:
           '         sin*4 = s  ---> sin()*4 = s;
           '         t(abs/4)   ---> $t[abs()/4]
           '         sin   .    ---> sin().;
f            .  ()   =e    +             
           '-----------------------------------------
'======================================================================================
'          end of CORE-TERM
'MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 



'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
'          TO COVER THE CASE OF "e IS AN ARRAY NAME"
'---------------------------------------------------------------------------------------
           ' fe:  x(3)=3     ---> $x[3]=3;
           '      x() = 3    ---> $x[]=3;        
           '      extra syntax: y=sin(x)(4);
           '                    "hello"(4) = a;
e          (       =e,we     [             
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
'          PARAMETERS LIST FOR FUNCTION AND FOR ARRAY 
'=======================================================================================
e,e        )       ]          <         'f.e. array(x,y  and )
           ,       ][         =we       'constructing parameters list: array[i][j] ...

           'to cover "ar() = another_array":
           '  extra syntax: sin(x)(x) = 3;
e,we       )       ]                    "!! is this what programmer means?".r 
f,e        )       )          <e        'f.e  function(4,5  and );
           ,       ,          =we       'constructing parameters list: function[e,e, ...
f,we       )       )          <e        'this allows f(), 
                                        '     but allows: f( 5+); f( 5+(); f(x,) 
           ,       NULL,                'converts: 
                                        ' fun(6,,"message") --> fun(6,NULL,"message")
'---------------------------------------------------------------------------------------
'          COVERS procedure-call-statements like "print x" ---> "print(x)"
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
ws,f,we   .t    NULL  +)   +             'for err.raise 6,, ---> ...6,NULL,NULL)
ws,f,e    .t          +)   +             
'mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm




'=======================================================================================
'        TRANSITION we --> e
'---------------------------------------------------------------------------------------
we   (        (          =(,we        'This leads to ( e ); 
     not.k    !                       '!L logical; bitwise will be ~; 
                                      'to use only for boolan, replace ~ with ! 
     -        -            
(,e  )        )           <e
(    (        (           >(,we
'========================================================================================

|include."arithmetic.txt"


'========================================================================================
'         COMPLETING SOURCE TEXT STATEMENTS
'----------------------------------------------------------------------------------------
-s       .r10           >ws     .i     'this regenerates FSM to accept next statement 
                                       'and makes appropriate indent 
                                       'for the next statement;
         .:    " "      >ws            'this also regenerates FSM for the next statement, 
                                       'but no indent as is set in source text; 
                                       'adding space for nice output;
'========================================================================================

|include."control_structures.txt"
|include."function_and_sub_statements.txt"
|include."keywords_combination_recognition.txt"


'          NOT CAUGHT EVENTS WHICH ARE IGNORED 
-          .r10        
           .tempty    
           .tfull                    
           .t                            'does this really required (in elseif?)


'=========================================================================================
'          "Constructs" to skip.
'-----------------------------------------------------------------------------------------
-          @           //      .&    +.R    
           option.k    //      .&    +.R
           preserve.k    
           call.k
           public.k    +dim.k            '!~
           private.k   +dim.k            '!~
           redim.k     +dim.k            


'==========================================================================================================
-          .E         "Source Text Syntax Exception."          =end_text +.print_declarations
           .exc       .~                                       =end_text .end
end_text   .print_declarations                                 .end    
'==========================================================================================================



///////////////////////////////////////////////////////////////////////////////////////////////////////////
'      INITIALIZATIONS
'==========================================================================================================
'      SET TEXT-TASK DEPENDING ON ROUND AND EXTENSION 
'----------------------------------------------------------------------------------------------------------
-      .bot :
            .L.ext  :
            = =begin  :
            *"$ext ".extension   

       'setting extensions for files to be converted:
begin  asp.extension  :
            ..=p_rextension."php"          +.go      
       bas.extension                       +.go                   'disable this to preserve *.bas files 
       inc.extension                       +.go
       htm.extension                       +.go                   'in case to replace .asp --> .php only.
       html.extension                      +.go                   '---"---
       .extension    :
            ..=out.in  :                                          'mirror the file; don't convert;
            "non-specified_extension\l".~ :
            .end       

-     .go  :
           "\l...executing round $round ...\l".~ :
           ..output_text_to_console.f :                           '! change to preferred true/false value
           =main,-s,ws,html :                                     'restore initial text nest;
           ..percept."html" :                                     'restore initial Tokenizer perception;
           "<?php // require(""../replacers.inc""); \l ?>\l"      'add wrappers;
'==========================================================================================================


'==========================================================================================================
'   terminating/initializing Compi-project
'----------------------------------------------------------------------------------------------------------
-    .eop  :
         =project_end :
         ..?round."1"  ..restart_project +.terminating_project
         
project_end     
        
    .terminating_project :

         "***** Terminating Projects at Round $round  *****\l".~ :

         ..save$custom."custom.inc" :
         ..save$replacers."replacers.inc" :

         "\l\lGlobal variables: $variables \l\l".~  :    

         "$warn_asp ".=warn_asp."\n"."\l" :
         ..?warn_asp."" : :
             "\l"".asp"" -> "".php"" RISKY REPLACEMENT(S) ARE MADE IN STRINGS IN HTML PART:
             \l$warn_asp \l\l\l".~ :

         "$warn_str ".=warn_str."\n"."\l" :
         ..?warn_str."" : :
            "\lREPLACEMENT(S) ""\\"" -> ""/"" "".asp"" -> "".php"" 
             \lMAY BE DONE IN FOLLOWING STRINGS IN ASP CODE:\l$warn_str \l\l".~ 


-   .bop   :

       ..+round.1 :
       "\l****** Project-Unit $round  Round Start *****\l".~   :
       ..?round."1"   ..save_file_mode.false  ..save_file_mode.true :
       ..=warn_asp."" :
       ..=warn_str."" 



'==========================================================
'To view the assembled schema as a result of |include statements,
'   uncomment the following line
'|=out.in |stop
'   and click on  menu\Run - to view in RESULT window; 
'  Increase text box limit to enable to select and copy all text.
'Another method to get assembled text saved is to uncomment
'the following line and print variable $x 
'as soon as source project will run:
'|=x.in
'==========================================================
'to debug work right after schema:
'|suspend |debug

|=warn_forgiven."\l//!!Compi forgives this exception and continues parsing, but care must be taken ... \l"