Unit CastleScriptParser
Classes, Interfaces, Objects and Records Constants Variables
Description
Parser for CastleScript language, see [http://castle-engine.sourceforge.net/castle_script.php].
Can parse whole program in CastleScript language, is also prepared to parse only a single expression (usefull for cases when I need to input only a mathematical expression, like for glplotter function expression).
Uses
Overview
Functions and Procedures
Types
Description
Functions and Procedures
function ParseFloatExpression(const S: string; const Variables: array of TCasScriptValue): TCasScriptExpression; |
Parse a CastleScript expression that should be calculated to a float value. The easiest way to evaluate such expression is to call TCasScriptExpression.AsFloat method.
This creates and returns an instance of TCasScriptExpression, that represents parsed tree of expression in S, casted to float. This parses a subset of CastleScript language, that allows you to define only one expression without any assignments. Also the end result is always casted to the float() type (just like it would be wrapped inside float() function call — in fact this is exactly what happens.)
The end result is that this is perfect for describing things like function expressions, ideal e.g. for [http://castle-engine.sourceforge.net/glplotter_and_gen_function.php].
Parameters
- Variables
- contains a list of named values you want to allow in this expression.
Important: They will all have OwnedByParentExpression set to False , and you will have to free them yourself. That's because given expression may use the same variable more than once (so freeing it twice would cause bugs), or not use it at all (so it will be automatically freed at all).
So setting OwnedByParentExpression and freeing it yourself is the only sensible thing to do.
Exceptions raised
- ECasScriptSyntaxError
- in case of error when parsing expression.
|
function ParseConstantFloatExpression(const S: string): Float; |
Parse constant float expression. This can be used as a drop-in replacement for StrToFloat. Takes a string with any constant mathematical expression, according to CastleScript syntax, parses it and calculates.
Exceptions raised
- ECasScriptSyntaxError
- in case of error when parsing expression.
|
Types
Generated by PasDoc 0.15.0.
|