source: trunk/src/engine.h @ 62

Last change on this file since 62 was 62, checked in by ksherdy, 11 years ago

Include document start and document end action routines.

File size: 3.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    ~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 routine for document start. */
74        void DocumentStart_action();   
75       
76        /* Action routine for document end. */
77        void DocumentEnd_action();
78       
79        /* Action routine for an XML comment in "<!--"  "-->" brackets. */
80        void Comment_action(int start_pos, int end_pos);
81       
82        /* Action routine for a CDATA section enclosed in "<![CDATA[" and "]]>" brackets. */
83        void CDATA_action(int start_pos, int end_pos);
84       
85        /* Action routine for an XML processing instruction enclosed in "<?" and "?>" brackets. */
86        void PI_action(int start_pos, int end_pos);
87       
88        /* Action routine for an empty element enclosed in "<" and "/>" brackets. */
89        void EmptyElement_action(int start_pos, int end_pos);
90       
91        /* Action routine for a start tag enclosed in "<" and ">" brackets. */
92        void StartTag_action(int start_pos, int end_pos);
93       
94        /* Action routine for an end tag enclosed in "</" and ">" brackets. */
95        void EndTag_action(int start_pos, int end_pos);
96       
97        /* Action routine for an error item */
98        void Error_action(int start_pos, int end_pos);
99       
100        /* Action routine for a text item */
101        void Text_action(int start_pos, int end_pos);
102       
103        /* Action routine for a character or entity reference.*/
104        void Reference_action(int start_pos, int end_pos);
105       
106        /* Action routine for an element name occurring immediately after the
107        opening "<" of a start tag or empty element tag. */
108        void ElementName_action(int start_pos, int end_pos);
109       
110        /* Action routine for a processing instruction target name occurring immediately
111        after the opening "<?" of a processing instruction. */
112        void PI_Target_action(int start_pos, int end_pos);
113       
114        /* Action routine for an individual attribute/value pair occurring in
115        a element start tag or an empty element tag. */
116        void AttributeValue_action(int name_start, int name_end, 
117                                        int val_start, int val_end);
118       
119        /* Action routine for an individual namespace binding occurring in
120        a element start tag or an empty element tag. */
121        void Namespace_action(int name_start, int name_end, 
122                                int URI_start, int URI_end);
123       
124        void FinalizeBuffer_action();
125
126};
127
128
129#endif
Note: See TracBrowser for help on using the repository browser.