JULC Internal Organization

( Home )


Internal Structure


Phase B: Lexical Analysis

Lexer (lexer.hpp)

  1. Get characters from the Input Buffer Module
  2. Eliminates comments
  3. Preprocessing: includes files using the "$" command
  4. Identifies indentation
  

    ALLOCATING A "Symbol"

     - If a module allocates a Symbol and does not delete that Symbol
       itself, each allocated Symbol should be added to the end-of-
       program deletion list using: gScopeManager->addSymbolToList (Symbol*)
     - If a module allocates a Symbol and deletes the Symbol itself,
       the above may be ignored.

    ROUTINES

     - There are 4 runtime stacks operating concurrently:

         call-stack:
           recursive routine calling and returning

         local-stack:
           holds local values during routine invocation

         param-stack:
           holds routine parameters and routine return values

         exp-stack:
           sed by instructions to evaluate expressions

     - Stack Manipulation Order (Routine Call)

         pushl a      {{ push local vars to LocalStack
         pushl b      {{ "
         pushl c      {{ "
         pushl T1     {{ push temporaries to LocalStack
         pushl T2     {{ "
         pushl T3     {{ "
         pushp z      {{ push parameters to ReturnStack
         pushp y      {{ "
         pushp x      {{ "
         call test    {{ push return address to CallStack, go to "test"
         popl T3      {{ pop temporaries from LocalStack
         popl T2      {{ "
         popl T1      {{ "
         popl c       {{ pop local vars from LocalStack
         popl b       {{ "
         popl a       {{ "
         popp r       {{ pop returned value from Return Stack

     - Stack Manipulation Order (Routine Body)

       Example Juliet Code:
         rout test:int (x:int, y:int, z:int)
           (body)
           return r

       Corresponding Portia Code:
         popp x       {{ pop arguments from ReturnStack
         popp y       {{ "
         popp z       {{ "
         (body)       {{ body of routine
         pushp r      {{ push return value to ReturnStack
         ret          {{ go to location popped off of CallStack
 
    

( Home )