net.scheinerman.phoenix.interpreter
Class ImportInterpreter

java.lang.Object
  extended by net.scheinerman.phoenix.interpreter.Interpreter
      extended by net.scheinerman.phoenix.interpreter.ImportInterpreter

public class ImportInterpreter
extends Interpreter

Extends the standard interpreter to provide functionality for importing functions from modules into the currently executing program. This provides five different ways of importing modules into the current program. Each import type has an import statement which is a variant of the general phrase: [modifier] import [*] module_path.phx. Whether or not there is a modifier or a * depends on the import type. The module_path.phx is the relative path of a Phoenix program. This path should be delimited by slashes and specify an existing file. If no .phx file extension is specified, the import will be taken from the Phoenix standard library. All imported functions are imported as module_name.function_name. All of the possible import types are listed below, along with the import statement necessary to get it and the description of what it does.

*
Type Import statement Description
Full import module.phx Imports all top-level (no indent) global and local functions as their respective types. Thus, all top-level global functions become global function and all top-level local functions become local functions in the current scope (the scope in which the import is called).
Global only global import module.phx Imports only top-level global functions as global functions.
Global full global import * module.phx Imports all top-level global and local functions as global functions.
Local only local import module.phx Imports only top-level local functions as local functions in the current scope.
Local full local import * module.phx Imports all top-level global and local functions as local functions in the current scope.

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman

Field Summary
static int ALL
          A constant that indicates that the imports from a module should be all top-level functions as their respective types.
static int ALL_AS_GLOBAL
          A constant that indicates that the imports from a module should be all top-level functions as global functions.
static int ALL_AS_LOCAL
          A constant that indicates that the imports from a module should be all top-level functions as local functions.
static int GLOBAL_ONLY
          A constant that indicates that the imports from a module should only be the top-level global functions as global functions.
private  java.util.Scanner input
           
static int LOCAL_ONLY
          A constant that indicates that the imports from a module should only be the top-level local functions as local functions.
private  java.io.File modFile
           
private  java.lang.String module
           
private  java.lang.String prefix
           
private  int type
           
 
Fields inherited from class net.scheinerman.phoenix.interpreter.Interpreter
_break, _continue, _return, breakValue, code, fat, file, keywordList, line, line_diff, printValues, retType, retTypeSet, retValue, run_code, stop, vat
 
Constructor Summary
ImportInterpreter(java.lang.String module, int type, java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat, java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
           
 
Method Summary
 void run()
          Begins the interpretation process.
 
Methods inherited from class net.scheinerman.phoenix.interpreter.Interpreter
dealWithBreak, dealWithContinue, dealWithError, dealWithReturn, delete, doRun, getBlock, getFunction, getFunctionArguments, getFunctionFromDefinition, getReturnValue, getVariable, getWhitespace, initNewTables, isValidIdentifier, makeDefaultVariable, makeFunction, makeVariable, makeVariable, parsePhrase, putFunction, removeComments, removeWhitespace, retValueMatches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static final int ALL
A constant that indicates that the imports from a module should be all top-level functions as their respective types. In other words, global functions become global functions and local functions become local functions. The import statement should be: import module.phx

See Also:
Constant Field Values

GLOBAL_ONLY

public static final int GLOBAL_ONLY
A constant that indicates that the imports from a module should only be the top-level global functions as global functions. The import statement for this import type should be: global import module.phx

See Also:
Constant Field Values

ALL_AS_GLOBAL

public static final int ALL_AS_GLOBAL
A constant that indicates that the imports from a module should be all top-level functions as global functions. In other words, all top-level functions will be imported and added as global functions. The import statement should be: global import * module.phx

See Also:
Constant Field Values

LOCAL_ONLY

public static final int LOCAL_ONLY
A constant that indicates that the imports from a module should only be the top-level local functions as local functions. The import statement for this import type should be: local import module.phx

See Also:
Constant Field Values

ALL_AS_LOCAL

public static final int ALL_AS_LOCAL
A constant that indicates that the imports from a module should be all top-level functions as local functions. In other words, all top-level functions will be imported and added as local functions. The import statement should be: local import * module.phx

See Also:
Constant Field Values

module

private java.lang.String module

modFile

private java.io.File modFile

input

private java.util.Scanner input

type

private int type

prefix

private java.lang.String prefix
Constructor Detail

ImportInterpreter

public ImportInterpreter(java.lang.String module,
                         int type,
                         java.util.LinkedList<java.util.HashMap<java.lang.String,Variable>> vat,
                         java.util.LinkedList<java.util.HashMap<java.lang.String,Function>> fat)
Method Detail

run

public void run()
Description copied from class: Interpreter
Begins the interpretation process. This method only calls the doRun() method and then removes the front entries of the VAT and FAT queues. If the interpreter class is to be subclassed, this method should be overridden to provide surrounding functionality to the doRun() method.

Overrides:
run in class Interpreter