Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Friends
packrat_parser_rep Class Reference

#include <packrat_parser.hpp>

Inheritance diagram for packrat_parser_rep:
Inheritance graph
[legend]
Collaboration diagram for packrat_parser_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 packrat_parser_rep (packrat_grammar gr)
int decode_string_position (C pos)
C encode_string_position (int i)
path decode_tree_position (C pos)
C encode_tree_position (path p)
C parse (C sym, C pos)
void inspect (C sym, C pos, array< C > &syms, array< C > &poss)
bool is_left_recursive (C sym)
bool is_associative (C sym)
bool is_anti_associative (C sym)
bool is_list_like (C sym)
bool is_selectable (C sym)
void context (C sym, C pos, C left, C right, int mode, array< C > &kind, array< C > &begin, array< C > &end)
void compress (array< C > &kind, array< C > &begin, array< C > &end)
void highlight (tree t, path tp, path p1, path p2, int col)
void highlight (C sym, C pos)

Public Attributes

hashmap< C, array< C > > grammar
hashmap< C, treeproductions
hashmap< D, stringproperties
tree current_tree
string current_string
hashmap< path, int > current_start
hashmap< path, int > current_end
hashmap< path, int > current_path_pos
hashmap< int, pathcurrent_pos_path
C current_cursor
int current_hl_lan
array< Ccurrent_input
hashmap< D, Ccurrent_cache
hashmap< D, treecurrent_production

Protected Member Functions

void serialize_atomic (tree t, path p)
void serialize_compound (tree t, path p)
void serialize (tree t, path p)
void set_input (tree t)
void set_cursor (path t_pos)
path decode_path (tree t, path p, int pos)
int encode_path (tree t, path p, path pos)

Private Attributes

int ref_count

Friends

class packrat_parser

Detailed Description

Definition at line 19 of file packrat_parser.hpp.


Constructor & Destructor Documentation

packrat_parser_rep::packrat_parser_rep ( packrat_grammar  gr)

Member Function Documentation

void packrat_parser_rep::compress ( array< C > &  kind,
array< C > &  begin,
array< C > &  end 
)

Definition at line 560 of file packrat_parser.cpp.

{
  array<C> new_kind, new_begin, new_end;
  for (int i=0; i<N(kind); i++) {
    int n= N(new_kind);
    if (is_selectable (kind[i]))
      if (N(new_kind) == 0 ||
         new_kind [n-1] != kind[i] ||
         (new_begin[n-1] != begin[i] && new_end[n-1] != end[i])) {
       new_kind  << kind[i];
       new_begin << begin[i];
       new_end   << end[i];
      }
  }
  kind = new_kind;
  begin= new_begin;
  end  = new_end;
}

Here is the call graph for this function:

void packrat_parser_rep::context ( C  sym,
C  pos,
C  left,
C  right,
int  mode,
array< C > &  kind,
array< C > &  begin,
array< C > &  end 
)

Definition at line 416 of file packrat_parser.cpp.

