private void Reset(int newListId) { posBldr.Init(); curSymLen = 0; prvSymAry = Bry_.Empty; dd_chk = false; listId = newListId; }
public int MakeTkn_bgn( Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) { // REF.MW: Parser|doBlockLevels if (bgn_pos == Xop_parser_.Doc_bgn_bos) bgn_pos = 0; // do not allow -1 pos // pop hdr if exists; EX: \n== a ==\n*b; \n* needs to close hdr int acsPos = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_hdr); if (acsPos != -1) ctx.Stack_pop_til(root, src, acsPos, true, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_list); // close apos ctx.Apos().End_frame(ctx, root, src, bgn_pos, false); byte symByt = src[ cur_pos - 1]; // -1 b/c symByt is byte before curByt; EX: \n*a; cur_pos is at a; want to get // * int prvSymLen = curSymLen; cur_pos = SymAry_fill(src, cur_pos, src_len, symByt); symByt = src[ cur_pos - 1]; // NOTE: get symByt again b/c cur_pos may have changed; EX: "#*"; # may have // triggered list, but last symByt should be * if (SymAry_fill_overflow) return ctx.Lxr_make_txt_(cur_pos); PrvItm_compare(); ctx.Para() .Process_block__bgn__nl_w_symbol( ctx, root, src, bgn_pos, cur_pos - 1, Xop_xnde_tag_ .Tag__li); // -1 b/c cur_pos includes sym_byte; EX: \n*; pass li; should pass // correct tag, but for purposes of para_wkr, <li> doesn't matter if (prvSymMatch) { PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.N_byte); posBldr.MoveNext(); prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen); Xop_list_tkn prvItm = tkn_mkr.List_bgn(bgn_pos, cur_pos, curSymAry[curSymLen - 1], curSymLen) .List_path_(posBldr.XtoIntAry()) .List_uid_(listId); ctx.Subs_add_and_stack(root, prvItm); ctx.Empty_ignored_y_(); } else { for (int i = prvSymLen; i > commonSymLen; i--) { // close all discontinued itms: EX: ##\n#\n PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.Y_byte); posBldr.MoveUp(); } if (commonSymLen == 0 && prvSymLen != 0) { // nothing in common; reset list listId++; posBldr.Init(); } if (curSymLen == commonSymLen) { // add another itm if continuing; EX: #\n#\n PopTil(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, Bool_.N_byte); if ((prvSymLen - curSymLen) > 0 // moving up many levels; do not open new list; just MoveNext; EX: #1\n###3\n##2 && curSymLen != 1) { // do not moveNext if at level 1; this has to do with strange incrementing // logic in posBldr at rootLvl posBldr.MoveNext(); } else { posBldr.MoveUp(); posBldr.MoveDown(); } prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen); symByt = src[cur_pos - 1]; Xop_list_tkn prvItm = tkn_mkr.List_bgn(bgn_pos, cur_pos, symByt, curSymLen) .List_path_(posBldr.XtoIntAry()) .List_uid_(listId); ctx.Subs_add_and_stack(root, prvItm); ctx.Empty_ignored_y_(); } for (int i = commonSymLen; i < curSymLen; i++) { // open new itms; EX: #\n##\n posBldr.MoveDown(); symByt = curSymAry[i]; prvSymAry = Xop_list_wkr_.MakeSymAry(curSymAry, curSymLen); Xop_list_tkn prvItm = tkn_mkr.List_bgn(bgn_pos, cur_pos, symByt, i + List_adp_.Base1) .List_path_(posBldr.XtoIntAry()) .List_uid_(listId); ctx.Subs_add_and_stack(root, prvItm); ctx.Empty_ignored_y_(); } } if (allDd && cur_pos < src_len - 2 && src[cur_pos] == '{' && src[cur_pos + 1] == '|') // NOTE: if indent && next == {| then invoke table; EX: ":::{|" return ctx.Tblw() .Make_tkn_bgn( ctx, tkn_mkr, root, src, src_len, cur_pos, cur_pos + 2, false, Xop_tblw_wkr.Tblw_type_tb, Xop_tblw_wkr.Called_from_list, -1, -1); // NOTE: ws_enabled must be set to true; see test for Adinkras; Cato the Elder else { dd_chk = symByt == Xop_list_tkn_.List_itmTyp_dt; return cur_pos; } }