1. with Expressions.Parsers;               use Expressions.Parsers; 
  2. with Tokens.Scanners;                   use Tokens.Scanners; 
  3.  
  4. package Expressions.Evaluators is 
  5.  
  6.     -- An Evaluator can parse and evaluate scripts and expressions. Currently 
  7.     -- only expressions are supported for evaluation. Symbols in expressions 
  8.     -- are resolved by an object implementing the Symbol_Resolver interface. 
  9.     -- The Evaluator can be reused to perform multiple evaluations on different 
  10.     -- input and it is recommended that objects not be created and deleted for 
  11.     -- every evaluation, to limit overhead. 
  12.     type Evaluator is new Limited_Object with private; 
  13.     type A_Evaluator is access all Evaluator'Class; 
  14.  
  15.     -- Creates a new Evaluator to evaluate text script/expressions. 
  16.     function Create_Evaluator return A_Evaluator; 
  17.  
  18.     -- Evaluates the text of 'expression' and returns 'result'. Specify 
  19.     -- 'resolver' to resolve symbols by name during evaluation. If the 
  20.     -- expression couldn't be evaluated due to a runtime error, null will be 
  21.     -- returned. (For example, a variable couldn't be resolved or a value type 
  22.     -- mismatch occured.) If a parsing error occurs then Parse_Exception will be 
  23.     -- raised. 
  24.     procedure Evaluate( this       : not null access Evaluator'Class; 
  25.                         expression : String; 
  26.                         resolver   : A_Symbol_Resolver; 
  27.                         result     : in out A_Value ); 
  28.  
  29.     -- Deletes the Evaluator. 
  30.     procedure Delete( this : in out A_Evaluator ); 
  31.  
  32. private 
  33.  
  34.      type Evaluator is new Limited_Object with 
  35.         record 
  36.             scanner : A_Token_Scanner := Create_Token_Scanner; 
  37.             parser  : A_Expression_Parser := Create_Expression_Parser; 
  38.         end record; 
  39.  
  40.     procedure Delete( this : in out Evaluator ); 
  41.  
  42. end Expressions.Evaluators;