Compiler.hh

00001 
00019 #ifndef avro_Compiler_hh__
00020 #define avro_Compiler_hh__
00021 
00022 #include "Boost.hh"
00023 
00024 #include <FlexLexer.h>
00025 #include "Types.hh"
00026 #include "Node.hh"
00027 #include "CompilerNode.hh"
00028 
00029 namespace avro {
00030 
00035     
00036 class CompilerContext {
00037 
00038 
00039   public:
00040 
00041     CompilerContext(std::istream &is) :
00042         lexer_(&is)
00043     {}
00044 
00047     void setText(const char *text) {
00048         text_ = text;
00049     }
00050 
00051     void addNamedType();
00052 
00053     void startType();
00054     void stopType();
00055 
00056     void addType(avro::Type type);
00057 
00058     void setSizeAttribute();
00059     void setNameAttribute();
00060     void setSymbolsAttribute();
00061 
00062     void setFieldsAttribute();
00063     void setItemsAttribute();
00064     void setValuesAttribute();
00065     void setTypesAttribute();
00066 
00067     void textContainsFieldName();
00068 
00069     const FlexLexer &lexer() const {
00070         return lexer_;
00071     }
00072     FlexLexer &lexer() {
00073         return lexer_;
00074     }
00075 
00076     const NodePtr &getRoot() const {
00077         return root_;
00078     }
00079 
00080   private:
00081 
00082     typedef boost::ptr_vector<CompilerNode> Stack;
00083 
00084     void add(const NodePtr &node);
00085 
00086     yyFlexLexer lexer_;
00087     std::string text_;
00088     
00089     NodePtr   root_;
00090     Stack     stack_;
00091 };
00092 
00093 class ValidSchema;
00094 
00098 
00099 void compileJsonSchema(std::istream &is, ValidSchema &schema);
00100 
00105 
00106 bool compileJsonSchema(std::istream &is, ValidSchema &schema, std::string &error);
00107 
00108 } // namespace avro
00109 
00110 #endif

Generated on Tue Feb 23 15:31:29 2010 for Avro C++ by  doxygen 1.6.1