{
  C next= parse (sym, pos);
  if (next < 0 || pos > w1 || next < w2) return;

  if (mode == 2 && (pos == w1 || next == w2)) {
    static C prop= encode_symbol (compound ("property", "operator"));
    D key = (((D) prop) << 32) + ((D) (sym ^ prop));
    if (properties->contains (key)) return;
  }

  if (true) {
    static C sel_prop= encode_symbol (compound ("property", "selectable"));
    static C foc_prop= encode_symbol (compound ("property", "focus"));
    D sel_key = (((D) sel_prop) << 32) + ((D) (sym ^ sel_prop));
    D foc_key = (((D) foc_prop) << 32) + ((D) (sym ^ foc_prop));
    if (properties->contains (sel_key) &&
        properties[sel_key] == "inside");
    else if (properties->contains (foc_key) &&
             properties[foc_key] == "disallow" &&
             mode == 2);
    else {
      int n= N(kind);
      if (n >= 1 && begin[n-1] == pos && end[n-1] == next) {
        if (is_selectable (sym) || !is_selectable (kind[n-1]))
          kind[n-1]= sym;
      }
      else {
        kind  << sym;
        begin << pos;
        end   << next;
      }
    }
  }

  if (mode >= 0) {
    static C prop= encode_symbol (compound ("property", "atomic"));
    D key = (((D) prop) << 32) + ((D) (sym ^ prop));
    if (properties->contains (key)) return;
  }

  if (is_left_recursive (sym) && mode == 0) {
    array<C> inst= grammar [sym];
    C before= pos;
    C middle= parse (inst[1], before);
    if (middle == PACKRAT_FAILED) return;
    C after = parse (inst[2], middle);
    if (after == PACKRAT_FAILED) return;
    array<C> csym;
    array<C> cpos;
    inspect (inst[2], middle, csym, cpos);
    csym= append (inst[1], csym);
    cpos= append (before, cpos);
    cpos << after;
    int i1, i2;
    for (i1=0; i1<N(csym); i1++)
      if (cpos[i1+1] > w1) break;
    for (i2=i1; i2<N(csym); i2++)
      if (cpos[i2+1] >= w2) break;
    if (i1 == i2) {
      int i, n= N(kind);
      context (csym[i1], cpos[i1], w1, w2, mode, kind, begin, end);
      for (i=n; i<N(kind); i++)
        if (is_selectable (kind[i]))
          return;
      kind  -> resize (n);
      begin -> resize (n);
      end   -> resize (n);
    }
    C alt_start= -1;
    while (i1 > 0) {
      array<C> ccsym;
      array<C> ccpos;
      inspect (csym[i1], cpos[i1], ccsym, ccpos);
      if (N(ccsym)>1 && is_associative (ccsym[0])) {
        if (w1 >= ccpos[1]) alt_start= ccpos[1];
        break;
      }
      if (N(ccsym)>0 && is_anti_associative (ccsym[0])) break;
      i1--;
    }
    tree sel= compound ("partial", packrat_decode[sym]);
    kind  << encode_symbol (sel);
    begin << (alt_start<0? cpos[i1]: alt_start);
    end   << cpos[i2+1];
    return;
  }

  if (sym >= PACKRAT_TM_OPEN) {
    array<C> inst= grammar [sym];
    //cout << "Context " << inst << " at " << pos << LF;
    switch (inst[0]) {
    case PACKRAT_OR:
      for (int i=1; i<N(inst); i++)
       if (parse (inst[i], pos) != PACKRAT_FAILED) {
         context (inst[i], pos, w1, w2, mode, kind, begin, end);
         break;
       }
      break;
    case PACKRAT_CONCAT:
      for (int i=1; i<N(inst); i++) {
       next= parse (inst[i], pos);
       if (next == PACKRAT_FAILED) break;
       if (pos <= w1 && w2 <= next)
         context (inst[i], pos, w1, w2, mode, kind, begin, end);
       if (next > w2) break;
       pos= next;
      }
      break;
    case PACKRAT_WHILE:
    case PACKRAT_REPEAT:
      while (true) {
       C next= parse (inst[1], pos);
       if (next == PACKRAT_FAILED) break;
       if (pos <= w1 && w2 <= next)
         context (inst[1], pos, w1, w2, mode, kind, begin, end);
       if (next > w2) break;
       pos= next;
      }
      break;
    case PACKRAT_RANGE:
    case PACKRAT_NOT:
      break;
    case PACKRAT_EXCEPT:
      context (inst[1], pos, w1, w2, mode, kind, begin, end);
      break;
    case PACKRAT_TM_OPEN:
    case PACKRAT_TM_ANY:
    case PACKRAT_TM_ARGS:
    case PACKRAT_TM_LEAF:
    case PACKRAT_TM_CHAR:
    case PACKRAT_TM_CURSOR:
    case PACKRAT_TM_FAIL:
      break;
    default:
      context (inst[0], pos, w1, w2, mode, kind, begin, end);
      break;
    }
  }
}

Here is the call graph for this function:

path packrat_parser_rep::decode_path ( tree  t,
path  p,
int  pos 
) [protected]

