Adding code to indicate subexpression numbers
This commit is contained in:
parent
4a8103f404
commit
60d7cab504
@ -36,4 +36,8 @@ parser.Parser.RepeatOptional = RepeatOptional;
|
||||
parser.Parser.RepeatRequired = RepeatRequired;
|
||||
parser.Parser.RepeatSpec = RepeatSpec;
|
||||
|
||||
parser.resetGroupCounter = () => {
|
||||
parser.Parser.Subexp.resetCounter();
|
||||
}
|
||||
|
||||
export default parser;
|
||||
|
@ -1,6 +1,8 @@
|
||||
import _ from 'lodash';
|
||||
import Base from './base.js';
|
||||
|
||||
var groupCounter = 1;
|
||||
|
||||
export default _.extend({}, Base, {
|
||||
type: 'subexp',
|
||||
|
||||
@ -72,7 +74,11 @@ export default _.extend({}, Base, {
|
||||
if (_.has(this.labelMap, this._capture.textValue)) {
|
||||
return this.labelMap[this._capture.textValue];
|
||||
} else {
|
||||
return 'group #TBA';
|
||||
}
|
||||
return 'group #' + (groupCounter++);
|
||||
}
|
||||
},
|
||||
|
||||
resetCounter() {
|
||||
groupCounter = 1;
|
||||
},
|
||||
});
|
||||
|
@ -87,6 +87,8 @@ export default class Regexper {
|
||||
|
||||
snap.selectAll('g').remove();
|
||||
|
||||
parser.resetGroupCounter();
|
||||
|
||||
return Q.fcall(parser.parse.bind(parser), expression)
|
||||
.then((result) => {
|
||||
result.container = snap.group();
|
||||
|
Loading…
Reference in New Issue
Block a user