Ejemplo n.º 1
0
 private int Parse(
     Texvc_root root,
     Texvc_ctx ctx,
     Btrie_fast_mgr lxr_trie,
     byte[] src,
     int src_len,
     int bgn_pos,
     int end_pos) {
   int pos = bgn_pos;
   int txt_bgn = pos, txt_uid = -1;
   byte b = src[pos];
   while (true) {
     Object o = lxr_trie.Match_at_w_b0(trv, b, src, pos, src_len);
     if (o == null) // no lxr found; char is txt; increment pos
     pos++;
     else { // lxr found
       Texvc_lxr lxr = (Texvc_lxr) o;
       if (txt_bgn != pos)
         txt_uid =
             Txt_calc(
                 ctx, root, src, src_len, pos, txt_bgn,
                 txt_uid); // chars exist between pos and txt_bgn; make txt_tkn;
       pos = lxr.Make_tkn(ctx, root, src, src_len, pos, trv.Pos());
       if (pos > 0) {
         txt_bgn = pos;
         txt_uid = -1;
       } // reset txt_tkn
     }
     if (pos == end_pos) break;
     b = src[pos];
   }
   if (txt_bgn != pos) txt_uid = Txt_calc(ctx, root, src, src_len, src_len, txt_bgn, txt_uid);
   return pos;
 }
Ejemplo n.º 2
0
 public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {
   core_trie.Add(Xop_tkn_.Lnki_bgn, this);
 }
Ejemplo n.º 3
0
class Xop_vnt_flag_ {
  public static final Xop_vnt_flag[] Ary_empty = new Xop_vnt_flag[0];
  public static final byte Tid_unknown = 0,
      Tid_show = 1 // EX: -{S|zh-hans:A;zh-hant:B}-  -> "A"
      ,
      Tid_all = 2 // EX: -{+|zh-hans:A;zh-hant:B}-  -> "A"
      ,
      Tid_err = 3 // EX: -{E|zh-hans:A;zh-hant:B}-  -> "A"
      ,
      Tid_add = 4 // add and output;		EX: -{A|zh-hans:A;zh-hant:B}-  -> "A"
      ,
      Tid_title = 5 // page_title;			EX: -{T|zh-hans:A;zh-hant:B}-  -> ""
      ,
      Tid_raw = 6 // raw: no convert;		EX: -{R|zh-hans:A;zh-hant:B}-  -> "zh-hans:A;zh-hant:B"
      ,
      Tid_descrip =
          7 // describe;			EX: -{D|zh-hans:A;zh-hant:B}-  -> "简体:A;繁體:B;"
            // (简体=Simplified;繁體=Traditional)
      ,
      Tid_del = 8 // remove;				EX: -{-|zh-hans:A;zh-hant:B}-  -> ""
      ,
      Tid_macro = 9 // macro;				EX: -{H|zh-hans:A;zh-hant:B}-  -> ""
      ,
      Tid_name = 10 // EX: -{N|zh-hans:A;zh-hant:B}-		-> ""
      ,
      Tid_lang = 11 // EX: -{zh-hant|B}-					-> "B"
  ;

  public static String Xto_name(byte tid) {
    switch (tid) {
      case Tid_unknown:
        return "unknown";
      case Tid_show:
        return "show";
      case Tid_all:
        return "all";
      case Tid_err:
        return "err";
      case Tid_add:
        return "add";
      case Tid_title:
        return "title";
      case Tid_raw:
        return "raw";
      case Tid_descrip:
        return "descrip";
      case Tid_del:
        return "del";
      case Tid_macro:
        return "macro";
      case Tid_name:
        return "name";
      case Tid_lang:
        return "lang";
      default:
        throw Err_.unhandled(tid);
    }
  }

  public static final byte Tid__max = 12;
  public static final byte Key_show = Byte_ascii.Ltr_S,
      Key_all = Byte_ascii.Plus,
      Key_err = Byte_ascii.Ltr_E,
      Key_add = Byte_ascii.Ltr_A,
      Key_title = Byte_ascii.Ltr_T,
      Key_raw = Byte_ascii.Ltr_R,
      Key_descrip = Byte_ascii.Ltr_D,
      Key_del = Byte_ascii.Dash,
      Key_macro = Byte_ascii.Ltr_H,
      Key_name = Byte_ascii.Ltr_N;
  public static final Xop_vnt_flag Flag_unknown = new Xop_vnt_flag(Tid_unknown),
      Flag_show = new Xop_vnt_flag(Tid_show),
      Flag_all = new Xop_vnt_flag(Tid_all),
      Flag_err = new Xop_vnt_flag(Tid_err),
      Flag_add = new Xop_vnt_flag(Tid_add),
      Flag_title = new Xop_vnt_flag(Tid_title),
      Flag_raw = new Xop_vnt_flag(Tid_raw),
      Flag_descrip = new Xop_vnt_flag(Tid_descrip),
      Flag_del = new Xop_vnt_flag(Tid_del),
      Flag_macro = new Xop_vnt_flag(Tid_macro),
      Flag_name = new Xop_vnt_flag(Tid_name);
  public static final Btrie_fast_mgr Trie =
      Btrie_fast_mgr
          .ci_ascii_() // NOTE: match either lc or uc; EX: -{D}- or -{d}-; //
                       // NOTE:ci.ascii:MW_const.en; flag keys; EX: -{S|a}-
          .Add(Byte_ascii.Ltr_S, Xop_vnt_flag_.Flag_show)
          .Add(Byte_ascii.Plus, Xop_vnt_flag_.Flag_all)
          .Add(Byte_ascii.Ltr_E, Xop_vnt_flag_.Flag_err)
          .Add(Byte_ascii.Ltr_A, Xop_vnt_flag_.Flag_add)
          .Add(Byte_ascii.Ltr_T, Xop_vnt_flag_.Flag_title)
          .Add(Byte_ascii.Ltr_R, Xop_vnt_flag_.Flag_raw)
          .Add(Byte_ascii.Ltr_D, Xop_vnt_flag_.Flag_descrip)
          .Add(Byte_ascii.Dash, Xop_vnt_flag_.Flag_del)
          .Add(Byte_ascii.Ltr_H, Xop_vnt_flag_.Flag_macro)
          .Add(Byte_ascii.Ltr_N, Xop_vnt_flag_.Flag_name);

  public static Xop_vnt_flag new_langs_(byte[][] langs) {
    return new Xop_vnt_flag(Tid_lang, langs);
  }
}