File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -197,20 +197,21 @@ exports.newLen = (cs) => exports.unpack(cs).newLen;
197197 * @returns {OpIter } Operator iterator object.
198198 */
199199exports . opIterator = ( opsStr ) => {
200- const regex = / ( (?: \* [ 0 - 9 a - z ] + ) * ) (?: \| ( [ 0 - 9 a - z ] + ) ) ? ( [ - + = ] ) ( [ 0 - 9 a - z ] + ) | \? | / g;
200+ const regex = / ( (?: \* [ 0 - 9 a - z ] + ) * ) (?: \| ( [ 0 - 9 a - z ] + ) ) ? ( [ - + = ] ) ( [ 0 - 9 a - z ] + ) | ( . ) / g;
201201
202202 const nextRegexMatch = ( ) => {
203203 const result = regex . exec ( opsStr ) ;
204- if ( result [ 0 ] === '?' ) {
205- error ( 'Hit error opcode in op stream' ) ;
206- }
207-
204+ if ( ! result ) return null ;
205+ if ( result [ 5 ] === '$' ) return null ; // Start of the insert operation character bank.
206+ if ( result [ 5 ] != null ) error ( `invalid operation: ${ opsStr . slice ( regex . lastIndex - 1 ) } ` ) ;
208207 return result ;
209208 } ;
210209 let regexResult = nextRegexMatch ( ) ;
211210
211+ const hasNext = ( ) => regexResult && ! ! regexResult [ 0 ] ;
212+
212213 const next = ( op = new Op ( ) ) => {
213- if ( regexResult [ 0 ] ) {
214+ if ( hasNext ( ) ) {
214215 op . attribs = regexResult [ 1 ] ;
215216 op . lines = exports . parseNum ( regexResult [ 2 ] || '0' ) ;
216217 op . opcode = regexResult [ 3 ] ;
@@ -222,8 +223,6 @@ exports.opIterator = (opsStr) => {
222223 return op ;
223224 } ;
224225
225- const hasNext = ( ) => ! ! ( regexResult [ 0 ] ) ;
226-
227226 return {
228227 next,
229228 hasNext,
You can’t perform that action at this time.
0 commit comments