Package fmpp.tdd
Class Interpreter
java.lang.Object
fmpp.tdd.Interpreter
Evaluates TDD expressions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EvaluationEnvironmentEvaluates function calls to itself. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringConverts an object to a TDD-like representation (not necessary valid TDD).static Objecteval(Fragment fragment, EvaluationEnvironment ee, boolean forceStringValues) Evaluates aFragmentas single TDD expression.static ObjectSame aseval(text, null, false, null).static Objecteval(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as single TDD expression.static ObjectSame aseval(text, null, false, fileName).static MapevalAsHash(String text) Same asevalAsHash(text, null, false, null).static MapevalAsHash(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as a list of key:value pairs.static MapevalAsHash(String text, String fileName) Same asevalAsHash(text, null, false, fileName).static ListevalAsSequence(String text) Same asevalAsList(text, null, false, null).static ListevalAsSequence(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as a list values.static ListevalAsSequence(String text, String fileName) Same asevalAsList(text, null, false, fileName).intgetText()static StringgetTypeName(Object value) static StringLoads a TDD file with utilizing #encoding:enc header.static StringloadTdd(InputStream in, String defaultEncoding) Loads a TDD file with utilizing #encoding:enc header.
-
Field Details
-
SIMPLE_EVALUATION_ENVIRONMENT
Evaluates function calls to itself.
-
-
Method Details
-
eval
public static Object eval(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException Evaluates text as single TDD expression.- Parameters:
text- the text to interpret.ee- theEvaluationEnvironmentused to resolve function calls. If it isnullthenSIMPLE_EVALUATION_ENVIRONMENTwill be used.forceStringValues- specifies if expressions as true and 123 should be interpreted as strings, or as boolean and number respectively.fileName- the path of the source file, or other description of the source. It is used for informative purposes only, as in error messages.- Returns:
- the result of the evaluation. Possibly an empty
Map, but nevernull. - Throws:
EvalException
-
eval
public static Object eval(Fragment fragment, EvaluationEnvironment ee, boolean forceStringValues) throws EvalException Evaluates aFragmentas single TDD expression. The expression can be surrounded with superfluous white-space.- Throws:
EvalException- See Also:
-
eval
Same aseval(text, null, false, fileName).- Throws:
EvalException- See Also:
-
eval
Same aseval(text, null, false, null).- Throws:
EvalException- See Also:
-
evalAsHash
public static Map evalAsHash(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException Evaluates text as a list of key:value pairs.- Parameters:
text- the text to interpret.ee- theEvaluationEnvironmentused to resolve function calls. If it isnullthenSIMPLE_EVALUATION_ENVIRONMENTwill be used.forceStringValues- specifies if expressions as true and 123 should be interpreted as strings, or as boolean and number respectively.fileName- the path of the source file, or other description of the source. It is used for informative purposes only, as in error messages.- Returns:
- the result of the evaluation. Possibly an empty
Map, but nevernull. - Throws:
EvalException
-
evalAsHash
Same asevalAsHash(text, null, false, null).- Throws:
EvalException- See Also:
-
evalAsHash
Same asevalAsHash(text, null, false, fileName).- Throws:
EvalException- See Also:
-
evalAsSequence
public static List evalAsSequence(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException Evaluates text as a list values.- Parameters:
text- the text to interpret.ee- theEvaluationEnvironmentused to resolve function calls. If it isnullthenSIMPLE_EVALUATION_ENVIRONMENTwill be used.forceStringValues- specifies if expressions as true and 123 should be interpreted as strings, or as boolean and number respectively.fileName- the path of the source file, or other description of the source. It is used for informative purposes only, as in error messages.- Returns:
- the result of the evaluation. Possibly an empty
List, but nevernull. - Throws:
EvalException
-
evalAsSequence
Same asevalAsList(text, null, false, null).- Throws:
EvalException- See Also:
-
evalAsSequence
Same asevalAsList(text, null, false, fileName).- Throws:
EvalException- See Also:
-
loadTdd
Loads a TDD file with utilizing #encoding:enc header. If the header is missing, the encoding given as parameter is used.- Parameters:
in- the stream that reads the content of the file.- Throws:
IOException
-
loadTdd
Loads a TDD file with utilizing #encoding:enc header. If the header is missing, the encoding given as parameter is used.- Parameters:
b- the content of the file.- Throws:
IOException
-
dump
Converts an object to a TDD-like representation (not necessary valid TDD).- Parameters:
value- the object to convert- Returns:
- the TDD "source code".
-
getTypeName
-
getPosition
public int getPosition() -
getText
-
getFileName
-
getEvaluationEnvironment
-