#ifndef ASTCI_H
#define ASTCI_H

/*
 astci.h

 Script Language Development Kit
 Compile bytecode from an Abstract Syntax Tree

 Copyright (c) 1996-2002 Parsifal Software.
 All Rights Reserved.

 For further information about this program or the AnaGram
 parser generator, please contact:

    Parsifal Software
    http://www.parsifalsoft.com
    info@parsifalsoft.com
    +1-800-879-2577, Voice/Fax +1-508-358-2564
    P.O. Box 219
    Wayland, MA 01778
    USA
*/

#include "astdefs.h"
#include "bcidefs.h"

#define OPTIMIZE

class Compiler {
  AbstractSyntaxTree tree;
  AgDictionary<AgString> &dictionary;
  AgDictionary<Constant> constants;
  AgDictionary<AgString> fieldNames;

#ifdef OPTIMIZE
  void doConstantArithmetic(AstNode *&node);
#endif

CodeFragment compile(const AstNode *node);

friend class ScriptMethod;

public:
  Compiler(const char *text, AgDictionary<AgString> &d) : tree(buildTree(text)), dictionary(d) {}
  ~Compiler() {}
  CodeFragment compile();
};



#endif
