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.RepeatRequired = RepeatRequired;
|
||||||
parser.Parser.RepeatSpec = RepeatSpec;
|
parser.Parser.RepeatSpec = RepeatSpec;
|
||||||
|
|
||||||
|
parser.resetGroupCounter = () => {
|
||||||
|
parser.Parser.Subexp.resetCounter();
|
||||||
|
}
|
||||||
|
|
||||||
export default parser;
|
export default parser;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import Base from './base.js';
|
import Base from './base.js';
|
||||||
|
|
||||||
|
var groupCounter = 1;
|
||||||
|
|
||||||
export default _.extend({}, Base, {
|
export default _.extend({}, Base, {
|
||||||
type: 'subexp',
|
type: 'subexp',
|
||||||
|
|
||||||
@ -72,7 +74,11 @@ export default _.extend({}, Base, {
|
|||||||
if (_.has(this.labelMap, this._capture.textValue)) {
|
if (_.has(this.labelMap, this._capture.textValue)) {
|
||||||
return this.labelMap[this._capture.textValue];
|
return this.labelMap[this._capture.textValue];
|
||||||
} else {
|
} else {
|
||||||
return 'group #TBA';
|
return 'group #' + (groupCounter++);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
resetCounter() {
|
||||||
|
groupCounter = 1;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -87,6 +87,8 @@ export default class Regexper {
|
|||||||
|
|
||||||
snap.selectAll('g').remove();
|
snap.selectAll('g').remove();
|
||||||
|
|
||||||
|
parser.resetGroupCounter();
|
||||||
|
|
||||||
return Q.fcall(parser.parse.bind(parser), expression)
|
return Q.fcall(parser.parse.bind(parser), expression)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
result.container = snap.group();
|
result.container = snap.group();
|
||||||
|
Loading…
Reference in New Issue
Block a user