gnu.expr
public abstract class Language extends Object
Field Summary | |
---|---|
protected static ThreadLocation | current |
protected Environment | environ The environment for language built-ins and predefined bindings. |
protected static int | env_counter |
static int | FUNCTION_NAMESPACE |
static int | NAMESPACE_PREFIX_NAMESPACE |
static int | PARSE_IMMEDIATE Flag to tell parse that expression will be evaluated immediately.
|
static int | PARSE_ONE_LINE Flag to tell parse to only read a single line if possible.
|
static int | PARSE_PROLOG Flag to tell parser to continue until we have the module name.
|
static boolean | requirePedantic |
protected Environment | userEnv If non-null, the user environment.
|
static int | VALUE_NAMESPACE |
Constructor Summary | |
---|---|
protected | Language() |
Method Summary | |
---|---|
Type | asType(Object spec) "Coerce" a language-specific "type specifier" object to a Type. |
Object | booleanObject(boolean b) |
Object | coerceFromObject(Class clas, Object obj) |
Object | coerceToObject(Class clas, Object obj) |
Object | coerceToObject(int val) |
Declaration | declFromField(ModuleExp mod, Object fvalue, Field fld) |
protected void | defAliasStFld(String name, String cname, String fname) Declare in the current Environment a variable aliased to a static field. |
void | define(String sym, Object p) Enter a value into the current environment. |
void | defineFunction(Named proc) Enter a named function into the current environment. |
void | defineFunction(String name, Object proc) Enter a function into the current environment.
|
protected void | defProcStFld(String name, String cname, String fname) Declare in the current Environment a procedure bound to a static field. |
protected void | defProcStFld(String name, String cname) Declare in the current Environment a procedure bound to a static field. |
static Language | detect(InputStream in) Detect the programming language of a file based on its first line. |
static Language | detect(InPort port) Detect the programming language of a file based on its first line. |
static Language | detect(String line) Detect the programming language of a file based on its first line. |
void | emitCoerceToBoolean(CodeAttr code) Generate code to test if an object is considered true.
|
void | emitPushBoolean(boolean value, CodeAttr code) |
Object | eval(String string) Return the result of evaluating a string as a source expression. |
Object | eval(Reader in) Evaluate expression(s) read from a Reader.
|
Object | eval(InPort port) Evaluate expression(s) read from an InPort. |
void | eval(String string, Writer out) Evaluate a string and write the result value(s) on a Writer. |
void | eval(String string, PrintConsumer out) Evaluate a string and write the result value(s) to a PrintConsumer.
|
void | eval(String string, Consumer out) Evaluate a string and write the result value(s) to a Consumer. |
void | eval(Reader in, Writer out) Read expressions from a Reader and write the result to a Writer. |
void | eval(Reader in, Consumer out) Read expressions from a Reader and write the result to a Consumer. |
void | eval(InPort port, CallContext ctx) |
String | formatType(Type type) |
Compilation | getCompilation(Lexer lexer, SourceMessages messages) |
static Language | getDefaultLanguage() |
Environment | getEnvironment() Get current user environment. |
Object | getEnvPropertyFor(Field fld, Object value) |
Object | getEnvPropertyFor(Declaration decl) |
AbstractFormat | getFormat(boolean readable) |
static Language | getInstance(String name) Look for a language with the given name or extension.
|
static Language | getInstance(String langName, Class langClass) |
static Language | getInstanceFromFilenameExtension(String filename) |
Environment | getLangEnvironment() |
Type | getLangTypeFor(Type type) |
static String[][] | getLanguages() Get a list of all available languages |
abstract Lexer | getLexer(InPort inp, SourceMessages messages) |
String | getName() |
int | getNamespaceOf(Declaration decl) Return the namespace (e.g value or function) of a Declaration.
|
Environment | getNewEnvironment() |
Consumer | getOutputConsumer(Writer out) |
Procedure | getPrompter() |
Symbol | getSymbol(String name) |
Type | getTypeFor(Class clas) |
Type | getTypeFor(String name) |
Type | getTypeFor(Object spec, boolean lenient) |
Type | getTypeFor(Expression exp) |
Type | getTypeFor(Expression exp, boolean lenient) |
boolean | hasNamespace(Declaration decl, int namespace) True if a Declaration is in the specified namespace. |
boolean | hasSeparateFunctionNamespace() True if functions are in a separate anme space from variable.
|
boolean | isTrue(Object value) Test if a value is considered "true" in this language. |
void | loadClass(String name) |
Object | lookup(String name) |
NamedLocation | lookupBuiltin(Symbol name, Object property, int hash) |
Object | noValue() The value to return for a "void" result. |
Compilation | parse(InPort port, SourceMessages messages, int options) Parse one or more expressions. |
Compilation | parse(InPort port, SourceMessages messages, ModuleInfo info) |
Compilation | parse(Lexer lexer, int options, ModuleInfo info) |
abstract boolean | parse(Compilation comp, int options) |
static void | registerLanguage(String[] langMapping) Add a language to the list.
|
void | resolve(Compilation comp) Perform any need post-processing after we've read all the modules
to be compiled.
|
void | runAsApplication(String[] args) |
static void | setDefaultLanguage(Language language) |
static void | setDefaults(Language lang) |
static Type | string2Type(String name) |
Parameters: name the procedure's source-level name. cname the name of the class containing the field. fname the name of the field, which should be a static final field whose type extends gnu.mapping.Procedure.
Parameters: name the procedure's source-level name. cname the name of the class containing the field.
The name of the field is the mangling of name
.
Returns: a suitable Language or null if we didn't recognize one.
Returns: a suitable Language or null if we didn't recognize one.
Parameters: line the first input line
Returns: a suitable Language or null if we didn't recognize one.
Parameters: namespace normally a bitmask as returned by getNamespaceOf.
Parameters: port the InPort to read the expressions from. messages where to send error messages and warnings options various flags, includding PARSE_IMMEDIATE and PARSE_ONE_LINE
Returns: a new Compilation. May return null if PARSE_ONE_LINE on end-of-file.
Parameters: langMapping is a language definition, the first index is the language name, subsequent indexes are file types that might cause the language to be used and the final index is the name of the class that implements the language.