source: trunk/src/engine.h @ 52

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

Destructors

File size: 3.5 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    ~Parser_Interface();
22        static Parser_Interface * ParserFactory(char * filename);
23        virtual void ParseContent() = 0;
24        unsigned char * GetCodeUnitPtr(int pos);
25        bool has_ByteOrderMark();
26        XML_version get_version();
27        XML_standalone standalone_status();
28        bool has_EncodingDecl();
29        int get_Encoding_pos();
30        int get_Encoding_lgth();
31protected:
32        /* Co-classes */
33        Lexer_Interface * lexer;
34        XML_Buffer_Interface * xml_buf;
35        /* Parallel data streams for current buffer full of XML data. */
36        BytePack * x8data;
37        LexicalStreamSet * buf;
38               
39        int buffer_base_pos;
40        int buffer_rel_pos;
41        int buffer_limit_pos;
42};
43
44template <CodeUnit_Base C>
45class ParsingEngine : public Parser_Interface {
46public:
47        ParsingEngine(XML_Buffer_Interface * b);
48        ~ParsingEngine();
49        void ParseContent();
50protected:
51
52        /* Getters for current point/position information. */
53        int AbsPos() const;
54        int BufferRelPos() const;
55        unsigned char * cur() const;
56
57        bool at_EOF () const;
58
59        /* Mutators that advance the input. */
60        void Advance(int n);
61        void ScanTo(int lex_item);
62
63        /* Parsing routines. */
64
65        void Parse_Markup ();
66        void Parse_Comment ();
67        void Parse_StartTag ();
68        void Parse_EndTag ();
69        void Parse_CDATA ();
70        void Parse_PI ();
71        void Parse_Reference ();
72       
73        /* Action routines. */
74        /* Action routine for an XML comment in "<!--"  "-->" brackets. */
75        void Comment_action(int start_pos, int end_pos);
76       
77        /* Action routine for a CDATA section enclosed in "<![CDATA[" and "]]>" brackets. */
78        void CDATA_action(int start_pos, int end_pos);
79       
80        /* Action routine for an XML processing instruction enclosed in "<?" and "?>" brackets. */
81        void PI_action(int start_pos, int end_pos);
82       
83        /* Action routine for an empty element enclosed in "<" and "/>" brackets. */
84        void EmptyElement_action(int start_pos, int end_pos);
85       
86        /* Action routine for a start tag enclosed in "<" and ">" brackets. */
87        void StartTag_action(int start_pos, int end_pos);
88       
89        /* Action routine for an end tag enclosed in "</" and ">" brackets. */
90        void EndTag_action(int start_pos, int end_pos);
91       
92        /* Action routine for an error item */
93        void Error_action(int start_pos, int end_pos);
94       
95        /* Action routine for a text item */
96        void Text_action(int start_pos, int end_pos);
97       
98        /* Action routine for a character or entity reference.*/
99        void Reference_action(int start_pos, int end_pos);
100       
101        /* Action routine for an element name occurring immediately after the
102        opening "<" of a start tag or empty element tag. */
103        void ElementName_action(int start_pos, int end_pos);
104       
105        /* Action routine for a processing instruction target name occurring immediately
106        after the opening "<?" of a processing instruction. */
107        void PI_Target_action(int start_pos, int end_pos);
108       
109        /* Action routine for an individual attribute/value pair occurring in
110        a element start tag or an empty element tag. */
111        void AttributeValue_action(int name_start, int name_end, 
112                                        int val_start, int val_end);
113       
114        /* Action routine for an individual namespace binding occurring in
115        a element start tag or an empty element tag. */
116        void Namespace_action(int name_start, int name_end, 
117                                int URI_start, int URI_end);
118       
119        void FinalizeBuffer_action();
120
121};
122
123
124#endif
Note: See TracBrowser for help on using the repository browser.