Yo, sync and you'll get new version. MUCH simpler. Works like a charm, with some slight differences in operation. The beauty is that this does no reordering...it does some really fancy jiggerypokery on the instruction stream to combine instructions reducing to one op per token index. This should be faster and easier than last version...other targets can leave til next release if they want. I include comment from key method below. Shows all combinations of operations. Many new unit tests.

Locking 3 files ...
edit //depot/code/antlr/main/CHANGES.txt#67
edit //depot/code/antlr/main/runtime/Java/src/org/antlr/runtime/ TokenRewriteStream.java#5 edit //depot/code/antlr/main/src/org/antlr/test/ TestTokenRewriteStream.java#11
Change 4976 submitted.

/** We need to combine operations and report invalid operations (like * overlapping replaces that are not completed nested). Inserts to
     *  same index need to be combined etc...   Here are the cases:
     *
* I.i.u I.j.v leave alone, nonoverlapping
     *  I.i.u I.i.v                             combine: Iivu
     *
     *  R.i-j.u R.x-y.v | i-j in x-y            delete first R
     *  R.i-j.u R.i-j.v                         delete first R
     *  R.i-j.u R.x-y.v | x-y in i-j            ERROR
     *  R.i-j.u R.x-y.v | boundaries overlap    ERROR
     *
     *  I.i.u R.x-y.v | i in x-y                delete I
* I.i.u R.x-y.v | i not in x-y leave alone, nonoverlapping
     *  R.x-y.v I.i.u | i in x-y                ERROR
* R.x-y.v I.x.u R.x-y.uv (combine, delete I) * R.x-y.v I.i.u | i not in x-y leave alone, nonoverlapping
     *
     *  I.i.u = insert u before op @ index i
     *  R.x-y.u = replace x-y indexed tokens with u
     *
     *  First we need to examine replaces.  For any replace op:
     *
     *      1. wipe out any insertions before op within that range.
* 2. Drop any replace op before that is contained completely within
     *         that range.
* 3. Throw exception upon boundary overlap with any previous replace.
     *
     *  Then we can deal with inserts:
     *
* 1. for any inserts to same index, combine even if not adjacent. * 2. for any prior replace with same left boundary, combine this
     *         insert with replace and delete this replace.
* 3. throw exception if index in same range as previous replace
     *
* Don't actually delete; make op null in list. Easier to walk list.
     *  Later we can throw as we add to index -> op map.
     *
* Note that I.2 R.2-2 will wipe out I.2 even though, technically, the
     *  inserted stuff would be before the replace range.  But, if you
* add tokens in front of a method body '{' and then delete the method * body, I think the stuff before the '{' you added should disappear too.
     *
     *  Return a map from token index to operation.
     */

_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev

Reply via email to