source: trunk/src/engine.h @ 37

Last change on this file since 37 was 37, checked in by cameron, 11 years ago

Charset Architecture: Parser Factory

File size: 1.6 KB
Line 
1/*  engine.h - parabix parsing engine
2    Copyright (c) 2007, Robert D. Cameron
3    Licensed to the public under the Open Software License 3.0.
4    Licensed to International Characters, Inc., under the Academic
5    Free License 3.0.
6
7*/
8#ifndef ENGINE_H
9#define ENGINE_H
10
11#include "xmlparam.h"
12#include "xmlbuffer.h"
13#include "bitlex.h"
14
15
16/* A ParsingEngine is the principal class for parsing XML
17data.  */
18
19class Parser_Interface {
20public:
21        static Parser_Interface * ParserFactory(char * filename);
22        virtual void ParseContent() = 0;
23        unsigned char * GetCodeUnitPtr(int pos);
24        bool has_ByteOrderMark();
25        XML_version get_version();
26        XML_standalone standalone_status();
27        bool has_EncodingDecl();
28        int get_Encoding_pos();
29        int get_Encoding_lgth();
30protected:
31        /* Co-classes */
32        Lexer_Interface * lexer;
33        XML_Buffer_Interface * xml_buf;
34        /* Parallel data streams for current buffer full of XML data. */
35        BytePack * x8data;
36        LexicalStreamSet * buf;
37               
38        int buffer_base_pos;
39        int buffer_rel_pos;
40        int buffer_limit_pos;
41};
42
43template <CodeUnit_Base C>
44class ParsingEngine : public Parser_Interface {
45public:
46        ParsingEngine(XML_Buffer_Interface * b);
47        void ParseContent();
48protected:
49
50        /* Getters for current point/position information. */
51        int AbsPos() const;
52        int BufferRelPos() const;
53        unsigned char * cur() const;
54
55        bool at_EOF () const;
56
57        /* Mutators that advance the input. */
58        void Advance(int n);
59        void ScanTo(int lex_item);
60
61        /* Parsing routines. */
62
63        void Parse_Markup ();
64        void Parse_Comment ();
65        void Parse_StartTag ();
66        void Parse_EndTag ();
67        void Parse_CDATA ();
68        void Parse_PI ();
69        void Parse_Reference ();
70
71};
72
73
74#endif
Note: See TracBrowser for help on using the repository browser.