Definition at line 145 of file packrat_parser.cpp.

                                                        {
  //cout << "Search " << pos << " in " << t << ", " << p << "\n";
  //cout << "Range " << current_start[p] << " -- " << current_end[p] << "\n";
  if (is_atomic (t)) {
    if (current_pos_path->contains (pos))
      return current_pos_path[pos];
    else return p * (pos - current_start[p]);
  }
  else {
    for (int i=0; i<N(t); i++)
      if (pos >= current_start[p*i] && pos <= current_end[p*i])
       return decode_path (t[i], p * i, pos);
    if (pos <= current_start[p]) return p * 0;
    if (pos >= current_end[p]) return p * 1;
    return p * 0;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file packrat_parser.cpp.

                                                 {
  //cout << "Decode " << pos << "\n";
  if (pos == PACKRAT_FAILED) return -1;
  int i=0;
  C k=0;
  while (i<N(current_string) && k<pos) {
    tm_char_forwards (current_string, i);
    k++;
  }
  return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 164 of file packrat_parser.cpp.

                                               {
  int i= decode_string_position (pos);
  if (i < 0) return path (i);
  return decode_path (current_tree, path (), i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int packrat_parser_rep::encode_path ( tree  t,
path  p,
path  pos 
) [protected]

Definition at line 106 of file packrat_parser.cpp.

                                                         {
  //cout << "Search " << pos << " in " << t << ", " << p << "\n";
  //cout << "Range " << current_start[p] << " -- " << current_end[p] << "\n";
  if (is_nil (pos) || !current_start->contains (p)) return -1;
  else if (is_atomic (t)) {
    if (current_path_pos->contains (p * pos))
      return current_path_pos[p * pos];
    else if (pos->item < 0 || pos->item > N(t->label)) return -1;
    return current_start[p] + pos->item;
  }
  else {
    if (pos == path (0)) return current_start[p];
    if (pos == path (1)) return current_end[p];
    if (pos->item < 0 || pos->item > N(t) || is_nil (pos->next)) return -1;
    return encode_path (t[pos->item], p * pos->item, pos->next);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file packrat_parser.cpp.

                                                 {
  if (i < 0) return PACKRAT_FAILED;
  int j=0;
  C k=0;
  while (j<i && j<N(current_string)) {
    tm_char_forwards (current_string, j);
    k++;
  }
  return k;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file packrat_parser.cpp.

                                                {
  if (is_nil (p) || p->item < 0) return PACKRAT_FAILED;
  int i= encode_path (current_tree, path (), p);
  return encode_string_position (i);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void packrat_parser_rep::highlight ( tree  t,
path  tp,
path  p1,
path  p2,
int  col 
)

Definition at line 584 of file packrat_parser.cpp.

                                                                         {
  if (p1 == p2);
  else if (is_atomic (t)) {
    string s= t->label;
    ASSERT (is_atom (p1) && is_atom (p2), "invalid selection");
    ASSERT (0 <= p1->item && p1->item <= p2->item && p2->item <= N(s),
           "invalid selection");
    attach_highlight (t, current_hl_lan, col, p1->item, p2->item);
  }
  else if (N(t) == 0);
  else {
    ASSERT (!is_nil (p1) && !is_nil (p2) && p1->item <= p2->item,
           "invalid selection");
    if (p1 == path (0)) p1= path (0, 0);
    if (p2 == path (1)) p2= path (N(t) - 1, right_index (t[N(t) -1]));
    for (int i= max (0, p1->item); i <= min (p2->item, N(t)-1); i++) {
      path q1= (i == p1->item? p1->next: path (0));
      path q2= (i == p2->item? p2->next: path (right_index (t[i])));
      highlight (t[i], tp * i, q1, q2, col);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void packrat_parser_rep::highlight ( C  sym,
C  pos 
)

Definition at line 608 of file packrat_parser.cpp.

                                           {
  C next= parse (sym, pos);
  if (next < 0) return;
  if (sym >= PACKRAT_SYMBOLS) {
    static C prop= encode_symbol (compound ("property", "highlight"));
    D key = (((D) prop) << 32) + ((D) (sym ^ prop));
    if (properties->contains (key)) {
      int  col  = encode_color (properties [key]);
      path start= decode_tree_position (pos);
      path end  = decode_tree_position (next);
      highlight (current_tree, path (), start, end, col);
      static C prop= encode_symbol (compound ("property", "transparent"));
      D key = (((D) prop) << 32) + ((D) (sym ^ prop));
      if (!properties->contains (key)) return;
    }
  }

  if (sym >= PACKRAT_TM_OPEN) {
    array<C> inst= grammar [sym];
    //cout << "Parse " << inst << " at " << pos << LF;
    switch (inst[0]) {
    case PACKRAT_OR:
      for (int i=1; i<N(inst); i++)
       if (parse (inst[i], pos) != PACKRAT_FAILED) {
         highlight (inst[i], pos);
         break;
       }
      break;
    case PACKRAT_CONCAT:
      for (int i=1; i<N(inst); i++) {
       next= parse (inst[i], pos);
       highlight (inst[i], pos);
       pos= next;
      }
      break;
    case PACKRAT_WHILE:
    case PACKRAT_REPEAT:
      while (true) {
       C next= parse (inst[1], pos);
       if (next == PACKRAT_FAILED) break;
       highlight (inst[1], pos);
       if (next == pos) break;
       pos= next;
      }
      break;
    case PACKRAT_RANGE:
    case PACKRAT_NOT:
      break;
    case PACKRAT_EXCEPT:
      highlight (inst[1], pos);
      break;      
    case PACKRAT_TM_OPEN:
    case PACKRAT_TM_ANY:
    case PACKRAT_TM_ARGS:
    case PACKRAT_TM_LEAF:
    case PACKRAT_TM_CHAR:
    case PACKRAT_TM_CURSOR:
    case PACKRAT_TM_FAIL:
      break;
    default:
      highlight (inst[0], pos);
      break;
    }
  }
}

Here is the call graph for this function:

void packrat_parser_rep::inspect ( C  sym,
C  pos,
array< C > &  syms,
array< C > &  poss 
)

Definition at line 313 of file packrat_parser.cpp.

                                                                         {
  syms= array<C> ();
  poss= array<C> ();
  C next= parse (sym, pos);
  if (next == PACKRAT_FAILED) return;
  if (sym >= PACKRAT_TM_OPEN) {
    array<C> inst= grammar [sym];
    //cout << "Parse " << inst << " at " << pos << LF;
    switch (inst[0]) {
    case PACKRAT_OR:
      for (int i=1; i<N(inst); i++)
       if (parse (inst[i], pos) != PACKRAT_FAILED) {
         inspect (inst[i], pos, syms, poss);
         break;
       }
      break;
    case PACKRAT_CONCAT:
      for (int i=1; i<N(inst); i++) {
       next= parse (inst[i], pos);
       if (next == PACKRAT_FAILED) break;
        syms << inst[i];
        poss << pos;
       pos= next;
      }
      break;
    case PACKRAT_WHILE:
    case PACKRAT_REPEAT:
      while (true) {
        C next= parse (inst[1], pos);
        if (next == PACKRAT_FAILED) break;
        syms << inst[1];
        poss << pos;
        pos= next;
      }
      break;
    case PACKRAT_RANGE:
    case PACKRAT_NOT:
      break;
    case PACKRAT_EXCEPT:
      inspect (inst[1], pos, syms, poss);
      break;
    case PACKRAT_TM_OPEN:
    case PACKRAT_TM_ANY:
    case PACKRAT_TM_ARGS:
    case PACKRAT_TM_LEAF:
    case PACKRAT_TM_CHAR:
    case PACKRAT_TM_CURSOR:
    case PACKRAT_TM_FAIL:
      break;
    default:
      inspect (inst[0], pos, syms, poss);
      break;
    }
  }
}

Here is the call graph for this function:

Definition at line 388 of file packrat_parser.cpp.

                                              {
  static C prop= encode_symbol (compound ("property", "associativity"));
  D key = (((D) prop) << 32) + ((D) (sym ^ prop));
  if (!properties->contains (key)) return false;
  return properties[key] == "anti-associative";
}

Here is the call graph for this function:

Definition at line 380 of file packrat_parser.cpp.

                                         {
  static C prop= encode_symbol (compound ("property", "associativity"));
  D key = (((D) prop) << 32) + ((D) (sym ^ prop));
  if (!properties->contains (key)) return false;
  return properties[key] == "associative";
}

Here is the call graph for this function:

Definition at line 370 of file packrat_parser.cpp.

                                            {
  if (sym < PACKRAT_TM_OPEN) return false;
  array<C> inst= grammar [sym];
  if (inst[0] != PACKRAT_CONCAT || N(inst) != 3) return false;
  if (inst[1] < PACKRAT_TM_OPEN) return false;
  tree t= packrat_decode[inst[1]];
  return is_compound (t, "symbol", 1) && ends (t[0]->label, "-head");
}

Here is the call graph for this function:

Definition at line 396 of file packrat_parser.cpp.

                                       {
  (void) sym;
  return false;
}

Definition at line 402 of file packrat_parser.cpp.

                                        {
  tree t= packrat_decode[sym];
  if (is_compound (t, "partial", 1)) return true;
  if (!is_compound (t, "symbol", 1)) return false;
  string s= t[0]->label;
  return !ends (s, "-head") && !ends (s, "-tail");
}

Here is the call graph for this function:

C packrat_parser_rep::parse ( C  sym,
C  pos 
)

Definition at line 180 of file packrat_parser.cpp.

                                       {
  D key= (((D) sym) << 32) + ((D) (sym^pos));
  C im = current_cache [key];
  if (im != PACKRAT_UNDEFINED) {
    //cout << "Cached " << sym << " at " << pos << " -> " << im << LF;
    return im;
  }
  current_cache (key)= PACKRAT_FAILED;
  if (DEBUG_PACKRAT)
    cout << "Parse " << packrat_decode[sym] << " at " << pos << INDENT << LF;
  if (sym >= PACKRAT_TM_OPEN) {
    array<C> inst= grammar [sym];
    //cout << "Parse " << inst << " at " << pos << LF;
    switch (inst[0]) {
    case PACKRAT_OR:
      im= PACKRAT_FAILED;
      for (int i=1; i<N(inst); i++) {
       im= parse (inst[i], pos);
       if (im != PACKRAT_FAILED) break;
      }
      break;
    case PACKRAT_CONCAT:
      im= pos;
      for (int i=1; i<N(inst); i++) {
       im= parse (inst[i], im);
       if (im == PACKRAT_FAILED) break;
      }
      break;
    case PACKRAT_WHILE:
      im= pos;
      while (true) {
       C next= parse (inst[1], im);
       if (next == PACKRAT_FAILED || (next >= 0 && next <= im)) break;
       im= next;
      }
      break;
    case PACKRAT_REPEAT:
      im= parse (inst[1], pos);
      if (im != PACKRAT_FAILED)
       while (true) {
         C next= parse (inst[1], im);
         if (next == PACKRAT_FAILED || (next >= 0 && next <= im)) break;
         im= next;
       }
      break;
    case PACKRAT_RANGE:
      if (pos < N (current_input) &&
         current_input [pos] >= inst[1] &&
         current_input [pos] <= inst[2])
       im= pos + 1;
      else im= PACKRAT_FAILED;
      break;
    case PACKRAT_NOT:
      if (parse (inst[1], pos) == PACKRAT_FAILED) im= pos;
      else im= PACKRAT_FAILED;
      break;
    case PACKRAT_EXCEPT:
      im= parse (inst[1], pos);
      if (im != PACKRAT_FAILED)
       if (parse (inst[2], pos) != PACKRAT_FAILED)
         im= PACKRAT_FAILED;
      break;
    case PACKRAT_TM_OPEN:
      if (pos < N (current_input) &&
         starts (packrat_decode[current_input[pos]], "<\\"))
       im= pos + 1;
      else im= PACKRAT_FAILED;
      break;
    case PACKRAT_TM_ANY:
      im= pos;
      while (true) {
       C old= im;
       im= parse (PACKRAT_TM_OPEN, old);
       if (im == PACKRAT_FAILED)
         im= parse (PACKRAT_TM_LEAF, old);
       else {
         im= parse (PACKRAT_TM_ARGS, im);
         if (im != PACKRAT_FAILED)
           im= parse (encode_token ("</>"), im);
       }
       if (old == im) break;
      }
      break;
    case PACKRAT_TM_ARGS:
      im= parse (PACKRAT_TM_ANY, pos);
      while (im < N (current_input))
       if (current_input[im] != encode_token ("<|>")) break;
       else im= parse (PACKRAT_TM_ANY, im + 1);
      break;
    case PACKRAT_TM_LEAF:
      im= pos;
      while (im < N (current_input)) {
       tree t= packrat_decode[current_input[im]];
       if (starts (t, "<\\") || t == "<|>" || t == "</>") break;
       else im++;
      }
      break;
    case PACKRAT_TM_CHAR:
      if (pos >= N (current_input)) im= PACKRAT_FAILED;
      else {
       tree t= packrat_decode[current_input[pos]];
       if (starts (t, "<\\") || t == "<|>" || t == "</>") im= PACKRAT_FAILED;
       else im= pos + 1;
      }
      break;
    case PACKRAT_TM_CURSOR:
      if (pos == current_cursor) im= pos;
      else im= PACKRAT_FAILED;
      break;
    case PACKRAT_TM_FAIL:
      im= PACKRAT_FAILED;
      break;
    default:
      im= parse (inst[0], pos);
      break;
    }
  }
  else {
    if (pos < N (current_input) && current_input[pos] == sym) im= pos + 1;
    else im= PACKRAT_FAILED;
  }
  current_cache (key)= im;
  if (DEBUG_PACKRAT)
    cout << UNINDENT << "Parsed " << packrat_decode[sym]
        << " at " << pos << " -> " << im << LF;
  return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void packrat_parser_rep::serialize ( tree  t,
path  p 
) [protected]

Definition at line 55 of file packrat_serializer.cpp.

                                             {
  if (is_nil (p) || p->item != -1)
    current_start (p)= N(current_string);
  if (is_atomic (t)) {
    int begin= N(current_string);
    int pos=0;
    string s= t->label;
    while (true) {  
      if (N(current_string) != begin + pos)
        if (is_nil (p) || p->item != -1) {
          //cout << p * pos << " <-> " << N(current_string) << LF;
          //cout << "  " << s (0, pos) << LF;
          //cout << "  " << current_string (begin, N(current_string)) << LF;
          current_path_pos (p * pos)= N(current_string);
          current_pos_path (N(current_string))= p * pos;
        }
      if (pos >= N(s)) break;
      int start= pos;
      tm_char_forwards (s, pos);
      if (pos == start+1)
       current_string << s[start];
      else {
       string ss= s (start, pos);
        tree r= the_drd->get_syntax (ss);
        //if (r != UNINIT) cout << "Rewrite " << ss << " -> " << r << "\n";
        if (r == UNINIT) current_string << ss;
        else serialize (r, path (-1));
      }
    }
  }
  else switch (L(t)) {
    case RAW_DATA:
      current_string << "<\\rawdata></>";
      break;
    case DOCUMENT:
    case PARA:
      for (int i=0; i<N(t); i++) {
        serialize (t[i], p * i);
        current_string << "\n";
      }
      break;
    case SURROUND:
      serialize (t[0], p * 0);
      serialize (t[2], p * 2);
      serialize (t[1], p * 1);
      break;
    case CONCAT:
      for (int i=0; i<N(t); i++)
        serialize (t[i], p * i);
      break;
    case RIGID:
      serialize (t[0], p * 0);
      break;
    case HIDDEN:
      break;
    case FREEZE:
    case UNFREEZE:
      serialize (t[0], p * 0);
      break;
    case HSPACE:
    case VAR_VSPACE:
    case VSPACE:
    case SPACE:
    case HTAB:
      break;
    case MOVE:
    case SHIFT:
    case RESIZE:
    case CLIPPED:
      serialize (t[0], p * 0);
      break;

    case WITH_LIMITS:
    case LINE_BREAK:
    case NEW_LINE:
    case NEXT_LINE:
    case NO_BREAK:
    case YES_INDENT:
    case NO_INDENT:
    case VAR_YES_INDENT:
    case VAR_NO_INDENT:
    case VAR_PAGE_BREAK:
    case PAGE_BREAK:
    case VAR_NO_PAGE_BREAK:
    case NO_PAGE_BREAK:
    case VAR_NEW_PAGE:
    case NEW_PAGE:
    case VAR_NEW_DPAGE:
    case NEW_DPAGE:
      break;

    case SYNTAX:
      serialize (t[1], path (-1));
      break;
    case TFORMAT:
    case TWITH:
    case CWITH:
    case CELL:
      serialize (t[N(t)-1], p * (N(t)-1));
      break;

    case WITH:
      if (t[0] == "mode" && t[1] != "math");
      else serialize (t[N(t)-1], p * (N(t)-1));
      break;
    case VALUE: {
      tree r= the_drd->get_syntax (t);
      //if (r != UNINIT) cout << "Rewrite " << t << " -> " << r << "\n";
      if (r != UNINIT) serialize (r, path (-1));
      else serialize_compound (t, p);
      break;
    }

    case STYLE_WITH:
    case VAR_STYLE_WITH:
    case LOCUS:
      serialize (t[N(t)-1], p * (N(t)-1));
      break;
    case ID:
    case HARD_ID:
    case LINK:
    case URL:
    case SCRIPT:
      break;
    case HLINK:
    case ACTION:
      serialize (t[0], p * 0);
      break;
    case SET_BINDING:
    case GET_BINDING:
    case LABEL:
    case REFERENCE:
    case PAGEREF:
    case WRITE:
      break;

    case SPECIFIC:
      serialize (t[1], p * 1);
      break;
    case FLAG:
      break;

    default:
      serialize_compound (t, p);
      break;
    }
  if (is_nil (p) || p->item != -1)
    current_end (p)= N(current_string);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void packrat_parser_rep::serialize_atomic ( tree  t,
path  p 
) [protected]
void packrat_parser_rep::serialize_compound ( tree  t,
path  p 
) [protected]

Definition at line 35 of file packrat_serializer.cpp.

                                                      {
  tree r= the_drd->get_syntax (t, p);
  if (r != UNINIT)
    serialize (r, path (-1));
  else if (is_func (t, QUASI, 2)) {
    tree tt= t[0];
    path pp= as_path (t[1]);
    serialize (tt, pp);
  }
  else {
    current_string << "<\\" << as_string (L(t)) << ">";
    for (int i=0; i<N(t); i++) {
      if (i != 0) current_string << "<|>";
      serialize (t[i], p * i);
    }
    current_string << "</>";
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void packrat_parser_rep::set_cursor ( path  t_pos) [protected]

Definition at line 83 of file packrat_parser.cpp.

                                      {
  if (is_nil (p)) current_cursor= -1;
  else current_cursor= encode_tree_position (p);
  //cout << current_input << ", " << current_cursor << "\n";
}

Here is the call graph for this function:

void packrat_parser_rep::set_input ( tree  t) [protected]

Definition at line 73 of file packrat_parser.cpp.

                                     {
  current_string= "";
  current_tree  = t;
  serialize (t, path ());
  if (DEBUG_FLATTEN)
    cout << "Input " << current_string << "\n";
  current_input= encode_tokens (current_string);
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class packrat_parser [friend]

Definition at line 68 of file packrat_parser.hpp.


Member Data Documentation

Definition at line 35 of file packrat_parser.hpp.

Definition at line 31 of file packrat_parser.hpp.

Definition at line 28 of file packrat_parser.hpp.

Definition at line 32 of file packrat_parser.hpp.

Definition at line 34 of file packrat_parser.hpp.

Definition at line 29 of file packrat_parser.hpp.

Definition at line 30 of file packrat_parser.hpp.

Definition at line 36 of file packrat_parser.hpp.

Definition at line 27 of file packrat_parser.hpp.

Definition at line 26 of file packrat_parser.hpp.

Definition at line 25 of file packrat_parser.hpp.

Definition at line 21 of file packrat_parser.hpp.

Definition at line 22 of file packrat_parser.hpp.

Definition at line 23 of file packrat_parser.hpp.

int concrete_struct::ref_count [inherited]

Definition at line 135 of file basic.hpp.


The documentation for this class was generated from the following files: