public class Mapper extends Object implements Serializable
Mapper is a translated Mapping.| Constructor and Description |
|---|
Mapper(String name)
Creates a mapper with the specified name.
|
Mapper(String name,
ErrorHandler errorHandler) |
Mapper(String name,
Parser parser,
Oag oag)
Create a mapper with the specified parser and semantics.
|
Mapper(String name,
Parser parser,
Oag oag,
ErrorHandler errorHandler) |
| Modifier and Type | Method and Description |
|---|---|
ErrorHandler |
getErrorHandler() |
Parser |
getParser() |
Oag |
getSemantics() |
boolean |
isLoaded()
Returns true if the mapper tables have already been loaded.
|
void |
load()
Loads the mapper tables if not already done so.
|
Mapper |
newInstance()
Creates a new mapper instance.
|
void |
repl(String prompt,
String end)
Read-eval-print loop.
|
Object[] |
run(File file) |
Object[] |
run(net.oneandone.sushi.fs.Node node) |
Object[] |
run(Position position,
Reader src)
Reads an stream, creates the syntax tree, computes the attributes and returns
the attributes of the start symbol.
|
Object[] |
run(String fileName) |
Object[] |
run(String context,
Reader src) |
void |
setEnvironment(Object environment)
Defines the environment object of the mapper.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Defines the handler to report errors to.
|
void |
setLogging(PrintWriter logParsing,
PrintWriter logAttribution) |
String |
toString() |
public Mapper(String name)
public Mapper(String name, ErrorHandler errorHandler)
public Mapper(String name, Parser parser, Oag oag)
Mapper(String).public Mapper(String name, Parser parser, Oag oag, ErrorHandler errorHandler)
public Mapper newInstance()
public void load()
Loads the mapper tables if not already done so. This method is usually invoked implicity
by the various run methods. Don't call load explicitly unless
you want to force loading of mapper tables.
I tried to load the mapper from a background Thread started in the constructor. But the overall performance (of the jp example) was worse, probably because class loading is to fast (and out-performes the threading overhead).
IllegalStateException - to indicate a class loading problempublic boolean isLoaded()
public ErrorHandler getErrorHandler()
public void setErrorHandler(ErrorHandler errorHandler)
errorHandler - may be nullpublic void setEnvironment(Object environment)
YourSymbols : [env];. The default environment
object is this.environment - may be nullpublic void setLogging(PrintWriter logParsing, PrintWriter logAttribution)
public Parser getParser()
public Oag getSemantics()
public Object[] run(String fileName) throws IOException
IOExceptionpublic Object[] run(net.oneandone.sushi.fs.Node node) throws IOException
IOExceptionpublic Object[] run(File file) throws IOException
IOExceptionpublic Object[] run(String context, Reader src) throws IOException
IOExceptionpublic Object[] run(Position position, Reader src) throws IOException
run methods use it. Reports errors to the registered errorHander;
if there is no errorHandler defined, this method defines a PrintWriterErrorHandler
for System.err.src - when the method returns, src is always closed.IOException - to report errorspublic void repl(String prompt, String end)
prompt - prompt string.end - string to terminal real-eval-print loop; null specifies
that the loop will not be terminated.Copyright © 1998–2017 1&1. All rights reserved.