Changeset 49 for trunk/markup_stats.cxx


Ignore:
Timestamp:
Feb 16, 2008, 7:37:20 AM (12 years ago)
Author:
cameron
Message:

Make ilax actions into ParsingEngine? methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/markup_stats.cxx

    r45 r49  
    1818using namespace std;
    1919
    20 #include "src/ilax.h"
     20//#include "src/ilax.h"
    2121#include "src/engine.h"
    2222
     
    6262int total_namespace_URI_length = 0;
    6363
     64int last_item_start = 0;
     65int last_item_stop = 0;
     66int last_buffer_rel_pos = 0;
    6467
    6568/* Action routine for an XML comment in "<!--"  "-->" brackets. */
    66 //template <CodeUnit_Base C>
    67 static inline void Comment_action(int start_pos, int end_pos) {
     69template <CodeUnit_Base C>
     70inline void ParsingEngine<C>::Comment_action(int start_pos, int end_pos) {
    6871        comment_count +=1;
    6972        comment_length += end_pos - start_pos;
     73        last_item_start = start_pos;
     74        last_item_stop = end_pos;
     75        last_buffer_rel_pos = buffer_rel_pos;
    7076}
    7177
    7278/* Action routine for a CDATA section enclosed in "<![CDATA[" and "]]>" brackets. */
    73 //template <CodeUnit_Base C>
    74 static inline void CDATA_action(int start_pos, int end_pos) {
     79template <CodeUnit_Base C>
     80inline void ParsingEngine<C>::CDATA_action(int start_pos, int end_pos) {
    7581        CDATA_count +=1;
    7682        CDATA_length += end_pos - start_pos;
     83        last_item_start = start_pos;
     84        last_item_stop = end_pos;
     85        last_buffer_rel_pos = buffer_rel_pos;
    7786}
    7887
    7988/* Action routine for an XML processing instruction enclosed in "<?" and "?>" brackets. */
    80 //template <CodeUnit_Base C>
    81 static inline void PI_action(int start_pos, int end_pos) {
     89template <CodeUnit_Base C>
     90inline void ParsingEngine<C>::PI_action(int start_pos, int end_pos) {
    8291        PI_count +=1;
    8392        PI_length += end_pos - start_pos;
     93        last_item_start = start_pos;
     94        last_item_stop = end_pos;
     95        last_buffer_rel_pos = buffer_rel_pos;
    8496}
    8597
    8698/* Action routine for an empty element enclosed in "<" and "/>" brackets. */
    87 //template <CodeUnit_Base C>
    88 static inline void EmptyElement_action(int start_pos, int end_pos) {
     99template <CodeUnit_Base C>
     100inline void ParsingEngine<C>::EmptyElement_action(int start_pos, int end_pos) {
    89101        empty_elem_count +=1;
    90102        empty_elem_length += end_pos - start_pos;
     103        last_item_start = start_pos;
     104        last_item_stop = end_pos;
     105        last_buffer_rel_pos = buffer_rel_pos;
    91106}
    92107
    93108/* Action routine for a start tag enclosed in "<" and ">" brackets. */
    94 //template <CodeUnit_Base C>
    95 static inline void StartTag_action(int start_pos, int end_pos) {
     109template <CodeUnit_Base C>
     110inline void ParsingEngine<C>::StartTag_action(int start_pos, int end_pos) {
    96111        start_tag_count +=1;
    97112        start_tag_length += end_pos - start_pos;
    98113        nesting_depth += 1;
    99114        if (nesting_depth > max_nesting_depth) max_nesting_depth = nesting_depth;
     115        last_item_start = start_pos;
     116        last_item_stop = end_pos;
     117        last_buffer_rel_pos = buffer_rel_pos;
    100118}
    101119
    102120/* Action routine for an end tag enclosed in "</" and ">" brackets. */
    103 //template <CodeUnit_Base C>
    104 static inline void EndTag_action(int start_pos, int end_pos) {
     121template <CodeUnit_Base C>
     122inline void ParsingEngine<C>::EndTag_action(int start_pos, int end_pos) {
    105123        end_tag_count +=1;
    106124        end_tag_length += end_pos - start_pos;
    107125        nesting_depth -= 1;
     126        last_item_start = start_pos;
     127        last_item_stop = end_pos;
     128        last_buffer_rel_pos = buffer_rel_pos;
    108129}
    109130
    110131/* Action routine for an error item */
    111 //template <CodeUnit_Base C>
    112 static inline void Error_action(int start_pos, int end_pos) {
     132template <CodeUnit_Base C>
     133inline void ParsingEngine<C>::Error_action(int start_pos, int end_pos) {
    113134        error_item_count +=1;
    114135        error_item_length += end_pos - start_pos;
    115136        printf("Error: illegal markup at positions %i through %i.\n", start_pos, end_pos);
    116 
    117         cout << string((char *) parser->GetCodeUnitPtr(start_pos), end_pos - start_pos) << endl;
     137        printf("length = %i; buffer_rel_pos = %i\n", end_pos - start_pos, buffer_rel_pos);
     138        printf("last_item from %i to %i (rel_pos = %i)\n",
     139               last_item_start, last_item_stop, last_buffer_rel_pos);
     140
     141        cout << string((char *) GetCodeUnitPtr(start_pos), end_pos - start_pos) << endl;
    118142
    119143
     
    122146
    123147/* Action routine for a text item */
    124 //template <CodeUnit_Base C>
    125 static inline void Text_action(int start_pos, int end_pos) {
     148template <CodeUnit_Base C>
     149inline void ParsingEngine<C>::Text_action(int start_pos, int end_pos) {
    126150        text_item_count +=1;
    127151        text_item_length += end_pos - start_pos;
    128152}
    129153
    130 //template <CodeUnit_Base C>
    131 static inline void Reference_action(int start_pos, int end_pos) {
     154template <CodeUnit_Base C>
     155inline void ParsingEngine<C>::Reference_action(int start_pos, int end_pos) {
    132156        reference_count +=1;
    133157        reference_length += end_pos - start_pos;
     158        last_item_start = start_pos;
     159        last_item_stop = end_pos;
     160        last_buffer_rel_pos = buffer_rel_pos;
    134161}
    135162
     
    157184/* Action routine for an element name occurring immediately after the
    158185   opening "<" of a start tag or empty element tag. */
    159 //template <CodeUnit_Base C>
    160 static inline void ElementName_action(int start_pos, int end_pos) {
     186template <CodeUnit_Base C>
     187inline void ParsingEngine<C>::ElementName_action(int start_pos, int end_pos) {
    161188}
    162189
    163190/* Action routine for a processing instruction target name occurring immediately
    164191   after the opening "<?" of a processing instruction. */
    165 //template <CodeUnit_Base C>
    166 static inline void PI_Target_action(int start_pos, int end_pos) {
     192template <CodeUnit_Base C>
     193inline void ParsingEngine<C>::PI_Target_action(int start_pos, int end_pos) {
    167194}
    168195
    169196/* Action routine for an individual attribute/value pair occurring in
    170197   a element start tag or an empty element tag. */
    171 //template <CodeUnit_Base C>
    172 static inline void AttributeValue_action(int name_start, int name_end,
     198template <CodeUnit_Base C>
     199inline void ParsingEngine<C>::AttributeValue_action(int name_start, int name_end,
    173200                                  int val_start, int val_end) {
    174201        total_attribute_count+=1;
     
    179206/* Action routine for an individual attribute/value pair occurring in
    180207   a element start tag or an empty element tag. */
    181 //template <CodeUnit_Base C>
    182 static inline void Namespace_action(int name_start, int name_end,
     208template <CodeUnit_Base C>
     209inline void ParsingEngine<C>::Namespace_action(int name_start, int name_end,
    183210                             int URI_start, int URI_end) {
    184211        namespace_count+=1;
     
    188215
    189216
    190 //template <CodeUnit_Base C>
    191 static inline void FinalizeBuffer_action() {
     217template <CodeUnit_Base C>
     218inline void ParsingEngine<C>::FinalizeBuffer_action() {
    192219}
    193220
Note: See TracChangeset for help on using the changeset viewer.