Package fmpp.tdd
Class Interpreter
java.lang.Object
fmpp.tdd.Interpreter
Evaluates TDD expressions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EvaluationEnvironment
Evaluates function calls to itself. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Converts an object to a TDD-like representation (not necessary valid TDD).static Object
eval
(Fragment fragment, EvaluationEnvironment ee, boolean forceStringValues) Evaluates aFragment
as single TDD expression.static Object
Same aseval(text, null, false, null)
.static Object
eval
(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as single TDD expression.static Object
Same aseval(text, null, false, fileName)
.static Map
evalAsHash
(String text) Same asevalAsHash(text, null, false, null)
.static Map
evalAsHash
(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as a list of key:value pairs.static Map
evalAsHash
(String text, String fileName) Same asevalAsHash(text, null, false, fileName)
.static List
evalAsSequence
(String text) Same asevalAsList(text, null, false, null)
.static List
evalAsSequence
(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) Evaluates text as a list values.static List
evalAsSequence
(String text, String fileName) Same asevalAsList(text, null, false, fileName)
.int
getText()
static String
getTypeName
(Object value) static String
Loads a TDD file with utilizing #encoding:enc header.static String
loadTdd
(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
- theEvaluationEnvironment
used to resolve function calls. If it isnull
thenSIMPLE_EVALUATION_ENVIRONMENT
will 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 aFragment
as 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
- theEvaluationEnvironment
used to resolve function calls. If it isnull
thenSIMPLE_EVALUATION_ENVIRONMENT
will 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
- theEvaluationEnvironment
used to resolve function calls. If it isnull
thenSIMPLE_EVALUATION_ENVIRONMENT
will 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
-